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.

Question on HV_Solar_DC_DC Kit DPL-ISR.asm

Hi,

I have recently bought a HV_Solar_DC_DC Kit which uses Piccolo F28035 card. I'm playing with it before buying the DC-AC kit. I have a quastion about the DPL-ISR assembly file. I would highly appreciate if someone could kindly explain me the methodology used to introduce an offset to an ADC result in this assembly file. Please have a look at the following code, (you will find this in lines 196 to 210 in HV_Solar_DC_DC Kit software's DPL-ISR)

My Question is

1. If the PU value (niormalized value) of the offset is 0.026, why has TI used 0.02x4095 to calculate the value to be offset? (Kindly guide me if I'm mistaken)

Please let me know if the question is not clear

Many Thanks

Pas

;----------------------------------------------------

;Subtract IL CS amplifier offset and calculate IL

MOVW DP, #_AdcResult ; load Data Page to read ADC results

MOV ACC, @_AdcResult.ADCRESULT1<<12 ; ACC = IL_raw

SUB ACC, #82<<12 ; ACC = IL_raw - offset, IL CS OPAMP offset = 0.026*3.3V = 85.8mV, ; Therefore, 12bit offset value = 0.02*4095 = 82

MOVB XAR2, #0

MAXL ACC, @XAR2 ; set min value to zero, ; Save IL

.ref _IL

MOVW DP, #_IL

MOVL @_IL, ACC

;.endif

;----------------------------------------------------------

 

 

  • We take the 12 bit ADC result (the converted data in ADC Result Register) in Q12 format and, therefore, it is a PU value i.e., normalized with respect to the max 12 bit number 4095. 

    Now if you look at code ADCRESULT1 is left shifted by 12 bit and then saved in Q24 format (2nd line of the code above). This maintains the same PU value, i.e., a Q12 number left shifted by 12 bit and then saved as Q24 number maintains the same PU value.

    Since ADCRESULT1 is saved in Q24 format and then the offset(0.02 PU) is subtracted from it, therefore, the offset also has to be in Q24 format. This is done by left shifting 82 by 12 bit. Because the number 82 is in Q12 format that represents the offset (82/4095 = 0.02). So when the number 82, in Q12 format, is left shifted by 12 bit it becomes a Q24 number. But this still maintains the actual PU offset of 0.02.

    Hope this helps answer your question.

    Shamim

  • Hi shamim,

    Thank you very much for the prompt reply. My main confusion was whether you have rounded up the offset of 0.026 to 0.02 in this piece of code or is it something else. I do understand that the ADCRESULT is kept in Q24 and has to be converter to Q12. I was asking the question because if you use 0.026 * 4095, its 106 and if you use 0.02 * 4095 its 82. These two values have a significant difference . Kindly explain?

    Applogies for the confusion.

    Many Thanks

    Pas

  • No I did not round the offset value. I just corrected partially by 0.02. The closed current loop will also correct for this offset. But you can also take the offset as 0.026 if that's what you see in your hardware.

  • Hi Shamim,

    Thank you very much for the explanation. appretiate your support

    Many Thanks

    Pas