ADC Voltage Display ?

awlsr46

New Member
Hello
Is there code writen already that will display
the A/D port directly?
Like if there is 2.5v reads 128, Convert that to read 2.5volts on a serLCD ??

Thanks

-AWL
 

evanh

Senior Member
Your basic linear equation: y=Ax+B, or y=A(x+B)
Where <b>y </b> is number to be displayed, <b>x </b> is raw data from the ADC, <b>A </b> is the scale factor (gain, magnitude, Beta) and <b>B </b> is the offset compensation (zero offset, balance, calibration point).

Note: To get a couple of decimal points in the voltage readout the converted reading is a hundred times bigger than the real voltage.

<code><pre><font size=2>
symbol reading = w0
symbol gain = 192 ;This is treated as 1.92
symbol zero = 10 ;This is treated as 0.1 volts

loop:
readadc 0,reading
reading = reading * gain / 100 + zero ;The divide by 100 here is not related to the two decimal point of the final value

sertxd( &quot;Voltage is &quot;, reading/100, &quot;.&quot;, reading%100, &quot; &quot;, 13 )
goto loop
</font></pre></code>

This is the point where everyone that goes through the exercise wakes up to the usefulness of maths, going &quot;OMG, this stuff really does have real-world meaning!&quot;. Enjoy! :)


Evan

Edited by - evanh on 9/6/2005 10:14:05 PM
 
Top