Digital sensor and actuator examples, Simple digital sensor – Echelon Mini FX User Manual
Page 98

Mini FX User's Guide
85
• The example device applications presented in this section are not considered
interoperable mainly because they do not include a Node Object functional block. For
examples of interoperable device applications that are more complex, see the FT 5000
EVB examples or Mini FX/PL examples included with the Mini kit.
o
To view the source code for the FT 5000 EVB examples click Start, point to
Programs, pointing to Echelon Mini, point to Examples, point to FT 5000
EVB, click the desired Example Source Code folder, and then click the Source
folder. For more information on the FT 5000 EVB examples, see the FT 5000
EVB Examples Guide.
o
To view the source code for the Mini FX/PL examples click Start, point to
Programs, pointing to Echelon Mini, point to Examples, point to Mini EVB,
and then click the desired Example Source Code folder. For more information
on the FT 5000 EVB examples, see the Mini FX/PL Examples Guide.
Digital Sensor and Actuator Examples
The digital sensor and actuator examples creates a simple device which can sense a
switch, and drive an output network variable to reflect the switch’s on/off position. The
physical implementation uses the SW1 pushbutton to toggle the switch state with every
activation.
The digital actuator implements an input network variable of the same type, and reflects
every new value received in this input network variable by driving a lamp accordingly.
The physical implementation on the FT 5000 EVB or Mini Gizmo I/O board uses LED1
to represent that lamp.
The network variable is defined as a SNVT_switch type, which is defined similar to the
following pseudo-definition. The true definition of SNVT_switch is embedded in the
standard resources, and includes additional data such as scaling factors, comments or
supported value ranges:
typedef struct {
unsigned
value;
unsigned
state;
} SNVT_switch;
SNVT_switch reports the on/off state with its state member, where 0 indicates Off and 1
indicates On. The value field supports raw data in the 0–200 range, representing 0–
100% dimming level, in increments of 0.5%.
Simple Digital Sensor
The simple digital sensor example demonstrates the event-driven Neuron C
programming model, and showcases the integration of network variables into Neuron C.
The application code defines a network variable, nvoSwitch, similar to a global ‘C’
variable, and uses it just like any other global variable. The system firmware
automatically sends any newly assigned network variable value over the network.
Typically, the application code does not need to know where output network variable
values go.
Based on the I/O toolkit created by the examples in Performing Neuron C Input/Output,
the following code defines the simple digital sensor example.
#include "io.nc"
#pragma num_alias_table_entries 2
//
// Output network variable declaration. Will always be cleared to