Shop OBEX P1 Docs P2 Docs Learn Events
Argg! Why won't Stamp DAQ read values greater than 255? — Parallax Forums

Argg! Why won't Stamp DAQ read values greater than 255?

evergreenevergreen Posts: 43
edited 2006-05-17 03:30 in BASIC Stamp
Hey guys,

So pretty much I'm saving 400 values, with each value between 0-4095. I'm saving them as words, in EEPROM locations of 0-800 (step 2). After all of my data is saved (I tested by saving 4095 to all 400 locations), I run the attached program (dump test 001), which is a modified version of the example code that came with DAQ. I then go into DAQ, check the "download data" box, and click the "connect" button. DAQ then quickly reads all of the values in EEPROM locations 0-800 (step 2), and dumps it into a row.

Now here' the problem. All of the values are 255, instead of 4095. I've messed with the example dump code, and made all the variables words, hoping they would be large enough to hold the number "4095".

Does anyone know how to fix this problem?

Thanks
Matt

Comments

  • Adrian SchneiderAdrian Schneider Posts: 92
    edited 2006-05-16 07:31
    Hi Matt.
    READ/WRITE are by default byte sized. To handle multibyte values such as word use something like:

    READ X,StoreVal.LOWBYTE
    READ X+1,StoreVal.HIGHBYTE

    Regards
    Adrian
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-05-16 08:01
    Adrian and Matt -

    What Adrian said is correct, as far as it went. However, in PBASIC 2.5 there is another option as shown by this example extractred from the PBASIC Help File:

    quote

    ' {$PBASIC 2.5}

    idNum VAR Word
    score VAR Byte

    ID_Rec DATA Word 1125, 75 ' Store multiple items

    Main:
    READ ID_Rec, Word idNum, score ' Read multiple variables


    end quote

    As you can see, the new sub-parameter WORD was introduced as an optional part of the READ/WRITE command, such that WORD-sized varaibles can be read and written more easily. Adrian's example will work on any PBASIC level.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • evergreenevergreen Posts: 43
    edited 2006-05-17 03:30
    Okay, thanks you guys. But if I read two different values (highbyte and lowbyte), how do I combine them into a word and send it to DAQ?
    Thanks
    Matt
Sign In or Register to comment.