How to Filter Digital Inputs in PLC?

 When dealing with digital signals in a Programmable Logic Controller (PLC) system, the signals may be subject to noise, interference, or other unstable factors. Therefore, appropriate filtering methods need to be employed to ensure the stability and reliability of the system.

Filtering is a method used to eliminate unwanted spikes in the received signals within the PLC. Its purpose is to smooth out fluctuations and only pass appropriate signal changes to the PLC at specific times. Within the PLC, there is typically a filtering circuit followed by input processing circuitry, which receives the filtered input and applies it to its logic.

Digital signals typically represent two states, "0" and "1," such as switches, sensor outputs, etc. However, due to environmental factors and limitations of signal acquisition devices, digital signals may experience jitter, interference, or sudden changes, which can lead to system misjudgments or unstable operation.


Common Digital Signal Filtering Methods

  1. Hardware Filtering

Hardware filtering typically involves using electronic components such as RC circuits, filter chips, etc., to process signals and suppress high-frequency noise or remove interference.

  1. Software Filtering

Software filtering, on the other hand, involves processing digital signals in the PLC program using algorithms that define filtering based on time factors. Let's say you set a filtering time of 3 seconds. The role of the filter is to only accept input changes that occur over 3 seconds. If an input changes occurred within the last 3 seconds, the input will not be activated, and the input change will be ignored. This means that short-duration and high-frequency interference pulses will be disregarded.


Case Background:

In a factory's automated production line, sensors are employed to monitor the thickness of materials. However, the digital signals outputted by these sensors are susceptible to factors like vibration, electromagnetic interference, and unevenness in the materials, which result in signal instability.


Solution:

The engineer addressed this issue by employing software filtering, implementing a time-based filtering scheme within the PLC program. As depicted in the diagram below, the signal is only considered valid (highlighted in green) if the duration of the digital input signal exceeds 5 seconds. Otherwise, it is deemed invalid (highlighted in red).

Input IX is for raw input,

IEC_Timer_0_Instance is for delay-on timer,

Output QX is for filtered output, program as shown in the following diagram:


Only when the input IX maintains a high level for more than 5 seconds will QX produce an output. The input will only pass its changes to the processing section when it maintains a high-level state within the set time. The PT time factor determines the filtering level. The higher the time factor value, the higher the filtering capability, but the greater the delay.

Case Effect:

After filtering, the stability of the sensor output signal has significantly improved. The system's accuracy and stability in determining material thickness have been significantly enhanced, greatly reducing the probability of misjudgment.

Conclusion:

When dealing with digital signals in PLCs, filtering is a crucial step to ensure the stable operation of the system. Engineers can choose suitable filtering methods based on actual circumstances and combine hardware and software approaches to enhance the system's resistance to interference, ensuring the stability and reliability of digital signals.

Through the introduction and case analysis in this article, readers should have gained a deeper understanding of filtering digital signals in PLCs and be able to apply filtering techniques more flexibly to solve relevant problems in practical engineering applications.

Like my work? Consider a donation! 👇