DWORD counter value

Vinnie_vdb

Member
Join Date
Aug 2011
Location
Ghent
Posts
15
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
 
The (PLC) counters I'm familiar with do not reset themselves automatically when they reach preset - resetting is via a separately controlled input.

How will the Q output be turned off?
 
CV is not an output so it should be in normal declaration.
however it should work, so what goes wrong?
the Q is only ON for 1 cycle, as you make CV zero.

Have a look at www.oscat.de for a big open library.
 
Stupid me ;)

It was working but I was having 2 counters with the same number so that is why it wasn't counting :)

All good. Sorry guys and thanks for the help.
 

Similar Topics

Hello all, In SoMachine is there a standard Counter Up that is storing the value in a WORD but is that not enough. Is there a way to get a...
Replies
4
Views
2,457
I'm trying to set alarm as DWord where each bit is individual alarm. So far I have tryed with DWord.0, DWord.1, DWord.2, etc. DWord.L0...
Replies
8
Views
822
Hello, I am using Omron PLC: NX1P2 Software:-Sysmac Studio Plc in which I have to read data from an energy meter over Modbus RTU The data that I...
Replies
3
Views
881
Hello, I am provided with PLC tags with PLC_UDT datatype via symbolic connection. The structure of PLC_UDT (DI_hmi) is: DI_hmi.stat (UDINT)...
Replies
4
Views
1,436
This feels like a simple, elementary question, but I am a Siemens novice and know there are experts here. My S7-1500 project (TIA Portal v17) has...
Replies
10
Views
2,702
Back
Top Bottom