The discussion which you've posted assumed a couple of things on the user side:
- Familiarity with ADC measurement circuitrys.
- Familiarity with TI's IQMath formats.
I would try to explain the answer, but in case if something is still unclear please go through the above two in more details.
Let us assume that you're measuing +-10A range using the picollo controller.
And let us consider that you're measuring i = +5A via signal conditioning circuitry at the ADC. This signal conditioning circuitry would take care of offsetting -10A to 0V and +10A to 3.3V.
i.e. +-10A are scaled to 0-->3.3V at ADC input, where 0A value is read as 1.65V at ADC.
Which means, i = 5A is converted into 1.65V + (1.65/2)V = 2.475V
The equivalent 12-bit ADC count would be = (4095*2.475V/3.3V) = 3071.
Now, as you've mentioned already, this 12-bit count is stored in an 16-bit register.
Also, as already mentioned, this is right justified.
i.e. Number is stored as below
AdcResult.ADCRESULT0 = 0x0BFF;
AdcResult.ADCRESULT0 : 0 0 0 0 1 0 1 1 1 1 1 1 1 1 1 1
Now, you need to convert this number into an equivalent +-1 pu value, for further processing FOC or any other algorithm. Which means, you'd need to multiply the ADC result by some value, and would require the result in a floating point. While this is possible directly by the controller, the multiplication operation alone does consume alot of processing time! To accelerate such operations, especially for fractional numbers, Texas Instruments' C28x processors use IQMath format inside the code. More on this is available at the link at end of this post.
First, the 16-bit ADC result is copied into a 32 bit accumulator "as-is".
Value: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 1 1 1 1 1 1
Then, it is converted into IQ15 format, where last 15-bits represent fractional part, justified left. Thus, the q-value would be:
Q-value = 0 0 0 1 0 1 1 1 1 1 1 1 1 1 1
Which is wrong, as first three bits are zero, and our information is stored from forth bit on-wards. Hence, the coder has shifted the value to left by 3-bits to correct the Q-value.
The IQ15 value thus, becomes:
ADCValue_Q15 =
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 1 1 1 1 1 1 0 0 0
Offset = 0.5 is subtracted which is 2^(-1) hence, Q value would be:
Offset_Q15: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ADCResult_Q15 = ADCValue_Q15 - Offset_Q15
ADCResult_Q15 =
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0
This value is still IQ15, which is converted into global Q-value, which I guess should be Q24.
ADCResult_Q24 =
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
Since, this is a representation of only half amplitude of the current (due to +- taken care by sign bit), we should now multiply this by 2.
Which is done intelligently by the coder by left-shift in the code!
Result_Q24 =
0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0
If I only look at the Q-value, which begins after bit-9 above in Q24 format, I'd get the result of ADC operation in pu here:
Q-value = 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0
Converting into equivalent number, sign = 0, int_value = 0;
ADC_Value_pu = 0*(2^(-1)) + 1*(2^(-2)) + 1*(2^(-3)) + 1*(2^(-4)) +
1*(2^(-5)) + 1*(2^(-6)) + 1*(2^(-7)) + 1*(2^(-8)) + 1*(2^(-9)) +
1*(2^(-10))
ADC_Value_pu = 0.499;
Which is an equivalent pu representation of 5A, for an ADC measuring +-10A.
I hope that explained it. For more information, please spend one day on understanding the IQMath format by following link:
http://processors.wiki.ti.com/images/8/8c/IQMath_fixed_vs_floating.pdf