Echelon Mini FX User Manual

Page 103

Advertising
background image

90 Developing

Device

Applications

#include <string.h>
#include <snvt_hv.h>

#include "io.nc"

#pragma enable_sd_nv_names // Show useful names to integrator
#pragma run_unconfigured // Allow running standalone
#pragma num_alias_table_entries 10 // required by compiler

//
// Configuration properties:
//
network input cp SCPTsetPnts nciSetPnts; // See text!
network input cp SCPTmaxSendTime nciHeartbeat;
network input cp SCPTminDeltaTemp nciHysteresis;

network input cp SCPTgain nciCoolFactor; // Cooler coeff.
network input cp SCPTgain nciHeatFactor; // Heater coeff.

//
// Network variables
//
network input SNVT_temp_p nviSetpoint = 2100ul;

network output bind_info(unackd) SNVT_lev_percent nvoCool nv_properties {
nciCoolFactor = {3, 1}
};

network output bind_info(unackd) SNVT_lev_percent nvoHeat nv_properties {
nciHeatFactor = {5, 2}
};

network output bind_info(unackd) SNVT_temp_p nvoCurrent;
network output bind_info(unackd) SNVT_hvac_status nvoUnitStatus;

fblock SFPTthermostat {
nviSetpoint implements nviSetPoint;
nvoCool implements nvoCoolOutput;
nvoHeat implements nvoHeatOutput;
nvoCurrent implements nvoSpaceTemp;
nvoUnitStatus implements nvoUnitStatus;
} MyThermostat fb_properties {
nciSetPnts,
nciHeartbeat,
nciHysteresis = { 100 } // 1 degree
};

The application drives the control algorithm, which is implemented in the Thermostat()

function, when necessary:

//
// The application’s main algorithm is run from the 'Thermostat'
// function. This function is being called under three conditions:
// (a) during reset processing, (b) when the setpoint input network
// variable changes, or (c) once every second for periodic sampling
// of the current ambient temperature. Periodic sampling is governed
// by the sampleTimer application timer, whose interval is governed
// by SCPTmaxSendTime (nciHeartbeat). If this heartbeat CP is zero,
// the application samples at SAMPLETIMER_DEFAULT_INTERVAL (1s).
//

void Thermostat(void);

stimer sampleTimer;
#define SAMPLETIMER_DEFAULT_INTERVAL 1 // 1s

when(reset) {
InitializeIO();

LcdDisplayString(0,0, "Thermostat Example");
LcdDisplayString(1,0, "-+-+-+-+-+-+-+-+-+-+");

Advertising