
“This article proposes a wireless network system using the wireless transceiver chip nRF24LU1+. This network system makes full use of the advantages of USB and wireless transceiver modules to realize fast and convenient data transmission, and has the characteristics of high integration, small size, strong confidentiality, and low power consumption.
“
Authors: Li Jianming; Peng Jianxue; Yu Tao
introduction
With the development of personal computers and the maturity of USB (Universal Seral Bus) technology, USB devices are also developing at an astonishing speed. Digital cameras, printers, scanners in daily life, electrocardiographs, bedside monitoring systems in hospitals, and barcode scanners in libraries, supermarkets and logistics warehouses mostly use USB communication. However, due to the limited length of the USB cable (generally it is stipulated that the length of the low-speed cable shall not exceed 3 m, and the length of the full-speed cable shall not exceed 5 m), which brings a lot of inconvenience to use. In order to realize the high-speed transmission of data and make up for its limited cable length, this paper presents a wireless network system design scheme based on the RF24LU1+ USB interface device.
1 System design
The overall block diagram of the system is shown in Figure 1.
The working principle of the system: First, insert the USB plug of the wireless transceiver host into the USB socket of the PC to realize the hardware connection between the PC and the wireless transceiver host; similarly, realize the wireless transceiver slave and the USB device i (i=1,…, n) The hardware connection. The wireless transceiver master/slave can adopt self-powered according to the actual situation, or obtain power from the equipment connected to it. Then, the PC implements the USB enumeration process for the wireless transceiver host; at the same time, the USB master control unit of the wireless transceiver slave implements the USB enumeration process for the USB device. After the enumeration is over, establish a wireless network. The wireless transceiver host and each wireless transceiver slave are set with a unique address, and the wireless transceiver host communicates with the wireless transceiver slave by query. After the wireless network is established, the wireless communication of USB data stream can be carried out through the wireless transceiver master/slave.
2 hardware circuit design
2.1 Chip structure and characteristics of nRF24LU1+
nRF24LU1+ is a wireless transceiver chip launched by Nordic semiconductor that combines the functions of a high-performance radio frequency transceiver and a single-chip USBdongle. nRF24LU1+ contains an enhanced 8051MCU core, wireless transceiver module, full-speed USB 2.0 standard device controller, 2 KB on-chip SRAM, 16 KB or 32 KB on-chip Flash memory, and 6 general-purpose I /O port and voltage regulator. nRF24LU1+ significantly enhances the anti-wideband interference and intermodulation distortion (IMD) performance. The external components required by the nRF24LU1+ chip are only a low-cost 16 MHz crystal oscillator, decoupling circuit, matching network and antenna. VBUS (USB working power supply) operating voltage range is 4.0 ~ 5. 25 V. nRF24LU1+ is a monolithic structure with very small dimensions (5 mm×5 mm).
The wireless transceiver works in the global open 2.400~2.483 5 GHz frequency band, and the communication baud rate of the transceiver can be set to work at 2 50 kbps, 1 Mbps, 2 Mbps through software; data packets can be realized by using Enhanced ShockedBust technology Automatic packing/unpacking and transmission processing (response, retransmission); using MultiCeiver technology can support 6 wireless devices at the same time, frequency band, output energy and other radio frequency parameters can be easily programmed and adjusted through radio frequency registers; with point-to-multipoint Communication, and the use of AES encryption technology to achieve more secure data transmission; using ultra-low power (ULP) wireless technology, the typical peak current of 0 dBm output power is 11.1 mA; integrated with a voltage regulator, the chip can be directly Powered by the USB bus.
2.2 Chip structure and characteristics of ISP1161
ISP1161 is a USB interface chip conforming to the USB2.0 bus protocol from Philips. It has both host controller (HC) and device controller (DC), supports full-speed/low-speed transmission, 16-bit data bus, and supports 3.3 V/5 V dual power supply mode. When ISP1161 is a USB host controller, it provides two downward ports for USB device connection.
2.3 Wireless transceiver host with USB interface
The wireless transceiver host circuit is shown in Figure 2. The circuit consists of nRF24LU1+, 16 MHz crystal oscillator, and other components. The MCU in nRF24LU1+ is responsible for controlling its on-chip USB module and wireless module, and realizes the conversion from USB data stream to wireless data stream.
2.4 Wireless transceiver slave with USB interface
The connection circuit between the wireless transceiver slave and the external USB device is shown in Figure 3. The wireless transceiver is composed of Philips ARM7 processor LPC2103 and USB embedded host controller ISP1161, nRF24LU1+ and some peripheral devices. LPC2103 and ISP1161 constitute the USB host control unit (HCU). When ISP1161 is used as a host controller, there are two downstream ports, which are respectively connected to the USB port of nRF24LU1+ and external USB devices. nRF24LU1+ is responsible for the transmission of wireless data stream to USB data stream. HCU is responsible for the transmission of USB data from nRP24LU1+ and external LISB device data.
3 Software realization of USB wireless network system
3.1 USB module firmware programming of nRF24LU1+
The software development of USB devices includes the development of USB device drivers and interface applications on the PC side, as well as the development of chip firmware programs on the USB chip side. The chip firmware program refers to the program code running in the USB chip, which is responsible for the processing of the USB protocol and the data transmission between the USB device and the host. The development of chip firmware program is the key and difficult point.
3.1.1 Enumeration process of USB device
From the end user’s point of view, the USB system means that the peripherals are connected to the PC through a USB cable. USB provides communication services between peripherals and PCs. The peripherals are usually called “USB devices”, and the connected PCs are called “USB hosts”. USB uses bus enumeration operations to manage the connection and disconnection of USB devices. Take the connection of a USB device as an example to illustrate the enumeration process. Proceed as follows:
① The USB device is connected to the downstream port of the host or hub, and the USB device is powered on.
②Reset of USB device. The host should provide a reset recovery time of at least 10 ms. After the reset is complete, the USB device enters the default state, and the default device address can be used to respond to the control transaction of pipe 0.
③The host sends a Get Descriptor (Device) request to the USB device to obtain the maximum data packet length supported by its default control pipeline.
④ The host sends a SetAddress request to the USB device and assigns a unique device address to it.
⑤The host uses the new address to send a GetDescriptor (Configuration) request to the USB device and read all its configuration information. This process takes several ms.
⑥ The host selects a suitable device driver for it according to the configuration information of the device (such as supplier, product ID, etc.). Usually it needs to be written by the developer, and sometimes it is possible to use the generic driver provided by the device class or the supplier.
⑦After loading the USB device driver, the host sends a SetCon-figuration request to select a suitable configuration for the device. After the configuration is successful, the enumeration is over, and the USB device can transmit data with the host.
3.1.2 USB module firmware program design
The USB module of nRF24LU1+ is controlled by 2 SFR registers and XDATA register group. The USB firmware program is composed of two parts: the initialization program of the USB module and the interrupt service program.
(1) Initialization program of USB module
Turn off the USB interrupt, call the endpoint initialization function USB_endpoint_init (void) to set the transmission mode, buffer size, and interrupt event generation conditions of each USB endpoint, call the USB service function USB_setvice (void) to prepare for the call in the interrupt service routine; turn on the USB interrupt, Call the function USB_device_connect (void) to make the internal 1.5 kΩ pull-up resistor connected to the D+ line to realize the configuration of the full-speed USB device. In this way, you can respond to the host’s enumeration process.
(2) Interrupt service routine of USB module
The USB controller provides two interrupt signals to nRF24LU1+, which are the wake-up interrupt request USBWU signal and the USB interrupt request USBIRU signal. The USB interrupt request USBIRQ is an interrupt of nRF24Lu1+, and there are many interrupts under the USB interrupt request, including: 12 block endpoint interrupts, frame start interrupt (sofir), suspend interrupt (suspir), USB reset interrupt (uresir), establishment Token interruption (sutokir), establishment of data validity interruption (sudavir). If multiple USB interrupts occur at the same time, the USB controller will respond in order of priority. The activated interrupt is obtained in the interrupt vector register ivec. For example, when the sofir is interrupted, the content of the ivec register is 0x04. Part of the program code of USB interrupt request USBIRQ is as follows:
3.2 Wireless module programming of nRF24LU1+
nRF24LU1+ uses an embedded protocol engine (EnhancedShockBurst) 2.4 GHz GFSK RF transceiver. EnhancedShockBurst has the feature of automatic packet processing, which makes it easy to achieve a reliable two-way data link. The transmission of data packets is carried out between two transceivers, one of which serves as the primary receiver (PRX) and the other serves as the primary transmitter (PTX). The transmission of each data packet starts with the PTX sending the data packet, and ends with the PTX receiving the PRX response packet. During automatic packet transmission processing, nRF24LU1+ provides a hardware mechanism for automatic response and retransmission of data. The maximum number of retransmissions of data packets and the delay between the first transmission and the next retransmission are programmable.
The work flow of nRF24LU1+ transmitter in the case of Enhanced ShockBurst is shown in Figure 4.
The transmitter enters the PTX mode by setting the rfce bit of the RECON register high. If there is a data packet in the TX FIFO buffer area, the wireless transceiver enters the TX mode and sends the data packet. If automatic retransmission is enabled, the state machine checks whether the NO_ACK flag is set. If set, the RF transceiver enters the RX mode and is ready to receive response packets. If the received response packet is empty, only the TX_DS (transmission data sending) interrupt request occurs. If the response packet contains payload data, the TX_DS and RX_DR (receive data preparation) interrupt requests occur simultaneously before the transceiver returns to standby-I mode. If the delay time is up and the transceiver has not received the response packet, the transceiver returns to standby-II mode. Before the automatic retransmission time expires, it has been kept in standby-II mode. If the number of retransmissions does not reach the set value, the RF transceiver enters the TX mode and retransmits the last data packet again; otherwise, the maximum retransmission MAX_RT interrupt request occurs and returns to the standby-I mode. If the rfce bit of the RECON register is high and the TX FIFO (first-in, first-out data buffer) is empty, the RF transceiver enters standby-I mode.
Since the wireless transceiver module of nRF24LU1+ has a powerful hardware transceiver mechanism for data, it is relatively simple to write a program. You only need to set the relevant registers in the initialization program to enter the data transceiver. When sending data, after putting the data to be sent into the sending FIFO, the transceiver will send according to the setting, and the sending situation will be notified to the MCU through interrupts, and the MCU will execute the corresponding interrupt service routine according to the specific interrupt request. When receiving data, the transceiver will continuously search for a valid address. When a valid address is found, it will process the remaining data packets and verify the data packets with CRC. If this packet is valid, the payload data in the packet will be put into the RX FIFO.
The format of the data packet is as follows:
The wireless communication program is composed of two parts: the initialization program of the wireless communication module and the interrupt service program.
The initialization program sets the working mode, transmission rate, working band frequency of wireless communication, RF output power, address register, effective data length of data packet, CRC check length and RF interrupt register, etc. accordingly. The wireless communication module only occupies one interrupt source RFIRQ for nRF24LU1+. The specific interrupt can be obtained by querying the TX_DS, RX_DR, MAX_RT bits in the STATUS register. The interrupt service routine is divided into sending interrupt service routine, receiving interrupt service routine and maximum retransmission interrupt service routine.
Concluding remarks
This article proposes a wireless network system using the wireless transceiver chip nRF24LU1+. This network system makes full use of the advantages of USB and wireless transceiver modules to realize fast and convenient data transmission, and has the characteristics of high integration, small size, strong confidentiality, and low power consumption.
The Links: C123HAN011 LJ511AU27