Digital actuator example – Echelon Mini EVK User Manual

Page 57

Advertising
background image

= touch_byte(ioThermometer, 0xFFu);
CurrentTemperature.Bytes[0]
= touch_byte(ioThermometer, 0xFFu);

if (touch_reset(ioThermometer)) {
// Scale the raw reading
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 updat
nvoTemperature = temperature;

e

}
}

Digital Actuator Example

The following example application controls the state of the MiniGizmo LEDs
based on a network variable input, replacing the timer control in the previous

digital actuator example. The network variable code is highlighted in bold. A

network tool such as the LonMaker Integration Tool is required to test this
application.

#pragma num_alias_table_entries 2
#pragma run_unconfigured

// Define the device interface
network input SNVT_switch nviLight;

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

51

Advertising