
Originally Posted by
richard
14 mod 10 = 4 mod gives you the remainder after the division ie ten goes into 14 once with 4 leftover , its not what you want
frac = volts*10 mod 100 is what you want ie 1469 mod 100 = 69 but
the following is easier
forget the frac
volts_in = (volts_in * 10) / 498
try lcdout $fe, $c0, "voltage is: ", volts_in/100, ".", dec2 volts_in
Hmmm, neither of those seemed to work for me - didn't get what I was looking for.
Then I tried this:
Code:
MEASURE_VOLTS:
ADCIN 2, VOLTS_IN 'READ CURRENT VALUE OF INPUT VOLTAGE DIVIDER
VOLTS_VAL = (VOLTS_IN * 10) / 498
VOLTS_FRAC = (VOLTS_IN * 10) MOD 100
LCDOUT $FE, 1, "CURRENT INPUT"
LCDOUT $FE, $C0, "VOLTAGE IS: ", DEC2 VOLTS_VAL, ".", DEC2 VOLTS_FRAC
Still not right, so I modified the fraction line to: VOLTS_FRAC = ((VOLTS_IN * 10) / 498) MOD 100
But that gives me 14.14 - still not right. Any other ideas? And thanks again for the help
Bookmarks