ADE9153A Library

Hi, can someone explain for me the 2048 number in the library code. Thank you.

void ADE9153AClass:: ReadAcalRegs(struct AcalRegs *Data)
{
	uint32_t tempReg;
	float tempValue;
	
	tempReg = int32_t (SPI_Read_32(REG_MS_ACAL_AICC)); //Read AICC register
	Data->AcalAICCReg = tempReg;
	tempValue = (float)tempReg / (float)2048; //Calculate Conversion Constant (CC)
	Data->AICC = tempValue;
	tempReg = int32_t (SPI_Read_32(REG_MS_ACAL_AICERT)); //Read AICERT register
	Data->AcalAICERTReg = tempReg;
	
	tempReg = int32_t (SPI_Read_32(REG_MS_ACAL_AVCC)); //Read AVCC register
	Data->AcalAVCCReg = tempReg;
	tempValue = (float)tempReg / (float)2048; //Calculate Conversion Constant (CC)
	Data->AVCC = tempValue;
	tempReg = int32_t (SPI_Read_32(REG_MS_ACAL_AVCERT)); //Read AICERT register
	Data->AcalAVCERTReg = tempReg;
}

Top Replies

    •  Analog Employees 
    Nov 12, 2020 +1 verified

    Hello

    MS_ACAL_AICC and MS_ACAL_AVCC register values are 32-bit and the values are in nA/code and nV/code respectively.
    The division by 2048 comes from the format of those registers which are 21.11 fixed…

Parents
  • +1
    •  Analog Employees 
    on Nov 12, 2020 3:24 PM 2 months ago

    Hello

    MS_ACAL_AICC and MS_ACAL_AVCC register values are 32-bit and the values are in nA/code and nV/code respectively.
    The division by 2048 comes from the format of those registers which are 21.11 fixed point format (see AN-1571), 2^11 = 2048. You need to take the register value and divide by 2048 to move the decimal over.

    Furthermore, in the .ApplyAcal() function you can see that the AICC and AVCC values are then divided by CAL_xRMS_CC (originally in mikro-ampere and mikro-volt) that is multiplied by 1000 to bring to nA or nV to match the AICC and AVCC. The result of this calculation is the scale factor for the AIGAIN and AVGAIN. The 134217728 is the decimal number of 2(pow)27 which is the scaling of the xIGAIN and AVGAIN registers.

    I hope this helps.

Reply
  • +1
    •  Analog Employees 
    on Nov 12, 2020 3:24 PM 2 months ago

    Hello

    MS_ACAL_AICC and MS_ACAL_AVCC register values are 32-bit and the values are in nA/code and nV/code respectively.
    The division by 2048 comes from the format of those registers which are 21.11 fixed point format (see AN-1571), 2^11 = 2048. You need to take the register value and divide by 2048 to move the decimal over.

    Furthermore, in the .ApplyAcal() function you can see that the AICC and AVCC values are then divided by CAL_xRMS_CC (originally in mikro-ampere and mikro-volt) that is multiplied by 1000 to bring to nA or nV to match the AICC and AVCC. The result of this calculation is the scale factor for the AIGAIN and AVGAIN. The 134217728 is the decimal number of 2(pow)27 which is the scaling of the xIGAIN and AVGAIN registers.

    I hope this helps.

Children
No Data