Post Go back to editing

Hello Everyone,

I am trying the DC current example for measuring current. I am finding difficulty in understanding the current calculation part. Can anyone explain/elaborate current calculation part? Also, find the attached images for reference.

Current calculation code -

/* Calculate current in uA */
{
float fCurrent, fVoltage = 0.0;
fCurrent = fVoltage/RtiaVal;
return -fCurrent*1000000;
}

{
float kFactor = 1.835/1.82;
float fVolt = 0.0;
float tmp = 0;
tmp = (int32_t)code - 32768;
{
break;
tmp /= 1.5f;
break;
tmp /= 2.0f;
break;
tmp /= 4.0f;
break;
tmp /= 9.0f;
break;
default:break;
}
fVolt = tmp*VRef1p82/32768*kFactor;
return fVolt;
}  ## Top Replies

• Hi, The voltage output at AIN4/LPTIA output is given to ADC.

Hence,

ADC code corresponding to VLPTIA_output  = code/PGAgain

ADC code corresponding to Vzero = 0x8000 = 32678/PGAgain

Therefore,

ADC code corresponding to (VLPTIA_output - Vzero) = (code - 32678)/PGAgain

At LPTIA,

VLPTIA_output - Vzero = Iin * RTIA

where Iin = input current

Therefore,

Iin = (VLPTIA_output - Vzero)/RTIA

= code2Volt((code - 32768)/PGAgain)/RTIA

kFactor is used because the device is factory calibrated for 1.835 Volts.

• Hello Akila,

1. As per datasheet - for code to voltage conversion formula ADCBIAS_CAP (1.11V) is added at the end

2. return -fCurrent*1000000;

According to this statement, the negative value is passed to the main function. Is there any reason to pass this negative value?

• Hi,