News:

  • June 27, 2026, 10:55:59 PM

Login with username, password and session length

Author Topic: Best way to use multiple programs  (Read 13271 times)

Garyhlucas

  • Hero Member
  • *****
  • Posts: 421
Best way to use multiple programs
« on: October 24, 2016, 06:44:06 PM »
I am rewriting my waste treatment control program because I have come up with a whole new way to run the process. However there are lots of pumps and valves that need to operate in completely different ways for each mode. This started getting very difficult to understand.

So I have broken it up into COMmon programs that get shared by all modes, OFFline programs, CONTinuous programs, CLEANing programs, and SBMR programs.  My plan is to activate all the COM programs except in an E-stop, and the others if not in E-stop when I am in one of the four modes.

There is a master Mode program for each mode. What is the best way to turn on and off all the subprograms?  Currently I have run and halt rungs in the Main program that moves me between the 4 modes.  I see also that run is modal, and stays on unless specifically halted. Do it the same way in Main? Do it in the master Mode program?

Thanks,

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6164
  • Yes Pinky, Do-more will control the world!
Re: Best way to use multiple programs
« Reply #1 on: October 25, 2016, 12:08:03 AM »
I guess one question is whether you are using programs where you need tasks, but there isn't any harm in using HALT externally.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Garyhlucas

  • Hero Member
  • *****
  • Posts: 421
Re: Best way to use multiple programs
« Reply #2 on: October 25, 2016, 08:27:09 PM »
Bob,
The programs once started run continuously for hours, days, or even months at a time. Would you use a task for that?

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6164
  • Yes Pinky, Do-more will control the world!
Re: Best way to use multiple programs
« Reply #3 on: October 26, 2016, 07:02:25 AM »
It's not so much about duration as supervision. If your code is standalone and autonomous, and terminates itself when complete, that is a program. If the code remains under the control of a supervisor, and is simply a modularization of the supervisor's behavior, that is a task. It gets fuzzy if your task needs the sequencing ability stages provide, but the general distinction is who controls the lifespan of the code.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Scot

  • Sr. Member
  • ****
  • Posts: 78
Re: Best way to use multiple programs
« Reply #4 on: November 07, 2016, 02:12:59 PM »
Have you looked into Stage programming?

Garyhlucas

  • Hero Member
  • *****
  • Posts: 421
Re: Best way to use multiple programs
« Reply #5 on: November 09, 2016, 10:05:16 PM »
This program has stages all over the place. When it starts up it sequences through a bunch of stages, every ten minutes it jumps out to a backwash stage and returns. Valves are stepped open and closed in stages. The cleaning process has 36 stages. Sludge gets waste through a series of stages. Shutting down involves a whole series of stages to flush things out and start a recyle loop going. The new process I am adding requires an even more complex series of stages for filling, aerating, deaerating, filtering, sludge wasting and start over. I kind of think I have a handle on stages!

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
Re: Best way to use multiple programs
« Reply #6 on: November 10, 2016, 07:59:07 AM »
BTW, when online in run mode, you can turn status ON in your Project Browser View with your PROGRAM code-blocks expanded to the stage level and monitor the sequencing from that view.  Also, if you put rung comments on those SG instructions, the first line of those SG rung comments also show up in your Project Browser SG nodes, and you have a really good "process monitoring" view!

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: Best way to use multiple programs
« Reply #7 on: November 10, 2016, 10:54:07 AM »
When I use a Program block that needs to be shut down from a supervisory block, then I normally put a rung in the very top of the supervised block (above any stages) that has a contact with any relevant logic included that feeds an EXIT, or a SGSET to another STAGE that contains the EXIT. This allows me to do a controlled shutdown sequence internally to the block. What you do NOT want to do, is have a supervisory program block shut down a program that has a TCP connection open, or other other multi-scan instructions that are running that will cause locked up DEVICES.
I had a project where I would kill blocks externally and ended up with multiple locked up devices and dangling TCP connections. This new method has eliminated these problems.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com