Simple digital actuator, Advanced digital actuator – Echelon Mini FX User Manual
Page 99

86 Developing
Device
Applications
// zero after reset.
network output SNVT_switch nvoSwitch;
//
// OnButtonPressed() is called whenever the button becomes active.
//
void OnButtonPressed()
{
// toggle the reported switch status:
nvoSwitch.state ^= 1;
nvoSwitch.value = nvoSwitch.state ? 200u : 0;
}
when(reset) {
InitializeIO();
LcdDisplayString(0,0, "Simple Digital");
LcdDisplayString(1,0, "Sensor Example");
LcdDisplayString(2,0, "-+-+-+-+-+-+-+-+-+-+");
LcdDisplayString(3,0, "SW1 drives nvoSwitch");
}
Simple Digital Actuator
Similar to the OnButtonPressed() function, which was called by the I/O toolkit, the
when(nv_update_occurs) task executes when the specified network variable received
an update from the network. Most Neuron C applications focus on the application
algorithm, while delegating most or all of the processing related to the network to the
system firmware. The corresponding simple digital actuator is defined by the following
application.
#include "io.nc"
#pragma num_alias_table_entries 2 // required by compiler
//
// Input network variable declaration. Will always be cleared to
// zero after reset.
network input SNVT_switch nviSwitch;
//
// when(nv_update_occurs) executes when the referenced input network
// variable receives a new value:
//
when(nv_update_occurs(nviSwitch))
{
SetLeds(nviSwitch.state, FALSE);
}
when(reset) {
InitializeIO();
LcdDisplayString(0,0, "Simple Digital");
LcdDisplayString(1,0, "Actuator Example");
LcdDisplayString(2,0, "-+-+-+-+-+-+-+-+-+-+");
LcdDisplayString(3,0, "nviSwitch drives LED");
}
Advanced Digital Actuator
This example demonstrates a slightly more complex version of the digital actuator. This
example implements two digital actuators (driving LED1 and LED2 through one input
network variable each. This application also implements two SCPTlocation
configuration properties, which can be used to describe the lamps (for example, through
their location). Each lamp is represented by one functional block of type