Example 1: thermostat interface – Echelon Neuron C User Manual
Page 43

Neuron C Programmer’s Guide
31
Example 1: Thermostat Interface
This thermostat measures the resistance of a thermistor by measuring the pulse-
width of a waveform that is input to pin IO6. The I/O object declaration is set up
to measure the on-time of the waveform. A simple
T=mx+b
scaling of the on-time
yields the temperature.
ontime
The example also uses a shaft encoder generating a quadrature input as a dial to
select a new temperature setting (see Figure 2). The quadrature input object
type is used with the io_update_occurs event. The input value of the input object
represents the change in rotational offset since the last input. Shaft encoders
typically generate offsets of 16 to 256 counts per 360 degrees rotation. The
io_update_occurs event evaluates to TRUE only when a nonzero offset has been
measured. In the following application, the task associated with the when
(io_update_occurs...) clause is executed only when the quadrature input dial has
moved from the previously measured position.
Figure 2. Sample Thermostat Device
The io_changes event would rarely be used with the quadrature I/O object,
because the event would evaluate to TRUE only when a
change
in the measured
count occurred. The io_changes event would not evaluate to TRUE as long as the
input object were moving at a constant rate because the nonzero measurements
would be the same. This example is intended to illustrate use of typical I/O
objects. Network variable information has been omitted; it is covered in detail in
Chapter 3,
How Devices Communicate Using Network Variables
, on page 43.
// THERMOS.NC -- LonWorks thermostat device