Temperature sensor – Echelon Mini FX User Manual

Page 90

Advertising
background image

Mini FX User's Guide

77

#ifdef USE_5000EVB

IO_2 output bit ioLed1 = 1;
IO_3 output bit ioLed2 = 1;

#else
#ifdef USE_MINIGIZMO

IO_2 output bitshift numbits(8) ioLeds;
IO_1 output bit ioLedLoad = 1;

#endif // mini gizmo
#endif // 5000 evb

void SetLeds(boolean led1, boolean led2)
{
#ifdef USE_5000EVB
io_out(ioLed1, !led1);
io_out(ioLed2, !led2);
#else
#ifdef USE_MINIGIZMO
unsigned data;

// Compute the data byte for the shift register:
data = led1 ? 0x01 : 0x00;
data |= led2 ? 0x02 : 0x00;

// Push inverted data into shift register:
io_out(ioLeds, ~data);

// Strobe:
io_out(ioLedLoad, 0);
io_out(ioLedLoad, 1);
#endif // mini gizmo
#endif // 5000 evb
} // SetLeds

Temperature Sensor

Both the FT 5000 EVB and the Mini Gizmo I/O board include a Dallas DS18S20
temperature sensor. This temperature sensor is connected to the Smart Transceiver

through a one-wire touch I/O interface to pin I/O 7.
The following example illustrates the use of the touch I/O model. The
GetTemperature() function drives the 1-wire protocol to obtain two data bytes from the

sensor, maps those to a local variable in big endian notation, and transforms the data

received to meet the definition of a SNVT_temp_p standard network variable type,
which holds temperature information in Celsius, with a resolution of 0.01°.

IO_7 touch ioTemperatureSensor;

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

SNVT_temp_p GetTemperature(void)
{
union {
SNVT_temp_p value;
unsigned raw[2];
} current;

current.value = 32767l;

if (touch_reset(ioTemperatureSensor)) {
(void)touch_byte(ioTemperatureSensor, DS18S20_SKIP_ROM);
(void)touch_byte(ioTemperatureSensor, DS18S20_READ);
// Read data into big-endian variable:

current.raw[1] = (unsigned)touch_byte(ioTemperatureSensor, 0xFFu);

Advertising