beautypg.com

Echelon NodeBuilder FX/PL Examples User Manual

Page 29

background image

NodeBuilder FX/PL Examples Guide

21

ai_rawdata[iChannel][iIndex]

=

ai_rawdata[iChannel][iIndex

+

1];

}

// fetch current value (store in filter history and also

// use current value to initialize current result

ulValue

=

ai_rawdata[iChannel][AI_FILTERSIZE-1]

=

GizmoReadAnalog(iChannel);

// compute average over averaging window:

for (iIndex = 0; iIndex < AI_FILTERSIZE-1; ++iIndex) {

ulValue

+=

ai_rawdata[iChannel][iIndex];

}

// now we've got the sum, let's divide in a reasonable

// way. That is, we divide and round if appropriate:

if ((ulValue % AI_FILTERSIZE) >= (AI_FILTERSIZE / 2)) {

ulValue = ulValue / AI_FILTERSIZE + 1L;

}

else

{

ulValue

/=

AI_FILTERSIZE;

}

//

has

it

changed?

if (ulValue != ai_rawrecent[iChannel]) {

// it has indeed. Update history and network variable

ai_rawrecent[iChannel]

=

ulValue;

nvoAnalogInput[iChannel]

=

((SNVT_lev_percent)ulValue)*

20L;

}

} // next channel

} // not in business

// re-load timer. We do not use auto-reloading ("mtimer

// repeating...") because we want the update frequency to be

// adjustable through cpUpdateRate.

ai_timer = AnalogInput[0]::cpUpdateRate * 100L;

}

20. Build the development target. To do this, right click the Development target, and then click Build

on the shortcut menu. The LonMaker tool automatically loads the new application into the device
hardware.

21. Drag four new functional blocks to your drawing, one for each AnalogInput and AnalogOutput

functional block. Select the Create Shapes for all Network Variables check box for each
functional block.

22. Connect AnalogInput[0] to AnalogOutput[1]. See the LonMaker User’s Guide for more

information. When you are done, your LonMaker drawing should look something like this:

23. Insert jumpers between pins 1 and 2 of JP7 and JP8 in the lower right-hand corner of the Gizmo 4

board. These jumpers connect the AOUT1 output to the AIN1 input, and the AOUT2 output to
the AIN2 input.