Analysis of factors affecting the effect of wireless communication in intelligent wireless meter reading and design of wireless communication protocol
nRF401 single chip wireless transceiver chip has few peripheral components and can be directly connected to the serial port of single chip microcomputer, which provides a better solution for the design of short-range wireless data transmission applications such as intelligent wireless meter reading, and is widely used in many fields. However, due to the particularity of wireless communication, some external factors will affect the wireless transmission of data, so effective methods need to be adopted to ensure communication. In order to effectively apply wireless communication, this paper establishes a communication channel model of wireless data transmission, understands and discusses the influence of external factors on wireless data transmission, analyzes the causes and links of errors and how to effectively transmit data, and finally provides a practical wireless communication protocol
1 communication channel model and its analysis
in order to analyze the factors affecting wireless communication, we have established a wireless communication channel model. Communication channel refers to a complete channel from transmission to reception of data. It includes generating data source, encoding, transmitting, receiving, decoding, etc., as shown in Figure 1
1.1 data source
data source refers to the source of data generation. In different applications, the source of data is different. It may be the A/D data value of a temperature sensor, a file in the computer, or a key in the keyboard with output results. There is less possibility of data error here, and it is easier to find it through hardware or software
1.2 data coding
data coding mainly includes parallel to serial and additional coding information for reliable transmission. NRF401 requires serial data format, which is usually completed by single-chip UART (universal asynchronous transmission), and sometimes through software I/O simulation. The data is unlikely to be wrong here, and it can be tracked and found
1.3 data transmission
data transmission is completed through the transmission function of a single wireless transceiver chip nRF401. NRF401 adopts PLL frequency synthesis and FSK modulation technology, and its design is reliable. However, external factors such as improper power supply, poor PCB design and layout, noise, improper modulation voltage level, and improper antenna load can cause data flow errors. The key points to be solved need to be based on good RF PCB design, select peripheral components that meet the requirements, and pay attention to power supply (good power filtering, try not to use switching power supply). By comprehensively adopting the above measures, we can reduce the factors that cause errors in data flow and obtain more reasonable results
1.4 propagation path
propagation path is the path from transmission to reception of radio waves. Propagation loss will directly affect the effect of communication, and data errors are most likely to occur at this stage. Because the interference in the frequency band or the loss of RF signal in the propagation path reduces the sensitivity, and multipath and attenuation may also cause the receiver to receive wrong data. Propagation loss includes free space loss and other losses. Other main losses include: atmospheric, rainfall, cloud and fog losses; Loss of tree shelter; Loss of shelter such as buildings; In addition, sudden interference will also lead to "Li Jianbo said, causing data errors. Next, take free space loss as an example to predict propagation
the so-called free space propagation refers to the radio wave propagation when there is an infinite vacuum around the antenna. It is an ideal propagation condition. The propagation loss in free space is related to distance and working frequency. The following formula explains the loss of radio wave propagation in free space:
[Los] (DB) = 32.44 + 20lgd + 20lgf
, where LOS is the propagation loss, and the unit is db; D is the distance, in KM; F is the operating frequency, in MHz
it can be seen from the above formula that the radio wave propagation loss (also known as attenuation) in free space is only related to the working frequency f and the propagation distance D. when f or D is doubled, Los will increase by 6dB respectively
the following is an example to illustrate the propagation distance in free space of a wireless system (based on nRF401) with an operating frequency of 433.92mhz, a transmitting power of + 10dBm (10MW) and a receiving sensitivity of - 105dbm:
(1) by transmitting power of + 10dBm and a receiving sensitivity of - 105dbm, Los = 115dB
(2) calculated by LOS and F, d = 9.7 km
this is the transmission distance under ideal conditions, which will be lower than this value in practical application, because wireless communication is affected by various external factors, such as the loss caused by atmosphere, obstacles, multipath, etc. the approximate communication distance can be calculated by adding the reference value of the above loss into the above formula. Assuming that the loss caused by atmosphere and shielding is 25dB, the communication distance can be calculated as: D = 1.7 km. It can also be seen that the propagation loss has a great impact on the reliability of data transmission
1.5 data receiving
the receiving process is completed by the receiving function of a single wireless transceiver chip nRF401. When no signal is received, nRF401 will have random data output because of its high sensitivity. When the transmitter transmits, the random data output of the receiver is suppressed, and then the real data is output. In band interference and frequency drop may cause the receiver to receive incorrect data. As with data transmission, reasonable PCB design and layout, good power supply, etc. will produce better results
1.6 data decoding
the data output from nRF401 is serial data, which can usually be processed by UART of microcontroller or received by software method. The possibility of data errors in this process is very small, and it is easy to be tracked. If the error occurs before this, it can be found by software according to the frame error
1.7 data interpretation
data interpretation is usually realized in software, and error detection and correction are also realized at this stage. Data errors are unlikely to occur at this stage, and it is easy to track
2 basic requirements and design of wireless communication protocol
after analyzing the wireless communication channel model, understanding and discussing the influence of external factors on wireless data transmission, we can design a practical wireless communication protocol based on this
2.1 identification of start code and noise
this is because nRF401 has high sensitivity. Due to the characteristics of nRF401, nRF401 will have random data output when no signal is received, so the first thing of the protocol is to be able to identify noise and valid data. Noise occurs as random bytes, and there is no obvious way. An ideal noise source should be able to produce every possible combination of byte information. This characteristic of noise makes it quite difficult to find a byte combination as the beginning of an effective packet, but in fact, noise is not ideal. After testing and testing, we found that 0xff followed by 0x00 is not easy to occur in noise, and the transmission protocol should add the start byte 0xff followed by 0 in front of the packet
the start of the transmission protocol should be a byte of any content, such as 0XAA (because the data of the first byte is easy to be lost during transmission), followed by 0xff followed by 0x00; The receiving protocol stipulates that only packets starting with 0xff followed by a 00x00 are received
2.2 error detection
in order to find possible errors in data transmission, it is necessary to detect errors in the received data. Error detection can be achieved by analyzing the data before transmission, and then adding the analysis result to the data packet, which is called supervision bit; Compare the supervision bits attached to the information bits at the receiving end. If the two are different, the packet is wrong. According to the inspection practice in recent years, there are many methods of error detection, such as parity check, sum check and CRC check
parity check and sum check are commonly used and easy to implement methods. The following examples illustrate the parity check method
example 1: transmit data 10101010, and add parity flag bit after it. This is even flag (1), then send it as 10101001 and receive it as 00101001. Comparing the first 8 bits of parity with 1, it is wrong, so the reception is wrong. Parity check is easy to implement, but it is the most unreliable, because it can only find an odd number of errors. 490.3
another form of error checking is sum checking. Sum check is to add all data bytes first, then truncate the result to the required bit length and transmit it as a check sub. The following is illustrated by example 2
example 2:
4 bytes 1
109 bytes 2
65 bytes 3
204 bytes 4
126 8 bit checksum
checksum can detect more errors than parity, but when the byte order is reversed, the checksum cannot be found, because it cannot find the order error. If higher reliability is required, CRC Coding and ccitt16 error detection coding can be used. Theoretically, burst or random errors below 16 bits can be completely detected. Refer to relevant materials for specific principles and implementation methods
2.3 error correction
the purpose of error correction is to add some additional information when sending data coding to detect and correct errors in data transmission. Forward error correction methods include Hamming code, cyclic code and convolutional code
although some complex algorithms have good error correction and detection effects, for many people who are first exposed to the design of wireless communication protocols, they may need a lot of energy to understand the relevant mathematical knowledge. Therefore, here is an algorithm to correct and detect errors by using repeated codes. It is suitable for simple and practical communication protocols, and the programming is also easy to implement. It has been applied in the wireless data transmission system designed by nRF401. The following is a forward error correction method suitable for many wireless data transmissions. The data is copied twice in the package (a total of 3 copies). At the receiving end, the first copy is checked for errors. If there are errors, the remaining two backups are used to correct the errors
the error is corrected by comparing each of the three backup data. If two or more bits are 0, the correct one should be 0. For example:
0 000 01 01 COPY 1 (error bytes)
1 01 01 01 0 copy 2
1 01 01 0 copy 3
1 01 01 01 0 bytes that have been corrected
in practical application, triple decision or quintuple decision can be selected according to needs
3 basic requirements of wireless communication protocol design
according to the analysis of the wireless channel model, we can understand that the wireless communication protocol has the following basic requirements:
minimum overhead: in the process of wireless transmission, affected by noise or interference, there will be error codes. Therefore, various error correcting codes should be carried out on the data during transmission. Different coding methods have different error correction and detection capabilities. Some codes can only detect errors but not correct them. Generally speaking, the larger the proportion of supervision bit symbols, the stronger the error correction and detection capability. Error correction coding improves the reliability of transmission at the cost of reducing the information transmission rate. Therefore, increasing the number of information must be the least of the required information to ensure the efficiency of coding
reliability: a wireless communication protocol should be able to effectively detect and correct data errors
optimized wireless function: a wireless communication protocol should enable the device to work in an optimized way that can make full use of the characteristics of the transmitter and receiver
LINK
Copyright © 2011 JIN SHI