To improve the productivity of machines, designers and integrators look for ways to make them run smoother. But often real-world conditions pose problems along the way. For example, sensor feedback signals can be noisy, or the valves that are selected could pose a problem, making precise hydraulic control difficult. When the real world doesn’t “behave” smoothly, what do you do? 

If physical factors affect the smoothness or accuracy of machine operations, applying electronic filtering techniques can reduce output waste, accelerate production flow, and help machines last longer.

Simple electronic filtering
Just as hydraulic filters are used to remove unwanted particles from hydraulic oil, electrical filters made from discrete components or built into software or firmware are used to remove unwanted ‘noise’ from electronic signals. Filters can be of various types such as low pass, band pass or high pass, but this article will only cover the very basics of low pass filters that can easily be implemented in software in a PLC or motion controller. Most quality hydraulic motion controllers have built-in filters for different purposes.

Many hydraulic applications require a PLC or motion controller to control positions, speeds, pressures or forces. The control algorithms used for this purpose are dependent upon feedback devices that provide up-to-date information on the current state of the system so the controller can do precise closed-loop control. If the feedback signals transmit unwanted variations, then the control loop may produce unwanted variance in its output, which can cause a machine to exhibit unwanted motion. Many causes exist for noisy inputs coming from feedback devices, and some of the most prevalent ones are discussed in this article.

Noise or non-linearity
“Noise” can be true process noise, as in flow noise. But noise usually is not truly noise, but nonlinearities in the feedback system due to sample quantizing and jitter, discussed below. Most control systems are digital, so continuous analog data are converted to quantized digital numbers. The controllers use the digital information to estimate the true analog values. This is like using stairs to simulate a ramp. If there are many steps, then elevation change of each step is small. The more steps there are, the better the stairs approximate a true ramp, and the difference between the elevation anywhere along the stairs and the ramp become smaller and smaller.

Using higher-resolution feedback approximates the ramp in smaller steps. It is good to use the highest resolution feedback available to minimize the quantization error between the steps and the ramp.  Older PLCs may have only 12- or 14-bit feedback, whereas most new control systems and motion controllers have 16-bit feedback and some have over-sampling which can deliver one or two additional bits of resolution.

Sample jitter

Another source of ‘noise’ is sample jitter. It is caused by sampling at irregular intervals and affects rate of change estimates of a sensor value, such as counts from an encoder. For instance, a conveyor may be moving at 10 counts every 10 msec. However, if a PLC samples every 10 msec on average, but has a sample jitter of 1 msec, then the time between samples may be 9, 10, or 11 msec. This can result in a change in the encoder counts of 9, 10, or 11 counts, which represents a variation of 10%. Many PLCs provide interrupts to service I/O devices but often disable the interrupts during computer housekeeping operations, which can cause encoder counts to be missed or misused. The best way to eliminate sample jitter is to read the encoder using a chip that can latch the counts at fixed intervals without the need for software, such as in a motion controller. It is also important to select a controller with a consistent or repeatable cycle time fast enough to read the latched values in time to process these values and produce valid control outputs.

Both quantizing and jitter make it difficult to compute the derivative of digital data. For example, encoder counts in motion control are used to compute a position and velocity, and in some cases they are also used to compute acceleration. Because the encoder position changes in steps, the computed velocity also changes in steps  — and the acceleration changes in even bigger steps that are usually so large that the acceleration values calculated from the encoder data alone are not usable without some type of smoothing. A common question is how to compute linear or angular velocity from feedback provided by an encoder. This doesn’t look too hard at first, but complaints often arise that the computed velocity jumps around or isn’t stable. This really means that filtering must be applied.

The ideal low-pass filter
Low-pass filters are designed to eliminate high-frequency variations in signal data that would otherwise cause unintended fluctuations in control outputs. The ideal low-pass filter is one that eliminates all noise above a desired cutoff frequency. The-low pass filter doesn’t modify signal below the cutoff frequency and has no phase delay between the incoming signal and the filtered output.

In the reality of the physical world, however, the ideal filter doesn’t exist. Typically, the filtering effect of real-world filters starts to work gradually, and then more aggressively as the frequency approaches and exceeds the desired cutoff frequency. The filter usually causes some attenuation and phase delay starting before the cutoff frequency. The amount of signal attenuation and phase lag depends on the type of filters used.

Simple low-pass filters
The most common filter is the single-pole low-pass filter. The general form of the low pass filter is:

yn = A yn–1 + B xn                               (1)

Sometimes this formula is implemented as

yn = yn–1 + B (xnyn–1)                      (2)

Where xn is the input to be filtered,

yn is the new filtered value,

yn–1 is the previous filtered value,

xn is the input value to be filtered, and

A and B are coefficients that are determined by the cutoff frequency or the filter time constant. The sum of A and B should equal 1.

A = e–∆t/t                     (3)

A= evt                      (4)

B = 1 – A                    (5)

Where ∆t is the update period,

t is the filter time constant, and

w is the cutoff (corner) frequency in radians/sec. Again, the sum of A and B should equal 1. Equation 5 ensures this is so.

Most people use Equation 2 and simply adjust Buntil they obtain the best results. Rather than thinking about what frequencies they want to eliminate, they choose a cutoff frequency and finally calculate B, which will usually be less than 0.5. The smaller the number, the smoother the output from the filter, but at the cost of signal phase delay. For a simple low-pass filter, the attenuation is -3 dB, or 0.707 of the original signal, and the phase delay is 45° at the cutoff frequency. The approximately 30% reduction at the cutoff frequency isn’t much, but the attenuation does increase that rapidly at higher frequencies. Plotted on a logarithmic scale, the attenuation is only -20 dB per decade — or a factor of 10 for every 10 times increase in the frequency.

Sometimes it is more convenient to think in terms of a time constant instead of a cutoff frequency. If the input signal makes a step change, it takes five time constants for the filtered value to be within 1% of the input signal.

Simple low-pass filters are easy to implement, but they aren’t very effective at filtering unless the filter time constant is relatively long or the corner frequency is relatively low. The corner frequency occurs where an input signal power is cut down by a factor of about 0.708 and is the frequency at which the signal power is attenuated by 3 dB. Typically, power is reported in dB. In a low-pass filter, the frequency region below the corner frequency is called the pass band, whereas the region above is called the stop band.

One drawback to low-pass filters is that the longer the filter time constant, or the lower the cutoff frequency, the larger the phase delay, which refers to the time lag in control signal propagation caused by the filtering process itself. Phase delay can cause problems with stability in motion control applications.