Shop OBEX P1 Docs P2 Docs Learn Events
reading Parallel data — Parallax Forums

reading Parallel data

GadgetguyGadgetguy Posts: 4
edited 2004-11-23 03:48 in BASIC Stamp
Hello!

I am new at this Stamp programming.· I bought the starter package about 3 years ago, and am finally getting around to using it.· Anyway, here is my dilema-· I have two sets of parallel data (binary coded 1-2-4-8-16) that will be presented to two sets of input pins, essentially using 0 thru 4 and 5 thru 9.· Another input will control the program run command that will operate a control relay based on the data present on the two sets of binary data on the input pins.· At the end of the sequence, an additional·output pin will reset the registers that are storing the data on the 0-9 input pins.· I would like to combine (add) each set of binary data into a·decimal format that will be stored as a variable, so that in the running program I can refer to this variable in·decimal·form, rather that 5 bits of information.· Any ideas?

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-23 03:48
    With PBASIC, that's a breeze:

    value1 = INL & %00011111
    value2 = INS >> 5 & %00011111

    The first line masks bits 5 - 8 from the INL (P0 - P7 inputs) port. The second line shifts all the inputs·(P0 - P15)·right five bits to align the LSB with bit zero of value2, then masks out all but the lower 5 bits. Easy.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office


    Post Edited (Jon Williams) : 11/23/2004 3:49:57 AM GMT
Sign In or Register to comment.