Advanced digital sensor example – Echelon Mini FX User Manual
Page 101

88 Developing
Device
Applications
Advanced Digital Sensor Example
The advanced digital sensor example expands the previous simple digital sensor and
advanced digital actuator examples by adding an implementation of the
SFPTopenLoopSensor functional profile to the first digital sensor example, and by
adding configuration property processing to the application algorithm.
While the advanced digital actuator example added SCPTlocation configuration
properties, this advanced digital sensor example adds a SCPTclOffDelay configuration
property, which controls the duration after which the switch automatically returns to the
Off position. Network integrators can set this configuration property to 0.1–6553.5s, or
to 0 to disable the auto-off feature. The SCPTclOffDelay configuration property is set
to 300s by default and by definition of the SCPT type.
The implementation supports the entire value range of SCPTclOffDelay, but it
implements a resolution of 1s.
The SCPTclOffDelay configuration property is applied to the output network variable,
which in turn implements the nvoValue member of the SFPTopenLoopSensor profile.
This differs from the advanced digital actuator example, which applied SCPTlocation to
the entire functional block,
Repeated activation of the SW1 pushbutton toggles the switch state (as before), if the
auto-off feature is disabled. If the auto-off feature is enabled (the default), repeated
activation of the pushbutton re-triggers the timer, thus implementing a stairwell light
switch.
#include "io.nc"
#pragma num_alias_table_entries 2 // required by compiler
//
// Output network variable and configuration property declaration
//
network input cp SCPTclOffDelay nciOffDelay;
network output SNVT_switch nvoSwitch nv_properties {
nciOffDelay
};
//
// Functional block
//
fblock SFPTopenLoopSensor {
nvoSwitch implements nvoValue;
} mySwitch;
//
// The auto off timer
stimer autoOffTimer;
void OnButtonPressed(void)
{
if (nciOffDelay) {
//
// We are in stairwell mode. Set switch to "On" and
// retrigger the autoOffTimer. The timer implements a
// 1s resolution, but any non-zero CP values should
// activate the auto-off feature, so we correct the
// value towards the next full second:
//
nvoSwitch.state = 1;
autoOffTimer = (nciOffDelay + 9ul) / 10ul;
} else {
//
// We are in normal 'toggle mode.' Toggle the switch