Since RS-422 and RS-485 buses have the characteristics of strong anti-interference ability, high communication rate, long communication distance, and the ability to communicate with multiple slaves, they are widely used in master-slave multi-machine communication.
We have designed and developed an external serial port intelligent converter with AT90S2343 low-power single-chip microcomputer as the core, which converts RS232 serial port to RS-422 or RS-485 serial port. It does not require external power supply, and can automatically identify the communication baud rate (1200-115.2K) and communication mode (8-bit, 9-bit mode), intelligently control the connection between the receiving and sending circuits and the communication bus, and achieve plug-and-play without changing the existing software.
The converter has the characteristics of strong versatility, reliable performance, simple structure and easy use. It can be widely used in data acquisition, monitoring management and distributed control communication systems. In the insulation online monitoring system of electrical equipment, the author applies the converter to realize data communication of multiple data acquisition devices, and the communication performance is stable and reliable.
1. The overall structure of the circuit
The circuit diagram of the intelligent converter is shown in Figure 1. The entire circuit consists of four parts. The first part is the DC-DC power conversion circuit. It steals power from the signal line of the PC serial port and converts it into power for the intelligent converter ; the second part is the RS-232 interface circuit, which realizes the conversion between the RS-232 level and the TTL level of each signal; the third part is the RS485/RS422 interface circuit, which realizes the conversion between the RS485/RS422 level and the TTL level of the communication bus; the fourth part is the intelligent control circuit with the CPU as the core, which monitors the TXD sending signal of the PC, identifies the communication baud rate, communication mode (10/11 bit mode), and intelligently controls the sending and receiving of communication data.
When the converter is used as RS485 half-duplex communication mode, the in-phase and inverting terminals of the transmitter output and the receiver input must be short-circuited with two jumpers. 2 Circuit Working Principle
2.1 DC-DC power conversion circuit
Since the RS232 interface does not provide power, the power supply for the entire circuit can only be obtained from the RS-232 signal line. The RS-232 interface has three output signals: DTR, RTS, and TXD. Each signal can provide a typical output current of ±8mA. General software does not use the handshake signals RTS and DTR, and they are output as -12V. The TXD signal is also output as -12V when it is not sending data or sending data "1". In order to increase the output power of the power conversion circuit, the -12V output of the three signals DTR, RTS, and TXD is used as the power input of the power conversion circuit in the circuit.
Since there is no DC-DC converter that converts negative voltage input to stable positive voltage output , the author has developed a DC-DC conversion circuit with an input voltage of -12V and a +5V regulated output using the IC chip MAX761 based on the general DC-DC conversion circuit, with a conversion efficiency of >85%. The specific circuit is shown in Figure 2. In the circuit, MAX761 is a PFM (pulse frequency modulation) DC-DC conversion controller. The highest modulation frequency is 300KHZ. LX is the drain output terminal of the power driver tube (field effect tube); REF is the reference voltage output terminal; LB is the voltage sampling input terminal. The MAX761 controller and inductor L form a bootstrap boost circuit, and the output voltage sampling network consists of a voltage regulator tube W1, a transistor T, and resistors R1 and R2. The sampling voltage is input to the controller through LB, and the output voltage is stabilized by changing the frequency of the modulation pulse. The voltage regulation working principle of the circuit is as follows:
When the output voltage VOUT decreases, the base current IEB of the transistor T1 decreases, and the sampling voltage UR1 (βIEB×R1×) at the LB end decreases. When the sampling voltage (UR1) of LB is less than the internal reference voltage, the control signal controls the opening and closing of the power driver tube with the highest modulation frequency. When the power driver tube is turned on, LX is equal to -12V, the diode D4 is in the off state, and the current flows to LX through the inductor L. At this time, the inductor L stores energy. When the power driver tube is turned off, the inductor L releases energy, and the current generated by the back electromotive force charges the capacitor C4 through the diode D4, thereby increasing the output voltage VOUT.
When the output voltage VOUT increases, the base current IEB of the transistor T1 increases, and the sampling voltage UR1 (βIEB×R1×) at the LB end increases. When the sampling voltage (UR1) of LB ≥ the on-chip reference voltage, the control signal controls the power driver tube to be in the cut-off state within a complete modulation cycle, and the output voltage VOUT decreases due to load consumption.
Through the above pulse frequency modulation method of bootstrap boost regulation, the output voltage is stabilized at +5V.
The output voltage is determined by:
VOUT=Vw1+Veb+Ib×R2≈Vw1+Veb ≈ 5V
2.2 Working Principle of Single Chip Microcomputer Intelligent Control
The RS485 communication mode is a half-duplex communication mode that uses the same pair of differential communication buses to control the time-sharing reception and transmission of data through the software through the receiving and transmitting enable signals, and realizes two-way data communication. The RS232 communication interface cannot provide such an enable control signal. However, the single-chip microcomputer can monitor the host PC-TXD signal, accurately calculate the time to transmit a frame of data, and intelligently generate the receiving and transmitting enable signals to control the time-sharing reception and transmission of data, thus realizing half-duplex communication of data. The specific circuit of the serial port intelligent converter with the AT90S2343 low-power single-chip microcomputer as the core is shown in Figure 3.
The method for the microcontroller to identify the time to transmit a frame of data is as follows: When the microcontroller detects the start bit of the data sent by the host, it starts to measure the pulse width of each pulse of the PC-TXD signal and calculates the corresponding baud rate. If they all belong to the universal baud rate set, the highest baud rate among them is the communication baud rate. Otherwise, the pulse width is the interval time between sending two frames of data, and the moment of negative level transition is the beginning moment of the start bit, and the pulse width of each pulse is measured again. When the communication baud rate is determined, the level state of the tenth bit is detected. If it is a low level, it can be determined that it is an 11-bit communication mode. Otherwise, it is a 10-bit communication mode. The time to transmit a frame of data is calculated based on the communication baud rate and communication mode.
The intelligent control process of receiving and sending data by the communication interface is as follows: Whenever the start bit of the data sent by the host is detected, the single-chip microcomputer outputs the receive and send enable signal (RE=1, DE=1), controls the receive and send circuits to prohibit receiving and allow sending data, and the host data is sent to the RS485 communication bus, and the timer starts timing. When the timing time is equal to the time to send a frame of data, the single-chip microcomputer outputs the receive and send enable signal (RE=0, DE=0), controls the receive and send circuits to allow receiving and prohibit sending data. At this time, the host can receive the slave data on the RS485 communication bus. When the single-chip microcomputer detects the start bit of the data sent by the host again, the above sending process is repeated.
During the communication process, baud rate measurement and intelligent control of sending and receiving data must be performed synchronously, otherwise communication data will be lost.
To meet the requirements of high-speed communication, the circuit uses the AT90SL2343 single-chip microcomputer from Atmel, USA. It is one of the latest single-chip microcomputer series, and its outstanding features are high execution speed and rich hardware resources on the chip. The use of power supply monitoring and programmable watchdog timer inside the CPU makes the circuit have strong anti-interference ability.
The allocation and function of the microcontroller I/O port: PB3 input, monitoring the host PC-TXD signal; PB0 output, receiving enable signal; PB4 output, sending enable signal; PB2 input, K1 sets the duplex or half-duplex communication mode. 3 Software Design
3.1 Program flow chart
The program flow chart of the serial port intelligent expansion card is shown in Figure 4.
3.2 Software Design for Half-Duplex Communication
In the RS485 half-duplex communication mode, data reception is first allowed and data transmission is prohibited. After the data start bit of the PC-TXD signal is detected, the communication interface prohibits receiving and allows data transmission, and starts timing. By detecting the width of each pulse of the data signal, its baud rate and the number of data transmission bits are determined, and then the time allowed for each frame of data to be sent is calculated. When the timing time is greater than or equal to this time, the communication interface prohibits sending and allows receiving data. In the receiving state, the CPU repeatedly detects the start bit of the transmitted data. When the start bit of the transmitted data is detected, the above data transmission control process is repeated.
3.3 Duplex Communication Software Design
In RS422 duplex communication mode, the receive and send enable signals are always valid, allowing data to be received and sent at the same time.
4 Conclusion
The circuit structure is simple and does not require external power supply. It can be made into a serial port converter and directly plugged into the serial port socket. It has the characteristics of strong versatility, reliable performance, simple structure and easy use. The circuit uses power supply monitoring and programmable watchdog monitoring timer to make the converter have strong anti-interference ability. The converter can be widely used in master-slave multi-machine communication systems.
Previous article:My opinion on the design of VCC winding of low-power flyback power supply
Next article:Design of AT89S52 MCU and SD card reading and writing of FAT16 files
- Popular Resources
- Popular amplifiers
- MathWorks and NXP Collaborate to Launch Model-Based Design Toolbox for Battery Management Systems
- STMicroelectronics' advanced galvanically isolated gate driver STGAP3S provides flexible protection for IGBTs and SiC MOSFETs
- New diaphragm-free solid-state lithium battery technology is launched: the distance between the positive and negative electrodes is less than 0.000001 meters
- [“Source” Observe the Autumn Series] Application and testing of the next generation of semiconductor gallium oxide device photodetectors
- 采用自主设计封装,绝缘电阻显著提高!ROHM开发出更高电压xEV系统的SiC肖特基势垒二极管
- Will GaN replace SiC? PI's disruptive 1700V InnoMux2 is here to demonstrate
- From Isolation to the Third and a Half Generation: Understanding Naxinwei's Gate Driver IC in One Article
- The appeal of 48 V technology: importance, benefits and key factors in system-level applications
- Important breakthrough in recycling of used lithium-ion batteries
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
- Let’s talk about the “Three Musketeers” of radar in autonomous driving
- Why software-defined vehicles transform cars from tools into living spaces
- How Lucid is overtaking Tesla with smaller motors
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Three simple steps to operate the msp430 serial port interrupt
- 【Ufan Learning】How small is the Ufan learning board? ?
- [MicroPython] STM32 branch fixes a CDC problem when USB is reconnected
- Comment to win a gift | TI SK-AM64 evaluation kit review
- I want to borrow a mm32f103 board
- Low power clock based on MSP430F413 fruit battery
- UART transmission
- Goodbye 2021, Hello 2022
- Clock module of MSP430G2553 microcontroller
- I need help from an expert to look at the program and tell me how to modify it so that the buzzer can sound three times and then pause for 0.5 seconds before sounding again.