Vinnie_vdb
Member
I have made a, to what I think, a counter that can store the output value in a DWORD. However, it doesn't seem to work on the SoMachine (Codesys) M2xx PLC.
Can somebody hint me where I go wrong here?
Thank you a DWORD already
This is the function block I made:
IF CU=TRUE THEN (* Output from the Rising Trigger *)
CV := CV + 1; (* Value of the Counter *)
END_IF
IF CV >= PV THEN
Q := TRUE; (* If you gonna trigger something *)
CV := 0; (* Reset of the Counter *)
END_IF
And his is the declaration of the variables:
FUNCTION_BLOCK FB_CNTUP
VAR_INPUT
CU: BOOL;
RESET: BOOL;
PV: DWORD;
END_VAR
VAR_OUTPUT
CV: DWORD;
Q: BOOL;
END_VAR
VAR
END_VAR
Can somebody hint me where I go wrong here?
Thank you a DWORD already
This is the function block I made:
IF CU=TRUE THEN (* Output from the Rising Trigger *)
CV := CV + 1; (* Value of the Counter *)
END_IF
IF CV >= PV THEN
Q := TRUE; (* If you gonna trigger something *)
CV := 0; (* Reset of the Counter *)
END_IF
And his is the declaration of the variables:
FUNCTION_BLOCK FB_CNTUP
VAR_INPUT
CU: BOOL;
RESET: BOOL;
PV: DWORD;
END_VAR
VAR_OUTPUT
CV: DWORD;
Q: BOOL;
END_VAR
VAR
END_VAR