PDA

View Full Version : LOOKUP tables



Brian Carpenter
08-18-2005, 11:02 AM
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, [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!!

Jon Williams
08-18-2005, 11:38 AM
You need to modify your LOOKDOWN to catch the values in between:

LOOKDOWN x, >=[7200, 7100, 7000, 6900, 6800, 6700, 6600, 6500, 6400], a

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Paul Baker
08-18-2005, 10:54 PM
Wow thats cool, I didn't know LOOKDOWN had the ability to modify it's comparasion operator, very handy.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10