RFID reader cxn to BS2
Don V
Posts: 3
KHi! I'm a newbie. I am working on an RFID reader project and I have the Parallax / Grand Idea RFID reader connected to LED and tone circuits. I downloaded and modified the RFID1.BS2 program, but the program I/O defInitions call for pin 0 of the reader as the Enable and pin 1 as the RX and pin 2 as the Speaker output and pin 3 as the latch. I plan to use the speaker output as is and the latch pin as my LED output, but I am confused as to how I connect the BS2 to the reader. Anybody solved this issue? Thanks!
Post Edited (Don V) : 9/25/2009 11:47:50 PM GMT
Post Edited (Don V) : 9/25/2009 11:47:50 PM GMT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
50 72 6F 6A 65 63 74 20 53 69 74 65
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
I'm also a newbie and have the RFID Reader, USB version, as well as the BASIC Stamp Discovery Kit, which includes the Board of Discovery. I connected the reader to my laptop via the USB port and then copied the RFID1.BS2 program into the Basic Stamp Editor. Using the program I was able to read the tags that came with the Sampler kit and display them on the laptop. That was with connecting the reader to the laptop vi the USB port. I have been working my way thru the exercises that came with the Discovery Kit, including the ones that have to do with operating the servo. For those exercises, I connected the BS2 to the laptop running the editor using the USB connection. My question is about how to connect both the reader and the BS2 to the laptop so that I can write and run a program that operates the servo based on input from the reader. Do I connect both the reader and the BS2 to the laptop using different USB ports and then somehow operate the servo thru the BS2, after reading input from the reader?
The Stamp is also designed to connect via USB to a PC. This connection is used for programming and for debugging, but can also be used for transferring data back and forth between the Stamp and a program on the PC. To the Stamp program, this connection looks like any other serial I/O connection and you can use the DEBUG and DEBUGIN statements to send and receive respectively. You can also use SEROUT and SERIN with a pin number of 16 (a special case ... there are only I/O pins 0-15) to do the same thing. On the PC side, you can also have a Visual Basic program using the same techniques that are used with the RFID reader. The main difference is that the DTR line is used to enable the RFID Reader. With the Stamp, the DTR line causes the Stamp to reset so it can be programmed.
You can have a Visual Basic program that communicates via two separate serial ports, but that's beyond the scope of this forum other than to say that it would use one serial port to read an RFID tag, somehow process the data, then use the other serial port to send some data to the Stamp where the Stamp would use the data to control the servo. This could be something as simple as a single number from 250 to 750 sent from the PC with a carriage return on the end. The Stamp would read this number with "DEBUGIN DEC number" and use the value to produce a control pulse for the servo with "PULSOUT servoPin,number".
Thanks for the great response. My ultimate goal is to have the Stamp connected to the RFID reader and the servo only, with the PC out of the loop. I was operating on the assumption, maybe erroneous, that I could write a program and load it into the Stamp that would cause the it to move the servo when a tag with the right code is presented to the RFID reader. I've written programs for the Stamp that cause it to move the server and I've written programs that print out the codes from the tags presented to the reader. You mentioned writing a VB pgm that communicated with the two separate serial ports, but I'm afraid that I didn't follow that thread. Thank you.
I'll order the serial version asap. I take it from your comment that I can plug that version of the reader directly into the BOE, and therefore to the stamp.
I appreciate the help.
I got the serial verison of the RFID reader and I apologize in advance for the elementary nature of this next question. How do I connect the reader to the Board of Discovery so that I write a program that reads from the reader and based on what it reads, operates the servo?
Thanks,
Ryan
Attached is a ZIP with a few programs.
Instead of branching to a servo routine they branch to a
couple of different LED
routines based on the ID.
I labelled the pins in the declarations.
Thanks for your zip file. That was helpful. I have resolved the problem that I was having with the physical connection of the reader to the BOE itself. Now the problem that I'm experiencing is with the SERIN command itself. I have one version of the command that I took right from the example code that uses the WAIT qualifier:
SERIN RX, T2400, [WAIT($0A), STR buf\10]
I'm not sure exactly what it's waiting for, but it appears to be a hex representation of numbers and letters, so either will be accepted. It then populates the buf array with what it reads. In this case it's the 10 chars from the RFID tag.
I want to use the TIMEOUT option and it appears that this is mutually exclusive of the WAIT qualifier but may be wrong on that. Either way, I have tried the following SERIN command and it populates the buf array also, but always leaves the first position in the array [0] blank for some reason.
SERIN RX, T2400, 5000, No_Data, [STR buf\10]
Does anyone have an idea as to why it's doing that?
Thank you
So after a real life (work) induced absence, I was able to continue work on my project. Here's the question that I can't seem to answer regarding the RFID reader. IF it's powered up and running and you bring one of the tags in range, it recognizes it and prints the tag id just as expected. What happens if you leave the tag in range? Can the reader detect a tag that is in range when it is powered up? What if the tag stays in range? Here's the dilemma: I bring the tag in range and as long as it is in range I want to perfrom one action, (open the door and keep it open), once the tag goes out of range, I want to perform another action (close the door). I've set up a loop in the PBASIC pgm that I thought would do it but it doesn't seem to recognize that the tag is in range the second time around.
######
DO
DEBUG "BEGIN", CR
GOSUB Close_Servo ' Move servo to Closed position
DEBUG "Activating the Reader", CR
LOW Enable ' activate the reader
SERIN RX, T2400, 10000, No_Data, [WAIT($0A), STR buf\10]
FOR tagNum = 1 TO LastTag ' scan through known tags
FOR idx = 0 TO 9 ' scan bytes in tag
READ (tagNum - 1 * 10 + idx), char ' get tag data from table
IF (char <> buf(idx)) THEN Bad_Char ' compare tag to table
NEXT
GOTO Tag_Found ' all bytes match!
Bad_Char:
NEXT
Bad_Tag:
tagNum = 0
GOSUB Show_Name ' print message
GOTO Main
Tag_Found:
GOSUB Show_Name ' print name
GOSUB Open_Servo ' Move server to Open position
FREQOUT Spkr, 2000 */ TmAdj, 880 */ FrAdj ' beep
GOTO Main
LOOP
END
######
Also, where is Main?
Thanks. I admit that I'm not familiar with the 'code' tags that you mentioned. I did indent but as you mentioned they didn't show up.
Ryan
SERIN RX, T2400, [WAIT($0A), STR buf\10]
What are you telling the code to do when it get to No_Data this need to go to a routine and told what to next
I hope this helps
SERIN RX, T2400, 10000, No_Data, [WAIT($0A), STR buf\10]
Also remember that you have to keep updating the servo position this a MUST
I hope this helps
Thank you. I am looping to keep the servo position constant.
What I ams seeing has more to do with the RFID reader than the servo.
The reader works fine if the reader is on and a tag is presented to it.
However, if the tag is already present and in range then the reader doesn't seem to recognize that it's there.
Ryan
2) open servo
3) poll rfid till "the right" card is not presented or no card is presented
4) move servo back
Managing a SERIN amidst a servo routine may prove a challenge.
You have to make that every 20msec rendezvous.
It'd be a cinch with a ServoPal.
Thanks for the tip. I'll give this a try.
I'm not familiar with ServoPal. What is that?
Ryan
http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/servopal/List/0/SortField/4/ProductID/481/Default.aspx