A new design scheme of RFID charging system
[ad_1]
1 Introduction
RFID (Radio Frequency IDentification) technology, that is, radio frequency identification technology, is a communication technology that is currently widely used in various charging situations, such as: public transportation charging systems, parking lot charging systems, and so on. At present, the system using RFID technology usually uses RS-485 and PC to exchange data, but RS-485 uses a single master node and adopts a polling method, so there are problems of low real-time performance and low communication efficiency.
With the continuous leaps in the level of computer science and the needs of industrial development, industrial control systems have undergone the transformation from base-based instrument control systems, centralized digital control systems, and distributed control systems to the widely used fieldbus control systems. CAN (Controller Area Net) bus is a field bus based on a serial communication network. The CAN bus adopts a multi-master working mode, and any node on the network can send information to other nodes on the network at any time. At the same time, the CAN bus adopts non-destructive arbitration technology. When two or more nodes transmit data to the network at the same time, the node with lower priority will stop sending until the node with higher priority finishes sending the data. This is effective To avoid bus contention. The CAN communication distance can be as far as 10km/5kbps, and the communication rate can be as large as 1Mbps. Each frame of CAN data has CRC check or other detection methods to ensure the reliability of data communication.
When a serious error occurs in a CAN node, the node will automatically shut down, so as not to affect the normal operation of other nodes. Therefore, the CAN bus has the advantages of strong reliability, high real-time performance and high efficiency, and can completely replace the RS 485 bus.
Considering that in the actual application environment, in order to reduce a lot of wiring work, 2.4G wireless network is used as a transfer station for data transmission from RFID to CAN bus. Wireless technology has the characteristics of low cost, high flexibility, high reliability and short installation time. This design uses nRF24L01 to form a wireless communication network. The chip supports multi-point communication and can receive data from 6 different channels in the receiving mode.
That is, the receiving end of the wireless network can receive data from 6 different sending ends, and the data of the sending end is obtained through the RFID module.
Based on the above discussion, this article will present a new RFID charging system based on CAN bus and 2.4G wireless network.
2 hardware system design
2.1 System topology and system composition
2.1.1 System topology
As shown in Figure 1, the relevant data of the RFID device will be transmitted to the CAN transceiver through the wireless network, and the latter will then transmit the data to the PC through the CAN bus. The PC uses a PCI-E expansion card with a CAN interface. In addition, the wireless communication chip nRF24L01 can receive data from 6 different channels in the receiving mode, so as to realize a CAN node to control the data transmission of 6 RFID terminal devices at most. In the case that the 6 RFID charging terminals cannot meet the demand, more nodes can be added. All nodes are mounted on the CAN bus. Through the CAN bus, each node transmits data to the PC.
Figure 1 System topology diagram
2.1.2 System composition
This system (CAN node) consists of two subsystems. The B subsystem is composed of single chip microcomputer, RFID module, wireless module, watchdog, LCD screen, clock module, keys and EEPROM. The microcontroller (MCU) controls the RFID module to read and write to the Mifare 1 card, and the wireless module sends the relevant data to the A subsystem. The A subsystem is composed of single-chip microcomputer, wireless module, watchdog and CAN module. The MCU sends the data received via the wireless module to the PC through the CAN module. Since a node can control up to 6 RFID device terminals, in a complete system, there is only one A subsystem, and a maximum of six B subsystems.
Figure 2 Block diagram of subsystem A
Figure 3 Block diagram of Subsystem B
2.2 Microcontroller
The microcontroller uses STC89LE58RD+, which has 4 8-bit parallel I/O ports P0~P3, 1 4-bit parallel port P4, 32KB FLASHROM, 1280 bytes RAM, 3 timers, 8 interrupt sources and 4 interrupts Priority interrupt system. Its performance fully meets the design requirements.
2.3 CAN module
The hardware implementation of CAN bus selects Philips SJA1000 and PCA82C250.
2.3.1 Introduction to SJA1000 Chip
SJA1000 is an independent CAN controller. It supports the PeliCAN mode extension function (using CAN2.0B protocol), has an 11-bit or 29-bit identifier, a 64-byte receive FIFO, has an arbitration mechanism and powerful error detection capabilities.
2.3.2 PCA82C250 chip introduction
PCA82C250 is a CAN bus transceiver, which is mainly designed for high-speed communication (up to 1Mbps) applications in automobiles. It can resist a wide range of industrial mode interference and electromagnetic interference (EMI), reduce radio frequency interference (RFI), and has a thermal protection function. Up to 110 nodes can be connected.
2.3.3 Hardware interface connection
As shown in Figure 4, port P1 is used as a multiplexed address/data bus to connect to the AD port of SJA1000, and P2.0 is connected to the CS of SJA1000, making SJA1000 an I/O device that is mapped to the peripheral memory of the microcontroller. In addition, RX0 and TX0 of SJA1000 are connected to RXD and TXD of PCA82C250.
Figure 4 SJA1000 and PCA82C250 interface connection diagram
2.4 Wireless module
2.4.1 nRF24L01 chip introduction
The wireless chip is nRF24L01. It is a 2.4GHz wireless radio frequency transceiver chip with a transmission rate of up to 2Mbps, supports 125 optional operating frequencies, has address and CRC check functions, and provides an SPI interface.
There are dedicated interrupt pins that support 3 interrupt sources and can send interrupt signals to the MCU. It has an automatic response function, which records the address after confirming the receipt of the data, and sends a response signal with this address as the target address. Support ShockBurstTM mode, in this mode, nRF24L01 can be connected with low-speed MCU. nRF24L01 can receive 6 different channels of data in receiving mode.
2.4.2 nRF24L01 hardware interface connection
As shown in Figure 5, the one-chip computer communicates with nRF24L01 by simulating the SPI bus timing. Its external interrupt pin IRQ is connected to P3.2 (external interrupt 0) of the microcontroller.
Figure 5 Schematic diagram of nRF24L01 interface connection
2.5 RFID module
2.5.1 MF RC500 chip introduction
The RFID module uses Philips MF RC500, which is one of the widely used RFID chips. MF RC500 supports ISO14443A protocol, supports MIFARE dual-interface card, and has a highly integrated analog circuit for demodulation and decoding of answering cards. It has a 64-byte transceiver FIFO buffer and a non-volatile key memory. In addition, there are dedicated interrupt pins that support 6 interrupt sources and can send interrupt signals to the MCU.
2.5.2 MF RC500 hardware interface connection
As shown in Figure 6, MCU accesses the registers in MF RC500 as external RAM. The INT pin is left floating and the interrupt function is not used.
Figure 6 Schematic diagram of MF RC500 interface connection
3 Software system design
In the initialization of the microcontroller program, the external interrupt of Subsystem A is set to low level trigger. The interrupt signal source of Subsystem A is provided by nRF24L01. When nRF24L01 receives data, it generates an interrupt signal and informs the MCU to read the data. Subsystem B does not use the interrupt function.
In the program of initializing nRF24L01, subsystem B is configured as sending mode, using 16-bit CRC check. To use the automatic response function, data channel 0 is set to receive the response signal, and the receiving address of data channel 0 must be equal to the address of the sender to ensure that the response signal can be received correctly. A system can consist of up to six subsystems A, and the sending addresses of these six subsystems cannot be repeated. Subsystem A is configured in receiving mode, using 16-bit CRC check, and receiving data of up to 6 channels. These 6 receiving addresses are equal to the sending addresses in each subsystem B. In the initial SJA1000, the PliCAN mode is used, the baud rate is 125Kbps, and the receiving and sending interrupts are prohibited; the output control register configuration is as follows: normal mode, TX pull-down, and output control polarity. In addition, the acceptance code register and acceptance mask register must be correctly configured. This configuration is used to implement the CAN bus arbitration function.
In the initialization of MF RC500, its main settings are as follows: TX1 and TX2 output configuration is 13.56MHz energy carrier; decoder input source is internal demodulator; use Q clock as receiver clock; prohibit sending and receiving interrupts; set RxThreshold The register value is 0xFF, the BitPhase register value is 0xAD, etc.
The reset request function will search for the Mifare1 card within the effective range of the antenna. If there is a card, it will establish a communication connection and read the card type number TAGTYPE on the card. The anti-collision function makes the MF RC500 select one of the multiple Mifare 1 cards open. The card selection function can communicate with cards with known serial numbers. The authentication function matches the password on the Mifare 1 card with the key in the EEPROM of the MF RC500.
Only after the match is correct, can the ** read and write operations be performed. Send the stop command to set the Mifare 1 card to HALT MODE.
The CAN function is used to send relevant data to the PC. This design uses a query method to ensure that the data has been sent. By querying the flag bits TBS, TCS and TS in the status register, you can confirm whether the data has been sent. Similarly, in the wireless function, to ensure that the data has been sent, you can query TX_DS in the status register.
Figure 7 Subsystem A software flow
Figure 8 Subsystem B software flow chart
4 System test
First, the RFID module was tested. Put the MIFARE 1 card into the effective range of the antenna, read and write the card, and display the relevant data on the LCD screen. After this test, the RFID module reads and writes normally. Subsequently, the real-time performance of the transmission network of the system is tested. This article uses the wireless transmission of temperature data to test. The device for measuring temperature is DS18B20 single-wire temperature sensor. Connect the temperature sensor to Subsystem B. The temperature sensor samples the indoor temperature every second. The microcontroller reads the temperature data and sends it to Subsystem A via the wireless network. Subsystem A receives the data and sends it via the CAN bus. To the PC side.
The PC side uses Visual Basic 6.0 to write the upper computer program, and the upper computer draws the temperature data into a curve and writes the text. The temperature curve is shown in Figure 8, where the accuracy of the temperature value is 1 degree Celsius. By comparing and observing the temperature graph and text data, it is found that there is no abnormality in the temperature data, and there is no loss of data.
Figure 9 Temperature graph
5 Conclusion
This article uses the CAN bus to replace the RS-485 bus, which overcomes the shortcomings of the latter. At the same time, wireless technology is used to reduce a lot of wiring work while taking full advantage of the multi-point communication function of nRF24L01. After the system was built, I tested the system for a long time. The test results show that the data transmission is stable, reliable, and high in real-time. It overcomes the shortcomings of the traditional RFID charging system based on the RS485 bus design, and has strong use value.
[ad_2]