element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • More
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • More
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • More
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • More
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Safe and Sound
  • Challenges & Projects
  • Design Challenges
  • Safe and Sound
  • More
  • Cancel
Safe and Sound
Blog Safe&Sound: Wearable Tracking Device for Miners - 14: RC522- reading RFID tags
  • Blog
  • Forum
  • Documents
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: sunnyiut
  • Date Created: 7 Jul 2017 8:47 PM Date Created
  • Views 313 views
  • Likes 3 likes
  • Comments 1 comment
  • safe and sound design challenge
  • nfcrfidch
  • mikromedia for stm32 m4
  • rc522
Related
Recommended

Safe&Sound: Wearable Tracking Device for Miners - 14: RC522- reading RFID tags

sunnyiut
sunnyiut
7 Jul 2017

Title: Wearable Tracking Device for Miners

By: sunnyiut

Previous Blogs
01: Introduction02: The Kit
03: Review_MSP432P401R04: Review_430BOOST-SHARP96
05: Review_BOOSTXL-SENSORS06: Review_DLP7970ABP
07: Project proposal update08: TFT interfacing
09: Light sensor interfacing10: Environmental sensor interfacing
11: IR temperature sensor interfacing12: Integrating 3 sensors in firmware
13: H/W design - Wearable Device

 

Design Challenge: Safe and Sound Wearables

Blog number: 14

 

 

 

Intro:

This blog describes half of the second part of my proposal, where RC522 module will be used to detect valid RFID tags of miners and the device will display the corresponding miner's profile.

 

 

 

Objective:

 

The second part of my project proposal-

A system that will read the RFID tags of the Miners and upon valid ID detection,

     it will send the

    • Zone ID,
    • Miner's ID and
    • Time of Entry in the working area

     to the Central Monitor using I2C communication.

 

The objective of this blog is to describe the first half of the system where

  • the RFID tags will be detected
  • miner's profile will be displayed for valid ID
  • an RTC will keep the time of punching tags

 

 

Placement of the Device:

 

The system works with 13.56MHz RFID tags [based on ISO14443 card communication]. The reader [RC522] has an operation range of about 35mm.

Therefore, these cards/tags have to be punched / placed near the reader module.

 

So, in my proposed system, every zone will have an RFID tag reader device and these devices will be placed at the entry of the working zone. The miners have to punch their card at the time of their entry.

 

 

Components:

 

  • RC522 - 13.56MHz RFID tag reader [works best with MiFare cards like ULTRA, ONE, PRO, DESFIRE]
  • MikroMedia for STM32M4
    • MCU - STM32F407VG
    • 2.8" 320x240 TFT
    • Built in RTC
    • on board MicroSD card interface for data logging [not implemented in this firmware, but can be (future work)]
    • on board power management and battery charger [useful for power failure]

**I am using this Mikromedia board, as it is handy and a compact solution for me.

 

Related imagemikromedia for STM32 M4

RC522 RFID reader                                             Mikromedia for STM32 M4 [by MikroElektronika]

 

Compiler:     MikroC PRO for ARM

 

Firmware:

Full source code can be found at LIBSTOCK.

 

 

Interfacing:

 

Interfacing protocol - SPI

Experimental Tags - MiFare One S70 [card and tag]

Communication protocol - ISO14443

Initialization -

/*
 * Function Name:------------- InitMFRC522--------------
 * Description: Initialize RC522
 * Input: None
 * Return value: None
*/
void MFRC522_Init(void)
{
  NRSTPD = 1;

  MFRC522_Reset();

  //Timer: TPrescaler*TreloadVal/6.78MHz = 24ms
  Write_MFRC522(TModeReg, 0x8D);        //Tauto=1; f(Timer) = 6.78MHz/TPreScaler
  Write_MFRC522(TPrescalerReg, 0x3E);   //TModeReg[3..0] + TPrescalerReg
  Write_MFRC522(TReloadRegL, 30);
  Write_MFRC522(TReloadRegH, 0);

  Write_MFRC522(TxAutoReg, 0x40);       //100%ASK
  Write_MFRC522(ModeReg, 0x3D);         //CRC Initial value 0x6363        ???

  //ClearBitMask(Status2Reg, 0x08);     //MFCrypto1On=0
  //Write_MFRC522(RxSelReg, 0x86);      //RxWait = RxSelReg[5..0]
  //Write_MFRC522(RFCfgReg, 0x7F);      //RxGain = 48dB

  AntennaOn();                          //Open the antenna
}

 

Finding tags -

/*
 * Function Name: -------------MFRC522_FindTAG------------
 * Description: Find cards, read the card type number
 * Input parameters: reqMode - find cards way
 *                         TagType - Return Card Type
 *                                0x4400 = Mifare_UltraLight
 *                                0x0400 = Mifare_One(S50)
 *                                0x0200 = Mifare_One(S70)
 *                                0x0800 = Mifare_Pro(X)
 *                                0x4403 = Mifare_DESFire
 * Return value: the successful return = 0 [MI_OK]
 */
uchar MFRC522_FindTAG(uchar reqMode, uchar *TagType)
{
  uchar status;
  uint backBits;                        //The received data bits

  Write_MFRC522(BitFramingReg, 0x07);  //TxLastBists = BitFramingReg[2..0] ???

  TagType[0] = reqMode;
  status = MFRC522_ISO14443TAG(PCD_TRANSCEIVE, TagType, 1, TagType, &backBits);

  if ((status != MI_OK) || (backBits != 0x10))
  {
    status = MI_ERR;
  }

  return status;
}

 

Anti-collision from multiple cards -

/*
 * Function Name: -------------MFRC522_Anticoll---------------
 * Description: Anti-collision detection, 
 *              reading selected TAG serial number
 * Input parameters: serNum [0...3] -> returns 4 bytes of TAG serial number, 
 *                   serNum [4] -> XOR checksum byte of TAG serial number
 * Return value: the successful return = 0 [MI_OK]
 */
uchar MFRC522_Anticoll(uchar *serNum)
{
  uchar status;
  uchar i;
  uchar serNumCheck=0;
  uint unLen;

  //ClearBitMask(Status2Reg, 0x08);    //TempSensclear
  //ClearBitMask(CollReg,0x80);        //ValuesAfterColl
  Write_MFRC522(BitFramingReg, 0x00);  //TxLastBists = BitFramingReg[2..0]

  serNum[0] = PICC_ANTICOLL;
  serNum[1] = 0x20;
  status = MFRC522_ISO14443TAG(PCD_TRANSCEIVE, serNum, 2, serNum, &unLen);

  if (status == MI_OK)
  {
    //Check card serial number
    for (i=0; i<4; i++)
    {
      serNumCheck ^= serNum[i];    // performs bitwise XOR of serial number
                                   // serNum [0..3] -> XOR stored in serNumCheck
    }
    if (serNumCheck != serNum[i])  // serNumCheck should be same as serNum[4]
    {
      status = MI_ERR;
    }
  }
  //SetBitMask(CollReg, 0x80);                //ValuesAfterColl=1

  return status;
}

 

 

Reading TAG01:

 

Reading TAG02:

 

 

** for an invalid tag ID, Device shows "Unknown TAG". The Zone no. is preprogrammed.

All the working zones will have this RFID reader device at the entry point with separate zone IDs, where the Miners have to punch their tag.

 

Second half of the device:

 

After detecting a valid ID from the miner, device sends the zone ID, Miner's ID and time of entry to the central monitor using I2C.

But to demonstrate that I need to setup the Central Monitor with I2C communication first.

 

So, the other half of this RFID tag reader system will be demonstrated in the upcoming blog on the "Central Monitor".

 

One more component to design.... !!

there's not much time left ......

However, theoretically that's the end of designing the second part of the total system. One more to go... - the "Central Monitor"

I have to solder and test the wearable sensor device and design a wrist mount for it.

Which one should I do first..... ummm confused

 

A short video on testing the RFID reader is attached below -

You don't have permission to edit metadata of this video.
Edit media
x
Upload Preview

Anonymous
  • DAB
    DAB over 4 years ago

    Nice update.

     

    It looks like all of the pieces are coming together.

     

    I think you have a good start at a demonstration system that could be applied to a lot of workplace domains.

     

    I look forward to some actual mine testing results.

     

    DAB

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
Element14

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2022 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube