RS 232-to-one-wire protocol module and conversion method
Technical Field
The invention belongs to the technical field of bus interfaces, and relates to an RS 232-to-one-wire protocol module and a conversion method thereof.
Background
A single bus (one-wire bus) is a peripheral serial expansion bus technology introduced by DALLAS corporation of america, and unlike a serial data communication method, it uses a single signal line to transmit both a clock and data, and data transmission is bidirectional. The RS232 to one-wire bus interface circuit is a bridge circuit for converting from an RS232 serial interface to one-wire network protocols. As long as a computer or other host equipment has a common RS232 serial interface, a one-wire waveform controlled by strict timing and voltage slew rate can be generated through the circuit, and communication with a one-wire system device is facilitated. The interface circuit receives the instruction and data to be sent, executes one-wire operation, and returns the result to the host.
At present, a plurality of sensors are used when a field simulation test is carried out, and a temperature control plate needs to be accessed frequently every time; when a field simulation experiment is carried out, the temperature of the temperature control module needs to be increased and decreased physically, such as roasting and freezing, so that the process is complicated, the material consumption is high, and potential safety hazards are easily caused.
Disclosure of Invention
The invention provides a module for converting RS232 to one-wire protocol and a conversion method thereof; the conversion between high level and low level can be carried out between circuit modules in different working voltage domains.
The invention is realized by the following technical scheme:
an RS 232-to-one-wire protocol module comprises an RS232 interface module, an RS232 interface level conversion module, a control module, a one-wire interface level conversion module and a one-wire interface module;
the upper computer sends temperature signals and serial number information of the temperature sensor to be simulated to the control module through the RS232 interface module and the RS232 interface level conversion module;
the control module comprises a main control board and a power distribution module for supplying power; the main control board receives a signal sent by the RS232 interface level conversion module, analyzes the time sequence of the signal and simulates a temperature signal; the simulated temperature signal and the serial number information are transmitted to a one-wire interface module by a one-wire interface level conversion module and then are sent to an external temperature control module; and the external temperature control module generates corresponding temperature change according to the analog temperature signal and the serial number information.
Furthermore, the power distribution module supplies power to the main control board, the RS232 interface module, the RS232 interface level conversion module, the one-wire interface level conversion module and the one-wire interface module, and comprises a 5V power conversion module and a 3.3V power conversion module.
Furthermore, a main control board circuit is arranged on the main control board, and a light emitting diode LED1, a resistor R1, a resistor R4 and a light emitting diode LED2 are sequentially connected between a PA11 pin and a PA12 pin of the main control board; the input ends of the resistor R1 and the resistor R4 are both connected with the 3.3V power supply conversion module;
the BOOT0 pin of the main control board is connected with a resistor R9 connected with the 3.3V power supply conversion module and a resistor R10 connected with the digital ground;
a resistor R21 and a crystal oscillator X1 which are connected in parallel are arranged between a PD0 pin and a PD1 pin of the main control board, two ends of a crystal oscillator X1 are also connected in series with a capacitor C4 and a capacitor C5, and the connection ends of the capacitor C4 and the capacitor C5 are both connected with a digital ground;
the SWDCLK pin and the SWDIO pin of the main control board are respectively connected with the third pin and the second pin of the download debugging interface, a resistor R17 is connected between the SWDCLK pin of the main control board and the third pin of the download debugging interface, and a resistor R18 is connected between the SWDIO pin of the main control board and the second pin of the download debugging interface; downloading a first pin of a debugging interface to be connected with a digital ground; a fourth pin of the download debugging interface is connected with the input end of the resistor R1;
the VBAT pin, the VDD _1 pin, the VDD _2 pin, the VDD _3 pin, the VDD _4 pin and the VDDA pin of the main control board are all connected with the input end of a capacitor C12, and the output end of a capacitor C12 is connected with digital ground; a VBAT pin of the main control board is connected with the 3.3V power supply conversion module; the two ends of the capacitor C12 are also connected in parallel with an electrolytic capacitor C6, a capacitor C7, a capacitor C8, a capacitor C9, a capacitor C10 and a capacitor C11; the input end of the capacitor C12 is connected with the input end of the resistor R1;
the pin VSS _1, pin VSS _2, pin VSS _3, pin VSS _4 and pin VSSA of the main control board are all connected to digital ground.
Further, the RS232 interface module comprises an interface chip U6 and an RS232 interface; the T1OUT pin of the interface chip U6 is connected with the second pin of the RS232 interface through a resistor R32; the R1IN pin of the interface chip U6 is connected with the third pin of the RS232 interface through a resistor R34; a first pin of the RS232 interface is connected with the 5V power supply conversion module; the fourth pin of the RS232 interface is connected with a digital ground;
a transient suppression diode TVS9 and a transient suppression diode TVS10 which are connected with digital ground are also connected in series between the second pin and the third pin of the RS232 interface;
the VCC pin, the V + pin and the V-pin of the interface chip U6 are respectively connected with a capacitor C16, a capacitor C19 and a capacitor C20 which are connected with a digital ground; the VCC pin of the interface chip U6 is connected with the 3.3V voltage stabilizing module;
a capacitor C17 is connected between the C1+ pin and the C1-pin of the interface chip U6; a capacitor C21 is connected between a C2+ pin and a C2-pin of the interface chip U6; the T2IN pin of the interface chip U6 is connected with a resistor R38 connected with a digital ground; the pin R2IN of the interface chip U6 is connected with a resistor R39 connected with a digital ground;
the T1IN pin of the interface chip U6 is connected with the RS232 interface level conversion module through a resistor R33; the R1OUT pin of the interface chip U6 is connected with the RS232 interface level conversion module through a resistor R35.
Further, the RS232 interface level conversion module includes a photocoupler U2 and a photocoupler U3;
a first pin of the photoelectric coupler U2 is connected with the output end of the resistor R13, the input end of the resistor R13 is connected with the 3.3V power supply conversion module, and a second pin of the photoelectric coupler U2 is connected with the output end of the resistor R33; the third pin of the photoelectric coupler U2 is grounded; a fourth pin of the photoelectric coupler U2 is connected with the output end of the resistor R11, the input end of the resistor R11 is connected with the 3.3V power supply conversion module, and a fourth pin of the photoelectric coupler U2 is connected with a TXD1 pin of the main control board;
a first pin of the photoelectric coupler U3 is connected with the output end of the resistor R14, the input end of the resistor R14 is connected with the 3.3V power supply conversion module, and a second pin of the photoelectric coupler U3 is connected with the output end of the resistor R35; the third pin of the photoelectric coupler U3 is grounded; the fourth pin of the photoelectric coupler U3 is connected with the output end of the resistor R12, the input end of the resistor R12 is connected with the 3.3V power supply conversion module, and the fourth pin of the photoelectric coupler U3 is connected with the RXD1 pin of the main control board.
Furthermore, the one-wire interface level conversion module comprises a resistor R22 and a resistor R24, wherein the second contact is connected with the 5V power conversion module interface, and a triode Q1 connected with a digital ground is connected in series between the resistor R22 and the first contact of the resistor R24; the first contact of the resistor R22 is also connected with the first contact of the resistor R42, and the second contact of the resistor R42 is connected with the digital ground transient suppression diode TVS 1;
a first contact of the resistor R24 is connected with a second contact of the transistor Q3; the third contact of transistor Q3 is connected to digital ground; the first contact of the triode Q3 is connected with the 18B20_ D interface of the main control board through a resistor R44; the first contact of the triode Q3 is further connected with the transient suppression diode TVS3 connected to the ground and the first contact of the resistor R27, the second contact of the resistor R27 is connected with the second contact of the triode Q5, the first contact of the triode Q5 is connected with the second contact of the resistor R29, the first contact of the resistor R29 is connected with the second contact of the resistor R27, and the first contact of the resistor R29 is connected with the 3.3V power conversion module; the third contact of transistor Q5 is connected to digital ground;
a second contact of the resistor R29 is connected to a second contact of the transistor Q7, and a first contact of the transistor Q7 is connected to a second contact of the resistor R42; the third contact of transistor Q7 is connected to digital ground.
A method for converting RS232 to one-wire protocol module includes the following steps:
s1, an upper computer sends a temperature signal and serial number information of a temperature sensor to be simulated to a control module through an RS232 interface module and an RS232 interface level conversion module;
s2, the main control board of the control module receives the signal sent by the RS232 interface level conversion module, analyzes the time sequence and simulates a temperature signal;
s3, transmitting the simulated temperature signal and the serial number information to a one-wire interface module by the one-wire interface level conversion module, and then transmitting to an external temperature control module;
and S4, the external temperature control module generates corresponding temperature change according to the analog temperature signal and the serial number information.
Compared with the prior art, the invention has the following beneficial technical effects:
1. the RS232 interface level conversion circuit and the one-wire interface level conversion circuit in the invention can convert high level and low level between circuit modules in different working voltage domains, thereby facilitating communication of different circuit modules; meanwhile, the device can also play a role in isolating and filtering input signals and output signals; the invention uses the transient suppression diode to protect the internal circuit of the RS232 to one-wire connector module, can prevent the failure of a microprocessor or a singlechip in the circuit on the conversion board caused by static electricity and surge, and can also avoid the influence of unnecessary noise on data and control buses.
2. The main control board receives temperature and serial number information sent by an upper computer through an RS232 interface circuit, simulates 18b20 time sequence through an 18b20 time sequence simulation circuit, transmits the information to an external temperature control module through a one-wire interface circuit, and can realize the function test of the temperature control module only by inputting a temperature value to be simulated on an interface of the upper computer; the operation process is simple and convenient, and the temperature control module is not required to be physically heated or cooled, so that the damage to the tested product caused by the way of fire baking and freezing when the temperature control module is physically heated or cooled is avoided, and the occurrence of potential safety hazard accidents is reduced.
Drawings
FIG. 1 is a schematic diagram of an overall module of the present invention;
FIG. 2 is a circuit diagram of a main control board circuit;
FIG. 3 is a circuit diagram of light emitting diode LED1 and light emitting diode LED 2;
FIG. 4 is a circuit diagram of a download debug interface;
FIG. 5 is a circuit diagram of a 5V power conversion module and a 3.3V power conversion module in a power distribution module;
FIG. 6 is a circuit diagram of an RS232 interface module;
FIG. 7 is a circuit diagram of an RS232 interface level shift module;
fig. 8 is a circuit diagram of the one-wire interface level conversion module and the one-wire interface module.
Detailed Description
The present invention will now be described more fully hereinafter with reference to the accompanying drawings, in which the invention is shown by way of illustration and not by way of limitation.
As shown in fig. 1, an RS232 to one-wire protocol module includes an RS232 interface module, an RS232 interface level conversion module, a control module, an one-wire interface level conversion module, and an one-wire interface module;
the upper computer sends the temperature signal and the serial number information of the temperature sensor to be simulated to the control module through the RS232 interface module and the RS232 interface level conversion module;
the control module comprises a main control board and a power distribution module for supplying power; the main control board receives a signal sent by the RS232 interface level conversion module, analyzes the time sequence of the signal and simulates a temperature signal; the analog temperature signal and the serial number information are transmitted to a one-wire interface module by a one-wire interface level conversion module and then are sent to an external temperature control module; and the external temperature control module generates corresponding temperature change according to the analog temperature signal and the serial number information.
As shown in fig. 5, the power distribution module supplies power to the main control board, the RS232 interface module, the RS232 interface level conversion module, the one-wire interface level conversion module, and the one-wire interface module, and the power distribution module includes a 5V power conversion module and a 3.3V power conversion module, and both the 5V power conversion module and the 3.3V power conversion module adopt the prior art.
As shown in fig. 2 and 3, a main control board circuit is arranged on the main control board, the model of the main control board is STM32F103RCT6, and a light emitting diode LED1, a resistor R1, a resistor R4 and a light emitting diode LED2 are sequentially connected between a PA11 pin and a PA12 pin of the main control board; the input ends of the resistor R1 and the resistor R4 are both connected with the 3.3V power supply conversion module;
the BOOT0 pin of the main control board is connected with a resistor R9 connected with the 3.3V power supply conversion module and a resistor R10 connected with the digital ground;
a resistor R21 and a crystal oscillator X1 which are connected in parallel are arranged between a PD0 pin and a PD1 pin of the main control board, two ends of a crystal oscillator X1 are also connected in series with a capacitor C4 and a capacitor C5, and the connection ends of the capacitor C4 and the capacitor C5 are both connected with a digital ground;
as shown in fig. 4, the SWDCLK pin and the SWDIO pin of the main control board are respectively connected to the third pin and the second pin of the download debugging interface, a resistor R17 is connected between the SWDCLK pin of the main control board and the third pin of the download debugging interface, and a resistor R18 is connected between the SWDIO pin of the main control board and the second pin of the download debugging interface; downloading a first pin of a debugging interface to be connected with a digital ground; a fourth pin of the download debugging interface is connected with the input end of the resistor R1;
a VBAT pin, a VDD _1 pin, a VDD _2 pin, a VDD _3 pin, a VDD _4 pin and a VDDA pin of the main control board are all connected with the input end of a capacitor C12, and the output end of a capacitor C12 is connected with digital ground; a VBAT pin of the main control board is connected with the 3.3V power supply conversion module; the two ends of the capacitor C12 are also connected in parallel with an electrolytic capacitor C6, a capacitor C7, a capacitor C8, a capacitor C9, a capacitor C10 and a capacitor C11; the input end of the capacitor C12 is connected with the input end of the resistor R1;
the VSS _1 pin, the VSS _2 pin, the VSS _3 pin, the VSS _4 pin and the VSSA pin of the main control board are all connected with a digital ground.
As shown in fig. 6, the RS232 interface module includes an interface chip U6 and an RS232 interface; the model of the interface chip U6 is TP 3232N-SR; the T1OUT pin of the interface chip U6 is connected with the second pin of the RS232 interface through a resistor R32; the R1IN pin of the interface chip U6 is connected with the third pin of the RS232 interface through a resistor R34; a first pin of the RS232 interface is connected with the 5V power supply conversion module; the fourth pin of the RS232 interface is connected with a digital ground;
a transient suppression diode TVS9 and a transient suppression diode TVS10 which are connected with digital ground are also connected in series between the second pin and the third pin of the RS232 interface; the transient suppression diode is used for surge and electrostatic protection of the main control panel.
The VCC pin, the V + pin and the V-pin of the interface chip U6 are respectively connected with a capacitor C16, a capacitor C19 and a capacitor C20 which are connected with a digital ground; the VCC pin of the interface chip U6 is connected with the 3.3V voltage stabilizing module;
a capacitor C17 is connected between a C1+ pin and a C1-pin of the interface chip U6; a capacitor C21 is connected between a C2+ pin and a C2-pin of the interface chip U6; the T2IN pin of the interface chip U6 is connected with a resistor R38 connected with a digital ground; the pin R2IN of the interface chip U6 is connected with a resistor R39 connected with a digital ground;
the T1IN pin of the interface chip U6 is connected with the RS232 interface level conversion module through a resistor R33; the R1OUT pin of the interface chip U6 is connected with the RS232 interface level conversion module through a resistor R35.
As shown in fig. 6 and 7, the RS232 interface level conversion module includes a photocoupler U2 and a photocoupler U3; the model of the photocoupler U2 and the photocoupler U3 is TLP 185;
as shown in fig. 2, a first pin of the photoelectric coupler U2 is connected to an output terminal of the resistor R13, an input terminal of the resistor R13 is connected to the 3.3V power conversion module, and a second pin of the photoelectric coupler U2 is connected to an output terminal of the resistor R33; a third pin of the photoelectric coupler U2 is grounded; a fourth pin of the photoelectric coupler U2 is connected with the output end of the resistor R11, the input end of the resistor R11 is connected with the 3.3V power supply conversion module, and a fourth pin of the photoelectric coupler U2 is connected with a TXD1 pin of the main control board;
as shown in fig. 2, a first pin of the photocoupler U3 is connected to an output terminal of the resistor R14, an input terminal of the resistor R14 is connected to the 3.3V power conversion module, and a second pin of the photocoupler U3 is connected to an output terminal of the resistor R35; the third pin of the photoelectric coupler U3 is grounded; the fourth pin of the photoelectric coupler U3 is connected with the output end of the resistor R12, the input end of the resistor R12 is connected with the 3.3V power supply conversion module, and the fourth pin of the photoelectric coupler U3 is connected with the RXD1 pin of the main control board.
As shown in fig. 8, the one-wire interface level conversion module includes a resistor R22 and a resistor R24, where the second contact is connected to the 5V power conversion module interface, and a digital ground connected triode Q1 is connected in series between the resistor R22 and the first contact of the resistor R24; the first contact of the resistor R22 is also connected with the first contact of the resistor R42, and the second contact of the resistor R42 is connected with the digital ground transient suppression diode TVS 1;
a first contact of the resistor R24 is connected with a second contact of the transistor Q3; the third contact of the transistor Q3 is connected to digital ground; as shown in fig. 2, the first contact of the transistor Q3 is connected to the 18B20_ D interface of the main control board through a resistor R44; the first contact of the triode Q3 is also connected with the transient suppression diode TVS3 connected to the ground and the first contact of the resistor R27, the second contact of the resistor R27 is connected with the second contact of the triode Q5, the first contact of the triode Q5 is connected with the second contact of the resistor R29, the first contact of the resistor R29 is connected with the second contact of the resistor R27, and the first contact of the resistor R29 is connected with the 3.3V power conversion module; the third contact of transistor Q5 is connected to digital ground;
a second contact of the resistor R29 is connected with a second contact of the transistor Q7, and a first contact of the transistor Q7 is connected with a second contact of the resistor R42; the third contact of transistor Q7 is connected to digital ground.
The invention also discloses a method for converting the RS232 to the one-wire protocol module, which comprises the following specific operation steps:
s1, an upper computer sends a temperature signal and serial number information of a temperature sensor to be simulated to a control module through an RS232 interface module and an RS232 interface level conversion module;
s2, the main control board of the control module receives the signal sent by the RS232 interface level conversion module, analyzes the time sequence and simulates the temperature signal;
s3, transmitting the simulated temperature signal and the serial number information to a one-wire interface module by the one-wire interface level conversion module, and then transmitting to an external temperature control module;
and S4, the external temperature control module generates corresponding temperature change according to the analog temperature signal and the serial number information.
The embodiments given above are preferable examples for implementing the present invention, and the present invention is not limited to the above-described embodiments. Any non-essential addition and replacement made by the technical characteristics of the technical scheme of the invention by a person skilled in the art belong to the protection scope of the invention.