need help comparing this varible
skynugget
Posts: 172
hi all i have this battery charge monitor that i can communicate via serial and i am having trouble with a signed varible
the charger gives me me 16bit numbers in 8bit form strings so i get grab them like this
SERIN TXD, sbaud, 2000, NoGo, [noparse][[/noparse]Amps.HIGHBYTE,Amps.LOWBYTE]
now amps = a value from -32768-32767 in twos compliment
ie -200 = 65336
my question is how can i make the stamp realize this is a signed varible so that i can compare it like
if amps > -200 then go
thanks in advance!
the charger gives me me 16bit numbers in 8bit form strings so i get grab them like this
SERIN TXD, sbaud, 2000, NoGo, [noparse][[/noparse]Amps.HIGHBYTE,Amps.LOWBYTE]
now amps = a value from -32768-32767 in twos compliment
ie -200 = 65336
my question is how can i make the stamp realize this is a signed varible so that i can compare it like
if amps > -200 then go
thanks in advance!
Comments
this thread:
http://forums.parallax.com/forums/default.aspx?f=5&m=75016&g=75032#m75032
provided the solution of adding a 32768 offset to my numbers.. works like a charm!