1 Introduction
Short-distance wireless transmission has the advantages of strong anti-interference performance, high reliability, good security, less geographical restrictions, and flexible installation. It has broad application prospects in many fields. Low power consumption and miniaturization are the actual needs of users for current wireless communication products, especially portable products. Short-distance wireless communication has gradually attracted widespread attention. Common short-distance wireless communications include 802.11-based wireless LAN WLAN, Bluetooth (blueTooth), HomeRF and Europe's HiperLAN (high-performance wireless LAN), but their hardware design, interface mode, communication protocol and software stack are complex, requiring a special development system, high development cost, long cycle, and high final product cost. Therefore, these technologies have not been widely used in embedded systems. Ordinary RF products do not have these problems, and short-distance wireless data transmission technology is mature, simple in function, and easy to carry, which makes it widely used in embedded short-distance wireless products.
2 PTR2000 Pin Introduction and Design
2.1 PTR2000 device pin functions
PTR2000 is a wireless data transmission module based on nRF401 device, which adopts low transmission frequency and high sensitivity design. The device uses 433 MHz frequency band and is a true single-chip UHF wireless transceiver device. Its working mode includes the setting of working channel and sending, receiving and standby states, which are jointly determined by TXEN, CS and PWM three pins. Its working mode setting is shown in Table 1.
2.2 PrR2000 module design
The main circuits around the device are as follows:
(1) Connection circuit with single-chip microcomputer The RXD and TXD pins of the single-chip microcomputer AT89C52 are directly connected to the DO and DI pins of the PTR2000 module. The mode control pin of PTR2000 is connected to the control pin of the single-chip microcomputer.
(2) The connection circuit with the PC uses the MAX202 device to convert the RS-232 and TTL levels of the PTR2000 module and the computer serial port, connects the input and output signals of the PTR2000 and MAX202, and connects the converted signals to the computer serial port.
3 Hardware Design
In situations where wired transmission is not possible, it is a more reasonable solution to use a wireless data transmission module combined with a single-chip microcomputer for data transmission. PTR2000 uses a serial port for data transmission, and both the single-chip microcomputer and the PC have serial ports. Therefore, PTR2000 can be used as a wireless interface for data transmission between the single-chip microcomputer and the PC. Its hardware structure diagram is shown in Figure 1.
The acquisition system mainly uses the AT89C52 single-chip microcomputer as the control and processing core. It completes the data acquisition and processing as well as the wireless transmission of the control data. The AT89C52 single-chip microcomputer has a fast 8051 core, 8 KB Flash E2PROM, and 256 bytes of RAM. In order to realize wireless data transmission, the PTR2000 device, an unlimited transceiver integrated data transmission MODEM module, is used. The device integrates high-frequency reception, PLL synthesis, PSK modulation/demodulation, parameter amplification, power amplification, channel switching and other functions, which fully meets the hardware requirements of wireless data communication. In order to reduce costs, based on the minimum hardware design, C51 high-level C language programming is used, and the system functions are implemented as much as possible with software programs.
3.1 Design of clock circuit and reset circuit of single chip microcomputer
In the design of the microcontroller clock circuit, the crystal frequency is selected as 11.0592 MHz, the communication rate between the PC and the microcontroller is agreed to be 9600 b/s, and the corresponding capacitor is selected to connect to the clock pin of the microcontroller to form a clock loop. In the reset circuit design, the reset pin and the corresponding capacitor and resistor are used to form a reset circuit. The principle circuit of the interface between the microcontroller and PTR2000 is shown in Figure 2.
3.2 Design of the interface circuit between MCU and PTR2000
In Figure 2, the AT89C52 microcontroller mainly completes data acquisition and processing, sends data to the PTR2000 module, and receives data transmitted by the PC through the PTR2000. The PTR2000 module connected to the microcontroller mainly modulates the data to be transmitted by the microcontroller into a radio frequency signal, and then sends it to the PTR2000 module on the PC side. At the same time, it receives the radio frequency signal transmitted by the PTR2000 module on the PC side, and modulates it into a TTL signal that the microcontroller can recognize and sends it to the microcontroller. The RXD and TXD pins of the microcontroller are respectively connected to the DO and DI pins of the PTR2000 to realize serial data transmission; the TXEN, CS, and PWR three pins that determine the working mode of the PTR2000 module are respectively connected to P2.0~P2.2 of the I/O control port of the microcontroller. When PTR2000 is working, its working mode is controlled in real time by the running control program in the microcontroller.
3.3 Design of PC and PTR2000 interface circuit
The interface circuit design first needs to be level converted. The serial port of the PC supports the RS-232 standard, while the PTR2000 module supports the TTL level. The MAX232 device is selected for level conversion between the two. The interface circuit is shown in Figure 3. The PTR2000 module performs serial input and output, and the pins DI and DO are connected to the PC serial port through the level conversion device; the low power control pin PWR of PTR2000 is connected to the high level VCC, that is, PTR2000 is fixed to work in normal working state; the channel selection pin CS is connected to the low level GND, that is, the fixed communication channel 1 is used, and it is fixed to work at 433.92 MHz; the RTS signal of the PC serial port controls the TXEN pin to determine when the PTR2000 module is in the receiving and transmitting state. The transmission rate of the PC and the serial port is set to 9600 b/s, which is consistent with the microcontroller.
4 Software Design
The software design of the wireless communication system includes two parts: the microcontroller side and the PC side. The two parts of the software cooperate with each other to set the working status of their respective PTR2000 modules.
4.1 PTR2000 module programming
The MCU and PC software work together to set the state of PTR2000 (transmit or receive), select the fixed communication channel 1 (CS=0), and keep the PTR2000 module in normal working state (PWM=1). The wireless communication implementation process is as follows:
(1) Send Before sending data, the PTR2000 module should be placed in the transmit mode, that is, TXEN = 1. Then wait for at least 5 ms (the switching time from receiving to transmitting) before sending data. After the sending is completed, the module should be placed in the receive state, that is, TXEN = 0.
(2) For receiving, PTR2000 should be placed in receiving mode, that is, TXEN = 0. The MCU is in receiving mode most of the time when it is not sending. When the MCU is sending, the PC should be receiving; when the PC is sending, the MCU should be receiving.
4.2 Serial Wireless Communication Protocol Design
In wireless communication, due to the interference of the external environment, the bit error rate is usually high, so the design of the communication protocol is very important to ensure the reliability of communication. The design of the protocol is mainly the design of the frame structure. In this wireless communication system, there are command frames and data frames. The content of the data frame includes the start byte, data length byte, data byte, end byte and checksum byte, as shown in Table 2.
The start byte is defined as the "$" character, whose value is 0x24; the end byte is defined as the "*" character, whose value is 0x2A.
The frame is checked by using the checksum method, adding all bytes and then truncating the result to the required bit length. The sender calculates the checksum of the data to be sent and sends the checksum value after the data; at the receiving end, the received data is checked and calculated, and then compared with the received checksum byte to make a bit error judgment.
For the MCU, there are three main types of command frames: request to send command sent by PC to MCU, error/timeout resend command, and send completion command sent by MCU to PC. In the system design, the command frame adopts the format of data frame, and the data byte is fixed as one byte, and the data status is judged according to the defined byte.
4.3 Program Flow
The single chip microcomputer needs to set the wireless data transmission module PTR2000 to the receiving state at the beginning, identify the instructions transmitted by the PC through the wireless channel through the serial port interrupt, collect data according to the content of the received instructions and start sending. Before sending, the PTR2000 module needs to be set to the transmitting state and wait for 5 ms before sending. After sending, send the "sending end instruction" to the PC end and reset the PTR2000 module to the receiving state. Figure 4 is the system software design flow chart.
5 Conclusion
The design of the single-chip wireless communication system is based on the PTR2000 wireless data transmission solution, which can achieve short-distance communication of less than 300 m. The experiment verifies that the wireless data transmission system works well and the single-chip control is quite accurate. When applied, the system can be easily transplanted as a module to build a more complex wireless communication network. It can be applied to small wireless networks, wireless meter reading, community paging, industrial data acquisition systems, security and fire protection systems, etc., and has certain practical value.
Previous article:Design and analysis of fluorescence signal acquisition system
Next article:Design and implementation of reverse collision warning system based on single chip microcomputer
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- New breakthrough! Ultra-fast memory accelerates Intel Xeon 6-core processors
- New breakthrough! Ultra-fast memory accelerates Intel Xeon 6-core processors
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Building ESP32-C3 development environment based on window Visual Studio Code: ESP-IDF
- I don't know much about the commonly used domestic device manufacturers.
- GD32 setup reminder when downloading program in KEIL
- Cadence Allegro beginners must read
- [Atria Development Board AT32F421 Review] 1. Unboxing and lighting
- EEWORLD University ---- Introduction to CC2650MODAPluetooth? Low-energy RF module
- Thank you for having me + EE has brought me so much knowledge this year! + Thank you to my family for their support and love! + Thank you to my colleagues and friends for their generous help along the way!
- After the microcontroller is powered on, it runs a display program and encounters a very strange problem.
- A brief discussion on LTE technology and practical application solutions
- What is the drilling process in the Siliton ceramic substrate PCB?