Serial interface with RFID reader
Dear Helpful People:
I am trying to interface a PIC16F874A with an ID2 RFID reader (Mannings RFID; http://www.rfidshop.com), and am having no luck. The RD2 outputs a "start of text" code ($02) followed by 10 ASCII characters (an identification code) then a carriage return and a line feed. As a first step in a more in depth project, I want to read in those ten ascii characters and send them to a PC via another rs232 line. I have gotten all the components to work, but the whole thing won't come together.
I can send and recieve data from the PIC to a PC, and when I hook the ID2 up directly to the computer, I can read in the 10 character codes no problem at 9600 baud. So why can't the PIC read the codes in as well??
Here is some code I would like to use:
Include "modedefs.bas" ' Include serial modes
DEFINE OSC 20
SO VAR portb.0 ' Define serial out pin
SI VAR portb.1 ' Define serial in pin
RI VAR portb.3 ' serial in from reader
RR VAR portb.2 ' reader reset
B0 VAR byte 'byte variable
tag VAR BYTE[10] ' Creates a byte array of 10 bytes
HIGH RR 'reset Reader
loop: Serin SI,N9600,B0 ' B0 = input character
PAUSE 1500 'wait a sec
Serout SO,N9600,["ready", $0A, $0D] 'Send ready
SERIN2 RI, N9600,[WAIT($02),STR tag\10] 'get tag code
SEROUT SO,N9600,["got the code", $0A, $0D] 'acknowledge reciept
print: Serout SO,N9600,[tag,$0A, $0D] 'send code
Serout SO,N9600,[" done", $0A, $0D] 'send done
Goto loop 'do it again
I just can't get past the serin from the reader. I have tried T9600, and I've tried adding a pullup resistor to the line between the ID2 output and PIN B3. Also, I know that the reader is working because it has an LED indicator.
Please help (do not taunt)
My serin2 statement differs from the examples in the book in many ways. And I don't know which differences are important. I've tried lots of variations, and the error is not "plain as day" to me. Can I just get an answer? I promise I have not come the forum as a first resort.