Jump to content

Recommended Posts

Posted

Dear all,

I have the following issue/question. My company designs and builds water and waste water treatment plants and Unistream is our standard. Due to scope of technology, I always have  a lot of pumps and valves controlled by a PLC. Therefore I have defined structures for these elements and there is a rule that each element has two basic states

1. Manual where the user can simply start or open pump or valve without any restrictions

2. Automatic where the element works according some conditions

I always implement a button called "AUT" which puts all the elements to an automatic state and also a "STOP" button which puts all the elements to manual states and switch off (or close)

Thus for example, the pump structure always contains in C# notation something like that

struct SPump
{
    bool InAut;
    bool ShouldRun;
}

 

The AUT bottons sets InAut to true; the STOP buttons sets InAut to false and also ShouldRun to false.

I always draw in ladder for each element something like InAut-(S)- or InAut-(R)-ShouldRun-(R)- respectivelly for STOP button.

The question is how to achieve the same effect using For Each loop. Any Idea?

Thanks Jan

 

 

 

 

Posted

Create a list of your pumps, create a ForEach function that accepts a list of Pumps.

Call the ForEach function with your list.

The ForEach function has a local tag called CurrentItem. Do your logic on the CurrentItem

  • 2 weeks later...
Posted
On 11/19/2024 at 6:53 AM, Saragani said:

Create a list of your pumps, create a ForEach function that accepts a list of Pumps.

Call the ForEach function with your list.

The ForEach function has a local tag called CurrentItem. Do your logic on the CurrentItem

Bump.

Is there a size limit on how big the struct tag called by ForEach can be?

For example, I have a ForEach loop which updates a data table containing same structure as the struct in question. I do a simple query: CurrentItem.Index == Data Table Row 1 data (e.g. material code), and when same, it updates the data table row (CurrentItem -> Write to DT Row)..

This function worked kinda erratically. Data table couldn't be updated past row 3 or 4, so I've abandoned the ForEach and replaced it with 30+ rungs with compare functions. So it's solved for now, not just in the elegant way I wanted.

Posted
Quote

Is there a size limit on how big the struct tag called by ForEach can be?

The answer is no.

Can you please post your code or show print screens so we would be able to help you better?

Posted

Maybe you need a foreachloop in a foreachloop.

Ther parent foreach with all your structs and the inner foreach with your data table ?

please be more clear about "data table couldn't be updated past row 3 or 4...."

in your foreach with data table as "input", you only work with "current index" row of the data table

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.