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
RF Radio Frequency
  • Challenges & Projects
  • Project14
  • RF Radio Frequency
  • More
  • Cancel
RF Radio Frequency
Blog NFC Lock — run with NFC Tag Antenna
  • Blog
  • Forum
  • Documents
  • Events
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
RF Radio Frequency requires membership for participation - click to join
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fyaocn
  • Date Created: 8 Jan 2020 4:30 AM Date Created
  • Views 330 views
  • Likes 9 likes
  • Comments 13 comments
  • rfradiofrequencych
Related
Recommended

NFC Lock — run with NFC Tag Antenna

fyaocn
fyaocn
8 Jan 2020

Thanks to Element14 community with all the swag gift and sincerely greeting.

I would be my pleasure to share my test project for the new due-core M33 product from NXP theming RF.

 

 

NFC Lock

1. Brief

The NFC tag reader works on 125kHz, if read tag via I2C match the authorized ID, the lock is opened until next detection loop.

The servo used in this project runs with 50Hz PWM frequency and dutycycle  Percentage of 2.5% ~ 12.5%. In this design 5% vs 10% as On state and OFF state .

#define LOCK_ON 5
#define LOCK_OFF 10

Then update the PWM period for servo control.In which the last bit of rxBuff is set to 0xFF if the NFC ID is matched.g_master_rxBuff[I2C_DATA_LENGTH-1]g_dmvfvva g_master_rxBuff[I2C_DATA_LENGTH-1]ster_rxBuff[I2C_DATA_LENGTH-1]

updatedutyCyclePercent= LOCK_ON ? (g_master_rxBuff[I2C_DATA_LENGTH-1]==127):LOCK_OFF;
g_pulsePeriod = (g_pwmPeriod * (100 - updatedutyCyclePercent)) / 100;

 

2. Hardware

2.1 LPC55S69 dev board

2.2 NFC tag reader ID-12LA, on 125kHz

3. Main Code

3.1 With I2C and ctimer PWM, the NFC lock can be coded as follows,

int main(void)
{
    i2c_master_config_t masterConfig;
    status_t reVal        = kStatus_Fail;
    uint8_t deviceAddress = 0x01U;

  ctimer_config_t config;
    uint32_t srcClock_Hz;
    uint32_t timerClock;
uint8_t updatedutyCyclePercent;


    /* attach 12 MHz clock to FLEXCOMM0 (debug console) */
    CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);


    /* attach 12 MHz clock to FLEXCOMM8 (I2C master) */
    CLOCK_AttachClk(kFRO12M_to_FLEXCOMM4);


    /* Use 12 MHz clock for some of the Ctimers */
    CLOCK_AttachClk(kFRO_HF_to_CTIMER2);

    /* reset FLEXCOMM for I2C */
    RESET_PeripheralReset(kFC4_RST_SHIFT_RSTn);


    BOARD_InitPins();
    BOARD_BootClockPLL150M();
    BOARD_InitDebugConsole();

    /* CTimer0 counter uses the AHB clock, some CTimer1 modules use the Aysnc clock */
    srcClock_Hz = CTIMER_CLK_FREQ;


    PRINTF("CTimer example to generate a PWM signal\r\n");


    CTIMER_GetDefaultConfig(&config);
    timerClock = srcClock_Hz / (config.prescale + 1);


    CTIMER_Init(CTIMER, &config);


    /* Get the PWM period match value and pulse width match value of 50hz PWM signal with 2.5%~12.5% dutycycle , 20ms peoriod*/
    CTIMER_GetPwmPeriodValue(50, 10, timerClock);
    CTIMER_SetupPwmPeriod(CTIMER, CTIMER_MAT_OUT, g_pwmPeriod, g_pulsePeriod, false);
    CTIMER_StartTimer(CTIMER);
//CTIMER_UpdatePwmDutycycle(CTIMER_Type *base, ctimer_match_t matchChannel, uint8_t dutyCyclePercent);

    PRINTF("\r\nI2C board2board polling -- Master transfer.\r\n");


    g_master_txBuff[0] = I2C_DATA_LENGTH - 1U;
    for (uint32_t i = 1U; i < I2C_DATA_LENGTH; i++)
    {
        g_master_txBuff[i] = i - 1;
    }




    I2C_MasterGetDefaultConfig(&masterConfig);


    /* Change the default baudrate configuration */
    masterConfig.baudRate_Bps = I2C_BAUDRATE;


    /* Initialize the I2C master peripheral */
    I2C_MasterInit(EXAMPLE_I2C_MASTER, &masterConfig, I2C_MASTER_CLOCK_FREQUENCY);




    /* Wait until the slave is ready for transmit, wait time depend on user's case.
       Slave devices that need some time to process received byte or are not ready yet to
       send the next byte, can pull the clock low to signal to the master that it should wait.*/
    for (uint32_t i = 0U; i < WAIT_TIME; i++)
    {
        __NOP();
    }
    PRINTF("Receive sent data from slave :");

while (1)
    {
    for (uint32_t i = 0U; i < WAIT_TIME; i++)
    {        __NOP();    }
    /* Receive blocking data from slave */
    if (kStatus_Success == I2C_MasterStart(EXAMPLE_I2C_MASTER, I2C_MASTER_SLAVE_ADDR_7BIT, kI2C_Write))
    {


        reVal = I2C_MasterReadBlocking(EXAMPLE_I2C_MASTER, g_master_rxBuff, I2C_DATA_LENGTH - 1, kI2C_TransferDefaultFlag);
        if (reVal != kStatus_Success)
        {
            return -1;
        }


        reVal = I2C_MasterStop(EXAMPLE_I2C_MASTER);
        if (reVal != kStatus_Success)
        {
            return -1;
        }
    }


    for (uint32_t i = 0U; i < 4; i++)
    //for (uint32_t i = 0U; i < I2C_DATA_LENGTH - 1; i++)
    {
        if (i % 8 == 0)
        {
            PRINTF("\r\n");
        }
        PRINTF("0x%2x  ", g_master_rxBuff[i]);
if (g_master_rxBuff[i]== g_match_id[i] ){g_master_rxBuff[I2C_DATA_LENGTH-1]=127;}
    }
    PRINTF("\r\n\r\n");

// LOCK_UNLOCK, refreshed every loop and return to LOCK off status,
updatedutyCyclePercent= LOCK_ON ? (g_master_rxBuff[I2C_DATA_LENGTH-1]==127):LOCK_OFF;
g_pulsePeriod = (g_pwmPeriod * (100 - updatedutyCyclePercent)) / 100;
CTIMER_UpdatePwmDutycycle(CTIMER, CTIMER_MAT_OUT, g_pulsePeriod);


    }
    // PRINTF("\r\nEnd of I2C example .\r\n");
}

 

 

4. Demo video and pics.

 

 

{gallery} NFC lock

REPLACE THIS TEXT WITH YOUR IMAGE

IMAGE TITLE: THEN IMAGE DESCRIPTION

REPLACE THIS TEXT WITH YOUR IMAGE

IMAGE TITLE: THEN IMAGE DESCRIPTION

REPLACE THIS TEXT WITH YOUR IMAGE

IMAGE TITLE: THEN IMAGE DESCRIPTION

REPLACE THIS TEXT WITH YOUR IMAGE

IMAGE TITLE: THEN IMAGE DESCRIPTION

And the demo video

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

Anonymous

Top Comments

  • BigG
    BigG over 2 years ago in reply to BigG +4

    I just happened to receive my components this morning... this enabled me to solder up my new board I designed... guess what this is...

     

  • fyaocn
    fyaocn over 2 years ago in reply to BigG +3

    Very Interesting.

    Want to see what you will create and share.

  • fyaocn
    fyaocn over 2 years ago in reply to BigG +2

    Thanks for your tip. That is right.

    Near Field Communication is general term for cluster of Communication protocl. That of 125kHz is cheapest choice as (LF) RFID.

    Some due-frequency NFC card reader can…

  • shabaz
    shabaz over 2 years ago in reply to Fred27

    Ah, I see. I wonder if it is related to the signal being clipped, e.g. not being able to resonate to its max amplitude due to hitting the threshold for the switch operation. That would be harder to solve : (

    Maybe one way (super-experimental, no idea if it would work) would be to have a separate smaller coil/loop for inductively feeding the resonant circuit loop+capacitor. That way the feeding loop is not resonant. This is done with larger antennas (it is popular with HF antennas), but I've never seen it done with say NFC. Or, just use separate chips and no switching, since cost may be similar. Another approach could be not to use NFC, but a different backscatter based technology where it works over greater distances so that a single antenna could be used, assuming the tag antenna was fairly non-directional. I can't remember the names of the tags, but there are some that run in the sub-GHz range, and would fit inside the ball. But you may have reasons not to do that, e.g. your commercial use-case may have other specific requirements which mandate NFC or NFC-like technologies.

    • Cancel
    • Up +1 Down
    • Reply
    • More
    • Cancel
  • Fred27
    Fred27 over 2 years ago in reply to shabaz

    It's something I was doing as part of my new job so not really something I feel I can write up in detail. The antenna tuning should be OK. I tried various coils sizes and number of turns which I ranged from 0.7uH to 0.9uH. In addition to my previous VNA-less NFC antenna tuning technique I now have a NanoVNA (the same as Fabio's) which did an excellent job of measuring the final tuned circuit. I'm fairly confident they were pretty much as good as i could get them. You're about right in your guess at the capacitance required too.

    • Cancel
    • Up +2 Down
    • Reply
    • More
    • Cancel
  • shabaz
    shabaz over 2 years ago in reply to Fred27

    Hi Fred,

     

    Very interesting project! I almost missed seeing it in the comments. Looking forward to reading more about the experiment, I can see some practical uses for it.

    And also nice RF switch board, Peregrine parts are really cool : )

    I'm working on a different project with RF switches too, I went with an IDT part, but Peregrine has some exceptional stuff.

    Regarding the range, could it be the parallel capacitor? This type of antenna has a very sharp tuned range, so there's a chance it might not be tuned at 13.56 MHz. The only reason I know this is because I'm working on a loop antenna too, although for a different frequency range. The VNA that Fabio used Building a poor man’s quarter-wave 433MHz antenna: Comparing Antennae  could be really useful in this scenario.

    I know the inductance formula for a single turn, but don't know it for the multi-turn that you've got, so I'm not sure what capacitance could be needed, guessing it is low three-digit pF, just eyeballing the size of the coil in the photo? Possibly could be worth using NP0 1% capacitors if you're not already using similar types, just to eliminate capacitor value variability for your four antennas.

    Anyway, really interested to learn more about your experiment and findings.

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
  • fyaocn
    fyaocn over 2 years ago in reply to BigG

    Very Interesting.

    Want to see what you will create and share.

    • Cancel
    • Up +3 Down
    • Reply
    • More
    • Cancel
  • BigG
    BigG over 2 years ago in reply to Fred27

    You are using 125kHz for this?

     

    Maybe thie above project, when ready will help, as in demonstrate 13.56MHz read range performance using ISO15693.

     

    In my experience I found that small antennae don't perform as well regardless of tuning.

    • Cancel
    • Up +1 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