FUNCTION_BLOCK FB 1
TITLE =
VERSION : 0.1
VAR_INPUT
OB35_EXEC_TIME : INT ;
rSpeedInMetresPerMIn : REAL ;
rDistanceBetweenPulsescm : REAL ;
END_VAR
VAR_IN_OUT
bPulseQ : BOOL ;
END_VAR
VAR
rStoredPositioncm : REAL ;
END_VAR
VAR_TEMP
rDistanceIncrementcm : REAL ;
END_VAR
BEGIN
NETWORK
TITLE =
L #rSpeedInMetresPerMIn;
L 1.000000e+002;
*R ;
L 6.000000e+001; //convert to cm per sec
/R ;
L #OB35_EXEC_TIME;
ITD ;
DTR ;
*R ;
L 1.000000e+003;
/R ; //increment in position this scan
L #rStoredPositioncm;
+R ;
T #rStoredPositioncm; //update sum
NETWORK
TITLE =
L #rStoredPositioncm;
L #rDistanceBetweenPulsescm;
>R ; //rStoredposition > pulse distance ?
JCN Exit; //no then exit
-R ; //else save difference for next accumulation
T #rStoredPositioncm;
AN #bPulseQ; //and toggle the output bit
= #bPulseQ;
Exit: SET ;
SAVE ;
END_FUNCTION_BLOCK