Echelon Neuron C User Manual

Page 75

Advertising
background image

Neuron C Programmer’s Guide

63

Example:

network input SNVT_temp nviCurrent;
network input SNVT_temp nviSetpoint;
network output SNVT_volt nvoValve;

eeprom uninit SNVT_temp lastGoodCurrent, lastGoodSetpoint;

when(nv_update_occurs(nviCurrent)) {
lastGoodCurrent = nviCurrent;
nvoValve = algorithm(lastGoodCurrent, lastGoodSetpoint);
}

when(nv_update_occurs(nviSetpoint)) {
lastGoodSetpoint = nviSetpoint;
nvoValve = algorithm(lastGoodCurrent, lastGoodSetpoint);
}

• After power-up or reset, track which network variable has been updated,

and execute the algorithm only after all required input data has arrived.

Example:

#define CURRENT_OK 0x01
#define SETPOINT_OK 0x02
#define ALL_OK (CURRENT_OK | SETPOINT_OK)

unsigned received;

network input SNVT_temp nviCurrent;
network input SNVT_temp nviSetpoint;
network output SNVT_volt nvoValve;

when(nv_update_occurs(nviCurrent)) {
received |= CURRENT_OK;
if (received & ALL_OK == ALL_OK) {
nvoValve = algorithm(lastGoodCurrent, lastGoodSetpoint);
}
}

when(nv_update_occurs(nviSetpoint)) {
received |= SETPOINT_OK;
if (received & ALL_OK == ALL_OK) {
nvoValve = algorithm(lastGoodCurrent, lastGoodSetpoint);
}
}


After power-up, poll both input network variables, thus explicitly
requesting that the data sources resend their most recent value. This

solution is popular, simple, and straight-forward.

Example:

network input SNVT_temp nviCurrent;
network input SNVT_temp nviSetpoint;
network output SNVT_volt nvoValve;

when(reset) {
poll(nviCurrent);

Advertising