The encoder motor can be used as a counter. The number of revolutions is counted, not only when it is turning itself as a motor, but also when it is mechanically driven by an external force.
The Start each time block
The Start each time block offers the option of running a program when a condition is fulfilled. Therefore, it works similar to a case distinction, but runs not only one time, but rather every time the condition is fulfilled during the entire course of the program. The Start each time block:
Is an abbreviation for the following construct:
You can insert all conditions from this category into the counter category in the Start each time block.
Note: The program section in the Start each time block should be kept short, and should not contain any blocking calls or endless loops, so that this part of the program can be processed quickly.
Use Get counter value to obtain the value counted by the counter.
To query whether the counter has counted a certain value, use this
the drill hole. You can use the drop down menu (small triangle) to select how the counted value should be compared to the entered value (<, ≤, =, ≠, ≥, >) .
The counter starts over at 0 when the Reset counter block is executed.