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:full system.jpg

 

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

rc522IMG_1578.JPG

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:

IMG_1582.JPG1.jpg

 

Reading TAG02:

 

IMG_1579.JPG2.jpg

 

** 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 -