Step 7: implementing the temperature sensor – Echelon NodeBuilder FX/PL Examples User Manual
Page 33
NodeBuilder FX/PL Examples Guide
25
The (tempP * 2) term transforms an unscaled SNVT_temp_p value into an equivalent
unscaled SNVT_lev_percent value, and the second 100/30 term adjusts so that 30
° C converts
to 100% of the output signal range. Both terms could be combined in a single factor, but this
example uses both for double-precision intermediate results.
22. 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.
23. Add the Translator functional block to the LonMaker drawing.
24. Use the LonMaker Browser to browse the translator. Set the new configuration properties to
various values, enable monitoring for nvoPercentage, and force nviTempP to several values
within and outside the set range of 0-+30
°C. Connect nvoPercentage to the input network
variable of one of the analog output functional block blocks, connect a voltmeter to the relevant
analog output, use the LonMaker Browser to change the nviTempP value, and observe the results.
Step 7: Implementing the Temperature Sensor
You can implement a standard temperature sensor profile [SFPThvacTempSensor (1040)] to provide
a temperature sensor implementation for the Gizmo 4 I/O Board’s temperature sensor hardware. In
this step, you will observe the difference between floating-point vs. fixed-point arithmetic in Neuron
C. To perform this step, follow these steps:
1. Click the NodeBuilder tool Taskbar button in the Taskbar to return to the NodeBuilder tool.
Right-click on the device template and select Code Wizard from the shortcut menu. The Code
Wizard opens.
2. Right-click the device template’s Functional Blocks folder and select Add Functional Block
from the shortcut menu. The Add Functional Block dialog appears.
3. Add a single SFPThvacTempSensor functional block. Name the new functional block
TempSensor. Click OK.
4. Right-click
the
TempSensor functional block’s Optional NVs folder and select Implement
Optional NV from the shortcut menu. The Implement Optional NV dialog appears.
5. Implement
the
nvoFloatTemp network variable. This network variable has the SNVT_temp_f
type. Click OK.
6. Change the names of the three mandatory configuration properties to cpMaxSendTime,
cpMinDelta, and cpMinSendTime, respectively.
7. Click
Generate and Close.
8. Open
TempSensor.h from the Source Files folder and add the following code in bold:
#include "common.h"
SNVT_temp_p
HVACTempOld;
// most recent value, used for heartbeats
#define HVAC_CORETICK 500UL
// internal sampling rate
//and
minimum
heartbeat
interval
mtimer repeating hvac_coretick = HVAC_CORETICK;
unsigned long HvacMinSendTimer;
unsigned long HvacMaxSendTimer;
float_type f100 = {0, 0x42, 0x01, 0x48, 0 }; // 100.0 - see NXT.EXE
//utility
for
initializer
//{{NodeBuilder Code Wizard Start
9. Open
TempSensor.nc from the Source Files folder add the following code in bold to the
FBC_WHEN_RESET
else-if statement in the TempSensorDirector() function: