Counter causes an Integer Tag to increment (or decrement) when a specific Bit Tag changes value.
- Can count up to about 3 kHz (180 000 pulses/min).
- You can have as many counters as available inputs.
- For more than 3 kHz, see MotionIn which can up to 250 kHz.
Counter is a background task. When a Counter set to ‘counts up’ or ‘counts down’ is executed, it’ll continue counting until a Counter with the same Output Tag, set to ‘stop counter’ is executed.
You don’t have to execute this command every time you want it to increment or decrement. Execute it when you want to start, stop or change the Counter.
The ‘Output’ is the value that will count up or down. It can be of any Integer type (UI8, UI16, I16 or I32).
The other input box is for the Bit Tag that will cause the Output to count up or down. It isn’t needed for ’stop counter’.
‘rise’ causes Output to count when your Bit Tag goes from value 0 to 1.
‘fall’ causes Output to count when your Bit Tag goes from value 1 to 0.
In Ladder: How to execute tasks only once at startup?
Useful for defining the starting value of certain tags or for background tasks.
Note: Since some tools are background tasks, it is not necessary to run them every PLC cycle. If you run it every cycle, the tool will not work properly because you are constantly configuring it.
Just add a "BIT" that will be turned ON right after.
|All your lines that only need to start once at startup :
Note: You can use any name for the ColdStart bit.
Example how to use the counter
|ColdStart (or any other bit name) is used for one-time execution of tasks
Just for reset the counter
If it’s necessary (the reset is not enough), you can stop the counter.
If you have stopped the counter, you can restart it
We set ColdStart to 1 so that we don’t re-run tasks that only need to be done once.