Step 8: implementing the real time keeper – Echelon NodeBuilder FX/PL Examples User Manual

Page 35

Advertising
background image

NodeBuilder FX/PL Examples Guide

27

when (timer_expires(hvac_coretick)) {

// advance the timers:

HvacMinSendTimer += HVAC_CORETICK;

HvacMaxSendTimer += HVAC_CORETICK;

// get new value and re-transmit if needed

UpdateTemperature

();

// transmit most recent value if needed due to heartbeat timer:

if (cmptime((const SNVT_elapsed_tm * const)

&(TempSensor::cpMaxSendTime), HvacMaxSendTimer) <= 0 ) {

PropagateTemp(

HVACTempOld

);

}
}

void TempSensorDirector(unsigned uFblockIndex, int iCommand )

The cmptime(a,b) function compares the a and b values. It returns sign(a-b), for
example, - 1 if b > a, +1 if b < a, and 0 if b == a. The value of b is assumed to tick at
the rate defined by the HVAC_CORETICK value in milliseconds.

The PropagateTemp() function is used to propagate the output network variable. It includes
code to perform the necessary conversion to maintain the FLOAT type network variable, and to
administrate the functional block’s timers. This function mostly operates on fixed-point values
and converts to floating-point values when needed. This minimizes the number of floating-point
operations and thus maximizes the performance of the L

ON

W

ORKS

device.

The UpdateTemperature() function is used to obtain new temperature readings from the
Gizmo 4 temperature sensor hardware. It includes logic to decide whether this new value should
be made available to the network immediately or at a later time, based on the minimum update
interval defined in the nciMinSendTime configuration property.

The when statement uses the HVAC_CORETICK value to maintain the min/max send timers, looks
after regular conversions, and assures that updates are sent no further apart then the time specified
by the nciMaxSendTime configuration property (the heartbeat).

11. 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.

12. Add the new functional block and network variables to the LonMaker drawing and use the

LonMaker tool and LonMaker Browser to verify correct operation.

Step 8: Implementing the Real Time Keeper

In this step, you will implement the standard real time keeper functional profile template
[SFPTrealTimeKeeper (3300)]. You will add implementation-specific configuration properties and
network variables to this functional block. In addition, you will observe how network variable updates
are processed for a functional block with multiple input network variables.

1. Click the NodeBuilder tool Taskbar button in the Taskbar to return to the NodeBuilder tool.

2. Right-click the device template and select Code Wizard from the shortcut menu. The Code

Wizard opens.

3. Right-click the device template’s Functional Blocks folder and select Add Functional Block from

the shortcut menu. The Add Functional Block dialog appears.

4. Add a single SFPTrealTimeKeeper functional block. Name the new functional block

RealTimeKeeper.

5. Right-click

the

RealTimeKeeper functional block’s Optional NVs folder and select Implement

Optional NV from the shortcut menu. The Implement Optional NV dialog appears.

6. Implement

the

nviTimeSet network variable.

Advertising