5. CONFIGURATION
and used a function block equivalent to PulsedCommand function of library LibRtuStandard. The PulsedCommandNexto()
function block shows up coded in ST language.
FUNCTION_BLOCK PulsedCommandNexto
VAR_INPUT
byCmdType: BYTE; // command type:
// 100 = status
// 101 = close/on
// 102 = trip/off
byPulseTime: BYTE; // Pulse duration (in hundredths of second)
ptDbpVarAdr: POINTER TO DBP; // DBP variable address (can be mapped)
stQuality: QUALITY; // DBP point quality(digital module)
END_VAR
VAR_OUTPUT
bON: BOOL; // Odd output mapped on Nexto DO module
bOFF: BOOL; // Even output mapped on Nexto DO module
byStatus: BYTE:= 7; // Function return:
// 1 = invalid command
// 2 = Time out of valid range (2..255)
// 3 = command changed in running time
// 4 = module did not answer to the command (absent)
// 5 = command started or running
// 6 = There is already an active command on this point
// 7 = pulse command finished with success
END_VAR
VAR
byState: BYTE; // Function block state
udiPulseEnd: UDINT; // Pulse end instant
END_VAR
// PulsedCommandNexto state machine
CASE byState OF
0: // Init state, ready to receive commands:
CASE byCmdType OF
100:// Just returns the last status
101: // Execute pulse ON:
// Valids the pulse duration
IF byPulseTime > 1 THEN
// Check if there is already an active command on this point
IF ptDbpVarAdr^.ON OR ptDbpVarAdr^.OFF THEN
// Returns that there is already an active command
byStatus:= 6;
ELSE
// Enables CLOSE output
ptDbpVarAdr^.ON:= TRUE;
ptDbpVarAdr^.OFF:= FALSE;
// Next state: execute pulse ON
byState:= byCmdType;
// Returns started command
byStatus:= 5;
END_IF
ELSE
// Returns the out of range pulse
203