Sensors
Interfaces
I_DigitalSensorBase
Properties
Property |
Type |
Access |
Description |
Active |
BOOL |
RO |
Get the current state of the sensor |
DebounceMode |
E_DebounceMode |
RW |
Get/Set the filter to be applied to sensor input |
DebounceTime |
TIME |
RW |
Get/Set filter time to be used by DebounceMode |
Inverted |
BOOL |
RW |
Get/Set if output of sensor should be inverted with respect to its input |
SimulationInput |
BOOL |
RW |
Get/Set signal to use when component is in simulation mode |
SimulationMode |
E_SensorSimulationMode |
RW |
Get/Set type of simulation to be used in simulation mode |
TimeActive |
TIME |
RO |
Get time elapsed since last inactive state |
TimeInactive |
TIME |
RO |
Get time elapsed since last active state |
Function Blocks
FB_DigitalSensor
| FUNCTION_BLOCK FB_DigitalSensor EXTENDS FB_ComponentBase IMPLEMENTS I_DigitalSensorBase
|
Basic digital input processor for digital signals. Includes locally-defined HardwareInput AT %I* : BOOL
for linking to hardware.
DUTs
E_DebounceMode
| TYPE E_DebounceMode : (
RawInput,
SimpleFlickerFilter,
EdgeDetectFilter,
MovingAverage
) DINT;
END_TYPE
|
E_SensorSimulationMode
| TYPE E_SensorSimulationMode : (
InputDriven, //Follows the state of the SimulationInput property
Periodic //Follows a 50% duty cycle at the period specified in ms by SimulationInput);
);
END_TYPE
|
ST_DigitalSensor_HMI
| TYPE ST_DigitalSensor_HMI :
STRUCT
Config : ST_DigitalSensor_Config;
Command : ST_DigitalSensor_Command;
Status : ST_DigitalSensor_Status;
END_STRUCT
END_TYPE
|
ST_DigitalSensor_Command
| TYPE ST_DigitalSensor_Command :
STRUCT
END_STRUCT
END_TYPE
|
ST_DigitalSensor_Config
| TYPE ST_DigitalSensor_Config :
STRUCT
//Status information
DebounceMode : E_DebounceMode;
DebounceTime : TIME;
Inverted : BOOL;
SimulationMode : E_SensorSimulationMode;
SimulationTimebase : UINT;
END_STRUCT
END_TYPE
|
ST_DigitalSensor_Status
| TYPE ST_DigitalSensor_Status :
STRUCT
Active : BOOL;
TimeActive : LREAL;
TimeInactive : LREAL;
END_STRUCT
END_TYPE
|
Examples
E_DebounceMode.EdgeDetectFilter

The blue line represents the hardware input which bounces both when rising and falling. The green line is the output of the filter which detects the initial change and then ignores the bounces for the duration specified by DebounceTime
. This is useful for preventing a 'double-tap' that could occur when a button is pressed.
E_DebounceMode.SimpleFlickerFilter

The blue line represents the hardware input which bounces both when rising and falling. The green line is the output of the filter which monitors the input and only changes state when the input has been stable for the time specified by DebounceTime
. This is useful for preventing false triggers from noise, dust or other rapid changes in the input signal.