Shop OBEX P1 Docs P2 Docs Learn Events
Reading Serial Input from a RFID reader — Parallax Forums

Reading Serial Input from a RFID reader

BrainBrain Posts: 5
edited 2005-03-10 15:08 in BASIC Stamp
Hi everyone,

I am new to this and to the basic stamp and I was hoping someone may be able to help me...

as part of a university project I am attempting to get my stamp 2 to read in from a microchip reader. The reader reads in either a 10 or 16 digit number (inc a decimal place) and although the stamp is getting input from the reader it a) seems to bear no resemblance to the numbers on the readers screen and b) it is fluctuates.

I have just started to read in and store it in a variable a byte long and I get something resembling

235
0
0
132
68

This is not exact but either way it is different each time I scan the same chip and I have tried conversion formatters but nothing I try seems to resemble any ASCII or anything.

I am confused as to what a byte of the readers 16 digit number is because and I also get special characters if I ask it to print out using DEBUG NameOfVariable but numbers if I use DEBUG ? NameOfVariable.

I have read around lots but the only thing I can think of is flow control but isn't this for 2 stamps only?
be received at 9600bps in ASCII
First I thought it could be the baud rate but the reader says "All data will formatted text" and I have tried all·baud rates to this equivalent.

Also i am very new to electronics and I am using all sorts of different thickness of wires-would this matter?

I know this is a bit confusing but hopefully someone can shed some light somewhere please!

Thanks in advance.

Brain

cry.gif

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-02-24 16:10
    If the output is text, you should be able to "see" it with a terminal program. That may be an easier way to experiment. I'm working with a small reader now that outputs text, but starts with a linefeed, sends ten character bytes, then finishes with a carriage return. It's all very easy to see in a terminal, and once everything is understood connecting it to a Stamp was easy. In my case, the code looked like this:

    SERIN RFID, Baud, [noparse][[/noparse]WAIT($0A), STR buf\10]

    Once things are fully sorted out I'll tell you more about the reader I'm using -- but this is all I can say for the moment.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-02-24 21:56
    SNEAK PEAK· freaked.gif

    The boss has given me permission to post -- the product will arrive from production house in a month or two, and you can see my article in the April issue of Nuts & Volts.

    attachment.php?attachmentid=37167

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA


    Post Edited (Jon Williams) : 2/24/2005 10:03:45 PM GMT
    417 x 500 - 22K
  • steve_bsteve_b Posts: 1,563
    edited 2005-02-24 22:39
    You're job is too cool!! lol

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve
    http://members.rogers.com/steve.brady
    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-02-24 23:11
    Yes, I am indeed the luckiest person you have ever heard of.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • BrainBrain Posts: 5
    edited 2005-02-25 09:48
    Hi there Jon,

    Thanks very much for replying to my post. The work you are doing is very interestingscool.gif· thanks for giving us an insight-I·am truly out of my league here! freaked.gif

    Not quite sure what u mean on your post?

    By terminal program do you mean using the BASIC stamp software on my computer to see·what the stamp reads in from the reader? If so that is what I am doing...

    The problem is that by trying to read in 1byte with

    VarName VAR Byte

    SERIN 5, 16780, (VarName)

    DEBUG ?·VarName·················· 'If I type DEBUG VarName without '?' I get special characters as output

    I get·this output :

    30

    96

    120

    120

    120

    120

    This doesn't seem to bear any resemblance in any format to the actual numbers on the LCD screen and I am trying to get exactly what is on it in the same format in my stamp 2.

    I am asking for one Byte of the number 978.000000305967 and it seems impossible to tell how much one byte of this is that it is reading especially as if I try and read again it sometimes changes the reading slightly for the same chip!

    I don't have a WAIT in my code, should I have?

    Any light you could shed on any of this would be a truly great help.

    Sorry about the lack of knowledge everyone-I am extremely new to this.

    Many Thanks

    A very confuesd Brain!
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-02-25 19:00
    What you need to do is capture all of the output at once. How many bytes are being transmitted by the reader in one burst? With the Parallax reader, the answer is 12 -- the first byte is always $0A, so this code is used:

    SERIN RX, Baud, [noparse][[/noparse]WAIT($0A), STR buf\10]

    This line causes SERIN to wait for the $0A character before capturing the next 10 bytes into an array called buf. You should be able to do the same thing with your reader. You cannot capture and display one byte at a time -- DEBUG takes a lot of time and while you're doing that you'd be missing other characters.

    So ... find out what value your header byte is; you should have one -- then sub that in for my $0A. Find out how many bytes your reader is transmitting. If the answer is 10, then define a buffer like this:

    buf VAR Byte(10)

    Then setup your code like mine. Once you capture a "packet" you can loop through the bytes to examine them (here's where you'd use DEBUG).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • MikeSMikeS Posts: 131
    edited 2005-02-25 21:18
    Jon,
    Will RFID tags be available from Parallax also?
    Mike S.
  • Ken GraceyKen Gracey Posts: 7,387
    edited 2005-02-25 23:39
    Mike,

    Yes, we will offer two of them for between $1 and $2. One is a 50 mm round "world tag" and the other is a credit-card sized tag. The models we chose are passive tags and they work well up to 4" from the RFID Reader Module. We will post our documentation for the RFID Reader Module on this thread early next week.

    Ken Gracey
    Parallax, Inc.
  • BrainBrain Posts: 5
    edited 2005-02-26 11:30
    Ahhh... that makes sense!!

    Right, I will experiment with that right away... not sure how many bytes the reader is sending, it has 16 characters on the LCD display but I am not sure how that corresponds to bytes but I guess I can try a few lengths and when·I examine the individual ouput after I should be able to work it out.

    Thank you very much Jon, I'll let you know how I get on.

    Thanks again

    Brain
  • Ken GraceyKen Gracey Posts: 7,387
    edited 2005-03-03 19:56
    Hello,

    I'm attaching the draft documentation for the Parallax RFID Reader.

    The product is currently in manufacturing and we expect it back within six-eight weeks. Please don't call our office to ask for a release date.

    The target price is about $29-$39, we aren't exactly sure yet. As you know, we're trying to keep our retail prices low so you can easily use our products. The RFID Reader is one of our more innovative accessories this year and we expect you to really enjoy this one.

    Ken Gracey
    Parallax, Inc.
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-03-03 20:09
    Ken, you guys are just AMAZING. It keeps getting better and better.

    First, you release the SX/B for the SX. Then, the new SX52 proto-board coming out real-soon-now. Then, this RFID tag reader gizmo.

    Man, I just hope people don't start pestering you on a daily basis for delivery dates, or better yet "what comes next?". You are doing so much for us, I hope people don't get completely unrealistic expectations.

    So, people, Ken will tell you whatever he can tell you whenever he can tell it. New stuff will arrive when the manufacturers get it to Parallax.

    Please don't pester them if you can avoid it. Thank you very much.
  • Tom WalkerTom Walker Posts: 509
    edited 2005-03-03 21:56
    But Ken, what's the release date <bg>...(bet you've been getting that one about PING))) as well...huh?)

    Looks like more good learning coming up!!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truly Understand the Fundamentals and the Path will be so much easier...
  • BrainBrain Posts: 5
    edited 2005-03-10 14:20
    Hi Jon, Ken and the rest of the innovative Parallax team,

    Thanks for the help regarding RFID serial input. I have finally managed to get it working for my BS2. The DEBUG function was taking too long and missing input but also the actually reader only runs at half the baud rate it says on the specification for it!!

    Was very interesting to see your code for your reader. I have stored all my numbers in EEPROM a byte at a time i.e. Tag1 = locations 1 thro 16, tag2 = locations 16 thro 31 etc.

    I thought this would be easier seen as·the chips read in are received one byte at a time too. I notice you store the Tags as one long data stream but how does the program iterate through each byte of this data to test it with the bytes of serial data coming in? I know I have the code but I am very new to this sort of thing and would like to understand why your method is more efficient in terms of memory and lines of code (I am assuming it is no doubt!).

    How would you actually insert the numbers into·EEPROM Do you have a keypad?

    Thanks for the insight, would be·brilliant to hear an explanation if possible please.

    Cheers

    Brain
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-10 15:08
    Brian,

    The demo program receives an RFID packet and THEN does the comparison, one byte at a time. If a byte comparison fails for a given (known) tag, that tag is aborted and the next is tested.

    For that program you have to know the tag numbers in advance and include them in the code. So, the first program you need is simple a reader that will display the RFID string. Copy that from the DEBUG output window and paste it into a DATA statement.

    Remember that this is a simple demo; it's purpose was to show how to receive the RFID string and compare it to known values. In a more complex system you could write code that lets you scan a new tag and store it in the EEPROM for you (see the WRITE command).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
Sign In or Register to comment.