#### late_voyager

##### New Member
hi
I am trying to set a 24v low batt alarm.
i have been trying to read w4 or b10 and b11 to add in code if w4 < 24xxx then alarm etc
cant seem to read w4 or b10,b11 and act on them however can display on screen
was trying:
if w4 < 23 then
goto lowbatt

or
if b10 <2 and b11<9 then
goto low batt

or
if b27<24 then blah..

Code:
``````Symbol bbatt = w4
Symbol batt = w8
symbol bbattv = 250
symbol battv = 38

bbatt = bbatt *bbattv
bintoascii bbatt,b10,b11,b12,b13,b14
batt = batt *battv
bintoascii batt,b18,b19,b20,b21,b22

serout C.0,N2400,(254,128)
serout C.0,N2400,("Batt ",b10,b11,"v - ",b18,".",b19,"v ")``````

#### Aries

##### New Member
(1) what values are you getting/expecting to get from your readadc10? Multiplying by 250 is a bit risky if your values can exceed 262 (out of a maximum of 1023)

There's nothing wrong with "if w4 < 23 then ...", provided w4 can actually be less than 23. However, if it is an integer multiplied by 250, it is either zero or greater than 250 (and certainly greater than 23) unless it overflows the 65535 maximum value for a word variable.

I don't think you mean "read w4,b27". That translates as
"take the value from the address in ROM gven by w4 (actually b8, because ROM is only 256 values) and put it in b27"

#### late_voyager

##### New Member
using 24v in
used 39k and 2.2k volt div to give 1.28v

Code:
``````FVRSETUP FVR2048      'Set Fixed Voltage Reference = 2.048 Volts
multiply by 1 instead of 250=

not looking for accurate +/- 1v is ok...

#### late_voyager

##### New Member
Juggled the math to get w4 and w8 to read 24... i had forgotten to put in division... THANKS

#### Aries

##### New Member
using 24v in
used 39k and 2.2k volt div to give 1.28v

not looking for accurate +/- 1v is ok...

#### bfgstew

##### Senior Member
Make your bbattv 106 and change the bbatt = bbatt*bbattv to bbatt = bbatt * 10 / bbattv

#### westaust55

##### Moderator
Word variable W4 uses byte variables b8 and b9 (not b10 and b11)

#### Aries

##### New Member
Word variable W4 uses byte variables b8 and b9 (not b10 and b11)
True, but late_voyager was using bintoascii to put w4 into b10 ... b14