At a Glance
The following
example illustrates the READ_VAR
function with a
management parameter check.
Programming the function
Programming in ST:
IF NOT %M21 AND %I0.1.2 THEN
%MW210:4 := 0;
%MW212 := 50;
READ_VAR(ADDR(’0.3.1.7’),’%MW’,20,1,%MW210:4,%MW1701:1);
SET %M21;
END_IF;
the input bit
%I0.1.2
controls the function,the internet bit
%M21
is used to test the activity of the function,%MW210:4 := 0;
initializes the management table to 0,MW212 := 50;
initializes the timeout value to 5 seconds.
NOTE:
READ_VAR(ADDM(‘0.3.1.7’),’%MW’,20,1,%MW210:4,%MW1701:1);
syntax must be used for Modicon M340 PLCs as ADDR
function cannot be used by a Modicon M340 PLC.Programming the exchange check
Programming in ST:
IF %M21 AND NOT %M210.0 THEN
INC %MW214;
IF %MW211 = 0 THEN
INC %MW215;
ELSE
SET %Q0.2.2;
INC %MW216;
%MW217 := %MW211;
END_IF;
END_IF;
%MW214
counts the number of exchanges,%MW215
counts the number of correct exchanges,%MW216
counts the number of exchanges generating errors,%MW217
stores the error message,%Q0.2.2
indicates an exchange failure.