CN113064849A - Communication method, device and communication circuit - Google Patents

Communication method, device and communication circuit Download PDF

Info

Publication number
CN113064849A
CN113064849A CN202110260095.0A CN202110260095A CN113064849A CN 113064849 A CN113064849 A CN 113064849A CN 202110260095 A CN202110260095 A CN 202110260095A CN 113064849 A CN113064849 A CN 113064849A
Authority
CN
China
Prior art keywords
serial port
communication
logic signal
identification byte
signal received
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110260095.0A
Other languages
Chinese (zh)
Inventor
陈颜新
陈楚泽
戴东林
周友兴
李行杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Topband Co Ltd
Original Assignee
Shenzhen Topband Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Topband Co Ltd filed Critical Shenzhen Topband Co Ltd
Priority to CN202110260095.0A priority Critical patent/CN113064849A/en
Publication of CN113064849A publication Critical patent/CN113064849A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/40Bus structure
    • G06F13/4063Device-to-bus coupling
    • G06F13/4068Electrical coupling
    • G06F13/4072Drivers or receivers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0002Serial port, e.g. RS232C

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Information Transfer Systems (AREA)

Abstract

The invention is suitable for the technical field of communication, and provides a communication method, a communication device and a communication circuit, wherein the method comprises the following steps: setting a communication identification byte; controlling the first serial port and the second serial port to simultaneously receive the logic signal sent by the RS485 receiving and sending unit; polling to judge whether the check code of the logic signal received by the first serial port is a communication identification byte; if so, controlling the first serial port to perform transceiving work and shielding the second serial port; if not, when the check code of the logic signal received by the second serial port is judged to be the communication identification byte, the second serial port is controlled to carry out transceiving work, and the first serial port is shielded. The invention ensures that one serial port can receive the forward signal inevitably by arranging 2 serial ports, and also arranges the communication identification byte to accurately select the serial port capable of receiving the forward signal for data communication and shield the other serial port, thereby enabling the AB line to normally realize the data communication by positive and negative blind plugging, needing no special foolproof connector, simplifying the port structure and reducing the cost.

Description

Communication method, device and communication circuit
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a communication method, a communication device, and a communication circuit.
Background
The RS485 bus is widely used in electronic products as a universal serial bus, wherein the RS485 port is a communication connection port in the RS485 bus. The RS485 port needs to complete communication, and the RS485-A line and the RS485-B line of two communication parties need to be correspondingly connected, namely the A line is connected with the A line, and the B line is connected with the B line, so that normal communication can be realized. However, in many cases, the RS485-a line and the RS485-B line are mostly inserted in a blind manner, and if the lines are connected in a wrong manner, communication cannot be achieved.
In the prior art, in order to avoid wrong connection, the corresponding connection between the RS485-a line and the RS485-B line of both communication parties is realized by a mechanical way of fool-proof interface at present, but the way needs to design a special fool-proof connector, and has complex structure and high cost.
Disclosure of Invention
The embodiment of the invention provides a communication method, a communication device and a communication circuit, and aims to solve the technical problems of complex structure and high cost in the existing mode of ensuring that two RS485 communication parties are connected to a wire by designing a special foolproof connector and further ensuring normal communication of the two parties.
The embodiment of the invention is realized in such a way that a communication method comprises the following steps:
setting a communication identification byte;
controlling the first serial port and the second serial port to simultaneously receive the logic signal sent by the RS485 receiving and sending unit;
polling to judge whether a check code of a logic signal received by the first serial port is the communication identification byte;
if yes, controlling the first serial port to perform transceiving work, and shielding the second serial port;
if not, controlling the second serial port to carry out transceiving work and shielding the first serial port when the check code of the logic signal received by the second serial port is judged to be the communication identification byte.
An embodiment of the present invention further provides a communication device, where the device includes:
a setting unit for setting a communication identification byte;
the signal receiving unit is used for controlling the first serial port and the second serial port to simultaneously receive the logic signal sent by the RS485 receiving and sending unit;
a polling determination unit, configured to determine whether a check code of the logic signal received by the first serial port is the communication identification byte by polling;
if the check code of the logic signal received by the first serial port is judged to be the communication identification byte, controlling the first serial port to carry out transceiving work and shielding the second serial port;
and if the check code of the logic signal received by the first serial port is judged not to be the communication identification byte, controlling the second serial port to carry out transceiving work and shielding the first serial port when the check code of the logic signal received by the second serial port is judged to be the communication identification byte.
The embodiment of the invention also provides a communication circuit, which comprises an RS485 receiving and transmitting unit and an MCU unit,
the RS485 receiving and transmitting unit converts the bus differential signal into a logic signal which can be identified by the MCU unit;
the MCU unit is connected with the RS485 receiving and transmitting unit and is provided with a first serial port and a second serial port, the first serial port and the second serial port simultaneously receive the logic signals, the logic signals are identified as normal phase signals or reverse phase signals by the first serial port, and the logic signals are identified as reverse phase signals or normal phase signals by the second serial port.
The invention achieves the following beneficial effects: receive the signal of AB line simultaneously through setting up 2 serial ports, make no matter the AB line is just connecing or the transposition, can guarantee that one of them serial ports can receive the forward signal, in addition still set up the communication identification byte, come to discern the serial ports that can receive the forward signal with utilizing this communication identification byte, carry out data communication with the serial ports that can receive the forward signal with accurate the choosing, and shield another serial ports, thereby make the positive and negative blind plug of AB line can both normally realize data communication, need not to design special connector of preventing slow-witted, simplify port structure and reduce cost.
Drawings
FIG. 1 is a block diagram of a communication circuit provided by an embodiment of the present invention;
FIG. 2 is a flowchart of a communication method according to an embodiment of the present invention;
FIG. 3 is a flowchart of a communication method according to a second embodiment of the present invention;
fig. 4 is a flowchart of a communication method in the third embodiment of the present invention;
fig. 5 is a structural diagram of a communication device according to a fourth embodiment of the present invention;
FIG. 6 is a block diagram of a communication circuit according to a fifth embodiment of the present invention;
FIG. 7 is a detailed circuit diagram of a communication circuit according to a fifth embodiment of the present invention;
fig. 8 is another specific circuit diagram of the communication circuit according to the fifth embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The corresponding connection of the RS485-A line and the RS485-B line of two communication parties is ensured through the existing mechanical mode of fool-proof interface, so that the normal communication of the two parties is ensured. Therefore, an object of the present invention is to provide a communication method, device and circuit, in which 2 serial ports are provided to simultaneously receive signals of an AB line, so as to ensure that one of the serial ports can certainly receive a forward signal, and a communication identification byte is used to identify the serial port capable of receiving the forward signal, so as to accurately select a data communication serial port, thereby enabling the AB line to normally realize data communication through positive and negative blind plugging, without designing a special foolproof connector, simplifying a port structure and reducing cost.
The following embodiments can be applied to the communication circuit shown in fig. 1, the communication circuit shown in fig. 1 can be an internal circuit of an RS485 port, and the communication circuit specifically includes a processing unit and an RS485 transceiver unit connected to the processing unit, where:
the RS485 receiving and transmitting unit is connected with the RS485-A line and the RS485-B of the external equipment one by one through the RS485-A line and the RS485-B to realize the signal receiving and transmitting of the RS485 receiving and transmitting unit and the external equipment, thereby realizing the communication between the two parties. In specific implementation, the RS485-A line and the RS485-B line of the RS485 transceiving unit and the external equipment can be plugged through the connectors.
In addition, the processing unit is provided with a first serial port and a second serial port, and the first serial port and the second serial port are respectively connected with the RS485 receiving and transmitting unit through the same and parallel circuits so as to simultaneously receive signals sent by the RS485 receiving and transmitting unit. Specifically, the RS485 receiving and transmitting unit is used for receiving a differential signal between the RS485-A line and the RS485-B line, converting the differential signal into a logic signal which can be received by the processing unit, and simultaneously outputting the logic signal to a first serial port and a second serial port of the processing unit. In addition, the RS485 transceiver unit is also used for receiving the logic signal sent by the processing unit, converting the logic signal into a differential signal and outputting the differential signal to external equipment through an AB line. By way of example and not limitation, the Processing Unit may be, but is not limited to, an MCU (micro controller Unit), an ECU (Electronic Control Unit), a Central Processing Unit (CPU), a controller, a Microcontroller, a microprocessor or other data Processing chip, and the like.
It should be noted that the configuration shown in fig. 1 does not constitute a limitation of the communication circuit, which may comprise fewer or more elements than shown, or some elements may be combined, or a different arrangement of elements in other embodiments.
Example one
Referring to fig. 2, a communication method according to a first embodiment of the present invention is shown, which may be applied to a processing unit, where the processing unit is provided with a first serial port and a second serial port, and the communication method may be implemented by software and/or hardware, and specifically includes:
step S01, setting a communication identification byte;
step S02, controlling the first serial port and the second serial port to simultaneously receive the logic signal sent by the RS485 receiving and sending unit;
step S03, polling to determine whether the check code of the logic signal received by the first serial port is the communication identification byte; if the check code of the logic signal received by the first serial port is determined to be the communication identification byte, executing step S04; if the check code of the logic signal received by the first serial port is not determined to be the communication identification byte, step S05 is executed.
And step S04, controlling the first serial port to perform transceiving work and shielding the second serial port.
And step S05, when the check code of the logic signal received by the second serial port is judged to be the communication identification byte, controlling the second serial port to carry out transceiving work and shielding the first serial port.
It should be understood that when the RS485-a line and the RS485-B of the RS485 transceiver unit and the external device are connected in the positive direction, the differential signal received by the RS485 transceiver unit is a forward differential signal, and the forward differential signal is converted into a forward logic signal through the RS485 transceiver unit; on the contrary, when the RS485-A line and the RS485-B line of the RS485 transceiving unit and the external equipment are reversely connected, the differential signal received by the RS485 transceiving unit is a reverse differential signal, and the reverse differential signal is converted into a reverse logic signal through the RS485 transceiving unit. It should be noted that the forward connection refers to the connection of the RS485-a line and the RS485-a line, and the connection of the RS485-B line and the RS485-B line of the two communication parties, and the reverse connection refers to the connection of the RS485-a line and the RS485-B line, and the connection of the RS485-B line and the RS485-a line, and also refers to the forward and reverse plugging of the connector.
If the first serial port is configured to receive in the forward direction and the second serial port is configured to receive in the reverse direction, for example and without limitation, when the RS485 transceiver unit outputs a forward logic signal, the first serial port receives the forward logic signal, and the second serial port receives the reverse logic signal; on the contrary, when the RS485 transceiver unit outputs the reverse logic signal, the first serial port receives the reverse logic signal, and the second serial port receives the forward logic signal.
In addition, it should be noted that the communication identification byte is pre-stored data for identifying a serial port capable of receiving a forward signal from among the first serial port and the second serial port, for example, the communication identification byte may be Ox 01.
Therefore, in specific implementation, a preset check code may be added to the logic signal sent by the RS485 transceiver to the processing unit, for example, a CRC check code is added to a dock of the logic signal, and when the logic signal is a forward logic signal, the CRC check code is the same as the communication identification byte; on the contrary, when the logic signal is a reverse logic signal, the CRC check code is a complement code of the communication identification byte, so that the CRC check code of the logic signal received by the serial port is compared with the communication identification byte, and the current serial port receiving the forward signal in the first serial port and the second serial port can be determined.
For example, when the CRC check code of the logic signal received by the first serial port is the same as the communication identification byte, the first serial port is determined to be the serial port receiving the forward signal, and the first serial port is controlled to perform transceiving work and shield the second serial port; and when the CRC code of the logic signal received by the first serial port is the complement of the communication identification byte, analyzing whether the CRC code of the logic signal received by the second serial port is the same as the communication identification byte, if the CRC code of the logic signal received by the second serial port is the same as the communication identification byte, judging that the second serial port is the serial port receiving the forward signal, controlling the second serial port to carry out transceiving work, and shielding the first serial port.
In addition, it should be noted that in some optional embodiments, when it is determined that the CRC check code of the logic signal received by the first serial port is different from the communication identification byte, the logic signal received by the second serial port may not be analyzed, and the second serial port is directly determined as the serial port that receives the forward signal; meanwhile, since the first serial port and the second serial port are opposite, in other alternative embodiments, the logic signal of the second serial port may be analyzed first.
To sum up, communication method in the middle of this embodiment, come the signal of receiving the AB line simultaneously through setting up 2 serial ports, make no matter the AB line is just connecing or the transposition, can guarantee that one of them serial ports can receive the forward signal, in addition still set up the communication identification byte, come to discern the serial ports that can receive the forward signal with utilizing this communication identification byte, carry out data communication with the serial ports that can receive the forward signal of accurate selection, and shield another serial ports, thereby make the AB line just reverse blind plug can both normally realize data communication, need not to design special foolproof connector, simplify port structure and reduce cost.
Example two
Referring to fig. 3, a communication method according to a second embodiment of the present invention is shown, and the difference between the communication method according to the first embodiment of the present invention and the communication method according to the second embodiment of the present invention is that step S04 specifically includes:
step S041, judging whether the check code of the logic signal received by the second serial port is the complement code of the communication identification byte; when the check code of the logic signal received by the second serial port is judged to be the complement of the communication identification byte, executing step S042; and when the check code of the logic signal received by the second serial port is judged not to be the complement of the communication identification byte, executing step S043.
Step S042, controlling the first serial port to carry out transceiving work and shielding the second serial port;
and S043, shielding the first serial port and the second serial port.
In general, if the check code of the logic signal received by the first serial port is the communication identification byte, the check code of the logic signal received by the second serial port should be the complement of the communication identification byte; therefore, when the check code of the logic signal received by the second serial port is not determined to be the complement of the communication identification byte, the problems of signal disorder, RS485 transceiver unit failure and the like can be determined to occur currently, and in order to avoid the influence of the failure on the processing unit, in this embodiment, when the check code of the logic signal received by the first serial port is determined to be the communication identification byte, whether the check code of the logic signal received by the second serial port is the complement of the communication identification byte is also determined, and if yes, the first serial port is controlled to perform transceiving work and the second serial port is shielded; if not, the circuit is judged to be abnormal, and the first serial port and the second serial port are all shielded to discard data and avoid the processing unit from being influenced. When the first serial port and the second serial port are shielded for a certain time interval, the receiving can be recovered and the judgment can be carried out again, or when the problem occurs, the fault prompt mode can be sent to prompt the staff, so that the staff can timely remove the fault and reply the normal condition of both communication parties.
EXAMPLE III
Referring to fig. 4, a communication method in a third embodiment of the present invention is shown, which is applicable to a processing unit, where the processing unit is provided with a first serial port and a second serial port, and the communication method may be implemented by software and/or hardware, and specifically includes:
step S11, setting a communication identification byte;
step S12, controlling the first serial port and the second serial port to simultaneously receive the logic signal sent by the RS485 receiving and sending unit;
step S13, polling to determine whether the check code of the logic signal received by the first serial port is the communication identification byte; if the check code of the logic signal received by the first serial port is determined to be the communication identification byte, executing step S14; if the check code of the logic signal received by the first serial port is not determined to be the communication identification byte, step S15 is executed.
And step S14, controlling the first serial port to perform transceiving work and shielding the second serial port.
Step S15, determining whether the check code of the logic signal received by the second serial port is the communication identification byte; if the check code of the logic signal received by the second serial port is determined to be the communication identification byte, executing step S16; if the check code of the logic signal received by the second serial port is not the communication identification byte, step S17 is executed.
And step S16, controlling the second serial port to carry out transceiving work and shielding the first serial port.
And step S17, shielding the first serial port and the second serial port.
Generally, a check code of a logic signal received by one serial port is a communication identification byte in the first serial port and the second serial port, and if the check code of the logic signal received by the first serial port and the second serial port is not the communication identification byte, the problems of signal disorder, RS485 receiving and sending unit fault and the like can be judged to happen currently. And when the shielding interval between the first serial port and the second serial port is a certain time, the receiving can be recovered and the judgment can be carried out again.
Likewise, in some alternative embodiments, after determining that the logic signal received by the first serial port is the communication identification byte, the method further includes:
and shielding the first serial port and the second serial port when the check code of the logic signal received by the second serial port is judged to be the communication identification byte.
It should be noted that the above embodiments or features may be combined with each other without conflict.
Example four
Another aspect of the present invention further provides a communication device, please refer to fig. 5, which shows a communication device provided in the fourth embodiment of the present invention, which can be applied to a processing unit, where the processing unit is provided with a first serial port and a second serial port, and the communication device specifically includes:
a setting unit 11 for setting a communication identification byte;
the signal receiving unit 12 is used for controlling the first serial port and the second serial port to simultaneously receive the logic signal sent by the RS485 receiving and sending unit;
a polling determination unit 13, configured to determine whether a check code of a logic signal received by the first serial port is the communication identification byte by polling;
if the check code of the logic signal received by the first serial port is judged to be the communication identification byte, controlling the first serial port to carry out transceiving work and shielding the second serial port;
and if the check code of the logic signal received by the first serial port is judged not to be the communication identification byte, controlling the second serial port to carry out transceiving work and shielding the first serial port when the check code of the logic signal received by the second serial port is judged to be the communication identification byte.
It should be understood that when the RS485-a line and the RS485-B of the RS485 transceiver unit and the external device are connected in the positive direction, the differential signal received by the RS485 transceiver unit is a forward differential signal, and the forward differential signal is converted into a forward logic signal through the RS485 transceiver unit; on the contrary, when the RS485-A line and the RS485-B line of the RS485 transceiving unit and the external equipment are reversely connected, the differential signal received by the RS485 transceiving unit is a reverse differential signal, and the reverse differential signal is converted into a reverse logic signal through the RS485 transceiving unit.
If the first serial port is configured to receive in the forward direction and the second serial port is configured to receive in the reverse direction, for example and without limitation, when the RS485 transceiver unit outputs a forward logic signal, the first serial port receives the forward logic signal, and the second serial port receives the reverse logic signal; on the contrary, when the RS485 transceiver unit outputs the reverse logic signal, the first serial port receives the reverse logic signal, and the second serial port receives the forward logic signal.
In addition, it should be noted that the communication identification byte is pre-stored data for identifying a serial port capable of receiving a forward signal from among the first serial port and the second serial port, for example, the communication identification byte may be Ox 01.
Therefore, in specific implementation, a preset check code may be added to the logic signal sent by the RS485 transceiver to the processing unit, for example, a CRC check code is added to a dock of the logic signal, and when the logic signal is a forward logic signal, the CRC check code is the same as the communication identification byte; on the contrary, when the logic signal is a reverse logic signal, the CRC check code is a complement code of the communication identification byte, so that the CRC check code of the logic signal received by the serial port is compared with the communication identification byte, and the current serial port receiving the forward signal in the first serial port and the second serial port can be determined.
For example, when the CRC check code of the logic signal received by the first serial port is the same as the communication identification byte, the first serial port is determined to be the serial port receiving the forward signal, and the first serial port is controlled to perform transceiving work and shield the second serial port; and when the CRC code of the logic signal received by the first serial port is the complement of the communication identification byte, analyzing whether the CRC code of the logic signal received by the second serial port is the same as the communication identification byte, if the CRC code of the logic signal received by the second serial port is the same as the communication identification byte, judging that the second serial port is the serial port receiving the forward signal, controlling the second serial port to carry out transceiving work, and shielding the first serial port.
In addition, it should be noted that in some optional embodiments, when it is determined that the CRC check code of the logic signal received by the first serial port is different from the communication identification byte, the logic signal received by the second serial port may not be analyzed, and the second serial port is directly determined as the serial port that receives the forward signal; meanwhile, since the first serial port and the second serial port are opposite, in other alternative embodiments, the logic signal of the second serial port may be analyzed first.
Further, in some alternative embodiments of the present invention, the polling determining unit includes:
the complement determination module is used for determining whether the check code of the logic signal received by the second serial port is the complement of the communication identification byte;
if the check code of the logic signal received by the second serial port is judged to be the complement code of the communication identification byte, controlling the first serial port to carry out transceiving work and shielding the second serial port;
and shielding the first serial port and the second serial port if the check code of the logic signal received by the second serial port is judged not to be the complement of the communication identification byte.
Further, in some optional embodiments of the present invention, the communication device further includes:
and the first shielding unit is used for shielding the first serial port and the second serial port when the check code of the logic signal received by the second serial port is judged not to be the communication identification byte.
Further, in some optional embodiments of the present invention, the communication device further includes:
and the second shielding unit is used for shielding the first serial port and the second serial port when the check code of the logic signal received by the second serial port is judged to be the communication identification byte.
The functions or operation steps of the modules and units when executed are substantially the same as those of the method embodiments, and are not described herein again.
To sum up, communication device in the middle of this embodiment, come the signal of receiving the AB line simultaneously through setting up 2 serial ports, make no matter the AB line is just connecing or the transposition, can guarantee that one of them serial ports can receive the forward signal, in addition still set up the communication identification byte, come to discern the serial ports that can receive the forward signal with utilizing this communication identification byte, carry out data communication with the serial ports that can receive the forward signal in accurate selection, and shield another serial ports, thereby make the AB line positive and negative blind plug can both normally realize data communication, need not to design special connector of preventing slow-witted, simplify port structure and reduce cost.
EXAMPLE five
In another aspect of the present invention, referring to fig. 6, a communication circuit according to a fifth embodiment of the present invention is shown, which includes an RS485 transceiver unit and an MCU unit,
the RS485 receiving and transmitting unit converts the bus differential signal into a logic signal which can be identified by the MCU unit;
the MCU unit is connected with the RS485 receiving and transmitting unit and is provided with a first serial port and a second serial port, the first serial port and the second serial port simultaneously receive the logic signals, the logic signals are identified as positive phase signals or reverse phase signals by the first serial port, the logic signals are identified as reverse phase signals or positive phase signals by the second serial port, and the communication method of any one of the above embodiments is realized when the MCU unit executes a preset program.
Specifically, referring to fig. 6, a specific circuit diagram of an example of the communication circuit in the present embodiment is shown, in which the RS485 transceiver unit includes a processing chip U2, a pin 7 of the processing chip U2 is connected to a pin 1 of a connector P1 through an RS485-a line, a pin 6 of the processing chip U2 is connected to a pin 2 of a connector P1 through an RS485-B line, the connector P1 is used for plugging an external device, and pins 1 and 2 of the connector P1 are respectively connected to an RS485-a line and an RS485-B line of the external device. The processing chip U2 is used for receiving differential signals of external devices and converting the differential signals into logic signals recognizable by the MCU unit.
In addition, a first serial port and a second serial port of the MCU unit are arranged in parallel, the RX end and the DE end of the first serial port and the second serial port are respectively connected with two output pins 1 and 2 of a processing chip U2, the RX end and the DE end of the first serial port and the second serial port simultaneously receive logic signals output by the processing chip U2, in addition, the DE end of the first serial port and the DE end of the second serial port are also connected with an input pin 3 of the processing chip U2, so that the DE end of the serial ports also has a signal sending function, the other TX end of the first serial port and the second serial port is connected with an input pin 4 of the processing chip U2, the TX end of the serial ports also has a signal sending function, and therefore signal receiving and sending between the MCU unit and the processing chip U2 are achieved. In addition, the RS485 transceiver unit can further comprise a protection module connected between the processing chip U2 and the connector P1, wherein the protection module specifically comprises a first current limiting resistor R6 arranged on the RS485-A line, a second current limiting resistor R8 arranged on the RS485-B line, and a feedback resistor R7 connected between the RS485-A line and the RS485-B line.
Further, in some alternative embodiments of the present invention, as shown in fig. 8, the RX terminals of the first serial port and the second serial port may be connected to the output pin 1 of the processing chip U2 through the first signal isolation module, so as to perform signal isolation through the first signal isolation module. The first signal isolation module specifically comprises a first optical coupler signal isolator U1, a third current limiting resistor R4, a first pull-up resistor R2, a fourth current limiting resistor R3 and a second pull-up resistor R1, wherein an input end positive electrode pin 1 of a first optical coupler signal isolator U1 is connected with a 5V power supply through the first pull-up resistor R2, an input end negative electrode pin 2 of the first optical coupler signal isolator U1 is connected with an output pin 1 of a processing chip U2 through the third current limiting resistor R4, an output end positive electrode pin 4 of the first optical coupler signal isolator U1 is connected with a 3.3V power supply through the second pull-up resistor R1 and is connected with an RX end through the fourth current limiting resistor R3, and an output end negative electrode pin 3 of the first optical coupler signal isolator U1 is grounded.
Further, in some alternative embodiments of the present invention, the DE terminals of the first serial port and the second serial port may be connected to the output pin 2 and the input pin 3 of the processing chip U2 through a second signal isolation module, so as to perform signal isolation through the second signal isolation module. The second signal isolation module specifically comprises a second optical coupler signal isolator U3, a pull-down resistor R9 and a fifth current-limiting resistor R5, an input end anode pin 1 of the second optical coupler signal isolator U3 is connected with a DE end through the fifth current-limiting resistor R5, an input end cathode pin 2 of the second optical coupler signal isolator U3 is grounded, an output end anode pin 4 of the second optical coupler signal isolator U3 is connected with a 5V power supply, an output end cathode pin 3 of the second optical coupler signal isolator U3 is connected with an output pin 2 and an input pin 3 of a processing chip U2, and the output end cathode pin is grounded through a pull-down resistor R9.
Further, in some alternative embodiments of the present invention, the TX terminals of the first serial port and the second serial port may be connected to the input pin 4 of the processing chip U2 through a third signal isolation module, so as to perform signal isolation through the third signal isolation module. The third signal isolation module specifically comprises a third optical coupling signal isolator U4, a sixth current limiting resistor R13, a third pull-up resistor R11, a seventh current limiting resistor R12 and a fourth pull-up resistor R10, wherein an input end positive electrode pin 1 of a third optical coupling signal isolator U4 is connected with a 3.3V power supply through a third pull-up resistor R11, an input end negative electrode pin 2 of the third optical coupling signal isolator U4 is connected with a TX end through a sixth current limiting resistor R13, an output end positive electrode pin 4 of a third optical coupling signal isolator U4 is connected with a 5V power supply through a fourth pull-up resistor R10 and is connected with an input pin 4 of a processing chip U2 through a seventh current limiting resistor R12, and an output end negative electrode pin 3 of the third optical coupling signal isolator U4 is grounded.
When a signal is sent, enabling ends DE of the first serial port and the second serial port provide a high-level signal to a second optical coupling signal isolator U3, the high-level signal is optically coupled and isolated by a second optical coupling signal isolator U3 and then sent to an RE end and a DE end of a processing chip U2, so that the processing chip U2 works in a sending state, namely, the processing chip U2 can send the signal to an RS485 bus, and at the moment, the processing chip U2 can receive the signal of a DI end; the TX ends of the first serial port and the second serial port send high-level signals or low-level signals, the high-level signals or the low-level signals are transmitted to a DI port of a processing chip U2 after being optically coupled and isolated by a third optically coupled signal isolator U4, and differential signals are formed and transmitted to an RS485 bus through a A, B port after being processed by a processing chip U2;
when receiving signals, the enabling ends DE of the first serial port and the second serial port provide low-level signals to the second optical coupling signal isolator U3, the low-level signals are optically coupled and isolated by the second optical coupling signal isolator U3 and then are sent to the RE end and the DE end of the processing chip U2, so that the processing chip U2 works in a receiving state, namely, the processing chip U2 can receive signals transmitted by an RS485 bus, and at the moment, the processing chip U2 can send signals through RO; A. the B end receives the differential signal through the RS485 bus, converts the differential signal into a digital signal, sends the digital signal to the first optical coupling signal isolator U1 through the RO end, and sends the digital signal to the RX ends of the first serial port and the second serial port after being optically coupled and isolated by the first optical coupling signal isolator U1.
It should be noted that the configurations shown in fig. 6-8 are not limiting for the communication circuit, and in other embodiments, the communication circuit may include fewer or more elements than shown, or some elements may be combined, or a different arrangement of elements.
To sum up, communication circuit in the middle of this embodiment, come the signal of receiving the AB line simultaneously through setting up 2 serial ports, make no matter the AB line is just connecing or the transposition, can guarantee that one of them serial ports can receive the forward signal, in addition still set up the communication identification byte, come to discern the serial ports that can receive the forward signal with utilizing this communication identification byte, carry out data communication with the serial ports that can receive the forward signal in accurate selection, and shield another serial ports, thereby make the AB line positive and negative blind plug can both normally realize data communication, need not to design special connector P1 that prevents slow-witted, simplify port structure and reduce cost.
Those of skill in the art will understand that the logic and/or steps represented in the flowcharts or otherwise described herein, e.g., an ordered listing of executable instructions that can be viewed as implementing logical functions, can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. For the purposes of this description, a "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device.
More specific examples (a non-exhaustive list) of the computer-readable medium would include the following: an electrical connection (electronic device) having one or more wires, a portable computer diskette (magnetic device), a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium could even be paper or another suitable medium upon which the program is printed, as the program can be electronically captured, via for instance optical scanning of the paper or other medium, then compiled, interpreted or otherwise processed in a suitable manner if necessary, and then stored in a computer memory.
It should be understood that portions of the present invention may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application specific integrated circuit having an appropriate combinational logic gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or the like.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents and improvements made within the spirit and principle of the present invention are intended to be included within the scope of the present invention.

Claims (9)

1. A communication method, comprising the steps of:
setting a communication identification byte;
controlling the first serial port and the second serial port to simultaneously receive the logic signal sent by the RS485 receiving and sending unit;
polling to judge whether a check code of a logic signal received by the first serial port is the communication identification byte;
if yes, controlling the first serial port to perform transceiving work, and shielding the second serial port;
if not, controlling the second serial port to carry out transceiving work and shielding the first serial port when the check code of the logic signal received by the second serial port is judged to be the communication identification byte.
2. The communication method according to claim 1, wherein the step of controlling the first serial port to perform transceiving operation and shielding the second serial port specifically comprises:
judging whether the check code of the logic signal received by the second serial port is the complement of the communication identification byte or not;
if yes, controlling the first serial port to perform transceiving work, and shielding the second serial port;
and if not, shielding the first serial port and the second serial port.
3. The method of claim 1, further comprising, if the step of determining that the logic signal received by the first port is not the communication identification byte:
and shielding the first serial port and the second serial port when the check code of the logic signal received by the second serial port is judged not to be the communication identification byte.
4. The method of claim 1, further comprising, after determining that the logic signal received by the first port is the communication identification byte:
and shielding the first serial port and the second serial port when the check code of the logic signal received by the second serial port is judged to be the communication identification byte.
5. A communication device, the device comprising:
a setting unit for setting a communication identification byte;
the signal receiving unit is used for controlling the first serial port and the second serial port to simultaneously receive the logic signal sent by the RS485 receiving and sending unit;
a polling determination unit, configured to determine whether a check code of the logic signal received by the first serial port is the communication identification byte by polling;
if the check code of the logic signal received by the first serial port is judged to be the communication identification byte, controlling the first serial port to carry out transceiving work and shielding the second serial port;
and if the check code of the logic signal received by the first serial port is judged not to be the communication identification byte, controlling the second serial port to carry out transceiving work and shielding the first serial port when the check code of the logic signal received by the second serial port is judged to be the communication identification byte.
6. The communication apparatus according to claim 5, wherein the polling determination unit includes:
the complement determination module is used for determining whether the check code of the logic signal received by the second serial port is the complement of the communication identification byte;
if the check code of the logic signal received by the second serial port is judged to be the complement code of the communication identification byte, controlling the first serial port to carry out transceiving work and shielding the second serial port;
and shielding the first serial port and the second serial port if the check code of the logic signal received by the second serial port is judged not to be the complement of the communication identification byte.
7. The communication device of claim 5, further comprising:
and the first shielding unit is used for shielding the first serial port and the second serial port when the check code of the logic signal received by the second serial port is judged not to be the communication identification byte.
8. The communication device of claim 5, further comprising:
and the second shielding unit is used for shielding the first serial port and the second serial port when the check code of the logic signal received by the second serial port is judged to be the communication identification byte.
9. A communication circuit is characterized by comprising an RS485 receiving and transmitting unit and an MCU unit,
the RS485 receiving and transmitting unit converts the bus differential signal into a logic signal which can be identified by the MCU unit;
the MCU unit is connected with the RS485 receiving and transmitting unit and is provided with a first serial port and a second serial port, the first serial port and the second serial port simultaneously receive the logic signals, the logic signals are identified as normal phase signals or reverse phase signals by the first serial port, and the logic signals are identified as reverse phase signals or normal phase signals by the second serial port.
CN202110260095.0A 2021-03-10 2021-03-10 Communication method, device and communication circuit Pending CN113064849A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110260095.0A CN113064849A (en) 2021-03-10 2021-03-10 Communication method, device and communication circuit

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110260095.0A CN113064849A (en) 2021-03-10 2021-03-10 Communication method, device and communication circuit

Publications (1)

Publication Number Publication Date
CN113064849A true CN113064849A (en) 2021-07-02

Family

ID=76560365

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110260095.0A Pending CN113064849A (en) 2021-03-10 2021-03-10 Communication method, device and communication circuit

Country Status (1)

Country Link
CN (1) CN113064849A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114281738A (en) * 2021-12-29 2022-04-05 武汉中旗生物医疗电子有限公司 Serial port communication system and method

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104090511A (en) * 2014-06-30 2014-10-08 上海贝岭股份有限公司 Circuit and method for achieving non-polar 485 communication
CN109714235A (en) * 2019-01-18 2019-05-03 武汉光谷电气有限公司 A kind of nonpolarity RS485 communication interface and the method for realizing nonpolarity RS485 communication
US10892910B1 (en) * 2019-12-26 2021-01-12 Beijing Segrun Intelligence Technology Co., Ltd. Data transmission over wired networks

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104090511A (en) * 2014-06-30 2014-10-08 上海贝岭股份有限公司 Circuit and method for achieving non-polar 485 communication
CN109714235A (en) * 2019-01-18 2019-05-03 武汉光谷电气有限公司 A kind of nonpolarity RS485 communication interface and the method for realizing nonpolarity RS485 communication
US10892910B1 (en) * 2019-12-26 2021-01-12 Beijing Segrun Intelligence Technology Co., Ltd. Data transmission over wired networks

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114281738A (en) * 2021-12-29 2022-04-05 武汉中旗生物医疗电子有限公司 Serial port communication system and method

Similar Documents

Publication Publication Date Title
US8553578B2 (en) Automated protocol selection for host adapter card
US7715433B2 (en) Universal controller and signal monitor
TW469367B (en) Testing of USB hub
US20060200257A1 (en) Microprocessor system for a machine controller in safety-certifiable applications
KR20010062398A (en) Method for controlling option devices
WO2018001168A1 (en) Method and apparatus for managing main board card and backup board card
CN113064849A (en) Communication method, device and communication circuit
CN112988648A (en) Communication method, device and communication circuit
EP2161586A1 (en) Enhanced HDMI cable detection
US8588282B2 (en) Transmitting/receiving device and signal transmitting apparatus
CN110471878B (en) Method, device, equipment and storage medium for realizing blind plugging control of double TypeC interfaces
US8218672B2 (en) Differential data transceiver and method with reversed-wire immunity
US6810439B2 (en) System and method to monitor connections to a device
CN108737673B (en) Network telephone equipment, external connection card and communication method of network telephone equipment
CN211906270U (en) 485 device and RS485 interface of self-adaptation serial bus polarity
US11778072B2 (en) Control and data transfer system for supporting different communication protocols and an adapter module
CN213717215U (en) A Type-C data line and signal test system for signal switching device
CN219085413U (en) Embedded ATE equipment of PC
CN112118163B (en) System and method for energy and data transmission in an automation system
CN117215983B (en) Circuit structure and method for avoiding error starting and stopping conditions of I2C interface
CN215871361U (en) Signal conversion device and electronic equipment
CN111769863B (en) Relay method and relay board card for TPCM communication
CN112291128B (en) Bus-based communication system, system on chip and method therefor
US20230176954A1 (en) Usb integrated circuit, testing platform and operating method for usb integrated circuit
JP2701769B2 (en) Hot-swap method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination