How to compare strings/array? RFID Project


Closed Thread
Results 1 to 40 of 101

Hybrid View

  1. #1
    Join Date
    Aug 2007
    Posts
    7

    Question How to compare strings/array? RFID Project

    I am trying to make an RFID reader using Parallax's RFID Reader Module and a PIC 16F628A.
    I am using PBP and am having troubles figuring out how to convert over the sample code found at Parallax to work in PBP.
    Sample code: http://www.parallax.com/dl/src/prod/RFID1.BS2

    The main trouble I am having is getting the comparison to work. I'm not sure what the best way would be to compare the scanned RFID 10 byte string array against a set of known tags.
    Below is the part of the code I believe is not working right.
    Does anybody have any idea on what I can do to fix this or perhaps someone has a better way of doing it? Thanks in advance!
    -Dan

    ' -----[ EEPROM Data ]-----------------------------------------------------
    Tag1 DATA "100050D77C" ' valid tags
    Tag2 DATA "1000504B02"
    Tag3 DATA "1000502DC9"
    Tag4 DATA "100050803A"
    Tag5 DATA "100050C472"

    ' -----[ Program Code ]----------------------------------------------------
    Main:
    LOW portb.3 ' activate the reader
    SERIN2 portb.2, T2400, [WAIT($0A), STR buf\10] ' wait for hdr + ID
    HIGH portb.3 ' deactivate reader

    Check_List:
    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: ' try next tag
    NEXT
    Last edited by dan-tron; - 25th August 2007 at 00:18. Reason: Typo in title

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Try using 396 instead of T2400 in the SERIN2 statement.

    Constants like T2400 are only for SERIN (without the 2).
    <br>
    DT

  3. #3
    Join Date
    Aug 2007
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    No luck. I replaced the T2400 with 396 and it made no difference. I don't believe that the serial input is the problem because I can debug with a serial LCD and I can get it to print the actual RFID tag numbers on the LCD. The problem seems to lie under Check_List:. Specifically the line...
    READ (tagNum - 1 * 10 + idx), char ' get tag data from table

    I've never saved anything to EEPROM before. Maybe its not reading it correctly? Or saving it?

  4. #4
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Can you post your complete code?
    I have to understand what are you´re trying to do.

    regards Rob

  5. #5
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    You might try using WRITE to store the data. That might isolate the problem to your DATA or READ statements.

  6. #6
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Maybe this one will help you.
    I don´t try before working with SERIN2 but give it a try. You can change this part with storing data to eeprom too. It´s only to see how to realize that, if i´m not wrong.
    To store data on eeprom use
    DATA @$00,$D7,$7C,$4B,$02,$2D,$C9,$80,$3A,$C4,$72

    Code:
    Loop      VAR BYTE
    ReadTag   VAR BYTE[2]
    ConvTag   VAR WORD
    Tag       VAR WORD[5]
    
    Tag(1) = $D77C
    Tag(2) = $4B02
    Tag(3) = $2DC9
    Tag(4) = $803A
    Tag(5) = $C472
    
    ' -----[ Program Code ]----------------------------------------------------
    Main:
    
    LOW PORTB.3 ' activate the reader
    SERIN2 PORTB.2, T2400, [WAIT($0A,"100050"), STR ReadTag\2]
    HIGH PORTB.3 ' deactivate reader
    
    Check_List:
    ConvTag = ReadTag(0)*$100 + ReadTag(1)
    FOR Loop = 1 to 5
        IF ConvTag = Tag(Loop) THEN Tag_found
    NEXT Loop 
    GOTO Bad_Char
    
    Bad_Char: ' try next tag
    '....
    '....
    GOTO main
    
    Tag_Found:

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 : 2

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