Digital actuator example – Echelon Mini EVK User Manual

Page 69

Advertising
background image

Digital Actuator Example

The following example application adds ISI support to the previous digital

actuator example. The network variable input may be automatically connected
to all digital sensors in the network programmed to accept enrollment from a

SFTPopenLoopActuator functional block. The ISI code is highlighted in bold.

#pragma enable_sd_nv_names
#pragma num_alias_table_entries 2

#include <isi.h>

// Define the device interface
network input SNVT_switch nviLight;

fblock SFPTopenLoopActuator {

nviLight implements nviValue;

} fbSwitch external_name("Light");

// Configure the I/O pins
IO_1 output bit ioLEDLd = 1;
IO_2 output bitshift numbits(8) ioLEDs;

// Start the ISI engine
when(reset) {
IsiStartS(isiFlagNone);
}

// Process ISI Messages
when(msg_arrives) {
if (IsiApproveMsg()) {
(void)IsiProcessMsgS();
}
}


// Set the MiniGizmo LEDs to all on or all off
void SetLED(const boolean state) {
// Shift out the LED value
io_out(ioLEDs, state ? 0 : 0xFF);

// Latch the new value
io_out(ioLEDLd, 0);
io_out(ioLEDLd, 1);
}

// Update LEDs when an nviLight update is received
when(nv_update_occurs(nviLight)) {
SetLED(nviLight.state && nviLight.value);
}

// Call IsiTick() every 250 milliseconds
mtimer repeating isiTimer = 250;

when(timer_expires(isiTimer)) {
IsiTickS();
}

// MyCsmoData defines the connection details for the automatic ISI
// network variable connection advertised by this device.
static const IsiCsmoData MyCsmoData =
{ ISI_DEFAULT_GROUP, isiDirectionInput, 1, 4, 95u, 0 };

Mini EVK User’s Guide

63

Advertising