SrpCPccfym

[RA] Express box with card opening function based on Renesas MCU

 
Overview

Project Description

  • Lichuang express box with card opening function based on Renesas RA2E1 MCU

basic skills

  • Use the serial port to communicate with PN532.
  • When the express box is opened, swipe the card to enter the unboxing NFC card information. After the entry is successful, the buzzer will sound a long tone. It can be used to replace the card.
  • When the express box is closed, swipe the card. When the NFC card is correct, the box will automatically open and make a short sound. When the NFC card is not entered, the buzzer will sound twice.

Circuit description

master control

  • Use RA2E1 MCU as the main control, this part refers to the training camp teaching content.

Pin description

  • Configure P000 as the input mode as the express box switch status signal. According to the instructions provided by the titanium wire lock merchant, when the lock is open, the two signal lines are open, and when the lock is closed, the signal line is conductive, so as to determine the box switch status.
  • Configure P915 in output mode to control the titanium wire lock. The electrical parameters of the titanium wire lock are 5V/1.2A, and NMOS is used as the titanium wire lock switch.
  • Configure P407 as output mode, and control the buzzer as a prompt for success and failure during work.
  • Configure P212/P213 as a serial port to communicate with PN532.

Program Description

The data is parsed according to the PN532 communication protocol. The code is as follows

void user_uart1_callback (uart_callback_args_t * p_args)
{
    if(p_args->event == UART_EVENT_TX_COMPLETE)
    {
        uart1_send_complete_flag = true;
    }

    if(p_args->event == UART_EVENT_RX_CHAR)
    {
        RxBuff[0] = p_args->data;
        RxLine++;                      //每接收到一个数据,进入回调数据长度加1
        DataBuff[RxLine-1]=RxBuff[0];  //把每次接收到的数据保存到缓存数组
        Rx_flag=1;
        Rx_len++;
        if (Rx_len == 0x09) { //开始读取长度
            Rx_clen = RxBuff[9] + 13;
        }

        if(Rx_len == Rx_clen) 
        {
            Rx_flag_finish=1;
            Rx_len--;
        }
        RxBuff[0]=0;
    }
}

When the titanium wire lock is opened, the card number is read and stored.

    err = R_FLASH_LP_Erase(&g_flash0_ctrl, FLASH_DF_BLOCK_0, 1);
    assert(FSP_SUCCESS == err);
    printf("R_FLASH_LP_Erase
");
    while (!interrupt_called)
    {
    ;
    }
    assert(FLASH_EVENT_ERASE_COMPLETE == flash_event);
    interrupt_called = false;
    flash_status_t status;
    err = R_FLASH_LP_Write(&g_flash0_ctrl, (uint32_t) cardId, FLASH_DF_BLOCK_0, cardId_length);

When the titanium wire lock is closed, the card number is read and compared with the stored card number and processed.

    if (0 == memcmp(cardId, (uint8_t *) FLASH_DF_BLOCK_0, 4))
    {
        open_box();
    }else
    {
        err_beep();
    }

Finished product display

PCB

  • QQ20220502-191538@2x.png
  • QQ20220502-191117@2x.png

internal

  • QQ20220502-191255@2x.png
  • QQ20220502-191305@2x.png

external

  • QQ20220502-191227@2x.png

Use video

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-05-22 08:37:42

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号