Summary of the invention
The object of this invention is to provide the sensing data transmission system failure monitoring method based on Ethernet, the method takes counter-measure for the various faults that may occur in data transmission procedure, monitoring data transmission fault, improves the reliability of transfer of data.
In order to achieve the above object, technical scheme of the present invention there is provided a kind of sensing data transmission system failure monitoring method based on Ethernet, this sensing data transmission system comprises the host computer as client computer, host computer reads as the data in the data acquisition module of server or A/D module, the controller as server is re-send to after process, it is characterized in that, take triple surveillance and control measure: connect fault for each server, in host computer, design trap routine judge whether host computer connects with each server; For data distortion fault, in host computer, design detects data and beats whether range program to detect host computer data streams read scope of beating excessive, judges data whether distortion; For data transmission failure, design house dog program in the controller, monitoring data transmission state, in a transmission cycle, is embodied as:
Read in each server data process at host computer, successively: judge whether host computer connects with each server, whether reads the data of each server designated space by the trap routine designed in host computer; The threshold value whether host computer data streams read scope of beating exceed setting is detected by the detection data designed in host computer range program of beating; Send in data procedures at host computer to controller, successively: judge whether host computer connects with controller by the trap routine designed in host computer; Host computer is judged whether to the designated space write data of controller by the house dog program designed in controller.
Preferably, the specific implementation step of described trap routine is:
Define the Socket socket corresponding to connecting each server process and trap tag, at the last sentence of connection server statement, trap tag is set to state A, trap tag is set to state B by latter one at connection server statement; In trap routine implementation, if connection server success, then, after executing connection server statement, trap tag will be set to state B; If connection server is unsuccessful, then connection server statement can not normally perform, and trap tag then remains state A, and jumps to trap dispose part, and in trap handler, if trap tag is state A, then exporting can not connection server failure warning.
Preferably, in host computer, detect the concrete steps whether its data streams read scope of beating exceed setting threshold is:
Sampled value after current read data filtering is compared with last filter value, when detect higher than setting ratio the filtered sampled value of current data away from last filter value time, then decision data scope of beating is excessive, has occurred the faults such as the unstable or electromagnetic interference of power supply; Host computer, once detect that data scope of beating is excessive, just stops sending data to controller, abandons the sampled value after current read data filtering, export warning, and again read data.
Preferably, the specific implementation step of described house dog program is:
Select a register in controller data holding register district as status register, host computer sends in data procedures to controller, the data of a multi-embedding word are sent to status register in a data frame, this status register alternately changes between two different states, according to two different states, start two timers respectively, the timing of timer is greater than the cycle of a transfer of data; In transfer of data under normal circumstances, the state of status register alternately changes, and two timers also will alternately be started and stop thereupon, and the timing due to timer is greater than the cycle of a transfer of data, and two timers can not arrive its timing; If the timing of any one timer arrives, all the state for extended periods of description status register does not change, and controller does not receive data from host computer for a long time, can judge that transfer of data breaks down, a transfer of data fault flag connected by controller, and carries out corresponding actions.In the timing of timer, the state of status register changes, and controller still normally works, and ensures that controller has fault-tolerance to data transmission failure in time.
The present invention adopts the advantage of above technical scheme to be:
(1) according to designed data transmission failure monitoring main program flow, host computer complete monitoring data transmission state can be ensured.
(2) arrange trap routine for connection server process, according to trap tag state, can judge can not connection server fault export warning.Owing to being provided with trap tag respectively for each server process of connection, when occurring connecting fault, program accurately can be located connection fault.
(3) before host computer sends data to controller, detect the scope of beating of host computer data streams read, once data are beated, scope is excessive, just stops sending data to controller, avoids controller to carry out malfunction according to misdata and causes a serious accident.
(4) design of software watchdog program in controller, ensure that the identification of controller to data transmission failure, and has fault-tolerance to data transmission failure in time, avoid each data transmission failure controller and all will shut down.
(5) employing of triple surveillance and control measure, can detect data transmission failure timely and effectively, substantially increases the reliability of transfer of data.
Embodiment
For making the present invention become apparent, hereby with preferred embodiment, and accompanying drawing is coordinated to be described in detail below.
As shown in Figure 1, the data in the A/D module that controller such as host computer reading data acquisition module or PLC etc. carries, re-send in the controllers such as PLC after process system global structure of the present invention.
As shown in Figure 2, host computer is in a transmission cycle, and a point double teacher judges transmission fault for data transmission failure monitoring main program flow.Read in data procedures, first judge whether host computer is successfully connected with each data acquisition module and PLC, next judges whether the data reading designated space; After data processing, judge that whether data scope of beating is normal; Send in data procedures, first judge whether host computer connects with PLC, next judges whether to designated space write data.Find fault in any stage, host computer all exports warning, and turns back to initial position and again read data.
Under VB environment, design trap routine, first define and be connected the corresponding Socket socket of each server (comprising data acquisition module and PLC) process and trap tag, then socket connection server statement Connect (" IP address ", port numbers) last sentence trap tag is arranged a state, as set to 0, then trap tag is modified as another state, as put 1 by latter one of then connection server statement.In program process, if connection server success, after executing connection server statement, trap tag will be set to 1; If connection server is unsuccessful, connection server statement can not normally perform, and trap tag is put 1 statement and can not be performed, and trap tag state will remain 0.On Error GoTo statement is used at program the beginning part, occurring in program process can not connection server mistake, and program will jump to the trap dispose part of specifying, in trap handler, according to trap tag state, output can not connection server failure warning.Arrange trap tag respectively for each server process of connection, when occurring connecting fault, program accurately can be located connection fault.
Power supply shakiness or electromagnetic interference can make multiple sensing data distortion simultaneously, detect data and beat range program according to this feature detection.The data processing of main program comprises data filtering, sampled value after current read data filtering is compared with last filter value, when detect higher than 70% the filtered sampled value of current data away from last filter value time, decision data scope of beating is excessive, has occurred the faults such as the unstable or electromagnetic interference of power supply.Host computer, once detect that data scope of beating is excessive, just stops sending data to PLC, abandons the sampled value after current read data filtering, export warning, and turns back to main program initial position and again read data.
As shown in Figure 3, select a register in plc data holding register district as status register, selected D1 in figure 3, its state is as the logical condition of PLC identification data transmission fault for software watchdog programming ladder diagram.Host computer sends in data procedures to PLC, and the data of a multi-embedding word are sent to status register selected in PLC in a data frame, alternately change the state of this register, such as, replace transmission 0000 and FFFF.PLC is according to two different states, and start two timers respectively, the timing of timer is greater than the cycle of a transfer of data.Under normal circumstances, the state of this status register alternately changes transfer of data, and two timers also will alternately be started and stop thereupon, and the timing due to timer is greater than the cycle of a transfer of data, and two timers can not arrive its timing.Any one timer arrives, all the state for extended periods of description status register does not change, and PLC does not receive data from host computer for a long time, can judge that transfer of data breaks down, PLC connects a transfer of data fault flag, and carries out corresponding actions.In the timing of timer, the state of status register is changed; even if there is data transmission failure in this process; PLC also can not carry out corresponding actions; but normally work; ensure that PLC has fault-tolerance to data transmission failure in time, avoid each data transmission failure PLC all will shut down.