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, etc. Current systems using RFID technology usually use RS-485 and PC for data exchange. However, RS-485 uses a single master node and adopts polling mode, so there are problems of low real-time performance and low communication efficiency.
With the continuous leap in the level of computer science and the needs of industrial development, industrial control systems have experienced the transformation from base instrument control systems, centralized digital control systems, distributed control systems to the now widely used fieldbus control systems. CAN (Controller Area Net) bus is a field bus based on 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 uses non-destructive arbitration technology. When two or more nodes transmit data to the network at the same time, the node with a lower priority will stop sending until the node with a higher priority has finished sending the data. This is effective. to avoid bus contention. The CAN communication distance can reach up to 10km/5kbps, and the communication rate can reach up to 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, thus not affecting the normal work 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 actual application environments, in order to reduce a large amount of wiring work, the 2.4G wireless network is used as a transfer station for data transmission from RFID to the CAN bus. Wireless technology offers low cost, flexibility, reliability and short installation time. This design uses nRF24L01 to build a wireless communication network. This chip supports multi-point communication and can receive data from 6 different channels in receiving mode.
That is to say, the receiving end of the wireless network can receive data from 6 different sending ends. The data from 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, thereby realizing a CAN node to control the data transmission of up to 6 RFID Terminal devices. When six 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.
2.1.2 System composition
This system (CAN node) consists of two subsystems. Subsystem B consists of microcontroller, RFID module, wireless module, watchdog, LCD screen, clock module, buttons and EEPROM. The microcontroller (MCU) controls the RFID module to read and write the Mifare 1 card, and the wireless module sends the relevant data to the A subsystem. Subsystem A consists of microcontroller, wireless module, watchdog and CAN module. The MCU sends the data received via the wireless module to the PC through the CAN module. Since one node can control up to 6 RFID device terminals, in a complete system, there is only 1 subsystem A, while there can be up to 6 subsystems B.
2.2 Microcontroller
The microcontroller is STC89LE58RD+, which has four 8-bit parallel I/O ports P0~P3, one 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 the CAN bus uses Philips' SJA1000 and PCA82C250.
2.3.1 SJA1000 chip introduction
SJA1000 is an independent CAN controller. It supports PeliCAN mode extension function (using CAN2.0B protocol), has 11-bit or 29-bit identifiers, 64-byte receiving FIFO, arbitration mechanism and powerful error detection capabilities, etc.
2.3.2 PCA82C250 chip introduction
PCA82C250 is a CAN bus transceiver, which is mainly designed for medium-to-high-speed communication (up to 1Mbps) applications in automobiles. It can resist a wide range of work-mode interference and electromagnetic interference (EMI), reduce radio frequency interference (RFI), and has thermal protection functions. Up to 110 nodes can be connected.
2.3.3 Hardware interface connection
As shown in Figure 4, the P1 port is used as a multiplexed address/data bus to connect to the AD port of SJA1000, and P2.0 is connected to the chip select section CS of SJA1000, making SJA1000 an I/O device for peripheral memory mapping of the microcontroller. In addition, RX0 and TX0 of SJA1000 are connected to RXD and TXD of PCA82C250.
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.
It has a dedicated interrupt pin, supports 3 interrupt sources, and can send interrupt signals to the MCU. It has an automatic response function, records the address after confirming receipt of data, and sends a response signal using this address as the target address. Supports ShockBurstTM mode, in this mode, nRF24L01 can be connected to low-speed MCU. nRF24L01 can receive data from 6 different channels in receiving mode.
2.4.2 nRF24L01 hardware interface connection
As shown in Figure 5, the microcontroller communicates with nRF24L01 by simulating SPI bus timing. Its external interrupt pin IRQ is connected to P3.2 (external interrupt 0) of the microcontroller.
2.5 RFID module
2.5.1 MF RC500 chip introduction
The RFID module uses Philips' MF RC500, which is one of the currently widely used RFID chips. MF RC500 supports ISO14443A protocol and MIFARE dual interface card. It has a highly integrated analog circuit inside for demodulation and decoding of the response card, and has a 64-byte transceiver FIFO buffer and non-volatile key memory. In addition, there is a dedicated interrupt pin that supports 6 interrupt sources and can send interrupt signals to the MCU.
2.5.2 MF RC500 hardware interface connection
As shown in Figure 6, the MCU accesses the registers in the MF RC500 as external RAM. The INT pin is left floating and the interrupt function is not used.
3 Software system design
In the initialization 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 the data, it generates an interrupt signal to notify the MCU to read the data. Subsystem B does not use interrupt functionality.
In the initialization nRF24L01 program, subsystem B is configured in transmit mode and uses 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 be composed of up to six subsystems A, and the sending addresses of these six subsystems cannot be repeated. Subsystem A is configured in receive mode, uses 16-bit CRC check, and can receive up to 6 channels of data. These 6 receiving addresses are equal to the sending addresses in each subsystem B. In the initial test of SJA1000, PliCAN mode is used, the baud rate is 125Kbps, and 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 need to be configured correctly. This configuration is used to implement the CAN bus arbitration function.
In initializing the MF RC500, its main settings are as follows: the outputs of TX1 and TX2 are configured as 13.56MHz energy carriers; the input source of the decoder is the internal demodulator; use the Q clock as the receiver clock; disable transmit and receive 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 a card exists, a communication connection will be established and the card type number TAGTYPE on the card will be read. The anti-collision function enables the MF RC500 to select one of 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 matching is correct, the read and write operations can be carried out. Send a shutdown 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 query mode to ensure that the data has been sent. You can confirm whether the data transmission is completed by querying the flag bits TBS, TCS and TS in the status register. Similarly, in the wireless function, to ensure that the data has been sent, just query the TX_DS in the status register.
4 System testing
First, the RFID module was tested. Put the MIFARE 1 card within the effective range of the antenna, perform read and write operations on 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 wireless transmission of temperature data for testing. The device for measuring temperature is a 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 through the wireless network. Subsystem A receives the data and sends it through the CAN bus. to PC.
On the PC side, Visual Basic 6.0 is used to write the host computer program. The host computer draws the temperature data into a curve and writes it into text. The temperature curve is shown in Figure 8, where the accuracy of the temperature values is 1 degree Celsius. Through comparative observation of the temperature curve graph and text data, it was found that there was no abnormality in the temperature data and no data loss.
5 Conclusion
This article uses the CAN bus to replace the RS-485 bus, overcoming the shortcomings of the latter. Wireless technology is also used to fully utilize the multi-point communication function of nRF24L01 while reducing a lot of wiring work. After the system was built, the author tested the system for a long time. The test results show that the data transmission is stable, reliable and has high real-time performance. It overcomes the shortcomings of the traditional RFID toll collection system based on RS485 bus design and has strong use value.
Contact: Adam
Phone: +86 18205991243
E-mail: sale1@rfid-life.com
Add: No.987,Innovation Park,Huli District,Xiamen,China