Digital sensor example – Echelon Mini EVK User Manual

Page 55

Advertising
background image

Figure 4.2 Network Variable Multicast Connection

Network variables greatly simplify the process of developing and installing

distributed systems because devices can be defined, developed, and produced

individually, then connected and reconnected easily into many new
L

ON

W

ORKS

applications. Network variables are discussed in detail in

Chapter 3, How Devices Communicate Using Network Variables, or the Neuron C
Programmer’s Guide
and also in the Neuron C Reference Guide.

To use an output network variable, you declare and write to it much like

other C variables. To use an input network variable, you declare and read
from it, also like a C variable. In the case of an input network variable you

can also respond to update events that occur when the network variable is
updated over the network.

Digital Sensor Example

The following example application reads the MiniGizmo push buttons every 50

milliseconds and sends its value to a network variable if it has changed, replacing
the console output in the previous digital sensor example. The output network

variable is a SNVT_switch structure with value and state fields. A value of 200

and state of 1 means any of the buttons is pressed, and a value of zero and a state
of zero means all the buttons are off. The network variable code is highlighted in

bold. A network tool such as the LonMaker tool is required to test this

application.

#pragma num_alias_table_entries 2
#pragma run_unconfigured

// Define the device interface
network output SNVT_switch nvoSwitch;

// Configure the I/O pins
IO_4 input bitshift numbits(8) clockedge(-) ioButtons;
IO_6 output bit ioButtonLd = 1;

// Read the MiniGizmo buttons
boolean GetButton(void) {

Mini EVK User’s Guide

49

Advertising