Search

CN-121979823-A - Serial port conversion device and conversion method based on RS 232-RS 485

CN121979823ACN 121979823 ACN121979823 ACN 121979823ACN-121979823-A

Abstract

The invention belongs to the technical field of telecommunication, and particularly relates to a serial port conversion device and a conversion method based on RS 232-RS 485, wherein the serial port conversion device comprises an RS232 serial port, an RS485 serial port, a first conversion circuit, a second conversion circuit and a third conversion circuit; when the TX transmitting end outputs a negative voltage signal or a positive voltage signal, the A end and the B end respectively acquire a +5V voltage signal, a 0V voltage signal or a 0V voltage signal and a +5V voltage signal through the first conversion circuit and the second conversion circuit, when the A end voltage of the RS485 serial port is larger than or smaller than the B end voltage, the RX receiving end acquires a-5V voltage signal or a +5V voltage signal through the third conversion circuit, the RS232 serial port signal can be converted into the RS485 serial port signal, the hardware cost is low, the conversion can be completed again by retransmitting the command after logic confusion, the power on and power off are not needed, and the stability of signal conversion is improved.

Inventors

  • YU GUANGYOU
  • SHI ZHE

Assignees

  • 苏州冠德能源科技有限公司

Dates

Publication Date
20260505
Application Date
20260128

Claims (10)

  1. 1. A serial port conversion device, characterized by comprising: an RS232 serial port, an RS485 serial port, a first conversion circuit, a second conversion circuit and a third conversion circuit, wherein The TX transmitting end of the RS232 serial port and the A end of the RS485 serial port are respectively and electrically connected with the first conversion circuit; the TX transmitting end of the RS232 serial port and the B end of the RS485 serial port are respectively and electrically connected with the second conversion circuit; The TX transmitting end of the RS232 serial port, the RX receiving end of the RS232 serial port, the A end of the RS485 serial port and the B end of the RS485 serial port are respectively and electrically connected with the third conversion circuit; when the TX transmitting end of the RS232 serial port outputs a negative voltage signal, the A end and the B end of the RS485 serial port respectively acquire a +5V voltage signal and a 0V voltage signal through a first conversion circuit and a second conversion circuit, and the third conversion circuit isolates the RX receiving end of the RS232 serial port from the TX transmitting end of the RS232 serial port, namely the RS232 serial port outputs logic 1 and the RS485 serial port receives logic 1; When the TX transmitting end of the RS232 serial port outputs a positive voltage signal, the A end and the B end of the RS485 serial port respectively acquire a 0V voltage signal and a +5V voltage signal through a first conversion circuit and a second conversion circuit, and the third conversion circuit isolates the RX receiving end of the RS232 serial port from the TX transmitting end of the RS232 serial port, the A end of the RS485 serial port and the B end of the RS485 serial port, namely, the RS232 serial port outputs logic 0 and the RS485 serial port receives logic 0; When the voltage of the A end of the RS485 serial port is larger than the voltage of the B end, the third conversion circuit isolates the TX transmitting end of the RS232 serial port from the RX receiving end of the RS232 serial port, the A end of the RS485 serial port and the B end of the RS485 serial port, and the RX receiving end of the RS232 serial port obtains-5V voltage signals through the third conversion circuit, namely, the RS485 serial port outputs logic 1 and the RS232 serial port receives logic 1; When the voltage of the A end of the RS485 serial port is smaller than the voltage of the B end, the third conversion circuit isolates the TX transmitting end of the RS232 serial port from the RX receiving end of the RS232 serial port, the A end of the RS485 serial port and the B end of the RS485 serial port, and the RX receiving end of the RS232 serial port obtains +5V voltage signals through the third conversion circuit, namely, the RS485 serial port outputs logic 0 and the RS232 serial port receives logic 0.
  2. 2. The serial port conversion device of claim 1, wherein, The first conversion circuit comprises a first MOS tube (Q1), a first resistor (R1) and a second resistor (R2); one end of the first resistor (R1) is electrically connected with a TX transmitting end of the RS232 serial port, the other end of the first resistor (R1) is electrically connected with a grid electrode of the first MOS tube (Q1) and one end of the second resistor (R2), a source electrode of the first MOS tube (Q1) is electrically connected with the other end of the second resistor (R2) and grounded, a drain electrode of the first MOS tube (Q1) is electrically connected with one end of the third resistor (R3) and an A end of the RS485 serial port, and the other end of the second resistor (R2) is connected with a +5V reference voltage source; When the TX transmitting end of the RS232 serial port outputs a negative voltage signal, the first MOS tube (Q1) is cut off, and the A end of the RS485 serial port acquires a +5V voltage signal; when the TX transmitting end of the RS232 serial port outputs a positive voltage signal, the first MOS tube (Q1) is conducted, and the A end of the RS485 serial port acquires a 0V voltage signal.
  3. 3. The serial port conversion device of claim 1, wherein, The second conversion circuit comprises a second MOS tube (Q2), a third MOS tube (Q3), a fourth resistor (R4), a fifth resistor (R5), a sixth resistor (R6) and a seventh resistor (R7); One end of the fourth resistor (R4) is electrically connected with a TX transmitting end of the RS232 serial port, the other end of the fourth resistor (R4) is electrically connected with a grid electrode of the third MOS tube (Q3) and one end of the fifth resistor (R5), a source electrode of the third MOS tube (Q3) is electrically connected with the other end of the fifth resistor (R5) and one end of the seventh resistor (R7) and is grounded, a drain electrode of the third MOS tube (Q3) is electrically connected with one end of the sixth resistor (R6) and a grid electrode of the second MOS tube (Q2), a drain electrode of the second MOS tube (Q2) is electrically connected with the other end of the sixth resistor (R6) and is electrically connected with a +5V reference voltage source, and a source electrode of the second MOS tube (Q2) is electrically connected with the other end of the seventh resistor (R7) and a B end of the RS485 serial port; when the TX transmitting end of the RS232 serial port outputs a negative voltage signal, the second MOS tube (Q2) is cut off, the third MOS tube (Q3) is cut off, and the B end of the RS485 serial port acquires a 0V voltage signal; when the TX transmitting end of the RS232 serial port outputs a positive voltage signal, the second MOS tube (Q2) is conducted, the third MOS tube (Q3) is conducted, and the B end of the RS485 serial port acquires a +5V voltage signal.
  4. 4. The serial port conversion device of claim 3 wherein, The second conversion circuit includes an eighth resistor (R8); The eighth resistor (R8) is connected between the end B of the RS485 serial port and the source electrode and the seventh resistor (R7) of the second MOS tube (Q2).
  5. 5. The serial port conversion device of claim 1, wherein, The third conversion circuit comprises a fourth MOS tube (Q4), a fifth MOS tube (Q5), a first optocoupler (U1), a first diode (D1), a ninth resistor (R9), a twelfth resistor (R12), a thirteenth resistor (R13), a fourteenth resistor (R14) and a fifteenth resistor (R15); The receiving end of the first optocoupler (U1) is electrically connected with one end of a twelfth resistor (R12), the other end of the twelfth resistor (R12) is electrically connected with one end of a thirteenth resistor (R13), and the receiving end of the first optocoupler (U1) is also electrically connected with one end of a fourteenth resistor (R14) and a source electrode of a fourth MOS and is connected with a +5V reference voltage source; One end of the ninth resistor (R9) is electrically connected with the end B of the RS485 serial port, the other end of the ninth resistor (R9) is electrically connected with the transmitting end of the first optocoupler (U1), the negative electrode of the first diode (D1) is electrically connected with the end A of the RS485 serial port, and the positive electrode of the first diode (D1) is electrically connected with the transmitting end of the first optocoupler (U1); The grid electrode of the fifth MOS tube (Q5) is electrically connected with the other end of the thirteenth resistor (R13), the source electrode of the fifth MOS tube (Q5) is grounded, and the drain electrode of the fifth MOS tube (Q5) is electrically connected with the grid electrode of the fourth MOS at the other end of the fourteenth resistor (R14); the drain electrode of the fourth MOS is electrically connected with one end of a fifteenth resistor (R15) and the RX receiving end of the RS232 serial port, and the other end of the fifteenth resistor (R15) is electrically connected with a-5V reference voltage source; When the voltage of the end A of the RS485 serial port is larger than the voltage of the end B, the first diode (D1) is cut off, the first optocoupler (U1) is cut off, the fourth MOS tube (Q4) is cut off, the fifth MOS tube (Q5) is cut off, and an RX receiving end of the RS232 serial port acquires a-5V voltage signal; When the voltage of the end A of the RS485 serial port is smaller than the voltage of the end B, the first diode (D1) is conducted, the first optocoupler (U1) is conducted, the fourth MOS tube (Q4) is conducted, the fifth MOS tube (Q5) is conducted, and an RX receiving end of the RS232 serial port obtains a +5V voltage signal.
  6. 6. The serial port conversion device of claim 5 wherein, The third conversion circuit further comprises a sixth MOS tube (Q6), a tenth resistor (R10) and an eleventh resistor (R11); One end of the tenth resistor (R10) is electrically connected with a TX transmitting end of the RS232 serial port, the other end of the tenth resistor (R10) is electrically connected with a grid electrode of a sixth MOS tube (Q6) and one end of an eleventh resistor (R11), and a source electrode of the sixth MOS tube (Q6) is electrically connected with the other end of the eleventh resistor (R11) and grounded; the drain electrode of the sixth MOS tube (Q6) is electrically connected with a twelfth resistor (R12) and a thirteenth resistor (R13); When the TX transmitting end of the RS232 serial port transmits data, the sixth MOS tube (Q6) is conducted; when the TX transmitting end of the RS232 serial port stops transmitting data, the sixth MOS tube (Q6) is cut off.
  7. 7. The serial port conversion device of claim 5 wherein, The third conversion circuit includes a sixteenth resistor (R16); The sixteenth resistor (R16) is connected between the RX receiving end of the RS232 serial port and the drain electrode and the fifteenth resistor (R15) of the fourth MOS tube (Q4).
  8. 8. The serial port conversion apparatus according to claim 1, further comprising: an external power source; The external power supply is electrically connected with the first conversion circuit, the second conversion circuit and the third conversion circuit; the external power supply is adapted to provide a +5V reference voltage source to the first and second conversion circuits, and is further adapted to provide a +5V reference voltage source and a-5V reference voltage source to the third conversion circuit.
  9. 9. A method of conversion, comprising: when the TX transmitting end of the RS232 serial port outputs a negative voltage signal, the A end and the B end of the RS485 serial port respectively acquire a +5V voltage signal and a 0V voltage signal through a first conversion circuit and a second conversion circuit, and a third conversion circuit isolates the RX receiving end of the RS232 serial port from the TX transmitting end of the RS232 serial port, namely the RS232 serial port outputs logic 1 and the RS485 serial port receives logic 1; When the TX transmitting end of the RS232 serial port outputs a positive voltage signal, the A end and the B end of the RS485 serial port respectively acquire a 0V voltage signal and a +5V voltage signal through a first conversion circuit and a second conversion circuit, and a third conversion circuit isolates the RX receiving end of the RS232 serial port from the TX transmitting end of the RS232 serial port, the A end of the RS485 serial port and the B end of the RS485 serial port, namely the RS232 serial port outputs logic 0 and the RS485 serial port receives logic 0; When the voltage of the A end of the RS485 serial port is larger than the voltage of the B end, a third conversion circuit isolates a TX transmitting end of the RS232 serial port from an RX receiving end of the RS232 serial port, an A end of the RS485 serial port and a B end of the RS485 serial port, and the RX receiving end of the RS232 serial port obtains a-5V voltage signal through the third conversion circuit, namely the RS485 serial port outputs logic 1 and the RS232 serial port receives logic 1; when the voltage of the A end of the RS485 serial port is smaller than the voltage of the B end, the third conversion circuit isolates the TX transmitting end of the RS232 serial port from the RX receiving end of the RS232 serial port, the A end of the RS485 serial port and the B end of the RS485 serial port, and the RX receiving end of the RS232 serial port obtains +5V voltage signals through the third conversion circuit, namely, the RS485 serial port outputs logic 0 and the RS232 serial port receives logic 0.
  10. 10. A conversion method according to claim 9, characterized in that it is adapted to use a serial conversion device according to any one of claims 1-8.

Description

Serial port conversion device and conversion method based on RS 232-RS 485 Technical Field The invention belongs to the technical field of electric communication, in particular to digital information transmission equipment, and particularly relates to a serial port conversion device and a conversion method based on RS 232-RS 485 conversion. Background In practical application, the computer motherboard only contains one com port (adopting the RS232 protocol), if a plurality of lower computers need to be driven, RS232 serial port signals need to be converted into RS485 serial port signals, and then the plurality of lower computers are driven. At present, an RS232 serial port signal is firstly converted into a TTL232 serial port signal, then the TTL232 serial port signal is converted into an RS485, an RS 232-to-TTL chip and a TTL-to-RS 485 chip are required to be used, the cost is relatively high, and the RS 232-to-TTL chip is also provided with a charge pump, is easily interfered by the outside, and can be recovered only by powering on and powering off after the interference, and cannot be recovered through command interaction. Therefore, development of a new serial port conversion device and conversion method based on RS232 to RS485 is needed to solve the technical problems of high cost and charge pump interference caused by the need of TLL chip for conversion in the existing RS232 conversion RS 485. It should be noted that the above information disclosed in this background section is only for understanding the background of the inventive concept and therefore the above description is not to be construed as constituting prior art information. Disclosure of Invention The embodiment of the disclosure at least provides a serial port conversion device and a conversion method based on RS 232-RS 485. In a first aspect, an embodiment of the present disclosure provides a serial port conversion device, which includes an RS232 serial port, an RS485 serial port, a first conversion circuit, a second conversion circuit, and a third conversion circuit; the TX transmitting end of the RS232 serial port and the A end of the RS485 serial port are respectively and electrically connected with the first conversion circuit; the TX transmitting end of the RS232 serial port and the B end of the RS485 serial port are respectively and electrically connected with the second conversion circuit; the system comprises a TX transmitting end of an RS232 serial port, an RX receiving end of the RS232 serial port, an A end of the RS485 serial port and a B end of the RS485 serial port, wherein the A end and the B end of the RS485 serial port are respectively and electrically connected with a third conversion circuit, when the TX transmitting end of the RS232 serial port outputs a negative voltage signal, the A end and the B end of the RS485 serial port respectively acquire a +5V voltage signal and a 0V voltage signal through a first conversion circuit and a second conversion circuit, the third conversion circuit isolates the RX receiving end of the RS232 serial port from the TX transmitting end of the RS232 serial port, namely the RS232 serial port outputs logic 1 and the RS485 serial port receives logic 1, when the TX transmitting end of the RS232 serial port outputs a positive voltage signal, the A end and the B end of the RS485 serial port respectively acquire 0V voltage signal and +5V voltage signal through the first conversion circuit and the second conversion circuit, and the third conversion circuit isolates the RX receiving end of the RS232 serial port from the A end of the RS232 serial port, namely the A end of the RS485 serial port and the RS485 serial port receives the logic 1, and the RS485 serial port receives the RS232 serial port and the RS485 serial port receives the logic serial signal from the RS485 serial port when the A end of the RS485 serial port and the RS serial port receives the 0V signal and the RS serial port receives the 0V signal from the third serial port and the RS485 serial port and the RS485 serial port and the 0 serial port and the 0 and the serial port and the 0 and the serial port and the 0 and 0 and, when the voltage of the A end of the RS485 serial port is smaller than that of the B end, the third conversion circuit isolates the TX transmitting end of the RS232 serial port from the RX receiving end of the RS232 serial port, the A end of the RS485 serial port and the B end of the RS485 serial port, and the RX receiving end of the RS232 serial port obtains +5V voltage signals through the third conversion circuit, namely, the RS485 serial port outputs logic 0 and the RS232 serial port receives logic 0. In an alternative implementation mode, the first conversion circuit comprises a first MOS tube, a first resistor and a second resistor, one end of the first resistor is electrically connected with a TX transmitting end of an RS232 serial port, the other end of the first resistor is electrically connected with a