How to compare strings/array? RFID Project


Results 1 to 40 of 101

Threaded View

  1. #33
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

    Default Re: How to compare strings/array? RFID Project

    Quote Originally Posted by dan-tron View Post
    EUREKA!
    Thanks guys! You have been a huge help. I have finally figured it out.
    My problem was more like 3 problems...

    1. I have never done EEPROM stuff before so I was lost to begin with.
    2. As Bruce pointed out, the mathematical order of operations in one line was not correct. I guess the BS2 thinks a little differently from PBP in that respect.
    3. My PicBasic Pro compiler was Version 2.30 form 2000. It seems that v2.30 supports the PIC 16F628 but the PIC 16F628A was implemented in a later version. I have upgraded my PBP to version 2.47 and now the EEPROM features work correctly on the 16F628A. When I successfully tested a 16F84A using the same code, that lead me to question the compiler.

    So for future generations and the benefit of other people like me, here's my WORKING code that is tested successfully on a PIC 16F628A with a 20MHz resonator compiled using PBP v2.47. It reads data from the Parallax RFID Reader Module, compares it against known values stored in EEPROM and allows or denies access accordingly. Enjoy.

    Code:
    CMCON = 7   
    DEFINE OSC 20	'Set oscillator in MHz
    
    ' -----[ Variables ]-------------------------------------------------------
    
    buf	VAR	Byte(10)	' RFID bytes buffer
    tagNum	VAR	Byte	' from EEPROM table
    idx	VAR	Byte	' tag byte index
    char	VAR	Byte	' character from table
    
    ' -----[ EEPROM Data ]-----------------------------------------------------
    
    Tag1	DATA	"100050A4B7"
    Tag2	DATA	"1000508E0A"
    Tag3	DATA	"10005091DC"
    Tag4	DATA	"100050203A"
    Tag5	DATA	"100050DA36"
    
    ' -----[ Initialization ]--------------------------------------------------
    
    HIGH portb.3	' turn off RFID reader
    LOW portb.6	' lock the door!
    Low portb.4	'Turn off LED
    
    ' -----[ Program Code ]----------------------------------------------------
    
    Main:
    
    LOW portb.3				' activate the reader
    SERIN2 portb.2, 396, [WAIT($0A), STR buf\10]	' wait for hdr + ID
    HIGH portb.3				' deactivate reader
    
    Check_List:
      FOR tagNum = 1 to 5			' 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:					' try next tag
      NEXT
    
    Bad_Tag:
      tagNum = 0
      FREQOUT portb.5, 1000 */ $100, 115 */ $100	' groan
      PAUSE 1000
      GOTO Main
    
    Tag_Found:
      HIGH portb.6				' remove latch
      High portb.4				' Light LED
      FREQOUT portb.5, 2000 */ $100, 880 */$100	' beep
      LOW portb.6				' restore latch
      Low portb.4				' LED OFF
      GOTO Main
    hello all,

    i would like to see the schematic of the above code if it is possible.

    One more thing that i would like to incude at the code is to identify the name of the target id.

    For example, once you pass the RFID chip from the reader, on the display to give you the name of the carrier.

    if i have a chip with a target id : 123456789012 then i would like once i pass it from the reader to give a name like ASTANAPANE.

    I guess that on the code i have to corespond the name to the target id.

    How can we do that.

    I have bought the modules from SPARKFUN and the RFID chips also from them.

    I would like to make a small project for my room.

    thanks for any suggestions.

    Best Regards
    Last edited by astanapane; - 28th March 2011 at 10:45.

Similar Threads

  1. Parallax RFID Reader code example
    By dan-tron in forum Code Examples
    Replies: 4
    Last Post: - 19th April 2013, 22:16
  2. A Temperature & Humidity Data Recorder Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 9th July 2008, 18:47
  3. Replies: 3
    Last Post: - 12th March 2008, 05:33
  4. Free Web based RFID Online Courses
    By Thirumoorthy in forum General
    Replies: 0
    Last Post: - 19th November 2007, 13:38
  5. Free web based RFID online Course
    By Lesikar in forum GPS
    Replies: 0
    Last Post: - 19th October 2007, 22:28

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts