Shop OBEX P1 Docs P2 Docs Learn Events
Sending a number greater than 256? — Parallax Forums

Sending a number greater than 256?

worthyamherstworthyamherst Posts: 46
edited 2011-08-02 07:53 in BASIC Stamp
So i'm running into an issue in which i'm sending some sensor data wirelessly from stamp to stamp. The issue comes in when i have a numerical value greater than 256, the received/displayed data appears as said number - 256. Are there any solutions that anyone can offer? Example codes would be helpful

Comments

  • LeonLeon Posts: 7,620
    edited 2011-07-26 12:47
    Send it as two consecutive bytes?
  • worthyamherstworthyamherst Posts: 46
    edited 2011-07-27 06:03
    Leon wrote: »
    Send it as two consecutive bytes?

    I tried to do that but it still was not reading the data properly. So i then tried to using liek the 00001111, and then a 11110000 in order to break it up but that did not work
  • stamptrolstamptrol Posts: 1,731
    edited 2011-07-27 06:51
    The number you want to send is a WORD sized variable. Send the two pieces by using the HIGHBYTE and LOWBYTE modifiers. See the Helpfile.

    On the receiving end, re-assemble the WORD. variable= (256*highbyte) + (lowbyte)
  • worthyamherstworthyamherst Posts: 46
    edited 2011-07-28 08:34
    stamptrol wrote: »
    The number you want to send is a WORD sized variable. Send the two pieces by using the HIGHBYTE and LOWBYTE modifiers. See the Helpfile.

    On the receiving end, re-assemble the WORD. variable= (256*highbyte) + (lowbyte)
    We actually ended up using a masking system and different identifiers on the coding and then adjusted how it debugged/displayed
  • skylightskylight Posts: 1,915
    edited 2011-07-28 12:32
    could you also have divided the value by half before sending then double the result at the other end?
  • worthyamherstworthyamherst Posts: 46
    edited 2011-08-02 07:53
    skylight wrote: »
    could you also have divided the value by half before sending then double the result at the other end?
    we attempted to do that sort of thing at first but then because of the way it was sending it couldn't receive decimal values cause we were sending fairly small values
Sign In or Register to comment.