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( "Voltage is ", reading/100, ".", reading%100, " ", 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 "OMG, this stuff really does have real-world meaning!". Enjoy!
Evan
Edited by - evanh on 9/6/2005 10:14:05 PM