Realization of short distance wireless communication based on 51 single chip microcomputer

Publisher:芳华逝水Latest update time:2011-10-14 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

Working mode settings

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.

Hardware Block Diagram

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.

Principle circuit of interface between single chip microcomputer and PTR2000

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.

Interface Circuit

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.

Contents of the data frame

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.

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.


Reference address:Realization of short distance wireless communication based on 51 single chip microcomputer

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

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

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号