PBP doesn't support floating point, but you don't really need it for A/D
conversions.
For 8-bit A/D you can do something like this;
Quanta CON 5000 ' set this to +Vref. @5V use 5000. @4.990V 4990, etc.
Read the A/D value
ADCIN 0,ADval ' read RA0 A/D into word var ADval
ADval = ADval */ Quanta ' use middle 16-bits of multiplication.
LCDOUT DEC ADval DIG 3,".",DEC3 ADval ' 5.000, 3.962, etc,,
For 10-bit;
Quanta CON 1251 ' If +Vref = 5V.
To find Quanta take +Vref / 1023.
If +Vref = 5V then 5 / 1023 = 4.887mV.
4.887mV * 256 = 1.251 or 1251 for Quanta.
You can tweak the Quanta value to improve results. It may vary slightly from
PIC to PIC, but you want a good solid +Vref.
Bookmarks