Jump to content

Recommended Posts

  • MVP 2014

The first step is to create a counter to keep track of your cycles. There is no built-in loop counter like the FOR loop.

Then decide whether you want to complete all cycles in a single scan, or perform one cycle per scan.

I would also consider putting the sequence in a subroutine of its own. Programmers vary in their preference on when to use subroutines. The main goals are to make the code function correctly, and also be easy to understand for someone new.

1. All cycles in one Scan - add a label before the call of the subroutine containing your sequence and place a Jump to Label instruction after the subroutine call. Keep calling the Jump to Label until your loop counter has reached its target.

This structure will generate a compiler warning, as it is possible to create a very long scan time with loops that use Jump instructions. The PLC has a watchdog that will stop the PLC if the scan time is too long.

2. One Cycle per scan - call your routine once per PLC scan, until it has executed the required number of times. This is more in line with traditional PLC function, where the scan time is relatively constant.

You can monitor the actual scan time from SI 0.

Link to comment
Share on other sites

Thank you.

I am using the OPLC V1040-T20B.

I have a unit with some solenoid valves and a ballast tank. I need to open and close the valves to pressurize the system and get to a certain pressure, when the unit reaches that pressure we do a blow down and we need to start the whole process again, all this I must repeat N times.

Link to comment
Share on other sites

  • MVP 2023

Your sequence does not need the speed described by Simon's post. Take a look at the state machine example I posted here:


If you understand this programming concept, it would be easy to add a state that counts to N as part of the sequence and then finishes when your counts are done.

Joe T.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...