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

    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.

  2. #2
    Join Date
    Nov 2006
    Location
    Murrieta, CA
    Posts
    62


    Did you find this post helpful? Yes | No

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

    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
    whenever the PIC identifies a tag stored in the EEPROM it still holds onto the "tagNum" variable. from there you can have your program branch off with the "tagNum" variable to display whatever you want. for argument sake lets say your third RFID badge is yours then:

    Code:
    Tag_Found:
    IF tagNum = 3 then displayName
    GOTO Main
    
    displayName:
    Serout2 portc.0,84,["ASTANAPANE"]    'assuming your display is on portc.0 @ 9600 baud
    pause 5000                                       'Pause 5 sec then clear display
    gosub CLRLCD
    Goto main
    Hope this helps... Cheers

  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

    thank you very much for the help....

    i ordered the reader and the ID-12 from SPARKFUN, and i wait for them next week. Once i get them i will start to built my project.

    I will make schematics and PCBs and i will post them here.

    A lot of thanks for the code. I only need a little bit help of the code you made corresponding to the schematic.

    If you dont have time i will read the code and identify the Pins for the pic16f628.

    thank you very much again for your help.

    I dont see the time to have the reader and the rfid chips with me.

    Kind Regards,

  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

    i have also one more question please.

    I need to use the ID-12 with a display also. Can i use the pic16f628a to run both?

    thank you very much.

  5. #5
    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 also one more question please.

    I need to use the ID-12 with a display also. Can i use the pic16f628a to run both?

    thank you very much.
    Go read your manual about LCDOUT, it explains in a thorough treatise exactly how to do that. I am perceiving this to be a school project, and it would be rather easy to hand you the code, I think that would do you more harm than good.
    What you learn here you can then teach to someone else, that is how this forum works, a great many of the members ARE engineers, others are just interested hobbyist, and IF you are a student, as I believe, I do not want to enable you to fail and NO I do not mean fail the class. Write your code, Make the mistakes, Show us the mistakes, and receive help.
    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.

  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

    sorry Joe.

    i dont want to start that with student or not. If you think that i'm a student you might be right.

    A student that is graduated from E.E.E. and i didnt like it then gradueated with MSc DATA COMS with Distinction and i only know to do CISCO. If someone will ask me about cisco i will help him with all my stength and examples.

    Sorry i didnt like a lot my first degree thats why i dont know how to use programming very well.

    Right now i;m working for a reseller company of Stratasys which makes the FORTUS RP systems.

    I only want to make a small project for my father's home.

    I'm not a programmer or student sorry....i just do not have enouph time to spend on this.

    I will try by my self and i will ask for your help.

    thanks.

  7. #7
    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

    Not to be sorry . . . I just do not want to trip you up in your pursuit of life
    all that said make sense of this
    Code:
    ' Define LCD registers and bits as 4 bit 
    Define  LCD_DREG        PORTB        ' port b handling the data
    Define  LCD_DBIT        4                ' Data bits begin on PortB.4 generally must use consecutive ports starting with 0 or 4
    Define  LCD_RSREG       PORTA        ' R/S bit on portA
    Define  LCD_RSBIT       0                ' Defined as PortA.0
    Define  LCD_EREG        PORTA         ' E Bit defined as PortA
    Define  LCD_EBIT        1                 ' Ebit set to PortA.1
    
    DEFINE LCD_LINES 4             'Define using a 2 line LCD
    DEFINE LCD_COMMANDUS 2000     'Define delay time between sending LCD commands
    DEFINE LCD_DATAUS 50         'Define delay time between data sent.
    DEFINE OSC 20
    
    
    lcdout $FE,1    ' Clear LCD
    lcdout $FE,2,  "  Copyright 2006    " ' 
    lcdout $fe,$C0,"This is my text"  '
    This is a cut/paste from a project Darrel really helped a lot on,(DID MOST OF) a serial backpack lcd controller.
    The defines tell the pic which pins are working the LCD
    $FE1 clears the LCD
    $FE2 moves cursor to #1 position
    $FE,$C0 moves the cursor to another line, my book is not handy right now
    Keep in mind a 4X20 LCD is electrically in reality a 2X40 that is chopped in half and stacked so the beginning of line 2 is post 41? and the beginning of line 3 is 21, or something to that effect.
    Check out the project at http://www.picbasic.co.uk/forum/cont...rial-backpacks

    Oh and BTW , NOBODY hates school more than Me. I totally get it. I still on occasion have to go back and take classes
    just because I want to learn what they are teaching, and I still hate it!
    Last edited by Archangel; - 3rd December 2014 at 08:53. Reason: add btw
    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.

  8. #8
    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,

    first of all i would like to thank all of you for any help on my next week try.

    As i told you i'm waiting next week to receive the ID-12 RFID module and the RFID chips.

    I have a display and a pic16f628a here with me. I would like before i start to make first some steps in order everyone in the future to have it as a guidance.

    The project is based on the RFID. So this will be the INCOMING information from an RFID chip.

    The componets are going to be used are as follows. (sorry that i provide you the sparkfun but i ordered all mine from there exept the pic)

    1) PIC16f628a
    2) ID-12 RFID module http://www.sparkfun.com/products/8419
    3) RFID reader, you need this to read the IDs from the tags in order to use them on the programm (http://www.sparkfun.com/products/8852)
    4) tag (http://www.sparkfun.com/products/9417) you can use any at 125khz
    5) 16x2 Character LCD - White on Black 5V http://www.sparkfun.com/products/709

    these are the core components we need. Once i make the schematic and the program i will provide all the info you might need.

    So now what is the thought.

    1) to be able to open the door using an RFID tag.
    2) the rfid tag might be unique and stored in an eeprom
    3) once we pass the tag from the ID-12 module the pic will recognise the ID of the tag and display on the 16x2 the Name of the carrier.
    4) after the Displayed name (0,5 seconds) the door will open.
    5) there we need to clear everything and be ready to use an other tag.

    Now We need to think to use the 16x2 display and the RFID module with the same pic.

    1) From my point of view i need for the display 6 ports reserved from the PIC. (see attached file)

    we also need to give the above code at the beggining of our program in order to specify the parameter of the display.

    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 2
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 3
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2

    2) then we also need for the ID-12 to reserved some pins from the pic ports but i dont know which ones. ( here i need some help) According to the attached file i would like to tell me how which pins from the ID-12 i need to connect to pic.

    Once we know how many reserved pins we have then we share and seperate those pins to input from the ID-12 and output for the 16x2 lcd.

    i will keep you updated with the code that i will try to write next week. Please let me know if anyone is able to help on this. I will be fololwing the code is already written here from all of you.

    Best Regards,

    astanapane.
    Attached Images Attached Images   
    Last edited by astanapane; - 30th March 2011 at 11: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