Rfid mfrc522


Closed Thread
Results 1 to 20 of 20

Thread: Rfid mfrc522

Hybrid View

  1. #1
    metemoine's Avatar
    metemoine Guest


    Did you find this post helpful? Yes | No

    Default Re: Rfid mfrc522

    There are cheap RFID modules that can read and write Mifare's tags and being sold at several web stores, like eBay and included with many "starter kits" nowadays. Simply search RFID-RC522 (MF-RC522).

  2. #2
    Join Date
    Jan 2011
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Re: Rfid mfrc522

    hello metemoine,
    thanks for the answer, as already' mentioned I would want a simple code in picbasic for the reading the kit's rfid mentioned here' above that it works with "spi."

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Rfid mfrc522

    Does anything here help?

    http://melabs.com/samples/PBP-mixed/spimast.htm

    I've never used SPI.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  4. #4
    Join Date
    Jan 2011
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Re: Rfid mfrc522

    thanks for the indication Demon, I try to take a look.

  5. #5
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    962


    Did you find this post helpful? Yes | No

    Default Re: Rfid mfrc522

    Anyone did this?
    Roger

  6. #6
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    962


    Did you find this post helpful? Yes | No

    Default let's try to make it work....

    Hi,

    I might need a little help here - I'm stuck for hours now.

    It's the first time for me to use this RFID module and it is giving me some headache.

    For a test, I want to read the first three bytes of the tag's ID and print them serially out.

    But up to now, I can't make the RFID module "read" something. I'm not sure about my connections and about the different timings and whatever I have to do to "start" the read process.Name:  2017-10-07-Serial Communicator.jpg
Views: 4266
Size:  51.0 KB

    Does anyone have a good idea to get me started reading some data?

    My test project:
    Name:  K640_20171007_172516.JPG
Views: 4485
Size:  121.9 KB

    The RFID module I'm using is this one for ARDUINO and the connections I used:
    Name:  K640_RC522.JPG
Views: 7350
Size:  28.3 KB

    Here's is my current code:
    Code:
    ' ====== FUSES =====================================================================================
    ' PIC 16F690 Fuses (MPASM)
    @ __config _FCMEN_OFF &_IESO_OFF &_CPD_OFF &_WDT_OFF &_HS_OSC &_BOR_OFF &_CP_OFF &_PWRTE_OFF &_MCLRE_OFF
    
    ' ====== REGISTERS =================================================================================
    '             76543210
    OPTION_REG = %10000000 ' Pull-Ups OFF
    OSCCON     = %00000000 ' Internal RC
    ANSEL      = %00000000 ' Select analog inputs Channels 0 to 7
    ANSELH     = %00000000 ' Select analog inputs Channels 8 to 11
    WPUA       = %00000000 ' Select weak pull-ups
    WPUB       = %00000000 ' Select weak pull-ups
    ADCON0     = %00000000 ' Select the VP6 channel as ADC input bits5:2 (xx1101xx)
    ADCON1     = %00000000 ' Set FRC
    VRCON      = %00000000 ' VP6 reference
    CM1CON0    = %00000000 ' Comparator1 Module
    CM2CON0    = %00000000 ' Comparator2 Module
    INTCON     = %00000000 ' INTerrupts CONtrol; GIE=1, T0IE=1
    TRISA      = %00000000 ' Select Input/Output (0 to 5)
    PORTA      = %00000000 ' Set High/Low (0 to 5)
    TRISB      = %00000000 ' Select Input/Output (4 to 7)
    PORTB      = %00100000 ' Set High/Low (4 to 7)
    TRISC      = %00000000 ' Select Input/Output (0 to 7)
    PORTC      = %00000000 ' Set High/Low (0 to 7)
    
    ' ====== DEFINES ===================================================================================
    define OSC 4
    
    ' ====== VARIABLES & CONSTANTS =====================================================================
    SPI_SCK     Var PORTB.4 ' SCK (SPI Clock)
    SPI_MISO    Var PORTB.5 ' MISO (master In, Slave Out)
    SPI_NSS     VAR PORTB.6 ' "NOT" Slave Select (SDA pin of module RC522)
    LED         var PORTB.7
    Serial_Out  VAR PORTC.7
    
    SPI_Mode    var byte
    RFIDData    Var byte(10)
    Serial_Bdr  VAR word
    Counter     var word
    
    ' ====== INITIALIZE ================================================================================
    INIT:
    Serial_Out  = 1 ' to avoid garbage serial data
    Counter     = 0
    SPI_NSS     = 1
    SPI_Mode    = 0 ' MSBPRE
    RFIDData    = 0
    Serial_Bdr  = 84 '9600DTN
    
    ' ====== PROGRAM ===================================================================================
    MAIN:
        ' Read RFID tag
        SPI_NSS = 0 ' select the RFID reader
        PAUSEus 50
        Shiftin SPI_MISO, SPI_SCK, SPI_Mode, [RFIDData(0),RFIDData(1),RFIDData(2)]
        SPI_NSS = 1 ' deselect the RFID reader
        
        ' Printout RFID data
        Counter = Counter + 1
        serout2 Serial_Out, Serial_Bdr,[DEC5(Counter), " ",DEC(RFIDData[0]),DEC(RFIDData[1]),DEC(RFIDData[2]),13,10]
        
        ' Alive witness
        TOGGLE LED 
        
        Pause 500
        Goto main:
     
    End
    
    '======= CIRCUITRY =================================================================================
    'PORTA.0[19] ICSPDAT                  VDD >01-20< VSS/GND
    'PORTA.1[18] ICSPCLK             OSC1/RA5 |02-19| RA0/AN0/DAT
    'PORTA.2[17]                 AN3/OSC2/RA4 |03-18| RA1/AN1/CLK
    'PORTA.3[04] MCLR                MCLR/RA3 >04-17| RA2/AN2
    'PORTA.4[03] OSC2 - Xtal         CCP1/RC5 |05-16| RC0/AN4
    'PORTA.5[02] OSC1 - Xtal          P1B/RC4 |06-15| RC1/AN5
    '                             AN7/P1C/RC3 |07-14| RC2/AN6
    'PORTB.4[13] SPI_SCK              AN8/RC6 |08-13| RB4/AN10
    'PORTB.5[12] SPI_MISO             AN9/RC7 |09-12| RB5/AN11
    'PORTB.6[11] SPI_NSS                  RB7 |10-11| RB6
    'PORTB.7[10] LED
    '
    'PORTC.0[16]
    'PORTC.1[15]
    'PORTC.2[14]
    'PORTC.3[07]
    'PORTC.4[06]
    'PORTC.5[05]
    'PORTC.6[08]
    Name:  SPI theory.jpg
Views: 4638
Size:  253.3 KB

    Name:  SPI Timing.jpg
Views: 4992
Size:  109.5 KB
    Roger

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,626


    Did you find this post helpful? Yes | No

    Default Re: Rfid mfrc522

    Hi Roger,
    I'm confused, where do you see that shifiting in three bytes like that should give you the three first byte of a cards S/N number?

    It looks to me as if the RFID reader chip implements a "proper" SPI slave meaning you have to shift data out at the same time as you shift data in. If that's the case SHIFTIN/SHIFTOUT won't work because it can only shift data out OR shift data in, it can't do it simultanously.

    /Henrik.

Similar Threads

  1. RFID with PIC
    By aloon15 in forum General
    Replies: 0
    Last Post: - 23rd September 2014, 19:33
  2. RFID Issues.... HELP !!!!!
    By andybarrett1 in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 11th September 2014, 11:00
  3. RFID example.
    By StevenLim in forum General
    Replies: 2
    Last Post: - 8th February 2011, 10:08
  4. Rfid?
    By toalan in forum Off Topic
    Replies: 0
    Last Post: - 12th February 2005, 00:37
  5. RFid reader
    By paul farrugia in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 14th January 2005, 21:27

Members who have read this thread : 1

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