Hello,
I'm using MC56F8023 DSC and I would like to better understand relatioship between ADC value read from A/D converter and the Fractional arithmetic. Consider this example (based on AN1911).
We have the A/D converter (12 bit) that reads the DC Bus from a classic voltage divider. The fractional values used in the algorithms are scaled on 309.0 V, so for example 60V become ((60.0 / 309.0) * 32767) = 6362.
My question is: how do I convert the 4095-based value read from ADC to its corresponding Fractional value?
I tried this:
Frac16 value;
value = FRAC16(adcValue / 4096.0);
But I think this is not the right way (I get almost the value I expect, but not the precise one), am I right?
Thanks in advance
Sandro
Hi, Sandro,
This is the ADC result register format:
The maximum positive sample value is 0x7FF0 when the analog voltage is 3.3V in single-ended mode, the minimum negative sample value is 0x8000 when the analog voltage is -3.3V in differential mode or the OFFSET register value is 0x4000 in single-ended mode.
In conclusion, after you read the ADC result register to a variable, the variable is in FRAC16 format itself, you do not need any operation.
Hope it can help you
BR
Xiangjun Rong
Hello Xiangjun,
thank you for the answer, this is cool! I didn't figure out that the 3-bit offset would adapt the register with the Fractional arithmetic. My mistake was that I use macro from PE to get the ADC value, and this macro give the value without the 3-bit offset, correctly, but not for my need.
I try now to use the value with the offset, and if I still have problem I will let you know.
OT: do you think that this register-format was made apposite for Frac purpose?
Thank you very much Xiangjun,
BR
Sandro
Hi, Sandro,
Yes, the ADC result register format is designed to be apposite for Frac purpose.
Hope it can help you
BR
Xiangjun rong