Anti interference design of the most explosive con

  • Detail

Anti interference design of industrial control software

when the computer system is used in the industrial field, although a large number of interference sources cannot cause damage to the hardware system, they often make the computer system unable to operate normally, resulting in control failure and major accidents. The anti-interference of computer system, which is the main structure of computer testing machine, cannot be completely solved by hardware. Therefore, the research on software anti-interference has attracted more and more attention

first, the structural characteristics and interference ways of industrial control software

in different industrial control systems, although the functions completed by industrial control software are different, its structure generally has the following characteristics:

real time: some events in industrial control systems have randomness, which requires industrial control software to deal with random events in time

periodicity: the industrial control software enters the main program cycle after completing the initialization of the system. In the process of executing the main program, if there is an interrupt application, continue the main program cycle after executing the corresponding interrupt service program

relevance: industrial control software is composed of multiple task modules, which work together, are interrelated and interdependent

artificial: industrial control software allows operators to intervene in the operation of the system and adjust the working parameters of the system. Ideally, the industrial control software can be executed normally. However, under the interference of the industrial field environment, the periodicity, relevance and real-time of the industrial control software are destroyed, and the program cannot be executed normally, resulting in the loss of control of the industrial control system. Its performance is:

the PC value of the program counter changes, which destroys the normal operation of the program. The data after the PC value is disturbed is random, which causes the program execution confusion. Under the wrong guidance of the PC value, the program executes a series of meaningless instructions, and finally often enters a meaningless dead cycle, making the system out of control

the state of the input/output interface is disturbed, which destroys the relevance and periodicity of the industrial control software, causing the system resources to be monopolized by a task module, causing the system to deadlock

the error of data acquisition increases. Interference invades the forward channel of the system and superimposes on the signal, resulting in increased data acquisition error. Especially when the current sensor interface to the channel is a small voltage signal input, this phenomenon is more serious

ram data area changes due to interference. According to the different interference channels and the nature of the disturbed data, the system is damaged in different conditions, some of which cause numerical errors, some make the control fail, some change the program state, and some change the working state of some components (such as timer/counter, serial port, etc.). When developing the remote meter reading system of electric power, the author has encountered the situation that RAM data is often destroyed due to strong electromagnetic interference on site

control state failure. In industrial control system, the output of control state is often determined by the input of some conditional States and the logical processing results of conditional states. In these links, due to the intrusion of interference, the condition state error will be caused, resulting in the increase of output control error, and even the control malfunction

second, the software countermeasures for the abnormal operation of the program

the system is disturbed, causing the PC value to change, causing the abnormal operation of the program. The software countermeasure for the abnormal operation of the program is to guide the system to restore the original state in time after finding the abnormal state

1. Set the monitoring and tracking timer

use timed interrupt to monitor the running state of the program. The timing time of the timer is slightly longer than the normal operation of the main program for a cycle, and the timer time constant refresh operation is performed once during the operation of the main program. In this way, as long as the program runs normally, the timer will not be interrupted. When the program runs abnormally and cannot refresh the timer time constant in time, which leads to timing interruption, the system is reset by using the timing interruption service program. As an example of software anti-interference in 8031 application system, the specific method is:

use the overflow signal generated by the timer of 8155 as the external interrupt source INT1 of 8031. 555 timer is used as the external clock input of timer in 8155

8155 the timer timing value is slightly greater than the normal cycle time of the main program

in the main program, refresh the timing constant of 8155 timer every cycle

at the beginning of the main control program, classify and judge whether the automatic recovery caused by hardware reset or timing interruption is handled

2. Set software trap

when the PC is out of control, causing the program to fly disorderly and continue to enter the non program area, as long as the interception measures are set in the non program area to make the program enter the trap, and then force the program to enter the initial state. For example, the data FFH in the Z80 instruction system exactly corresponds to the restart instruction RST 56, which automatically transfers the program to the 0038h entry address. Therefore, in the application system composed of Z80 CPU, as long as all non program areas are set to FFH to intercept out of control programs. And set the transfer instruction at 0038h to transfer the program to the anti-interference processing program

III. software countermeasures for system deadlock

in industrial control systems, input/output interface circuits such as a/d, d/a, and display are essential. These interfaces and the CPU work in the way of query or interrupt, and these devices or interfaces are very sensitive to interference. Once the interference signal destroys the status word of an interface, it will cause the CPU to mistakenly believe that the interface has input/output request and stop the current work, and then transfer to execute the corresponding input/output service program. However, because the interface itself has no input/output data, the CPU resources are occupied by the service program for a long time without release, and other task programs cannot be executed, resulting in deadlock of the whole system. The deadlock caused by this interference can be solved by the method of time slice in software programming. The specific steps are:

allocate the corresponding maximum normal input/output time according to the time requirements of different input/output peripherals

add the corresponding timeout judgment program to each input/output task module. In this way, when the interference destroys the state of the interface and causes CPU misoperation, the system will automatically return from the service program of the peripheral after a certain period of time, because the prepared information of the peripheral is invalid for a long time, so as to ensure that the periodicity of the whole software is not affected, so as to avoid deadlock

IV. software countermeasures for data acquisition errors

according to the different nature of data interference and interference consequences, the software countermeasures adopted are different, and there is no fixed mode. For the real-time data acquisition system, in order to eliminate the interference signal in the sensor channel, the active or passive RLC network is often adopted in the hardware measures to form an analog filter to realize the frequency filtering of the signal. Similarly, using the operation and control functions of CPU can also realize frequency filtering and complete similar functions of analog filter, which is digital filtering. There are special discussions in many monographs on digital signal processing, which can be referred to. With the improvement of computer operation speed, digital filtering will be more and more widely used in real-time data acquisition system. In general data acquisition system, some simple numerical and logical operations can be used to achieve the effect of filtering. Here are some common methods

1. The arithmetic mean method

can use 10 years

to continuously sample a point of data for many times, calculate its arithmetic mean value, and take its mean value as the sampling result of the point. This method can reduce the influence of random interference of the system on the acquisition results. Generally, it is enough to average 3 ~ 5 times

2. Comparative trade-off method

when there is deviation in the individual data of the measurement results of the control system, in order to eliminate the individual wrong data, the comparative trade-off method can be used, that is, each sampling point can be sampled several times continuously, and the trade-off is determined according to the change law of the collected data, so as to eliminate the deviation data. For example, take two out of three, that is, take three consecutive samples at each sampling point, and take the same data twice as the sampling result

3. Median method

according to the situation that the sampling data is too large or too small caused by interference, multiple signals are continuously collected at a sampling point, and these sampling values are compared, and the median value is taken as the sampling result of the point

there is also a complete set of evaluation system4 First order recursive digital filtering method

this method uses software to complete the algorithm of RC low-pass filter, and realizes the replacement of hardware RC filter with software method. The formula of the first-order recursive digital filter is yn=q, because the single-chip computer is used to control xn+ (1-Q) yn-1, in which Q - the time constant of the digital filter; Xn - filter input at the nth sampling; Yn - filter output at the nth sampling. Using software filter to eliminate the error in data acquisition can obtain satisfactory results. However, it should be noted that the method selected should be selected according to the change law of the signal

v. software countermeasures for RAM data errors

in the process of real-time control, one of the more serious hazards caused by interference is to destroy the data in RAM. Because all kinds of original data, signs, variables, etc. are stored in RAM, if destroyed, it will cause system errors or inability to operate. According to the degree of data destruction, it can be generally divided into three categories:

* the whole ram data is destroyed

* a piece of data in RAM is destroyed

* individual data is destroyed

in the industrial control system, most of the contents of RAM are temporarily stored for analysis and comparison, and only a small part of the data that is not allowed to be lost. In this case, in addition to these data that are not allowed to be lost, most of the other contents are allowed to be destroyed in a short time, which only causes a very short-term fluctuation of the system at most, and can automatically return to normal soon. Therefore, in industrial control software, as long as we pay attention to the protection of a few data that are not allowed to be lost, the commonly used methods are verification method and standard setting method. These two methods have their own merits. The verification method is relatively complicated, but the reliability of error checking is high. The marking method is simple, but it is not difficult to check the error of individual data in the data sheet. Generally, it should be used comprehensively in programming. The specific method is:

* set a flag code of 0 or 1 at the beginning and end of the important area of ram working area respectively

* set the check word for the fixed data table in RAM

during the execution of the program, check whether each flag code is normal through the pre-designed error checking program at regular intervals. If it is abnormal, use data redundancy technology to correct it through anti-interference processing program; The general design principle of redundant data tables is:

* each data table should be set away from each other, so as to reduce the probability of redundant data being destroyed at the same time

* the data table should be as far away from the stack area as possible to reduce the possibility that the stack is flushed with data due to operation errors

the above recovery processing method for RAM area should be selected according to the specific situation in different application systems

VI. software countermeasures for abnormal control state

in the condition control system, people pay attention to whether the normal control state can be ensured. If the interference enters the system, it will affect various control conditions and cause control output errors. In order to ensure the safety of the system, the following software anti-interference measures can be taken:

1 Software redundancy

for the condition control system, the primary sampling and processing control output of the control conditions are changed into cyclic sampling and processing control output. This method has good

Copyright © 2011 JIN SHI