How to compare strings/array? RFID Project - Page 2


Closed Thread
Page 2 of 3 FirstFirst 123 LastLast
Results 41 to 80 of 101
  1. #41
    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.

  2. #42
    Join Date
    Oct 2010
    Posts
    411


    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.

  3. #43
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

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

    Joe,

    thank you a lot, hehehe i think we did post the same time.

    Hope you'll be here and help me out next week. I will start very simple and then we can improve everything accordinally.

    Best Regards

  4. #44
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

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

    some more questions.

    I guess that with the following format for the LCD


    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

    i can only use the LCDOUT command and not the SEROUT2.

    In case that i use for the pic16f628a the RB0 for the RFID READER then for the LCD can i use PORTA?

    Then i would need also some help in the command to transfer it from the following

    Serout2 porta.0,84

    to the LCDOUT.

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

    The LCDs are parallel LCD. I have seen some circuits using shift registers to adapt then to accept, or use the serial backpack you will find in the article section and serout / serout2 / hserout as you choose. It is in the final code, set to accept several baud rates. It does all the LCDOut overhead in it's PIC, freeing you projects PIC of the burden. I listed it before, but here it is again.
    http://www.picbasic.co.uk/forum/cont...rial-backpacks
    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. #46
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

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

    Hi Joe,

    thank you, i will try to fix the code before i get the componets, but it a bit difficult without them.

    I havent recieve the ID-12 modules yet. So i expect them next week possible on Wednesday.

  7. #47
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

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

    The attached file shown what i need to do with the ID-12 and the pic16f628a.

    I will seperate those in two circuits.

    The first circuit will read and identify the RFID cards and the second circuits will be based on the 3x4 keypad.

    Once you pass the rfid card from the ID-12 the circuit will check if the card is valid or not.

    If it is valid then will proceed and display your name. If not then you will need to go back and check card again.

    Once you are accepted from the system then you only have 5 seconds to open the door. You will need to type your 4 digit code in order to open the door.
    Attached Images Attached Images  
    Last edited by astanapane; - 1st April 2011 at 13:59.

  8. #48
    Join Date
    Oct 2010
    Posts
    411


    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.

  9. #49
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

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

    hi all,

    i did some small changes and read data on 9600.

    But i cannot make it work yet.

    When i pass the TAG from the reader does not display the name.

    It displays 'Bad Dag' only. And the tag is the valid one i pass from the reader.

    Could you please help me with my program?

    I have tags from Sparkfun that i believe are with 12 digits so i think we need to make some changes there.

    here is the code:

    Code:
    @ DEVICE PIC16F628A      
    
    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                                ' Ενεργοποίησε το LCD
    Lcdout $FE,1,4
    lcdout $FE, 1," Leonardo"
    pause 500
    ' -----[ 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:
    high portb.3
    low portb.1					    ' activate the reader
    SERIN2 portb.1, 84, [WAIT($0A)] ' STR buf\12]	' wait for hdr + ID
    high portb.1					' deactivate reader
    pause 500
     
    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
      high porta.3
      pause 200
      low porta.3
      pause 200
      lcdout $FE, 1," bad tag"
      pause 500
      FREQOUT porta.3, 1000 */ $100, 115 */ $100	' groan
      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,"ASTANAPANE"    'assuming your display is on porta.0 @ 9600 baud
    pause 500                                      'Pause ,5 sec then clear display
    goto open_door
    
    displayName2:
    lcdout $FE, 1,"TIGRI"   	'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 portb.3, 2000 */ $100, 880 */$100	' beep
      LOW portb.2					' restore latch
      Low portb.3					' LED OFF
      GOTO Main

  10. #50
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

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

    hi all again,

    i try to see what the problem is.

    I think there might be a problem on storing data to EEPROM of the pic16f628a...

    and there also be a problem somewhere on the code...

    Code:
    Main:
    high portb.3
    low portb.1					    ' activate the reader
    SERIN2 portb.1, 84, [WAIT($0A)] ' STR buf\12]	' wait for hdr + ID
    high portb.1					' deactivate reader
    pause 500
     
    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!
    when i try to pass the card from the reader it light the led of the reader but nothing happens to my LCD.

    then i pass second time the card from the reader the led on the porta.3 light up and i get on my lcd the Error tag.

    I dont understand what is happening on the first time that i pass the card. It doesnt do anything.

    Why when i pass it two times i have bad tag on the display.

    On other thing is that i cannot make it work to show me the name on the display on the right cards.

    If you have any solutions please help me.

    regards

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

    Just countin beans here:
    Code:
    buf        VAR    Byte(12)' RFID bytes buffer
    I think should read
    Code:
    buf        VAR    Byte[12]' RFID bytes buffer
    I am looking for other issues
    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.

  12. #52
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

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

    Thank you Joe,

    i will make the change in the afternoon, then i will check and let you know.

    Your help is much apreaciated.

    Best Regards,

  13. #53
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

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

    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?
    Last edited by astanapane; - 11th April 2011 at 17:23.

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

  15. #55
    Join Date
    Oct 2010
    Posts
    411


    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 07:22.

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

  17. #57
    Join Date
    Oct 2010
    Posts
    411


    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,

  18. #58
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    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

  19. #59
    Join Date
    Oct 2010
    Posts
    411


    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 14:49.

  20. #60
    Join Date
    Oct 2010
    Posts
    411


    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

  21. #61
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

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

    as i mentioned before, there might be a problem on the following lines.

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

    what is this value doing in here $0A is that the first digit of the tag?

    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

    what is this value after tagnum -1 is doing? is this the number of the digits of the tag?

    IF (char <> buf(idx)) THEN Bad_Char ' compare tag to table

  22. #62
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

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

    I do not know what the 0A is there for.

    It for sure NOT for the ID-12.

    In ASCII Hex mode,the ID-12 sends a STX (Start Sentinel) of 02 as the data sheet state.

    So no WAIT(0Ah). It will give Bad Tag message.

    On the e-mail I sent to you there was an error as I did not read correctly the Data Sheet.

    Correct one is the

    Code:
    serin2 port_pin1,baud_rate1,[wait($02),str buf\10]
     
    serout2 port_pin2,baud_rate2,[str buf\10,13,10]
    just to test if the reading data are correct.

    Ioannis

  23. #63
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

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

    for all our knowledge,

    i would also like to know if the 12 digits i get from the usb reader, as sparkfun's video on their page...http://www.sparkfun.com/products/8419 is ASCII code.

    It is needed first to understand what is this 12 digit number?

    Thank you very much for your help. I need also to help you by understanding the basics. then might be easier for you to give me the right instructions.

  24. #64
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

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

    Quote Originally Posted by Ioannis View Post
    I do not know what the 0A is there for.

    It for sure NOT for the ID-12.

    In ASCII Hex mode,the ID-12 sends a STX (Start Sentinel) of 02 as the data sheet state.

    So no WAIT(0Ah). It will give Bad Tag message.

    On the e-mail I sent to you there was an error as I did not read correctly the Data Sheet.

    Correct one is the

    Code:
    serin2 port_pin1,baud_rate1,[wait($02),str buf\10]
     
    serout2 port_pin2,baud_rate2,[str buf\10,13,10]
    just to test if the reading data are correct.

    Ioannis

    I will make the change to $02 this might solve the problem.

    If not then i will try to figure out how to connect it to the computer thought the serial port to see what i get.

    Can i do anything with the existing one i have (i mean the usb reader)?

    Can i find out from there what the Module is generating?

    Because i got consfused. With this reader i get a number throught the Secure CRT program with 12 digits.

  25. #65
    Join Date
    Jul 2005
    Location
    The Netherlands
    Posts
    39


    Did you find this post helpful? Yes | No

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

    Hi,

    I have a lot of applications done with RFID. See my web http://www.picshop.nl/rfid.html
    Here connected to a AmiPIC18 board with the PIC18F25K20. The firmware is in PICBASIC Pro.

    After reading a Tag, the reader give a Hex02. So, you have to wait for that character and store the next 10-byte in a string. Thats the Tag ID. If the first byte = 0, than you have a read only tag. (1 means read/write)
    The OEM reader what I use, has a CP signal, this will be high after reading a Tag, then 210ms later, the reader wil send out (9600 baud) the TAG ID. I use in the firmware the CP signal to poll of a Tag is reading or not. The micro is run on 8 Mhz or faster to read 9600baud.

    I will post tomorrow some firmware to show hows iets work if you want.

    Regards,

  26. #66
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

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

    Dear Mr. Gevo,

    thanks a lot for that. Mr. Ioannis gave me some information in order to start from, read and learn. So i need to read all these info and then i will come back with all my questions.

    I think i'm close to fix the problem and make the circuit to work.

    At the moment i have use 4Mhz resonator for 9600. Do you think that this might be a problem? I will change it to 8Mhz crystal then.

  27. #67
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

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

    If the PIC send without any poblem to a PC then its OK for the 4MHz.

    I have many times used 9600 on 628 with 4MHz resonator (not crystal) and went smooth.

    Ioannis

  28. #68
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

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

    Why not just use DEBUG for transmit & DEBUGIN for receive?

    These commands work 100% with a 4MHz oscillator up to 19200 bps, offer the same modifiers as SERIN2/SEROUT2, and produce much smaller code!
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  29. #69
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

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

    Bruce just cought me. These two commands would be the next step to suggest.

    astanapane is struggling with the basics so I did not put him to code changes. Debug need DEFINES declared on top of the code.

    Ioannis

  30. #70
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

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

    Yes that's true,

    i will focus at the moment to the basics and then i will try to your suggestions. In first place it is needed to understand the code itself. Then to get the datasheet from the RFID module and check everything in there step by step.

    For your info the module ID-12 can be run at 9600 as from the datasheet. The boundrate code for that it seems to work on SERIN2 portb.1, 84. I tried to use the 16468 but didnt do anything.

    Regards,

  31. #71
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

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

    For the Serin2 the 84 is for True RS232 signal. The 16468 is for inverted signal as is the case with the ID-12.

    I could not find in the manual where is the speed of the serial port.

    Does it clearly state 9600? I found the part that says the signal is inverted and no driver is required.

    Ioannis

  32. #72
    Join Date
    Jul 2005
    Location
    The Netherlands
    Posts
    39


    Did you find this post helpful? Yes | No

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

    ok,

    I use the OEM 125Khz reader See http://www.picshop.nl/rfid.html

    This Reader has a CP signal, Before the 10-byte is serial out, the CP signal will be High. Then I have 210ms time to readout the reader. The PIC in the application is a 16F887.

    buf var byte (10) ' RFID bytes from tag

    Main:

    If PORTA.7 = 0 then Read_Tag ' CP signal of the OEM reader, read within 210 mS

    ' Here other program lines

    Goto Main


    ' ----- [ GOSUB ] -----------------------------------------------------------

    Read_Tag:
    ' Wait for Hex 02 . . .
    serin2 PORTB.0, 84, [WAIT($02), str buf\10] ' Read 10 byte from ECO-125

    return

  33. #73
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

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

    Dear All,

    thank you very much for your help. Ioannis helped me out to identify my mistakes on the code and he also gave me the right instructions in order to solve the problem.

    i would like also to thanks, Joe, Bruce and Gevo for their support.

    Please find attached pictures of my circuit.
    Attached Images Attached Images     

  34. #74
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

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

    now the next and most difficult part is to configure the code for GLCD use.

    But i havent seen any library for GLCD. Some users in here have been working for many hours to built a standard code for GLCDs.

    the problem is that there would be much better if a library were available from PIC BASIC.

    i know and understand that will take place on the pic chip but in nowadays we all using more powerfull pic's.

    Regards,

    Leonardo

  35. #75
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

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

    You might find something interesting here
    http://www.picbasic.co.uk/forum/show...009#post102009

  36. #76
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

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

    here you can see a demo of the RFID circuit.



    I need now to improve it with GLCd and Keypad.

    i would like to say thanks to Mr. Ioannis for his patient and help.

    regards,

  37. #77
    Join Date
    May 2007
    Posts
    604


    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 need now to improve it with GLCd and Keypad.
    If this is a one-off (which it appears to be) and price is not an overwhelming obstacle, then look at a serial Graphic LCD such as this one http://www.sparkfun.com/products/9351
    Besides writing text, this serial graphic LCD allows the user to draw lines, circles and boxes, set or reset individual pixels, erase specific blocks of the display, control the backlight and adjust the baud rate. It costs $35 and you won't need a GLCD library.

    Better yet, this full color TFT has a built-in touch screen so you won't need a keyboard http://www.sparkfun.com/products/10089 - it costs more at $85 and is fully programmable OR can can be controlled with a serial port.

    Why pay for overpriced toys when you can have
    professional grade tools for FREE!!!

  38. #78
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

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

    hello rmteo,

    thanks for your advice.

    I dont know about the serial lcd. Can i drive it form a pic18f4550 for example?

    Could you give me some instructions? a sample code? I will first use the serial lcd and then i will try the color.

    How is the serial GLCD working, and why i dont need a GLCD library? As i see on the serial there is an ATEML chip. I dont know how to programm ATMEL. Sorry for my questions.

    Thank you very much for any help in advance.

    Kind regards,

    astanapane.

  39. #79
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

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

    The serial GLCD can be used with any MCU (including the PIC184550) that can output serial data. You do not need a GLCD library as it is an intelligent display that has an AtmelAVR MCU on board - you could say that the library lives in the AVR.

    I do not provide sample code. You send simple ASCII codes using SEROUT (or HSEROUT) at up to 115,200 baud. Take a look at the datasheet here http://www.sparkfun.com/datasheets/LCD/Monochrome/Corrected-SFE-0016-DataSheet-08884-SerialGraphicLCD-v2.pdf and and the tutorial here http://www.sparkfun.com/tutorials/120
    Why pay for overpriced toys when you can have
    professional grade tools for FREE!!!

  40. #80
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

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

    so using picbasic, can i include a file on my code with a picture?

    thanks a lot. Sorry for missanderstanding about a sample code. I didnt ask for an actual code but an example.

    Thanks anyway for give me the information.

    Kind regards,

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