Orion HE (Customer) asked a question.

Using Timers (STMR) with User-Defined Structures and Looping

I've created some User-Defined Structures (UDS) and called it Fancoil. It includes a fan and some refrigeration valves. I included STMR instructions within them to represent defrost timers. Then I created an array of Fancoils. My goal is to write the code once and loop through using an index tag.

 

The problem is the STMR instructions don't run as soon as the for loop has more than 1 loop in it. How can an STMR instruction be used in looping?


  • RBPLC (Customer)

    Don't. I tried to tackle this some time back and it won't work properly/reliably. The timers need to be outside of a loop to accumulate properly.

    Selected as Best
  • RBPLC (Customer)

    Don't. I tried to tackle this some time back and it won't work properly/reliably. The timers need to be outside of a loop to accumulate properly.

    Selected as Best
    • Orion HE (Customer)

      Yeah. I learned that even though a UDS will let you use a TMR or STMR, they don't function. I'm converting to CNT and SCNT now.

      • RBPLC (Customer)

        I'm finding that the more I try to be smart and decrease programming, infernal timers and counters consistently throw a wrench into things.

  • David_H (Customer)

    Here's the best solution I could come up with to timers in loops...

    It's still tedious coding each timer in the array, but it functions well, and it saves duplicating and renaming all the code in the loop.

    • Orion HE (Customer)

      I like what you did there. For me, I'm hoping to have solution that can be relatively easily expanded to any number of instances. I realize at some point, I'll have to map all of my class members to i/o points, but that's a small price to pay. My solution ended up using counters and the 1second bit. If I need more granularity, I'll make a then of a second timer and reference that bit.

       

      I'm grateful for the flexibility afforded to us in these PLCs. I put in a request to AD today to let us use dynamic IP addresses in Modbus fields. It's a real bummer to have to change the IP address manually across a bunch of modbus read/writes, when we could map them all to a tag in Do-more. Still, as I said, I'm thankful we can do what we can. Getting better all the time.

      Expand Post
  • z28z34man (Customer)

    See my post here about it. What i do is create a ladder using entirely one element of a user defined structure tag array copy and past the ladder and just change the array element in the copied ladder. If you need to make changed it throws a wrench in to the works as you will need to change every ladder

     

    https://community.automationdirect.com/s/question/0D53u00001ycdg3CAA/productivity-suite-user-defined-structures

     

    hopefully we can get a user defined instruction in the next major release

     

    another thread talks about it here

    https://community.automationdirect.com/s/question/0D53u00002Rj1rACAR/order-of-operations-best-practice

    Expand Post
    • RBPLC (Customer)

      I've already requested over at the HOST forum the need for AOI capability. This capability is needed in the Productivity platform as well. Having to deal with copy and paste and change is a major pain when dealing with larger systems. AD/FACTS, please be working on this.

  • z28z34man (Customer)

    Awesome. I know it is a big ask but I hope the functionality does get added in the next major release

  • Durallymax (Customer)

    Ran into this today, fortunately not too many instances to copy paste but kind of ruins the clean loop when parts have to be handled outside it individually, especially given Find/Replace inability to find/replace an array index.