How to compare strings/array? RFID Project


Closed Thread
Results 1 to 40 of 101

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

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

    Quote Originally Posted by astanapane View Post
    i have changed the () with this [] but didnt work.

    something else is the mistake and i cannot understand.

    When i pass the tag from the reader doesnt do anything, but i pass it twice then i get the bad tag on the display.

    It seems that doesnt recongise the tags i gave to the program.

    somthing has to do with this line

    SERIN2 portb.1, 84, [WAIT($0A), STR buf\10] 'the number 10 here is the 9600???

    i cannot understand this line could you help?

    FOR idx = 0 TO 11 ' here is it ok this line if my RFID tags have 12 digits?
    READ (((tagNum-1) * 10) + idx), char ' this line is chineese to me. what is the number 10 in there? What number should i put if my RFID tags have 12 digits?
    Working from memory here, my book is outside, and I am not dressed to go get it . . .
    As I remember the 84 is the Mode setting the baud rate, the buff\10 sets the string state to 10 characters - 0 to 11 would equal 12 characters in your index, so I am thinking your buf\10 should be buf\12 . . .
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  2. #2
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

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

    Hi Joe,

    i would also like to specify that the tags i have there are manchester encoding. Do i have to decode it through the program in order to work?

    I dont know how to decode it. As from the page here http://www.sparkfun.com/products/10169 these are the features
    Features:

    EM4001 ISO based RFID IC
    125kHz Carrier
    2kbps ASK
    Manchester encoding
    32-bit unique ID
    64-bit data stream [Header+ID+Data+Parity]


    From what you are saying now:

    i have already change the buf/10 to 12 but nothing happens.

    If you see the site in here http://melabs.com/resources/ser2modes.htm , there is a 4Mhz which i use at them moment.

    There are several numbers in there included the 84. The number 84 seems to read the data at 9600.

    Here is an other example of the code http://melabs.com/samples/PBP-mixed/ser2mod.htm

    Code:
    Serin2 pinin,396,[WAIT("F"), STR test8\8]
    
       Serout2 pinout,396,["14: ",STR test8\8,13,10]   ' 15: 7ZZ-0001
    
    ' Waits for the string "F", then collects the next 8 characters.  These are
    
    ' stored as ascii in 8 locations of the array variable test8.  The SerOut2
    
    ' statement uses the same modifier to send all 8 locations of the array
    
    ' variable as an ascii string.
    
       Serin2 pinin,396,[WAIT("Z",45), STR test8\8\"0"]
    
       Serout2 pinout,396,["15: ",STR test8\8,13,10]   ' 16: F7ZZ-
    
    ' This example demonstrates how you can put multiple characters in the
    
    ' WAIT.  It waits for the string "Z-", since the ascii code for "-" is
    
    ' 45.  The STR item is the same as above except we have added the stop
    
    ' character "0".  When it encounters "0" at the sixth character, it
    
    ' replaces it and fills the rest of the test8 array with null characters.
     
       Pause 2000
    
       Goto mainloop
     
       End
    Last edited by astanapane; - 12th April 2011 at 08:22.

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

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

    I know little to nothing about manchester encoding, I defer to the More Experienced members here, Right now I am still recovering from a hard drive crash, having "unearthed" my computer, I cannot see my bench for the scattered "stuff" ;(, at least the computer is up, except all my PDFs are corrupted.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  4. #4
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

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

    No problem Joe,

    thanks for you help. IF there is anyone else can check the code and give me his advice.

    Kind Regards,

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,172


    Did you find this post helpful? Yes | No

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

    There is a ' symbol after the wait that I think should go away. Buffer never gets filled.

    Code:
    SERIN2 portb.1, 84, [WAIT($0A)] ' STR buf\12]	' wait for hdr + ID
    Ioannis

  6. #6
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

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

    Hi Ioannis

    i will check that out later today and let you know.

    I think i have correct that error but i will check it.

    SERIN2 portb.1, 84, [WAIT($0A), STR buf\12]

    An other thing that i have in mind is he WAIT($0A),what is that $0A doing?

    what is waiting for? is that the first digit of the ID?

    (ευχαριστω πολυ)
    Last edited by astanapane; - 12th April 2011 at 15:49.

  7. #7
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

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

    hi all,

    this is my code for your reference....there is somewhere a mistake that cannot find.

    Code:
    @ DEVICE PIC16F628A      
    INCLUDE "modedefs.bas"
    CMCON = 7  
    DEFINE OSC 4	'Set oscillator in MHz
    
    DEFINE LCD_DREG PORTB  'define port to LCD
    DEFINE LCD_DBIT 4      'RB4 RB5 RB6 RB7 to D4 D5 D6 D7 display
    DEFINE LCD_RSREG PORTA 'RS on porta
    DEFINE LCD_RSBIT 0     'RS on porta.0
    DEFINE LCD_EREG PORTA  'Enable on porta
    DEFINE LCD_EBIT 1      'Numero Enable  porta.1
    DEFINE LCD_BITS 4      ' 
    DEFINE LCD_LINES 2     'lines 2 
    PAUSE 200              ' Stop 200ms
    LCDOUT $FE,1           ' power lcd
    Lcdout $FE,1,4
    lcdout $FE, 1,"  Copyright 2011"
    lcdout $FE, $C0,"***********"
    pause 2000
    lcdout $FE,1
    ' -----[ Variables ]-------------------------------------------------------
    
    buf	    VAR	byte [12]' 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  "450052B6BC1D"
    Tag2	DATA  "450052F2EB0E"
     
    ' -----[ Initialization ]--------------------------------------------------
    
    high portb.1	' turn off RFID reader portb.1 is the reciever port
    LOW portb.2	    ' lock the door!
    Low portb.3	    ' Turn off LED
    
    ' -----[ Program Code ]----------------------------------------------------
    
    Main:
    lcdout $FE,1," Please use your"
    lcdout $FE, $C0,"      TAG"
    pause 500
    high portb.3
    low portb.1        ' activate the reader
    pause 500
    SERIN2 portb.1, 84, [WAIT($34),STR buf\12]
    pause 500
    high portb.1         ' deactivate reader
                                    
    Check_List:
      FOR tagNum = 1 to 2       ' scan through known tags
        FOR idx = 0 TO 11		' scan bytes in tag
        READ (((tagNum-1)*12 ) + 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 porta.3, 1000 */ $100, 115 */ $100	' groan
      lcdout $FE, 1,"   invalid TAG"
      lcdout $FE, $C0,"   try again"
      pause 1000
      lcdout $FE,1
      GOTO Main
    
    Tag_Found:
    
    IF tagNum = 1 then displayName1
    
    IF tagNum = 2 then displayName2
    
    GOTO Main
    
    displayName1:
    lcdout $FE, 1,"  name_1"    
    lcdout $FE, $C0, "ACCESS GRANDED"
    pause 1000       'Pause ,5 sec then clear display
    goto open_door
    
    displayName2:
    lcdout $FE, 1,"  name_2"   	
    LCDout $FE, $C0," ACCESS GRANDED"
    pause    1000    'Pause ,5 sec then clear display
    goto open_door
    
    open_door:
      HIGH portb.2      ' remove latch
      pause 500
      LOW portb.2		' restore latch
      Low portb.3		' LED OFF
      GOTO Main

Similar Threads

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