日本語 English
KVKV-X

Digital filters

What Is a Digital Filter?

A digital filter is a signal processing technique for removing unwanted noise from a signal or extracting only specific frequency components. PLC analog input values often contain noise, and low-pass or notch filters make stable control and measurement possible.

Overview

This page introduces digital filter sample programs for the KEYENCE KV series and KV-X series.
Low-pass filters (LPF), high-pass filters (HPF), band-pass filters (BPF), notch filters and more are implemented as function blocks to remove noise from analog inputs and extract specific frequency components.
The waveforms and sample programs for each filter are published, so use them as a reference for signal processing and analog data analysis on PLCs.

Original waveform: 30 Hz sine wave with 500 Hz noise added

Original waveform

The original waveform contains a 30 Hz sine wave with 500 Hz noise
We apply the following 8 types of filters

Low-pass filter waveform

Low-pass filter

Cuts off frequencies above 100 Hz to remove noise

High-pass filter waveform

High-pass filter

Cuts off frequencies below 100 Hz to remove noise

Band-pass filter waveform

Band-pass filter

Passes one octave of frequencies around 30 Hz

Notch filter waveform

Notch filter

Removes one octave of frequencies around 30 Hz

Low-shelf filter waveform

Low-shelf filter

Amplifies frequencies below 100 Hz

High-shelf filter waveform

High-shelf filter

Amplifies frequencies above 100 Hz

Peaking filter waveform

Peaking filter

Amplifies one octave of frequencies around 30 Hz

All-pass filter waveform

All-pass filter

Shifts the phase around the cutoff frequency

Symbols

Input/output variables common to all functions

Input
In
Input value
SampFreq
Sampling frequency
Freq
Cutoff frequency
BandWidth
Bandwidth
gain
Gain
Output
Result
Result

The sampling frequency defaults to the task period of the executing task. For high-speed analog units that acquire multiple analog values per scan, enter the sampling frequency (Hz) according to the unit settings


LPF (low-pass filter)

A filter that passes frequencies below the cutoff frequency

LPF function block

HPF (high-pass filter)

A filter that passes frequencies above the cutoff frequency

HPF function block

BPF (band-pass filter)

A filter that passes only the bandwidth around the cutoff frequency
With a cutoff frequency of 30 Hz and a bandwidth of one octave, the range is 30/2 to 30×2, so 15 Hz to 60 Hz is passed

BPF function block

NotchF (notch filter)

A filter that passes everything except the bandwidth around the cutoff frequency
The opposite of BPF: everything except 15 Hz to 60 Hz is passed

Notch function block

LowShelfF (low-shelf filter)

A filter that amplifies frequencies below the cutoff frequency by the specified gain

LowShelf function block

HiShelfF (high-shelf filter)

A filter that amplifies frequencies above the cutoff frequency by the specified gain

HiShelf function block

PeekingF (peaking filter)

A filter that amplifies the bandwidth centered on the cutoff frequency by the specified gain

Peeking function block

AllPassF (all-pass filter)

A filter that changes only the phase around the cutoff frequency

AllPass function block

LPF (low-pass filter)

A filter that passes frequencies below the cutoff frequency

LPF function block

HPF (high-pass filter)

A filter that passes frequencies above the cutoff frequency

HPF function block

BPF (band-pass filter)

A filter that passes only the bandwidth around the cutoff frequency
With a cutoff frequency of 30 Hz and a bandwidth of one octave, the range is 30/2 to 30×2, so 15 Hz to 60 Hz is passed

BPF function block

NotchF (notch filter)

A filter that passes everything except the bandwidth around the cutoff frequency
The opposite of BPF: everything except 15 Hz to 60 Hz is passed

Notch function block

LowShelfF (low-shelf filter)

A filter that amplifies frequencies below the cutoff frequency by the specified gain

LowShelf function block

HiShelfF (high-shelf filter)

A filter that amplifies frequencies above the cutoff frequency by the specified gain

HiShelf function block

PeekingF (peaking filter)

A filter that amplifies the bandwidth centered on the cutoff frequency by the specified gain

Peeking function block

AllPassF (all-pass filter)

A filter that changes only the phase around the cutoff frequency

AllPass function block

References

Implementing simple digital filters (Japanese)

Download

* Operation on the KV-X was verified with the simulator

Comments