RFID Projects

eagletalontimeagletalontim Posts: 1,384
edited 2010-12-12 - 22:13:16 in Microcontrollers
I guess my last post was in the wrong place since no one replied to it :( I am attempting to create a hand held RFID tag reader which will display the tag's key on a 2x16 display without using a computer. As of now, I am am having and issue with the reader code itself. Each digit from the key is saved in a variable tagBuf like in the example code for the reader. I am using tagBuf(idx1) = RX_RFID to read the key 1 digit at a time. For some reason, if I pass the key in front of the reader, the chip "hangs" until I hold the key in front of the reader. It is like the tagBuf(idx1) = RX_RFID is not getting all the information and pauses the whole code till it finishes reading it.

Here is my current code :
FREQ            4_000_000
ID              "RFID"

LcdTx           VAR     RA.2                    ' LCD serial connection
RfidEn          VAR     RA.1                    ' RFID enable control
RfidRx          VAR     RA.0                    ' RFID serial input
Beeper          VAR     RB.0                    ' lock control

TagMax          CON     1                       ' three tags, (0 - 2)

LcdBaud         CON     "T19200"                ' or T2400, or T9600
RfidBaud        CON     "T2400"

LcdBkSpc        CON     $08                     ' move cursor left
LcdRt           CON     $09                     ' move cursor right
LcdLF           CON     $0A                     ' move cursor down 1 line
LcdCls          CON     $0C                     ' clear LCD (need 5 ms delay)
LcdCR           CON     $0D                     ' move pos 0 of next line
LcdBLon         CON     $11                     ' backlight on
LcdBLoff        CON     $12                     ' backlight off
LcdOff          CON     $15                     ' LCD off
LcdOn1          CON     $16                     ' LCD on; no crsr, no blink
LcdOn2          CON     $17                     ' LCD on; no crsr, blink on
LcdOn3          CON     $18                     ' LCD on; crsr on, no blink
LcdOn4          CON     $19                     ' LCD on; crsr on, blink on
LcdLine1        CON     $80                     ' move to line 1, column 0
LcdLine2        CON     $94                     ' move to line 2, column 0

Active          CON     0                       ' for RFID reader
Deactivated     CON     1

Open            CON     1                       ' for lock
Closed          CON     0

' -------------------------------------------------------------------------
' Variables
' -------------------------------------------------------------------------

idx1            VAR     Byte                    ' loop control
idx2            VAR     Byte
char            VAR     Byte

tagBuf          VAR     Byte(10)                ' tag bytes from reader
tagNum          VAR     Byte                    ' tag number
offset          VAR     Byte

tmpB1           VAR     Byte                    ' subroutine work vars
tmpB2           VAR     Byte
tmpB3           VAR     Byte
tmpB4           VAR     Byte
tmpB5           VAR     Byte
tmpW1           VAR     Word

' =========================================================================
' =========================================================================

DELAY           SUB     1, 2                    ' delay in milliseconds
LCD_OUT         SUB     1, 2                    ' byte or string to LCD
CLEAR_LCD       SUB     0                       ' clear LCD, BL is on
RX_RFID         SUB     0                       ' get char from RFID
print       	SUB	3, 4
Beep		SUB	2

' -------------------------------------------------------------------------
' Program Code
' -------------------------------------------------------------------------

  PLP_B = %00000001                             ' pull up unused pins
  PLP_C = %00000000
  RA = %0011                                    ' disable reader, lock it up
  TRIS_A = %0100

  Beep 1, 100
  print "Present ID.", 1, 1
  DELAY 1000
  LOW RfidEn
    char = RX_RFID
  LOOP UNTIL char = $0A 

' *************  It is hanging here ****************

  FOR idx1 = 0 TO 9                             ' get RFID bytes
    tagBuf(idx1) = RX_RFID
    IF tagBuf(idx1) = 0 THEN Next_Tag
    'print tagBuf(idx1), 2, 1
    print "Test...         ", 1, 1

  HIGH RfidEn
  GOTO Main

  tmpB1 = __PARAM1
  tmpB2 = __PARAM2
  tmpB3 = tmpB2 / 2
  FOR tmpB4 = 0 TO tmpB1
    HIGH Beeper
    DELAY tmpB3
    LOW Beeper
    DELAY tmpB3    

    tmpW1 = __PARAM1                            ' save byte value
    tmpW1 = __WPARAM12                          ' save word value
  PAUSE tmpW1

  tmpB1 = __PARAM1                ' save the byte
  SEROUT LcdTx, LcdBaud, tmpB1        ' transmit to LCD

  tmpW1 = __WPARAM12                            ' get string offset
  tmpB3 = __PARAM3
  tmpB4 = __PARAM4

  LCD_OUT LcdLine1
  IF tmpB3 = 1 THEN
    LCD_OUT LcdLine1
  ELSEIF tmpB3 = 2 THEN
    LCD_OUT LcdLine2
  FOR tmpB5 = 1 TO tmpB4
    LCD_OUT LcdRt
  LCD_OUT LcdBkSpc
    READ tmpW1, tmpB5                     ' read a character
    IF tmpB5 = 0 THEN EXIT                      ' if 0, string complete
    SEROUT LcdTx, LcdBaud, tmpB5
    INC tmpW1                                   ' point to next character

  LCD_OUT LcdBLon                               ' backlight on
  LCD_OUT LcdOn1                                ' no cursor or blink
  LCD_OUT LcdCls                                ' clear the LCD

  SERIN RfidRx, RfidBaud, tmpB1
  RETURN tmpB1

  DATA "ABCDEF0123456789"


Any help would be greatly appreciated!


  • Mike GreenMike Green Posts: 22,917
    edited 2010-12-11 - 11:36:26
    It's against forum rules to cross-post (post essentially the same message in more than one forum).

    Your question belongs in the SX forum or maybe the sensor forum. You're asking for help with your SX coding rather than how the RFID reader works, so the SX forum might be best. You're not getting answers because not that many forum members use the SX as compared to the Stamps or the Propeller
  • eagletalontimeagletalontim Posts: 1,384
    edited 2010-12-12 - 08:05:04
    Sorry about that. The forum has changed since the last time I posted and the SX forum was all sticky threads. I was not sure if I could post here. I did end up figuring out my problem and it all works now :) The problem was the speed I was running my chip at. So for future reference, the SX must be run with an external clock in order to read the RFID correctly.
  • RobotWorkshopRobotWorkshop Posts: 2,300
    edited 2010-12-12 - 12:16:15
    If you are doing any serial routines then it is best to use an external clock/resonator to ensure it is accurate. You might be able to get away with it on some devices if you calibrate the internal RC clock but I wouldn't risk it.

    For projects that don't need to run faster than the internal RC clock and that don't need precice timing the internal clock can work out ok.
  • eagletalontimeagletalontim Posts: 1,384
    edited 2010-12-12 - 12:54:40
    The product that I sell with the SX does not need timing at all and I got used to not using an external clock. Now I am having problems with power issues as listed in the Sensors topic. All I have access to is 7805 (5v) regulators due to budget for this project. When I move the circuit to my project board, and connect it to the power source (12v 7.5Ah battery), the 7805 get VERY HOT. Since the 12 volt battery is required, I need to find a way to power the SX chip, RFID reader, 2x16 1 wire serial display from Parallax, and a 256k eprom. The project is for an access control for my shed. If the power goes off, I still need to get in to it which is why the battery is required. A 9v battery will not have enough power to run a Mag lock if the power goes off and I don't want the doors to come open in case a bad storm comes and knocks the power out.
  • Mike GreenMike Green Posts: 22,917
    edited 2010-12-12 - 14:40:59
    Do you have any idea how much current is drawn from the +5V supply? With a 12V input to the regulator, you will have a 7V drop and any significant amount of current will result in quite a bit of heat to dissipate. The SX doesn't draw very much and an EEPROM won't draw much. Parallax's 2x16 displays don't draw much. That leaves the RFID reader. Make sure you don't leave it on most or all of the time. If you can activate it once or twice a second, just for enough time for one cycle (like 1/10 second), you'll cut down the power consumption significantly. Put an LED where it's visible from the outside and use that to tell the user that the RFID reader is active.

    If you don't want to do that, use a big heatsink to keep the 7805 cool.
  • eagletalontimeagletalontim Posts: 1,384
    edited 2010-12-12 - 17:38:06
    Thanks for your reply! Would it be possible to get another regulator, lets say a 9v output, and put that before the 7805 so there is not that much of a drop or would that have any affect at all? I have been digging though my electronics and have found a few regulators that I need to test and see what voltage they put out. I did notice the 7805 did still get pretty warm with just the SX and the EEPROM running...nothing else. I have had this problem in the past when running the SX with an external clock. As soon as I changed the code back to the internal clock and removed the crystal, the temp would stay low. For this project, I am running it at 5Mhz which is the only crystals I have on hand.
  • RobotWorkshopRobotWorkshop Posts: 2,300
    edited 2010-12-12 - 17:52:37
    In some projects I've used a set of 4-5 1n5401 diodes to drop the voltage before going into the voltage regulator. It has worked well for me.

    Another option if your budget allows are some of the small DC/DC switching regulators which can act as a drop-in replacement for many older 7805 parts. An example is one that Digikey sells:


  • eagletalontimeagletalontim Posts: 1,384
    edited 2010-12-12 - 19:52:44
    Would the DC/DC switching regulator work without any extra components? What about the heating problem. It looks as though the voltage drop would be the same since the output of the regulator you posted is still 5v DC. I am unsure what the wattage is from the 7805, so I am not sure how much is being put off as heat. I want to ensure this system is reliable so I would rather do it right the first time. I have finally sold a few products and will be able to afford to pick up a few parts if needed.....I just need to know what the best way to go is.
  • RobotWorkshopRobotWorkshop Posts: 2,300
    edited 2010-12-12 - 22:13:16
    That module shown at the Digikey link will run fine off 12V and shouldn't require any other extra parts other than a couple caps that should already be in place for you 7805. Since this is a DC/DC switching power supply in mini form it is more efficient and won't waste as much energy that would end up being turned into excess heat. It costs more than the plain 7805 but you should be generating less heat (wasted energy) and save some battery life. The part number I listed is rated at 1A. If you can measure what you're pulling now and you're under that then it should work. You may want to get at least one at try it. Check the current draw for both of them and see how much heat is generated.

Sign In or Register to comment.