I have a protect in which I need to control the end position of a pneumatic double acting cylinder for a certain number of cycles. At the moment I have a program which uses 2 switches (1 for each direction are pushed the cylinder will either go in or out.
So essentially I need a counting loop which when a switch is pushed turns off a relay. Do a need o use interrupts for this.
The basic behavior will be:
Wait in a loop while the activation switch is inactive (reading its input continuously)
Then activate output to extend the air cylinder
Wait in a loop until extension limit is activated
Delay extension time
Deactivate output to retract the cylinder
Wait in a loop until retracted limit is activated
Delay retraction time
Repeat the above block for the desired number of times.
There are some error checks I may add for cases where something goes wrong, but that logical structure I outlined will be fine for 99.99% of cases.