Digital actuator example, Serial actuator example – Echelon Mini EVK User Manual

Page 49

Advertising
background image


#define DS18S20_SKIP_ROM 0xCCu
#define DS18S20_CONVERT 0x44u
#define DS18S20_READ 0xBEu

// Get a temperature reading from the Touch temperature sensor
SNVT_temp_p GetTemperature(void) {
union {
SNVT_temp_p snvtTempP;
unsigned Bytes[2];
} CurrentTemperature;
CurrentTemperature.snvtTempP = 32767l;

if (touch_reset(ioThermometer)) {
(void) touch_byte(ioThermometer, DS18S20_SKIP_ROM);
(void) touch_byte(ioThermometer, DS18S20_READ);

CurrentTemperature.Bytes[1]
= 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;
}

Digital Actuator Example

The following example function sets the state of the eight LEDs on a MiniGizmo.
The LEDs are connected to a 74HC595 8-bit serial-in/parallel-out shift register.

Data is shifted on IO2 (clock) and IO3 (data), a rising edge on IO1 strobes data

into the latch. LEDs are driven active-low

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

Serial Actuator Example

The following example function sends a string to the serial port on an EVB. The

JP201 I010 jumper on the evaluation board must be inserted to enable the serial

Mini EVK User’s Guide

43

Advertising