The general digital acquisition system converts the captured field signal into an electrical signal through a sensor, and after sampling, quantization and encoding by the analog/digital converter ADC, it becomes a digital signal, which is stored in a data storage device, or sent to a microprocessor, or sent to the receiving end for processing by wireless means. The wireless data transmission system is a set of equipment that uses wireless means to send the collected data from the measuring station to the main control station.
1 System composition
The system composition is shown in Figure 1 and Figure 2.
The system consists of two parts: the measuring station and the main control station. The measuring station mainly completes the collection and storage of field signals, receives remote control commands and sends data. The main work of the main control station is to send remote control commands, receive data information, perform data processing and data management, and randomly display and print.
2 Serial communication between AT89C51 and digital radio
Atmel's AT89C51 microcontroller is a low-power, high-performance 8-bit CMOS microcontroller with 4KB Flash ROM on-chip, an operating voltage range of 2.7 to 6V (actually uses +5V power supply), and an 8-bit data bus. It has a programmable full-duplex serial communication interface that can simultaneously transmit and receive serial data. It communicates with the outside world through the RXD pin (serial data receiving end) and the TXD pin (serial data transmitting end).
2.1 Communication Protocol and Baud Rate
The communication protocol between the digital radio and the microcontroller and terminal host is:
Communication interface - standard serial RS232 interface, 9-wire half-duplex mode;
Communication frame format: 1 start bit, 8 data bits, 1 programmable data bit, 1 stop bit;
Baud rate – 1200 baud.
The digital radio uses Motorola's GM series car radio, which works in the VHF/UHF frequency band. It can perform wireless data transmission (9-wire standard serial RS232 interface) and voice communication. It adopts binary frequency shift keying (2FSK) modulation and demodulation, which complies with the CCITT.23 standard of the International Telegraph and Telephone Consultative Committee. When performing digital transmission in the voice band, it is recommended to use a data rate of no more than 1200b/s. In actual use, the radio works in the frequency range of 220~240MHz, and the half-duplex mode (performing receiving and transmitting operations, but not at the same time) can meet the system requirements.
2.2 AT89C51 serial port working mode
The AT89C51 serial port can be set to four working modes, with 8-bit, 10-bit and 11-bit frame formats. In this system, the AT89C51 serial port works in mode 3, that is, an asynchronous communication format with 11 bits of frame: 1 start bit, 8 data bits (low bit first), 1 programmable data bit, and 1 stop bit.
Before sending, the software sets the 9th data bit (TB8) as the parity bit, writes the data to be sent into SBUF, and starts the sending process. The serial port can automatically take out TB8, load it into the position of the 9th data bit, and then send it out one by one. After sending, TI=1.
When receiving, set REN in SCON to 1 to allow reception. When a transition from "1" to "0" (start bit) is detected at the RXD (P3.0 end), start receiving 9 bits of data and send them to the shift register (9 bits). When RI=0 and SM2=0 or the received 9 bits of data are 1, the first 8 bits of data are sent to SBUF, the 9th bit of data is sent to RB8 in SCON, and RI is set to 1; otherwise, this reception is invalid and RI is not set.
Mode 3 baud rate = T1 overflow rate / n
When SMOD = 0, n = 32; when SMOD = 1, n = 16. The overflow rate of T1 depends on the counting rate of T1 (counting rate = fosc/12) and the initial value preset by TI.
Timer T1 is used as a baud rate generator and works in mode 2 (automatically reload the initial value). Assume that the initial value of TH1 and TL1 is X, then T1 will overflow once every "2 8-X" machine cycles. The initial value X is determined as follows:
X = 256-fosc × (SMOD + 1) / 384 × BTL
In this system, SMOD=0, wave rate BTL=1200, crystal oscillator fosc=6MHz, so the initial value X=F3H.
2.3 Hardware connection between AT89C51 and digital radio
The hardware connection between AT89C51 and digital radio is shown in Figure 3.
The system uses asynchronous serial communication to transmit measurement data. The microcontroller serial port is connected to the digital radio RS232 data port. The radio is in the receiving state (PPT=0, receiving state; PPT=1, sending state), and the microcontroller P3.5 pin outputs a high level. The microcontroller uses TTL level, and the radio uses RS232 level. MAX232 completes the conversion between TTL level and RS232 level. Three optocouplers 6N137 are used to isolate the power supply between the microcontroller and the radio, enhancing the anti-interference performance of the system.
The single-chip microcomputer controls the radio's transceiver conversion, command reception and data transmission through the three-state buffer gate 74HC125 with control terminal and the NOT gate 74HC14. When receiving, P3.5=1, c2=1, 74HC125B is cut off; P3.5 is inverted and photoelectrically isolated by 74HC14, making the radio's PPT pin low level and setting it to the receiving state; at the same time, c1=0, 74HC125A is turned on, and the received command is input from the radio's RXD terminal, and sent to the single-chip microcomputer RXD pin after MAX232 level conversion, photoelectric isolation, and 74HC125A buffer gate. When transmitting, P3.5=0, and the radio's PPT pin is at a high level after being inverted and optically isolated by 74HC14, setting it to the transmitting state; at the same time, c1=1, 74HC125A is cut off, c2=0, 74HC125B is turned on, and the data is output from the TXD pin of the microcontroller, and is sent out through the TXD port of the radio after being buffered by 74HC125B, optically isolated, and converted by MAX232.
3 Communication Software Design
Communication software is crucial. Once a problem occurs, the entire system will be paralyzed. It is very important to adopt error control and fault tolerance technology.
*The command sent by the master station contains a certain number of synchronization symbols 55H and a 3-byte password. The measuring station verifies the password after receiving 5 synchronization symbols in succession. After the verification is passed, the command byte is officially received; if it fails, the measuring station sends a signal to the master station to resend. If the verification fails three times, the command will be stopped. When the measuring station sends/the master station receives, the verification method is the same. After the verification is passed, the measuring station starts to send data.
*A command consists of 3 bytes, the second byte is equal to the first byte plus 35H, and the third byte is equal to the second byte plus 36H. If the received command does not meet this rule, the command will be resent, and the command will be stopped after three consecutive errors.
* Every time the master station sends a command, the measuring station sends back a response signal, which contains the original command sample.
The basic communication procedure between the microcontroller serial port and the radio is given below.
Initialization procedure:
BTL EQU 2FH; the baud rate is placed in the 2FH unit of the internal RAM
MOV TMOD, #21H; T0 mode 1, 16-bit counter, T1 mode 2, for serial port
SETB TR0 ; Start T0
MOV BTL, #0F3H; baud rate is set to 1200
MOV SCON, #0C0H; serial port mode 3, 9-bit data, reception disabled
Receiving and Verification Procedures:
NUM EQU 2BH; The synchronization symbol value is stored in the 2BH unit of the internal RAM
TEMP EQU 2CH
ROM-CH: DB 55H, 55H, 55H, 55H, 55H, 55H, 55H, 55H, 55H, 55H
DB 55H, 55H, 55H, 55H, 55H, 55H, 55H, 55H, 55H, 20-byte synchronization character
MIM DB 'WSC': 3-byte password "WSC"
SETB P3.5; Set the radio receiving status
SETB REN ; Allow serial port to receive
A1: MOV NUM, #0; record the number of consecutive synchronization characters 55H
A2: JB RI, A2; serial port has data to A3
A3: CLR RI; clear the receive interrupt flag
MOV A, SBUF; read serial port data
CJNE A, #55H, A1; not a synchronous symbol, transfer to A1
INC NUM; the number of synchronization symbols received plus 1
MOV A, NUM; Get the number of synchronization characters received
CJNE A, #5, A2; if you do not receive 5 consecutive 55H, you can switch to A2
A4:MOV NUM,#0; Password verification, record the number of password bytes received
A5: MOV DPTR, #MIM; password character first address
MOV A, NUM
MOVC A, @A+DPTR; look up the table to get the password
MOV TEMP, A ; save password
JB RI, A6; after receiving a byte, the serial port transfers to A6
…
A6: CLR RI; clear the receive interrupt flag
MOV A, SBUF; read serial port data
CJNE A, TEMP, A4; if the password does not match, transfer to A4
INC NUM; the number of passwords received plus 1
MOV A, NUM; Get the number of password bytes received
CJNE A, #3, A5; if the password is not received, transfer to A5
Sending procedure:
CLR P3.5; Set the radio transmission status
MOV B, #23
MOV DPTR, #ROM-CH
B1:CLR A
MOVC A, @A+DPTR; look up the table to send the synchronization symbol and password, a total of 24 bytes
INC DPTR
LCALL SEND-CH ; call the send single byte subroutine
DJNZ B, B1
…
CLR A
MOV DPTR, #7000H; external RAM data first address, send data in external RAM to the radio
B2: CJNE R4, #0, B3
CJNE R3, #0, B3; R4R3 = number of bytes sent
B3: MOVX A, @DPTR; get data
INC DPTR
LCALL SEND-CH
CJNE R3, #0, B4
CJNE R4, #0, B5
B4:DEC R3
LJMP B2
DEC R3
DEC R4
LJMP B2
…
SEND-CH: SETB TB8
MOV SBUF, A
DB 0, 0, 0, 0, 0, 0, 0, 0
JNB TI, $; delay 4 μs
CLR TI
RET
Conclusion
After the wireless data transmission system was built, it has been used for more than two years. The operation results show that the system works stably and reliably. The use of relatively complete software and hardware design and anti-interference measures ensures the safety and reliability of the system. The measurement station transmits the collected field signals to the main control station in a timely manner, which improves the real-time performance of data processing. The software and hardware design of the single-chip microcomputer and digital radio interface has strong applicability and can be widely used in wireless data transmission equipment.
Previous article:Communication software design of 51 compatible carrier communication microcontroller PL3105
Next article:Interface Design between 51 Single Chip Microcomputer and Serial AD Converter TLC0834
Recommended ReadingLatest update time:2024-11-16 21:28
- Popular Resources
- Popular amplifiers
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Siemens Motion Control Technology and Engineering Applications (Tongxue, edited by Wu Xiaojun)
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
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
- 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!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- The serial port is always garbled when burning
- What do the MSP430 MCU POR and PUC mean?
- TI-C2000-Capture Module ECAP Application-Taking Omron E6B2-CWZ6C Speed Encoder as an Example
- 【Development Kit for nRF52840】+ Review 2: Pathfinder
- ZIGBEE power management POWER_SAVING related functions
- PCB wiring
- Children's Toy "Black Box"-- BabyCareAssistant
- Crazy Shell AI open source drone SPI (six-axis sensor data acquisition)
- TE's latest trend report | "How does temperature monitoring affect the generator market"
- 【NXP Rapid IoT Review】+7. Understand what each icon means