PDA

View Full Version : How to convert ADC input for floating point display?



CuriousOne
- 27th June 2013, 09:24
Hello.

I'm doing a simple ADC reading circuit, which works fine, and I read the value into variable, but want to display it as floating point voltage, not the decimal. Since floating point operations not supported, I'm getting output "4" where I should get "4.1". Is there a way to add some dots?

Currently, I've configured it such way, that when voltage is 4.88v, the variable value is 488. So I need to somehow place point between 4 and 88, so it looks like "4.88"

pedja089
- 27th June 2013, 09:42
Voltage=488
LCDOUT $FE, $1, #(Voltage DIG 2), ".", DEC2 Voltage

CuriousOne
- 27th June 2013, 09:48
Thank you very much, it works!

HenrikOlsson
- 27th June 2013, 10:19
Or possibly

LCDOUT $FE, $1, DEC (Voltage/100), ".", DEC (Voltage // 100)
It produces slightly smaller code.

/Henrik.