This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28379D: when will ADCPPBxOFFCAL be written negative number?

Part Number: TMS320F28379D


Hi,

For example, if the external sensor convert 0A current to -0.1V, 100A current to 2.0V, the offset -0.1V could not be compensated through ADCPPBxOFFCAL, we have to do some modification in external circuit to uplift the input voltage to positive voltage and then connect it to the ADC input pin(because the pin cannot accept negative voltage), and then the ADC output is always positive, so ADCPPBxOFFCAL should always be positive, right?

But ADCPPBxOFFCAL could be set to negative value, when will it be set negative?

  • Hi Howard,

    The PPB offset calibration is digital-only, so voltages below VREFLO or above VREFHI can not be calibrated.

    The calibration is signed though, so if the offset error is negative the signal can be calibrated for all input voltages that fall in the range of VREFLO to VREFHI.
  • Devin,
    So you mean if the voltage on the input pin is VREFLO, the ADCRESULT could be not 0 but negative? let's say -10, and by writing ADCPPBxOFFCAL=-10, we can compensate the offset error?
  • Hi Howard,

    Let's say that the true offset error for your external channel is +10mV:

    • When the sensor would ideally output 123mV it actually outputs 133mV. 
    • When the sensor would ideally output 1.200V it actually outputs 1.210V. 
    • When the sensor would ideally output 2.155V it actually outputs 2.165V. 
    • etc.

    Because of this, you want to digitally correct the signal using the PPB.  If VREFHI is 2.5V, then you would want to apply (-1)*(10mV/2.5V)*4096 = -16 digital counts of correction.  

    If you write this value to the OFFCAL register for the associated PPB channel, you get the following behavior:

    • Codes in the middle of the range are corrected (e.g. all of the voltages listed above will be corrected as desired)
    • On the low side, any input voltage that produces a raw digital code of 16 or less will result in a corrected output of '0' (the OFFCAL compensation saturates at 0 on the low side).  The overall effect of this is that the ADC range is reduced.
    • On the high side, once the input voltage hits 2.5V, the raw output will be 4095 and the corrected output will be 4095 - 16 =  4079.  Increasing voltage will not increase this result, so the ADC has again lost a little bit of range.  

    Overall, the compensation works for all codes in the ADC range, but the ADC range has been reduced.

    Instead of using the OFFCAL register, you could instead use the OFFREF register.  This does not saturate and can produce negative outputs.  The outputs go to the PPB results instead of the ADC results. In this case:

    • Codes in the middle of the range are corrected (e.g. all of the voltages listed above will be corrected as desired)
    • On the low side, any input voltage that produces a raw digital code of 16 or less will result in a corrected output of 0 or less.  At 0V analog input the corrected digital output will be -16.  
    • On the high side, once the input voltage hits 2.5V, the raw output will be 4095 and the corrected output will be 4095 - 16 =  4079.  Increasing voltage will not increase this result, so the ADC has again lost a little bit of range.  This is no different than the OFFCAL range. 

    The choice of which to use depends on whether the signal will get close to the rails and potentially saturate.  If not, probably use the OFFCAL calibration because the results in the regular ADC registers are available 1 cycle earlier than the PPB results.  If yes, then using the OFFREF might be a better choice, since less of the ADC range is lost (but the downstream algorithm needs to be able to handle a negative input value).  

  • Thank you. The explanation is absolutely clear.

    1. Just one thing to confirm. ADCRESULTy=ADC Output - ADCPPBxOFFCAL, so in your example, OFFCAL should be set 16, not -16, right?

    2. Besides, ADCPPBxRESULT = ADCPPBxOFFREF - ADCRESULTy, not ADCRESULTy - ADCPPBxOFFREF, correct? So if I set ADCPPBxOFFREF=0, ADCPPBxRESULT will be "- ADCRESULTy", not ADCRESULTy.

    But in technical reference manual 9.1.9.2 part, it's said "Writing a 0 to the OFFREF register effectively disables the error calculation feature, passing the ADCRESULT value unchanged to the ADCPPBxRESULT register."

    I just want to make sure the technical reference manual below is correct.

  • Hi Howard,

    1) Yeah, you are correct.

    2) It looks like the +/- are incorrect in the diagram here. The OFFREF works the same way and direction as the OFFCAL, except the result can be signed and the result goes into the PPB result register.