A kind of novel RS-485 port failure detection and shielding system and method thereof
Technical field
The present invention relates to total line traffic control field, relate in particular to a kind of novel RS-485 port failure detection and shielding system and method thereof.
Background technology
RS-485 communicating circuit: be a kind of serial type communicating circuit; Adopt balance to send with the differential received mode and realize communication: transmitting terminal becomes differential signal A with the Transistor-Transistor Logic level conversion of signals of serial port; The output of B two-way is reduced into Transistor-Transistor Logic level signal at receiving terminal with differential signal through after the cable transmission.Because transmission line uses twisted-pair feeder usually, is again differential transfer, so the ability of extremely strong again anti-common mode disturbances, bus transceiver sensitivity is very high, can detect to be low to moderate 200mV voltage.So transmission signals all is to recover outside km.
MCU (Micro Control Unit) Chinese is a micro-control unit; Claim one chip microcomputer (Single Chip Microcomputer) or single-chip microcomputer again; Be meant appearance and development thereof along with large scale integrated circuit; CPU, RAM, ROM, timing number device and the multiple I/O interface of computer are integrated on a slice chip, form the computer of chip-scale, do various combination for different application scenarios and control common memory device.
Require communication distance be tens meters on during km, extensively adopt the RS-485 universal serial bus.Each bus can with a plurality of have have the RS-485 communicating circuit from node.Because all are attempted by on the bus from node, break down so work as a certain RS-485 communicating circuit from node, will have influence on the operate as normal of whole RS-485 network system.
Present RS-485 bus system all is to adopt a twisted-pair cable to make bus, and each node is parallel on the bus, therefore after the RS-485 of a certain node circuit breaks down, will cause the data communication of whole RS-485 communication network to break down.Which is breaks down from the RS-485 communicating circuit of node if want to find out, and must investigate each node one by one, and workload is huge.
Summary of the invention
The object of the present invention is to provide a kind of novel RS-485 bus system and use the method that it carries out fault detect and isolation, thereby solve the foregoing problems that exists in the prior art.
To achieve these goals, the technical scheme of the present invention's employing is following:
A kind of novel RS-485 port failure detects and shielding system, comprises the RS-485 bus and is connected in a plurality of from node on the said RS-485 bus; Saidly comprise RS-485 communicating circuit, MCU and relay from node; Said MCU is connected with said RS-485 communicating circuit with said relay respectively; Said relay is connected with said MCU, said RS-485 communicating circuit and said RS-485 bus respectively; Said RS-485 communicating circuit is connected with said RS-485 bus through said relay.
Preferably, said relay is two two normally closed relays of often opening.
Preferably; Two common pin of said relay link to each other with two lines of A, B of said RS-485 communicating circuit respectively; Two normally closed pins of said relay link to each other with two lines of A, B of said RS-485 bus respectively, often open pin and link to each other with the IO mouth of said MCU respectively for two of said relay.
Use said novel RS-485 port failure and detect the method for carrying out fault detect and isolation, may further comprise the steps with shielding system:
S1, said RS-485 communicating circuit is communicated with said RS-485 bus through said relay;
S2, said RS-485 bus every at a distance from the first Preset Time length to said a plurality of from node transmission particular data;
S3 if saidly do not receive said particular data from node after through the second Preset Time length, then breaks off said RS-485 communicating circuit and said RS-485 bus through said relay temporarily;
S4 saidly carries out the oneself from node and detects;
S5 is if testing result is recovered said RS-485 communicating circuit and is communicated with said RS-485 bus through said relay for normally then remove interim the disconnection; If said testing result is undesired then through said relay said RS-485 communicating circuit and said RS-485 bus is forever broken off, until it is overhauled.
Preferably, the said second Preset Time length is greater than the said first Preset Time length.
Preferably; S1 is specially: two common pin of said relay link to each other with two connections of said RS-485 communicating circuit respectively; Two normally closed pins of said relay link to each other with two connections of said RS-485 bus respectively, often open pin and link to each other with the IO mouth of said MCU respectively for two of said relay; Under the normality, the common pin of said relay is communicated with normally closed pin.
Preferably, S3 is specially:
If saidly in the second Preset Time length, do not receive said particular data, judge that then said communication from node and said RS-485 bus breaks down from node;
Said said MCU from node controls the said actuating of relay; The common pin of said relay and the normally closed pin of said relay are broken off; Be communicated with the pin of often opening of said relay simultaneously, said RS-485 communicating circuit is communicated with the IO mouth of said MCU through said relay.
Preferably, S4 is specially:
The IO mouth of said MCU is simulated a RS-485 signal and is sent to said RS-485 communicating circuit through said relay, if said RS-485 communicating circuit can correctly receive a said RS-485 signal, the Data Receiving of then said RS-485 communicating circuit is normal; Said RS-485 communicating circuit sends the 2nd RS-485 signal to said IO mouth, if said IO mouth can correctly receive said the 2nd RS-485 signal, the data of then said RS-485 communicating circuit are sent normal;
If the data of said RS-485 communicating circuit are sent and the Data Receiving of said RS-485 communicating circuit is all normal, then said self-testing result from node is normal;
If the data of said RS-485 communicating circuit are sent undesired or Data Receiving is undesired, then said self-testing result from node is undesired.
Preferably, S5 is specially:
If self-testing result is normal; Then said MCU controls the said actuating of relay; The common pin of said relay is communicated with the normally closed pin of said relay; The pin of often opening with said relay breaks off simultaneously, is communicated with said RS-485 bus through said relay thereby recover said RS-485 communicating circuit; If self-testing result is undesired, the state that then keeps the normally closed pin of common pin and the said relay of said relay to break off forever breaks off said RS-485 communicating circuit and said RS-485 bus, waits Awaiting Overhaul.
The invention has the beneficial effects as follows:
1. when communication failure appears in the RS-485 bus,,, just can't judge self whether to break down if can not break away from bus because all nodes all are parallel to the RS-485 bus.The RS-485 communicating circuit is through being that a relay links to each other with bus in the RS-485 circuit of the present invention, when communication failure occurring, can break off voluntarily earlier and being connected of RS-485 system bus, and carries out self check then.
2. make things convenient for the follow-up maintenance of system.When confirming it is after self breaks down, will no longer be connected with system bus from node, make that bus can operate as normal, under this prerequisite, bus is failed for a long time and this communicates from node, can inform that the staff overhauls from node this.With current RS-485 system, greatly saved maintenance personal's workload relatively.
Description of drawings
Fig. 1 is a RS-485 communicating circuit circuit diagram of the present invention;
Fig. 2 is relay of the present invention and the binding post circuit diagram that connects the RS-485 bus from node;
Fig. 3 is a MCU circuit diagram of the present invention.
Embodiment
Clearer for technical problem, technical scheme and beneficial effect that the present invention is solved, below in conjunction with accompanying drawing, the present invention is further elaborated.Should be appreciated that embodiment described herein only in order to explanation the present invention, and be not used in qualification the present invention.
Of the present inventionly can judge the RS-485 bus communication from node and whether occurred unusually; After judging communication abnormality; Can automatic disconnection and being connected of RS-485 system bus; And carry out data communication through self IO mouth and its RS-485 communicating circuit, can operate as normal thereby can detect the RS-485 communicating circuit.
If detect normally, then go up bus from being dynamically connected.If it is undesired to detect, then be not connected to bus, like this, those can not communicate with the host node of RS-485 bus from node, just explain that these break down from node, thereby can directly find out fault from node and keep in repair.
Of the present inventionly from node, use one twoly often to drive two normally closed relays, succeed two common pin of electrical equipment from two lines of A, B of the RS-485 communicating circuit of node respectively.The A of RS-485 bus, two lines of B are succeeded two normally closed pins of electrical equipment respectively, receive respectively from the IO mouth of the MCU of node and two of relay often leave pin.
During operate as normal, relay is failure to actuate, so be connected to the RS-485 bus from the RS-485 communicating circuit of the contact normally closed pin through relay, realizes the proper communication of data.
The RS-485 bus can regularly be sent certain data that provide to all nodes, when correctly not receiving these data within a certain period of time from node, just can conclude that bus communication breaks down.
This moment, the MCU control relay from node moved; The common pin of relay is changed into and often opens pin and be connected by being connected with normally closed pin; Thereby broken off from being electrically connected of node R S-485 communicating circuit and RS-485 bus, simultaneously being connected on the IO mouth of MCU from node R S-485 communicating circuit.
Utilize the IO mouth simulation RS-485 communication of MCU.IO simulation RS-485 signal sends to the RS-485 communicating circuit from node; If it is correct to receive data; Explain that then this Data Receiving from node R S-485 communicating circuit is normal; Send data to the IO mouth from node R S-485 communicating circuit then, if the data that the IO mouth receives are also correct, then explanation should be sent normal from node R S-485 communicating circuit data.
If judge from the RS-485 communicating circuit Data Receiving of node with send all correctly, then the RS-485 communicating circuit with this node is connected on the bus.
If judge from the RS-485 communicating circuit Data Receiving of node or send incorrectly, then no longer the RS-485 communicating circuit of this node is connected to bus.Thereby avoided this malfunctioning node that the data communication of whole RS-485 communication network is impacted.
Referring to accompanying drawing:
Fig. 1 is a RS-485 communicating circuit circuit diagram of the present invention; Fig. 2 is relay of the present invention and the binding post circuit diagram that connects the RS-485 bus from node; Fig. 3 is a MCU circuit diagram of the present invention.
Among Fig. 1 from A ', B ' two lines of the RS-485 communicating circuit of node be with Fig. 2 two common port pins of relay R L1 link to each other.Among Fig. 2, binding post P1 externally is a connected system RS-485 bus, internally is connected to normally closed pin A (2), the B (7) of two of relay R L1.The IO mouth P3.3 that two of relay R L1 often open the MCU from node (U3) among pin A " with B " and Fig. 3 links to each other with P3.4.
When system's operate as normal, P37 is a low level, and relay R L1 is failure to actuate.This moment, A ' linked to each other with A, and B ' links to each other with B.Promptly the RS-485 communicating circuit from node is connected with the RS-485 bus.
When from node in setting-up time, fail to receive specific data from the RS-485 bus, the P37 pin of MCU (U3) output high level then, relay R L1 action this moment, A ', B ' and A ", B " link to each other.
MCU is through sending one group of data and compare with these group data that these group data and MCU receive to P3.3 and P3.4 mouth from the RS-485 communicating circuit of node; MCU compares to these data that the RS-485 communicating circuit from node sends data and uses these data and MCU to receive through P3.3 and P3.4 mouth then; If the comparison of two secondary data is all correct; Think that then this RS-485 communicating circuit from node does not have fault, can be connected to the RS-485 bus.The P37 output low level of MCU resets relay, and promptly the RS-485 communicating circuit from node is connected with the RS-485 bus again.If the comparison of two secondary data is once wrong or the comparison of two secondary data is all wrong, then keeps from the RS-485 communicating circuit of node and the disengaged position of RS-485 bus, thereby guaranteed that malfunctioning node does not affect the communication of RS-485 system bus.Simultaneously, bus with should be from node can't communicate by letter for a long time after, can inform that this break down from node, need to overhaul.
The above only is a preferred implementation of the present invention; Should be pointed out that for those skilled in the art, under the prerequisite that does not break away from the principle of the invention; Can also make some improvement and retouching, these improvement and retouching also should be looked protection scope of the present invention.