Shop OBEX P1 Docs P2 Docs Learn Events
Serial out packaging issue....? — Parallax Forums

Serial out packaging issue....?

OllieOllie Posts: 7
edited 2006-04-25 19:09 in BASIC Stamp
I am trying to send the following hex data as a command to a RFID reader: 01 0b 00 03 04 62 00 00 00 6f 90
I'm using the bs2
I've tried sending it as:

serout so, baud, ($01, $0b......

I'm not getting a response from the RFID reader...?

Any ideas?

Thanks, Ollie

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-24 18:08
    Does the reader want the bytes as hex text? (not likely) Do you have the correct baud setting? (the most likely problem) It would be helpful to know the model of the device you're attempting to connect to and a link to technical data for it, otherwise everything you get will be educated guesses.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • OllieOllie Posts: 7
    edited 2006-04-24 18:22
    The reader is a TI MFR S4100. The packet that I'm sending it is listed in TI's 15693 standard as a slotted inventory request. TI won't give any support because I'm interfacing with the BS. A link to the pdf from TI is:[noparse][[/noparse]url]http://www.ti.com/rfid/docs/manuals/refmanuals/RF-MGR-MNMN-15693-refGuide.pdf

    page 21 is where the specific packet info is we are using....
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-04-24 18:44
    First question -- okay, what platform WILL TI provide support for?

    If it's a PC with a serial port, get the thing working that way with TI's help, then port it to a BS2 without their help.

    Second question: Why didn't you use the "[font=Arial,Bold size=2]01 0B 00 03 04 62 01 00 00 6E 91" from the example?[/font]
    [font=Arial,Bold size=2]·[/font]
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-24 18:56
    I don't think the packet is the issue, I think your baud value probably is. What baud rate/mode are you using? In another doc it's clear that the serial is TTL level, so you should be using TRUE mode. That same doc says it can go up to 38.4 kbaud, but it also mentions auto-synchronization (auto-baud?) -- though I couldn't find any other details. Also, are you connected to the correct pins and have a common ground between the Stamp and the module?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • OllieOllie Posts: 7
    edited 2006-04-24 19:22
    I have the following code to send the packet out and then once received properly I will add code later.

    RX pin 6
    TX pin 7

    BAUD con 84

    cmd var byte


    Main:

    DO

    serout TX, BAUD, [noparse][[/noparse]$01,$0b,$00,$03,$04,$62,$01,$00,$00,$00,$6E,$90] <
    This packet is for a slotted inventory request. page 20 of above mentioned link.
    debug "sent"
    Pause 2000
    serin RX, BAUD, [noparse][[/noparse]cmd] <
    never receive response from TI RFID READER
    debug HEX ? cmd <
    Just to see the value
    LOOP

    END
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-04-24 19:36
    You REALLY don't want that "Pause 2000" in there, nor the "send" output before the SERIN. The BS2 is not "Listening" for a response UNTIL you enter the "SERIN" command. Thus, your current code will drop any response returned to you in the 2 seconds that you're "not listening".

    Now, you might give the SERIN command a 2 second timeout.

    Just remember, the BS2 has NO UART buffer of any kind. It can ONLY recieve 232 when the code is sitting in a SERIN statement, waiting for it.
  • OllieOllie Posts: 7
    edited 2006-04-24 20:12
    We have code written in VB that works with this reader and it looks like from a text box it take the "package hex value" and converts it to a binary string and sends that to the reader and then it looks like the vb code gets in a binary string and re converts it back to hex and displays that to the screen.

    I am not a huge VB guy but it seems we have to send our hex out as a binary string.
    value = %convertedValue <
    value eqaul to hex [noparse][[/noparse]$01,$0b,$00,$03,$04,$62,$01,$00,$00,$00,$6E,$90]

    serout TX,BAUD,[noparse][[/noparse]value]
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-04-24 20:20
    Now, for the serin, you probably want something like:

    Resp VAR BYTE(6)

    SEROUT SerPin, baudmode, [noparse][[/noparse]$01,$0b,$00,$03,$04,$62,$01,$00,$00,$00,$6E,$90]

    SERIN SerPin2, baudmode, [noparse][[/noparse]STR Resp\6]

    And make sure you enter the SERIN immediately.

    then you can print:

    FOR I = 0 to 5
    · DEBUG ? Hex Resp(I)
    NEXT
    DEBUG 13
    ·
  • OllieOllie Posts: 7
    edited 2006-04-24 20:54
    When we write

    serout· TX,BAUD,[noparse][[/noparse]$01,$0b,$00,$03,$04,$62,$01,$00,$00,$00,$6E,$90]

    what or how are these hex values getting sent?· Meaning does basic stamp convert them into binary, ascii or what?

    With the following code we are stopped on the SERIN command waiting for some serial data.



    ·SEROUT· so, baud, [noparse][[/noparse]$01,$0b,$00,$03,$04,$62,$01,$00,$00,$00,$6E,$90]·· <---- still think·how we are sending this data is the·issue.···························· 1
    ··· SERIN·· si, baud, [noparse][[/noparse]STR Resp\6]
    ··· FOR I = 0 TO 5
    ····· DEBUG ? HEX Resp(I)·· <
    ·DOES NOT WORK HERE
    ····· NEXT
    ···· DEBUG 13· <---- what was this debug for that you put here?
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-04-24 21:17
    Hmm. Well, you COULD serin a single value, just to see if you're getting something.

    The "DEBUG 13" was to insert a carriage return in your output.

    And the result of your SEROUT would be the byte value for 1, the byte value for $0b, the byte value for $00, etc.
    In other words, it would match what the spec is requesting.

    The various "HEX" or "DEC" modfiers take the value and convert it into the String version of itself.

    So, SEROUT .... [noparse][[/noparse]13] will output a CR character.
    SEROUT ... [noparse][[/noparse]DEC 13] will output the string "13".

    You might single-step the VB version to determine what EXACTLY (including checksum) is being sent by the program. It's also possible the device is returning data to you so fast that the SERIN misses the first character.
  • OllieOllie Posts: 7
    edited 2006-04-24 21:26
    THanks a bunch the final code works below. You were a huge help.

    SEROUT so, baud, [noparse][[/noparse]$01,$0b,$00,$03,$04,$62,$00,$00,$00,$6F,$90]
    SERIN si, baud, [noparse][[/noparse]STR Resp\9]
    FOR x = 0 TO 8
    DEBUG HEX ? Resp(x)
    NEXT
    DEBUG 13
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-04-25 01:36
    Ollie said...(trimmed)
    When we write
    serout· TX,BAUD,[noparse][[/noparse]$01,$0b,$00,$03,$04,$62,$01,$00,$00,$00,$6E,$90]
    what or how are these hex values getting sent?· Meaning does basic stamp convert them into binary, ascii or what?
    This question comes up a lot...The data is stored in binary no matter what.· That is the only language the BASIC Stamp (or any microcontroller for that matter) understands.· The way you choose to express it (Binary, Hex or Decimal) does not change how it is stored.· So sending %00000001, $01 or 1 is always going to send the same data.· In this case, a binary 1.· Now if you needed an ASCII 1 (one) then you would use the DEC formatter.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Tom WalkerTom Walker Posts: 509
    edited 2006-04-25 13:28
    ...and if it helps you to visualize things, think about the physical way that data is sent...a typical serial digital communication scheme can only impose a high (+5, +12, mark, etc) or a low (0, -12, space, etc). How would something like "5" be sent WITHOUT using "binary".

    Remember, EVERYTHING in the digital world is only 1s and 0s. Microprocessors, themseves, can be thought of as streams with "gates" that direct the flows of 1s and 0s (sorry for the over-simplification, Chip, but my analogy generator is on the fritz). Anything else you see (even programs) is just a presentation of those 1s and 0s that makes more sense to our brains...

    I need sleep...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truly Understand the Fundamentals and the Path will be so much easier...
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-04-25 19:09
    Yay! I always love it when people figure out their problems.
Sign In or Register to comment.