1 Baud rate conversion circuit
The baud rate conversion circuit is shown in Figure 2. The circuit uses two single-chip microcomputers 89C51 as the core of the circuit, and uses the UART serial port of the single-chip microcomputer to communicate with related devices. The single-chip microcomputer u1_L. (connected to a device with a low baud rate) communicates with a device with a baud rate of 115.2 kbps, and the single-chip microcomputer U2_H (connected to a device with a high baud rate) communicates with a device with a baud rate of 172.8 kbps. U1_I and U2_H communicate in parallel port mode to speed up the data transfer rate between U1_I and U2_H. The communication between U1_L and U2_H can be carried out in the form of interrupt query or handshake query.
The circuit uses two 75176 interface driver chips to form an RS-422 communication interface. The communication interface composed of U3 and U4 is connected to the 115.2 kbps device, and the communication interface composed of U5 and U6 is connected to the 172.8 kbps device. The communication interface uses interrupt technology. The working principle of the baud rate converter is as follows: After U1_I. receives the data from the device from the serial port, it outputs the data from the PI port and notifies U2_H to fetch the data. After U2_H fetches the data, it sends the data to the device and notifies U1_I. that the data has been taken away, preparing for the next data output by U1_L. When U2_H receives data from the device from the serial port, it queries U1_I to see whether it is allowed to receive data. If so, U2_H outputs data from port P1 and notifies Ul_L to fetch data. After Ul_L gets the data, it sends the data to the device and notifies U2_H that the data has been taken away, preparing for the next data output by U2_H. If Ul_L does not allow data reception, U2_H will temporarily suspend sending data.
2 Application of baud rate converter
In application, baud rate converter can be divided into unidirectional transmission and bidirectional transmission according to the usage. Data transmission between two single-chip microcomputers can be carried out in interrupt mode. It can also be carried out in query mode. If the query mode is adopted, the bits of P2 port are used as query signals during programming to realize unidirectional or bidirectional transmission.
2.1 Unidirectional transmission
Unidirectional transmission means that the data flow of the communication port is only in one direction, that is, the data received from Ul_L is sent out from U2_H, or the data received from U2_H is sent out from Ul_L. It is relatively simple to program software in this way. Now, taking U1_L only receiving data from external devices and U2_H only sending data to external devices, the flowchart of data transmission between two single-chip microcomputers is shown in Figure 3. Among them, P2.2 of Ul_L is used as the query signal for transmitting new data to U2_H (P2.5 of U2_H), P2.2 = "0" means there is new data, P2.2 = "1" means there is no new data; P2.2 of U2_H is used as the query signal for receiving U1_L data (P2.5 of U1_L), P2.2 = "0" means that new data can be received, P2.2 = "1" means that new data cannot be received. If the interrupt method is used, the query signal of the two microcontrollers is simpler, as long as Ul_L queries U2_H whether it can receive data, U2_H does not need to query U1_L's query signal.
2.2 Bidirectional transmission
Bidirectional transmission means that the communication port can receive and send data at the same time. The data flow is bidirectional. Ul_L and U2_H both receive and send data. The software programming of this method is relatively complex, especially when the bidirectional data transmission adopts the query method. The query signal between the microcontrollers is even more complicated. Taking the bidirectional query method as an example, the flow chart of data transmission between the two microcontrollers is shown in Figure 4. The process of U2_H is the same as that of U1_L. Among them, the query signal when U1_L transmits data to U2_H is the same as the definition of unidirectional transmission. P2.3 of U2_H is used as the query signal for transmitting new data to U1_L (P2.4 of U1_L). P2.3 = "0" indicates that there is new data, and P2.3 = "1" indicates that there is no new data; P2.3 of Ul_L is used as the query signal for receiving U2_H data (P2.4 of U2_H). P2.3 = "0" indicates that new data can be received, and P2.3 = "1" indicates that new data cannot be received. If the interrupt method is adopted, the query signal can be reduced and the programming can be simplified.
2.3 Notes on application
If the handshake between two MCUs is interrupted, since U2_H sends data to the outside faster than U1_L receives external data, when U1_L transmits data to U2_H, there is no need to consider the state of U2_H. When U2_H transmits data to U1_L, since U2_H receives external data faster than U1_L sends data to the outside, U2_H must query the state of U1_L, that is, whether U1_L is in the state of receiving U2_H data. Otherwise, U2_H cannot transmit data to U1_L.
If used as an RS_485 communication interface, only a slight change is needed to the circuit in Figure 2, adding read and write control of the 75176 chip. At the same time, the MCU connected to the main communication device in the two MCUs is used as the host, and the two MCUs are coordinated to receive or send data through a bit of the P2 port.
It is worth noting that the baud rate converter will be subject to certain limitations in different applications. When using it, pay attention to the following points: ① When the baud rate is very high, consider whether the serial port of the microcontroller can be realized; ② When changing from a high baud rate to a low baud rate, consider whether the microcontroller with a low baud rate can send data without losing it; ③ When converting in both directions, consider the above situation, as well as the size of the program and the impact of execution time on bidirectional data transmission, calculate whether the two microcontrollers can achieve conversion without losing data, and leave a margin in time; ④ When querying, pay attention to the relationship between the handshake signals, and do not read the same data repeatedly, so that the data is repeated; ⑤ When the baud rate is different, the microcontroller can use different crystal oscillator frequencies.
2.4 Examples and Source Code
In actual use, if the situation shown in Figure 1 is encountered, a baud rate converter is required to convert the communication data with a baud rate of 172.8kbps into a baud rate of 115.2kbps, and then transmit it to the host computer. The actual circuit used is shown in Figure 2. In this example, in order to prevent data loss due to the local receiving data being faster than the sending data, 8 data areas are added to the program of the U2_H microcontroller as the receiving data storage buffer.
3 Conclusion
Through long-term communication experiments and practical applications, the designed baud rate converter solution is feasible, the communication is reliable, and there is no data loss. In some systems, due to the special communication baud rate, when there is a baud rate mismatch between devices, the baud rate converter can realize communication between devices with different baud rates. By changing the crystal frequency of the microcontroller, the conversion of various baud rates (within the range allowed by the microcontroller) can be satisfied.
Previous article:Design of automatic trumpet sound player based on 51 single chip microcomputer
Next article:Implementation of a substation control and protection 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
- 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
- With the 5G wave, it’s time to upgrade RF filters!
- May Day holiday---spring cleaning
- Using efficient MicroSiP power modules to miniaturize ultrasonic smart probes
- Come quickly: Buy multimeters and development boards for 11.11 yuan, a Double 11 feast for new element11 users~
- Recommended RF front-end chips for mobile phones in the 5G era
- The Linux Foundation expects revenue to reach $177 million this year
- What does PAD mean in a circuit schematic?
- September 23 nexperia live broadcast review: Nexperia's efficient ESD solutions for connected car applications
- These two methods make electric vehicles run farther in winter
- Voltage Follower