LOOKUP tables
Brian Carpenter
Posts: 728
I have a memsic unit that will be mounted in my plane to keep the wings level.· I dont need to know what the angle is, just 5 or 7 set points·that if it gets there, it needs to respond with a correction.· i know that the range is between 7200 and 6400 pulses.· can i use a lookup table to handle this?· ie.. if 6500 than do one thing.
· ' SimpleTilt.bs2
' Measure room temperature tilt.
'{$STAMP BS2p}
'{$PBASIC 2.5}
x VAR Word
y VAR Word
a VAR Word
DO
PULSIN 6, 1, x
PULSIN 7, 1, y
DEBUG CLS, ? X, ? Y
IF x > 6800 THEN
HIGH 15
LOW 14
ENDIF
IF x < 6800 THEN
LOW 15
HIGH 14
ENDIF
LOOKDOWN x, [noparse][[/noparse]7200, 7100, 7000, 6900, 6800, 6700, 6600, 6500, 6400], a
·PAUSE 300
DEBUG CR, CR, CR, CR, "value is", DEC a
LOOP
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
It's Only A Stupid Question If You Have Not Googled It First!!
· ' SimpleTilt.bs2
' Measure room temperature tilt.
'{$STAMP BS2p}
'{$PBASIC 2.5}
x VAR Word
y VAR Word
a VAR Word
DO
PULSIN 6, 1, x
PULSIN 7, 1, y
DEBUG CLS, ? X, ? Y
IF x > 6800 THEN
HIGH 15
LOW 14
ENDIF
IF x < 6800 THEN
LOW 15
HIGH 14
ENDIF
LOOKDOWN x, [noparse][[/noparse]7200, 7100, 7000, 6900, 6800, 6700, 6600, 6500, 6400], a
·PAUSE 300
DEBUG CR, CR, CR, CR, "value is", DEC a
LOOP
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
It's Only A Stupid Question If You Have Not Googled It First!!
Comments
LOOKDOWN x, >=[noparse][[/noparse]7200, 7100, 7000, 6900, 6800, 6700, 6600, 6500, 6400], a
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10