How to compare strings/array? RFID Project


Closed Thread
Results 1 to 40 of 101

Hybrid View

  1. #1
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

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

    apologize for my absent so many years.

    I was working in Dubai for 4 years and really didnt have a time to login. I have more than a flight per day, so you understand that i wasnt able at all to handle many things at a time.

    Now im back to real life, and i will upload the code and the circuits as well tonight.

    Imagine that for so long time, the circuit remains the same in my lab, and i havent done anything to it yet apart from adding a second circuit, beside it with a keypad.

    None of the core of the codes are mine, i just did some configurations and changes to fit my needs. (im not proud of this, as i would like ones to write completely my own code from the scratch)

    The following image shows the circuit and the connection of one circuit to an other.

    Name:  rfid.jpg
Views: 843
Size:  555.8 KB

    I know that it is difficult to understand the schematic, as it is not corresponds at the moment to a circuit, but i have it on a TEST Board and i can do a small video of it.

    As i have mentioned, there are two circuits, separated, the RFID circuit (with the uLCD) and the CODELOCK with keyboard.

    What the circuit does:

    1) once you place the Tag to the RFID reader, the uLCD, displays the picture of the person carries the RFID tag
    2) at the same time, a BEEP on the buzzer is activated and sends a command to activate the second circuit.
    3) You have 5 seconds until you add the code on the keypad otherwise the circuit lose its power and is not activated any more.

  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

    the code for the RFID PIC16F88 chip

    Code:
    '*  Author  : LEONARDO BILALIS                                  *
    '*  Notice  : Copyright (c) 2017 [LEONARDOS BILALIS]            *
    '*          : All Rights Reserved                               *
    '*  Date    : 19/3/2017                                         *
    '*  Version : 1.3                                               *
    '*  Notes   : This is an RFID ACCESS control with ulcd          * 
    '*          : and an interrupt LED on portb.3                   *
    '****************************************************************
    @ ERRORLEVEL -306 ; this command prevents the compiler to give you a notice of
                      ; crossing page boundary - make sure bits are set 
    Include "MODEDEFS.BAS"
    INCLUDE "DT_INTS-14.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP.bas"     ' Include if using PBP interrupts
    DEFINE OSC 8	
    OSCCON=%01111000	 '8 Mhz
    CMCON = 7	         'turn comparators off
    ANSEL = 0                'All digital
    
    ;wsave   VAR BYTE    $20     SYSTEM      ' location for W if in bank0
    wsave   VAR BYTE    $70     SYSTEM      ' alternate save location for W 
                                             ' if using $70, comment wsave1-3
    
    ' --- IF any of these three lines cause an error ?? ------------------------
    '       Comment them out to fix the problem ----
    ' -- Which variables are needed, depends on the Chip you are using -- 
    wsave1  VAR BYTE    $A0     SYSTEM      ' location for W if in bank1
    wsave2  VAR BYTE    $120    SYSTEM      ' location for W if in bank2
    wsave3  VAR BYTE    $1A0    SYSTEM      ' location for W if in bank3
    
    ;-----------------------------------------------------------------
    LED   VAR  PORTb.3   ; this is the operation led
      
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR1_INT,  _ToggleLED1,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    T1CON = $31              ; Prescaler = 8, TMR1ON
    @ INT_ENABLE  TMR1_INT     ; enable Timer 1 interrupts
    ;-----------------------------------------------------------------
    ' -----[ 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
    x           var byte
    Symbol PWRLED  = PORTB.1   ; this shows that the initialization is finished and is ready for the RFID tag
    symbol LCD     = PORTB.5   ; to LCD operation
    Symbol rfidin  = PORTB.2   ; from RFID 
    Symbol GROAN   = PORTB.7   ; goes to groan when the rfid is denied
    Symbol TXRXIN  = PORTB.0   ; this is the RX input signal from the other circuit
    pause 2000
    
    serout2 LCD,32,[$55]      ' uOLED Initialize
    pause 2000
    serout2 lcd,32,[$56,$01]
    pause 1000
    serout2 lcd,32,[$45]
    pause 500
    serout2 lcd,32,[$55]
    pause 500
    serout2 lcd,32,[$45]
    pause 500
    serout2 lcd,32,[$73,$00,$03,$11,$ff,$ff," Leonardo Bilalis",$00]
    pause 200
    serout2 lcd,32,[$73,$02,$06,$10,$ff,"     Copyright 2017",$00]
    pause 3000
    serout2 lcd,32,[$45]
    pause 1000
    high pwrled                  'Software controlled Power LED (if this LED is not on at load check your code)
    ' -----[ EEPROM Data ]-----------------------------------------------------
    
    Tag1	DATA  "xxxxxxxxxx"
    Tag2	DATA  "xxxxxxxxxx"
    Tag3    data  "xxxxxxxxxx"
    Tag4    data  "xxxxxxxxxx"
    Tag5    data  "xxxxxxxxxx"
    Tag6    Data  "xxxxxxxxxx"
    Tag7    data  "xxxxxxxxxx"
    Tag8    data  "xxxxxxxxxx"
    Tag9    data  "xxxxxxxxxx"
    Tag10   data  "xxxxxxxxxx"
    
    ' -----[ Initialization ]--------------------------------------------------
    LOW portb.4	    ' lock the door!
    
    '----- [ LOGO ] ---------------------------------------------------------------
    logo:
    serout2 LCD,32,[$55]      ' uOLED Initialize
    pause 500 
    gosub Logo_png
    
    ' -----[ Program Code ]----------------------------------------------------
    
    Main:
    serin2 portb.2,84,[WAIT($02),str BUF\10]
    pause 500
                                    
    Check_List:
      FOR tagNum = 1 to 10       ' 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
        serout2 lcd,32,[$59,$03,$01]
        pause 1000
        serout2 lcd,32,[$40, $49, $00, $00, $80, $80, $10, $00, $00, $C0]
        pause 500
        FREQOUT groan, 1000 */ $100, 115 */ $100	' groan
        pause 500
        serout2 lcd,32,[$45]
        pause 500
        serout2 lcd,32,[$59,$03,$00]
        pause 200
        goto main
       
    Tag_Found:
    IF tagNum = 1 then Leonardo       
    
    IF tagNum = 2 then ELENI         
    
    if tagnum = 3 then MAMAANNA       
    
    if tagnum = 4 then THEIAMARIA     
    
    if tagnum = 5 then MARIA          
    
    if tagnum = 6 then displayName6
    
    if tagnum = 7 then displayName7
    
    if tagnum = 8 then displayName8
    
    if tagnum = 9 then displayname9
    
    if tagnum = 10 then displayname10
    
    GOTO main
    
    Leonardo:
        serout2 lcd,32,[$59,$03,$01]
        pause 1000
        serout2 lcd,32,[$40, $49, $00, $00, $80, $80, $10, $00, $00, $40]
        pause 500       'Pause ,5 sec then clear display
        goto open_door
    
    ELENI:
        serout2 lcd,32,[$59,$03,$01]
        pause 1000
        serout2 lcd,32,[$40, $49, $00, $00, $80, $80, $10, $00, $00, $00]
        pause 500    'Pause ,5 sec then clear display
        goto open_door
    
    MAMAANNA:
        serout2 lcd,32,[$59,$03,$01]
        pause 1000
        serout2 lcd,32,[$73,$00,$03,$11,$ff,$ff," Thank you ANNA",$00]
        pause 200
        serout2 lcd,32,[$73,$02,$06,$10,$ff,"   Please enter code",$00]
        pause 500
        goto open_door
        
    THEIAMARIA:
        serout2 lcd,32,[$59,$03,$01]
        pause 1000
        serout2 lcd,32,[$73,$00,$03,$11,$ff,$ff," Thank you MARIA",$00]
        pause 200
        serout2 lcd,32,[$73,$02,$06,$10,$ff,"    Please enter code",$00]
        pause 500
        goto open_door
    
    MARIA:
        serout2 lcd,32,[$59,$03,$01]
        pause 1000
        serout2 lcd,32,[$73,$00,$03,$11,$ff,$ff," Thank you MARIA",$00]
        pause 200
        serout2 lcd,32,[$73,$02,$06,$10,$ff,"    Please enter code",$00]
        pause 500
        goto open_door
    
    
    displayName6:
    
    
    displayName7:
    
    
    displayName8:
    
    
    displayName9:
    
    displayName10:
    '----------------------OPEN THE DOOR------------------------------    
    open_door:
        HIGH portb.4          ' remove latch
        pause 5000
        if TXRXIN = 1 then  
        pause 8000
        endif  
        LOW portb.4		' restore latch
        serout2 lcd,32,[$45]
        pause 500
        serout2 lcd,32,[$59,$03,$00] 
        goto main
    
     ;DOOR:
     ;  serout2 lcd,32,[$45]
     ;  serout2 lcd,32,[$73,$00,$03,$11,$ff,$ff,"DOOR is OPENED",$00]
     ;  return    
    '----------------- [ LOGO Routine ] ------------------------------
    
    Logo_png:
    serout2 lcd,32,[$40, $49, $00, $00, $80, $80, $10, $00, $00, $00]
    pause 3000
    serout2 lcd,32,[$59,$03,$00]
    pause 200
    return         
    '-------------------- [ CLEAR ] ----------------------------------
    Clearlcd:
    serout2 lcd,32,[$45]
    pause 500
    goto logo
    
    '---[TMR1 - interrupt handler]--------------------------------------------------
    ToggleLED1:
    TOGGLE led
    @ INT_RETURN
    and the code for the PIC16F84A

    Code:
     '****************************************************************
    '*  Name    : CodeLock.bas                                      *
    '*  Author  : xxxxxx                                            *
    '*  Date    : xxxxxxxxxx                                        *
    '*  Version : 1.0                                               *
    '*  Notes   : Programable Code Lock with the PIC-16F84          *
    '****************************************************************
    ; Change the code from 1234 by typing the code 1234 then * 1961#1961#   
    
    Include "MODEDEFS.BAS"
    '**************************************************
    RL1_ON_time con 1000 * 5  'sec. Relay ON time
    '**************************************************
    
    TrisA = 0  ' PORTA, all outputs
    PortA = 16 ' turn off Buzer
    OPTION_REG.7 = 0   ' PORTB Pullups.
    TrisB = %11110000  ' PORTB.0-3 outputs, 4-7 inputs  
    PortB = 0
     
    LD1 var PortA.2
    RL1 var PortA.3
    BUZ var portA.4
    
    cnt var byte
    
    key  var byte
    col  var byte
    row  var byte
    keycnt var byte
    pwOK var bit
    
    keybuf var byte[15]
    pwbuf var byte[4]
    
    EEPROM 0,[1,2,3,4] 'Default password 1,2,3,4 programmed at EEprom location 0..3
    Read 0, pwbuf[0]   'Copy password from EEprom address 0..3 in to pwbuf[0..3]
    Read 1, pwbuf[1]
    Read 2, pwbuf[2]
    Read 3, pwbuf[3]
    
    pwOK = 0
    keycnt = 0
    
    Main:
        high ld1
        pause 200
        gosub Chk_KEYPAD
        pause 100
       
    goto Main
    
    Chk_KEYPAD:
       for row = 0 to 3 
          PORTB = (dcd row) ^ $f    
          pause 1
          col = PORTB >> 4
          if (col <> $f) then  'key pressed 
             key = (row * 3) + (ncd (col ^ $f))
             gosub Got_KEY
             key = 255
          endif
       next 
    return    
    
    Beep:
       low ld1
       low buz 
       pause 40
       high buz
    return
    
    Got_KEY:
       gosub Beep
       while (PORTB >> 4) <> $f  
          pause 1
       wend
       if key = 11 then key = 0
       keybuf[keycnt] = key
       gosub Chk_keycnt
    return
    
    Chk_PwOK: 
       PwOK = 0
       if (keybuf[0] = pwbuf[0]) and (keybuf[1] = pwbuf[1]) and (keybuf[2] = pwbuf[2]) and (keybuf[3] = pwbuf[3]) then pwok = 1
    return 
    
    Chk_NewPwOK: 
       PwOK = 0
       if (keybuf[5] = keybuf[10]) and (keybuf[6] = keybuf[11]) and (keybuf[7] = keybuf[12]) and (keybuf[8] = keybuf[13]) then pwok = 1
    return 
    
    Pw_Change:   
       pwbuf[0] =  keybuf[5]
       pwbuf[1] =  keybuf[6]
       pwbuf[2] =  keybuf[7]
       pwbuf[3] =  keybuf[8]
       Write 0, pwbuf[0] 'Store new password to EEprom location 0..3
       Write 1, pwbuf[1]
       Write 2, pwbuf[2]
       Write 3, pwbuf[3]
    return
    
    Chk_keycnt:    
       select case keycnt
          case 4
             gosub Chk_PwOK
             if pwOK then 
                if keybuf[keycnt] = 12 then Access_OK
                if keybuf[keycnt] <> 10 then Clr_keybuf
                gosub Beep
             else
                goto Clr_keybuf
             endif
          case 9
             if keybuf[keycnt] <> 12 then Clr_keybuf
             gosub Beep
          case 14
             if keybuf[keycnt] <> 12 then Clr_keybuf
             gosub Beep
             gosub Chk_NewPwOK
             if pwOK then 
                gosub Beep
                gosub Pw_Change
                gosub Beep
                goto Clr_keybuf
             else
                goto Clr_keybuf
             endif
          case else
             if keybuf[keycnt] = 12 then Clr_keybuf
       end select
       keycnt = keycnt + 1    
    return
    
    Access_OK:
       High RL1
       pause RL1_ON_time
       low RL1
    
    Clr_keybuf:
       for cnt = 0 to 14 
          keybuf[cnt] = cnt 
       next
       keycnt = 0 
    goto Main
    
    end

  3. #3
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

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

    Tomorrow afternoon the video of what the circuit and the code are all about.

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    Did you find this post helpful? Yes | No

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

    Welcome back Leonardo!

    After this long time, your uLCD I guess is ... obsolete now!

    Ioannis

  5. #5
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

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

    Hi Ioanni, the ulcd is not obsolete but upgraded as for as i checked with a newer version. I think the only difference is the change of the pins position. Instead of the pins are place in one line now they are in 2 lines

  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

    Not very good quality of video and explanation but hope you can understand.

    Im not a programmer so, it is the best i could up to now.

    Next step is to add a RFID KEY MASTER in order to record more RFID tags in to the epprom without having to reprogram the chip.


  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

    Dear all,

    the project for my home up to now works OK!.

    Here is also a 3D printed case i have designed in order to place nice and clean all the components and electronics.


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