Trout914 (Customer) asked a question.

Order of operations, Best practice?

Hello All,

I am working on a project that, like most of my project is pushing my abilities. This is by far the largest and most complex program I have ever worked with.

First the hardware: 2 Productivity 2000 one with Analog I/Os and one with Relay outputs. Both will

communicate with an HMI (EC9) via Ethernet.

Second: The systems. I have 23 aquatic life support systems (freshwater fish and mussels)

Each system has 6 points that I am working with: (4-20ma) Temperature, Pressure,

Current (pump draw), (relay) an electronic ball valve (water changes) and a solenoid

valve (feeding)

Third: The Project. The goal is to monitor and control these systems, and (hopefully) log data.

The user will be able to select a system (basically a way to tell the PLC that a system is

in use). Allow the user to set the frequency and duration the two valves are open.

All via the HMI.

Right now I have a mostly structural question.

Is it best to scan to see if the each system's selector switch (to see its state) and call a subroutine if it is selected or scan a selector switch and write all the code for that system (23 times) or scan them all, write to a bit, then use the bit to run (on a later rung) a subroutine or execute the code with out a subroutine....

Obviously I don't really know what I am talking about, but I have a few systems up and running so I am not a total nube, just not clear on subroutine use and best practices. I need this system to be super reliable and easy for someone else to understand down the line.

 

Thank you,

 

Peter

 


  • Garry (Customer)

    Hi Peter,

    This is totally up to you on how you want the controller to scan your logic. I have found that subroutines or similar makes it easier to read the program.

    It does not sound like you have anything to quick in the logic.

    Here is a post on Program Control. It may give you some ideas.

    https://accautomation.ca/productivity-1000-series-plc-program-control/

    Regards,

    Garry

     

    https://accautomation.ca/series/productivity-1000-plc/

    Expand Post
  • Trout914 (Customer)

    Thank you Gary. I will read some more on the link you sent.

     

    Peter

    • Garry (Customer)

      Let me know if you have any questions.

      Regards,

      Garry

  • z28z34man (Customer)

    This sounds like the perfect case for user defined structures. How I would do it is create a run when called ladder with all tags being user defined structure tags. When you have that working properly for 1 unit create an array of the user defined structure tags then copy the run when called ladder and change just the array number. then you can call the ladders from a for loop.

     

    I haven't tried it but you might be able to use a copy data before and after the call sub routine and and call the same run when called ladder. Benefits being if you need to make changes you only need to change in one place. Determines being when trouble shooting it will be harder as you will not be able to see what is going on in each unit individually.

     

    I hope this makes sense

    Expand Post
    • David_H (Customer)

      We use the same concept where I work, (except its a Control Logix PLC instead of Productivity), and it works well.

       

      For troubleshooting, I created a duplicate subroutine that is never called, but that I can select which process I want to monitor and troubleshoot by changing the pointer number. I presume the same would work in Productivity.

    • z28z34man (Customer)

      I just tried the array of user defined tags and using a for loop to call a run when called ladder. I have a copy data to copy the tags before and after the call task instruction and it dose work but it throws the timers way off(running in the productivity simulator i lost around 27 seconds per minute).

       

      Using the first first method and having a separate ladder for each and just changing the array number for all the tags in the run when called ladder keeps the timers somewhat accurate(running in the productivity simulator after 10 minutes it was off 20 seconds).

      Expand Post
      • Frontier (Customer)

        I'd recommend running the timers in a separate run-every-scan task, and just enable the timers with bits you build into the UDS.

      • z28z34man (Customer)

        i just verified using a P1-540 using the separate ladder for each and just changing the array number for all the tags method and the trimmers are right on after 20 minutes leading me to believe the simulator doesn't quite keep accurate time.

         

        using the for loop and copy data method timers don't work at all on the P1-540

         

        Expand Post
      • z28z34man (Customer)

        I will have to play with it and it would most likely work in most situations but i could see there being issues when the logic requires a specific scan order to sequence correctly.

      • David_H (Customer)

        Try putting the timers in an array that isn't copied into/out of the UDS, and just use a pointer to reference them in the logic. I tried it on the simulator, mixed results, with an array of 5 timers being called in a for loop in the same logic, the odd numbered ones were cycling, the even numbered ones were not... I'm curious how it would do in a real machine....

         

        If that works, it saves you having to copy/paste separate subroutines for each, and renaming them....

        Expand Post
10 of 80