How to compare strings/array? RFID Project


Results 1 to 40 of 101

Threaded View

  1. #34
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

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

    hello all again,

    i just received the RFID module 12 from sparkfun.

    I test the serial usb device with Secure CRT and works fine.

    Now i'm building the circuit and the code.

    As i told you i would like to make a code that can display the name of the holder according to the ID of the RFID tag.

    I havent connect the ID-12 yet because the dimensions of the pins are not much to the standard ones. I will make a pcb this afternoon and then i will try to make a schematic.

    Now i have attached the code i have done so far, copied most of it from the people here in forum.

    Code:
    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 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                              'clear
    Lcdout $FE,1,4                                
    ' -----[ 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	"450052B6BC1A"
    Tag2	DATA	"450052F2EB0A"
    
    
    ' -----[ 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:
    
    LOW portb.1					    ' activate the reader
    SERIN2  portb.1, 396, [WAIT($0A)] ' STR buf\12]	' wait for hdr + ID
    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
      PAUSE 1000
      GOTO Main
    
    Tag_Found:
    
    IF tagNum = 1 then displayName1
    
    IF tagNum = 2 then displayName2
    
    GOTO Main
    
    displayName1:
    lcdout $FE, 1,"NAME for tag 1"    'assuming your display is on porta.0 @ 9600 baud
    pause 500                                      'Pause ,5 sec then clear display
    goto open_door
    
    displayName2:
    lcdout $FE, 1,"Name for tag 2"    'assuming your display is on porta.0 @ 9600 baud
    pause 500                                        'Pause ,5 sec then clear display
    goto open_door
    
    open_door:
      HIGH portb.2					' remove latch
      High portb.3					' Light LED
      FREQOUT porta.2, 2000 */ $100, 880 */$100	' beep
      LOW portb.2					' restore latch
      Low portb.3					' LED OFF
      GOTO Main
    i would like to know if i can use the command serin2 on the pin portb.1 on the pic16f628a in order to read the data.

    I know that the code may have a lot of mistakes but as i told you i'm not a programmer and i try to make it as good as i can.

    I only need a little bit of your help in certain points that you sure know better than me.

    thank you all for your help in advance.
    Attached Images Attached Images  
    Last edited by astanapane; - 9th April 2011 at 15:20.

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