Shop OBEX P1 Docs P2 Docs Learn Events
BS2 SERIN 8 Byte String — Parallax Forums

BS2 SERIN 8 Byte String

Jeff_5_Jeff_5_ Posts: 36
edited 2011-06-20 20:29 in BASIC Stamp
Ok i have a Basic Stamp hooked into my RFID reader. MY reader outputs an 8 byte string. The first four byes are a unique tag id. The nest four are a 3 digit decimal value that varies with tag range. The last byte is NULL. Ex. 1nKQ (4byte Tag ID) 103_ (3 digit dec.) or 1nKq93_ _ Few questions how can i read in the first four bytes in to one variable via serin? I want to read in the Tag id store it then compare it to the next reads to verify same tag. Also i want to the the next four bytes in to a variable to can compare the decimal number to see if it fall within a certain range. I really just need to know how to read in two 4 byte strings in to two different variables. for comparison.

Comments

  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2011-06-19 17:59
    Hi Jeff, at this link http://forums.parallax.com/showthread.php?132399-Parsing-Serial-Input-String there is a similar exercise that may be useful in answering your question.

    Jeff T.
  • Jeff_5_Jeff_5_ Posts: 36
    edited 2011-06-20 04:48
    Thanks for the reply but its a little confusing to me. I thought i read somewhere you could use the serin_Char function where you can read in char by char and tell it the number of bits. Is this true and if so does anybody know the syntax of this function? Or a link to in in a Parallax Manuel.
  • Mike GMike G Posts: 2,702
    edited 2011-06-20 05:08
    Use the SERIN command; SERIN <pin> <baud> [data\8].

    You end up with a byte array in memory. It's up to you to process the raw bytes.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-06-20 07:36
    "serin_Char" probably refers to a library function for the Parallax Propeller written in Spin that's intended to be used to substitute for the SERIN statement when converting programs written for the Stamps.
  • Mike GMike G Posts: 2,702
    edited 2011-06-20 08:39
    Jeff_5_, Do you have a STAMP or a Propeller?
  • Jeff_5_Jeff_5_ Posts: 36
    edited 2011-06-20 10:18
    I have the stamp. Its the BS2 Homework board.

    If i do this

    Tag VAR Byte

    SERIN 1, 84, [Tag/8]

    Can i need compare Tag to a value. Like

    It Tag="1234"

    Then do some other function
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2011-06-20 10:37
    Hi, as it is the SERIN instruction reads 8 bytes into an 8 byte array named "Tag".

    So if your RFID tag was actually 1234 in ASCII format then Tag(0) would contain "1", Tag(1) would contain "2", Tag(2) "3" and Tag(3) "4"

    BTW it's a backslash "\" not a forward slash "/" and the array should be declared Tag VAR Byte(8)

    Jeff T.
  • Jeff_5_Jeff_5_ Posts: 36
    edited 2011-06-20 19:29
    My tag is 8 bytes total. The first 4 bytes are the Tag ID the next four are a distance meter Decimal number 0-100.

    I want to have a function activated by holding a push button for 5 seconds that will read and store 3 tag ids (ONLY THE FIRST FOUR BYTES) I dont care about the distance here. This i will be saved and names TAG1 TAG2 TAG3

    Now in the main program Read Again in a loop all 8 bytes (TAG4) then run a loop these does these comparisons


    If Range (last four bytes) is great than 80 and if TAG4 Equals TAG1 or TAG2 or TAG3 Then do some code.

    This would be much easier if i could read my tag ids into a single variable for comparison.
  • Mike GMike G Posts: 2,702
    edited 2011-06-20 20:29
    Post a link to your RFID device.
Sign In or Register to comment.