why can I add VARs but not subtract?
epicjr77
Posts: 29
Hello I am expecting to get a value of 0 (or close to it possibly a negative number) for my I and j vars. For some reason I get a value around 65000 i=x-xzero j=y-yzero but when I use addition i=x+xzero j=y+yzero I get reasonable numbers
any Idea why? OR how can I fix this?
Also I only want to go through the "calibrate" process once then do the loop portion. Is this the best way to do so?
' {$STAMP BS2}
' {$PBASIC 2.5}
x VAR Word
y VAR Word
xzero VAR Word
yzero VAR Word
pulsecount VAR Byte
i VAR Word
j VAR Word
'
calibrate
FOR pulsecount = 0 TO 1
PULSIN 6,1,x
PULSIN 7,1,y
xzero=x
yzero=y
DEBUG CLS,?xzero ,?yzero
PAUSE 2000
NEXT
'
RUN
DO
PULSIN 6,1,x
PULSIN 7,1,y
i=x-xzero
j=y-yzero
DEBUG CLS,?x,?Y
PAUSE 1000
DEBUG CLS,?i,?j
PAUSE 1000
LOOP
any Idea why? OR how can I fix this?
Also I only want to go through the "calibrate" process once then do the loop portion. Is this the best way to do so?
' {$STAMP BS2}
' {$PBASIC 2.5}
x VAR Word
y VAR Word
xzero VAR Word
yzero VAR Word
pulsecount VAR Byte
i VAR Word
j VAR Word
'
calibrate
FOR pulsecount = 0 TO 1
PULSIN 6,1,x
PULSIN 7,1,y
xzero=x
yzero=y
DEBUG CLS,?xzero ,?yzero
PAUSE 2000
NEXT
'
RUN
DO
PULSIN 6,1,x
PULSIN 7,1,y
i=x-xzero
j=y-yzero
DEBUG CLS,?x,?Y
PAUSE 1000
DEBUG CLS,?i,?j
PAUSE 1000
LOOP
Comments
-Phil