Digital actuator example – Echelon Mini EVK User Manual

Page 63

Advertising
background image

CurrentTemperature.snvtTempP *= 50l;

// start the next conversion cycle:
(void) touch_byte(ioThermometer, DS18S20_SKIP_ROM);
(void) touch_byte(ioThermometer, DS18S20_CONVERT);
} else {
CurrentTemperature.snvtTempP = 32767l;
}
}
return CurrentTemperature.snvtTempP;
}

// Repeat every second
mtimer repeating readTimer = 1000;

// Read the temperature when the timer expires
when(timer_expires(readTimer)) {
SNVT_temp_p temperature;
static SNVT_temp_p lastTemperature;

temperature = GetTemperature();
if (temperature != lastTemperature) {
lastTemperature = temperature;

// Send network variable update
nvoTemperature = temperature;
}

}

Digital Actuator Example

The following example application adds an Open Loop Actuator functional block

to the previous digital actuator example. The network variable input is changed
to be a member of the functional block. The functional block code is highlighted

in bold. A network tool such as the LonMaker Integration Tool is required to test

this application.

#pragma enable_sd_nv_names
#pragma num_alias_table_entries 2
#pragma run_unconfigured

// 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;

// 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);
}

Mini EVK User’s Guide

57

Advertising