Software Version used in this video: Do-more Designer 2.0.0
Suppose you have a program or a task that needs to take a lot of time, but you don’t want it to extend the main scan loop any more than necessary. Maybe you are using a task to generate an end of shift report and you have to loop through tons of records to build a log, or maybe you need to respond to a communications event with a program and it’s going to take a while to collect the data for the response. Those can take a long time and you really don’t want them to slow down your scan loop to do it, right? Well, that’s where yielding comes in handy. The Do-more PLC lets you tell programs and tasks to just do a little bit of the job each scan so your main process isn’t affected. Now, each scan is spending most of the time taking care of your time critical main program. So Yielding is a great way to spread low priority tasks and programs out over time to help keep your main program running as fast as possible. To use Yielding you just right click on the program or task. If you choose never yield, a task and a program will run to completion regardless of how long it takes. The only thing that can change that is if you manually put a YIELD instruction in the code. Then the task or program will run to that instruction on one scan, and then pick up there on the next scan. You can do that as many times as you want to break up the task or program however you need. Always yield is basically the same thing, except it will also yield for a GOTO instruction – if the GOTO instruction points to something earlier in the code of course. Then on the next scan it will start at that previous line and continue to the bottom of the routine. Assuming it doesn’t hit another GOTO again, of course. And it will yield at the bottom of a loop: for next loop, a while end loop or a do until loop. Which means under this Always YIELD option, a program will run one iteration through the loop, then on the next scan run another iteration, next scan another iteration, etc. That’s an easy way to tell programs and tasks to run one iteration of a loop per scan. What if you have a loop inside a loop? Well, it will yield at the bottom of this loop, and keep doing that until it’s done, then on the next scan it will pick up here and yield at the bottom of this loop. Then on the next scan it will fall back into this loop and repeat the whole process again. Exactly what you would expect. And finally, this option takes that one step farther. Suppose you know you can afford for a Program or a TASK to take, let’s say, 1 millisecond of scan time without adversely affecting your main scan loop. Well, you put 1 millisecond here and now the program or task will run as many loop iterations as it can until 1 millisecond expires, then it will yield at the next yielding instruction which is usually the bottom of a loop. On the next scan it just picks up wherever it left off. Runs as many loop iterations as it can in the 1000 micro-seconds then yields again. Here’s something to think about: Can the main program Yield? That is, could you break up the main program so different parts run on different scans? Sure! The Main is just another program so all of these option still apply. The only difference is the Main program always runs – you can’t shut it down. Other than that, the Main Program acts just like any user created program. But, if you are using Yielding to break up your main program, that’s probably a pretty good sign that you need to be creating some more programs and tasks. So Yielding gives you incredible control over the performance of your system and its super easy to use! So be sure to take advantage of it when you need to optimize your system’s performance. In the next video we’ll do some live examples so you can get a better feel for the differences between tasks ad programs. If you have any questions, please contact AutomationDirect’s free, award winning support team during regular business hours. They will be happy to help. And don’t forget the forums. There are lots of automation professionals there that love to share their years of experience. Just don’t post any questions directed at AutomationDirect’s support team there, they don’t monitor the forums on a regular basis. Spend Less, Do-more. With AutomationDirect.