sandrom

MC56F802x 56800E core - from ADC value to real Frac16

Discussion created by sandrom on Nov 9, 2017
Latest reply on Nov 14, 2017 by xiangjun.rong

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

Outcomes