Shop OBEX P1 Docs P2 Docs Learn Events
LOOKUP tables — Parallax Forums

LOOKUP tables

Brian CarpenterBrian Carpenter Posts: 728
edited 2005-08-18 15:54 in BASIC Stamp
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!!

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-18 04:38
    You need to modify your LOOKDOWN to catch the values in between:

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

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-08-18 15:54
    Wow thats cool, I didn't know LOOKDOWN had the ability to modify it's comparasion operator, very handy.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
Sign In or Register to comment.