RFID reader and PIC microcontroller
Hi all,
I am trying out a simple security system using RFID and a PIC microcontroller. The microcontroller I am using is a PIC16F877. I would like to know whether there r any problems if I connect the S/OUT pin of the RFID reader directly to the RC7 pin of the microcontroller. I read from www.cytron.com.my/topic.asp?tid=1747 that the S/OUT pin should be connected to a voltage level converter before connecting it to the PIC.
Is this correct? Currently, I am only able to read in the first 2 bytes of the unique ID of a RFID tag and I am suspecting that this might be causing the problem for me. If u need more info, I will gladly provide them cos I do not know what other info is required here.
Thanks for the help!
I am trying out a simple security system using RFID and a PIC microcontroller. The microcontroller I am using is a PIC16F877. I would like to know whether there r any problems if I connect the S/OUT pin of the RFID reader directly to the RC7 pin of the microcontroller. I read from www.cytron.com.my/topic.asp?tid=1747 that the S/OUT pin should be connected to a voltage level converter before connecting it to the PIC.
Is this correct? Currently, I am only able to read in the first 2 bytes of the unique ID of a RFID tag and I am suspecting that this might be causing the problem for me. If u need more info, I will gladly provide them cos I do not know what other info is required here.
Thanks for the help!
Comments
I determined that I have received an overrun error (OERR), which may explain why I am only able to receive the first two bytes. Could this be a problem of an incorrect baud timing?
For the PIC16F877, I have set BRGH (high baud rate select pin) to 0. This should let the PIC operate in a low-speed asynchronous mode. According to the formula given in the datasheet: (Asynchronous) Baud Rate = FOSC/(64(X+1)). My FOSC is 20Mhz and I have set X=129. Thus, the given baud rate should be equal 2403bps. This is pretty close to the 2400bps rate stated in the RFID reader datasheet. Is there any misconception on my part?
A part of code that does the above is shown:
BRGH=0; // Fosc/(64(X+1))=2400bps
SPBRG=129; // X=129
SYNC=0; // USART Mode Select bit: Asynchronous mode
SPEN=1; //Serial port enabled (RC7 takes input from SOUT)
CREN=1; //Enables continuous receive
My PIC datasheet can be found at this link. ww1.microchip.com/downloads/en/DeviceDoc/30292c.pdf
Relevant pages are from pg95 to pg102.
Thks in advance!
It looks like you're using C. Some C compilers (such as CCS C) have built in abstracted serial methods which are very helpful. You might try using those instead of fiddling with the calculations directly (hopefully your compiler supports that).
Post Edited (Harrison.) : 9/10/2008 6:10:36 AM GMT
Of course, you have to get started with Parallax's IDE. They do have SX/C now. You may even eventually want to program in Assembler to get all the complete flexiblity that virtual peripherals programing can provide.
The SX-28 is quite similar to a generic PIC, but the SXes have a bit more robust I/O if you are concerned with damage. One of the reasons for Parallax's success is that the chips are among the most difficult to damage - ideal for a beginner.
The SXes also have more RAM and more EEPROM than similar PIC counterparts.
By generic I mean that you don't have a hardware USART. But you can create a software USART with the virtual peripherals approach. SXList.com is very helpful for moving over from PICs to SXes if you want to learn Assembler.
The big advantage of the SX-28 and SX-48 is that you don't have to waste money buying different features and waste time learning a different chip. You just provide the appropriate firmware and become a superior firmware programmer in the process. Both are faster than PICs and can use that extra speed to create similar hardware features with virtual peripherals.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
It's sunny and warm here. It is always sunny and warm here.... (unless a typhoon blows through).
Tropically, G. Herzog [noparse][[/noparse] 黃鶴 ] in Taiwan