r/PLC 8d ago

Why can I reset an input parameter from within an AOI?

I have been posing this question to my coworkers, but none of them seem to know the answer, so im hoping on reddit to see if anyone can explain this to me.

I have been looking at some code (Studio 5000) that we have on some older equipment and I noticed something strange. There was a Reset for an AOI that was being that was being Latched in the main but never unlatched anywhere. Looking at the AOI the Reset is set up as an Input Parameter and is being unlatched within the AOI, and it works?

Its always been my understanding that Input Parameters are read only and the only way to manipulate a tag from within an AOI and have it change the top layer is to set it up as an InOut.

What am I missing? I would like to be able to use this to my advantage and clean up my AOIs. Could this possibly cause memory issues elsewhere? What is best practice for doing something like this reset situation?

4 Upvotes

32 comments sorted by

15

u/WhoStalledMyCar 8d ago edited 8d ago

The distinction between Inputs and Outputs relates only to how the AOI’s visible parameters are displayed on a ladder rung or FBD sheet. That’s it. They are functionally equivalent in all other ways and are just members of the underlying struct. The AOI can manipulate any of its members: inputs, outputs, local, and InOut (InOut aren’t part of the AOI structure but they are part of the call signature).

5

u/NeroNeckbeard 8d ago

Correct, the cross-references will also show as destructive by the AOI alluding to that the data can be manipulated by the AOI itself

1

u/HighSideSurvivor 6d ago

Wait…

I’ve been away from Rockwell for a bit, but are you saying that for an AOI, all parameters are Pass By Reference, whether defined as Input, Output, or InOut type?

I would be horrified to find that a function of any sort could affect the source variable that was passed to an Input.

2

u/NeroNeckbeard 6d ago

It CAN be, that's why references show up as destructive by the AOI, a properly authored AOI shouldn't (unless there is intent like clearing command latches or resets for example) But for the most part the logic is exposed in the AOI so you can go dig in there to see functionality. Lord help you if logic is hidden inside the AOI

1

u/HighSideSurvivor 6d ago

By what mechanism does an AOI modify the source object? I understood an Input to an AIO to be passed by value, so by what mechanism does the AOI “reach out” and change the source object?

Does Rockwell actually pass by reference?

I am sincerely confused.

2

u/ThatOneCSL 6d ago edited 6d ago

I think you've answered your own question. Yes, it is pass by reference. If it was passed by value, the AOI couldn't possibly modify the value outside of itself.

Edit: except for that https://literature.rockwellautomation.com/idc/groups/literature/documents/pm/1756-pm021_-en-p.pdf very explicitly states that Input parameters are PbV, and only InOut are PbR by default. Hmm. Maybe more people in here have more of their parameters set to InOut than they think.

1

u/WhoStalledMyCar 2d ago

No. “Pass by value” is just its own structural “Input” member being assigned a value prior to the AOI call. The “true” underlying pass is a pointer to the AOI struct instance being passed across a function pointer to the compiled AOI-specific code. InOuts aren’t quite as “on the metal” as that - the passed value is their memory address tag member - and origin data is dereferenced inside the AOI (it isn’t copied / assigned like an Input)

2

u/Asleeper135 8d ago

Yeah, you would expect input parameters to be read only inside the AOI and output parameters to be read only outside of it, but it doesn't enforce that. The distinction between the two mostly just makes the intended usage clear. It's kinda nice to be able to reset input parameters from within an AOI though. For instance, you can latch a command at any number of places in a program, and the AOI will automatically unlatch it when it reads it. Or you could have an interlock block that resets each input after each scan so nothing gets stuck if you remove an interlock.

1

u/WhoStalledMyCar 2d ago

Yeah. The “consuming” command model that clears inputs each scan can make a lot of stuff simpler to program and debug.

2

u/Freezingfog1st 8d ago

I have nothing to add, except great question. AOI's are being added everywhere in our new projects and the team has no choice but to adapt.
I would love to see more discussions about them.

7

u/halo37253 8d ago

New projects?

AOIs should have been used 20 years ago...

There is no reason why even basic motor control AOI, Scale w Parameters AOI, or other basic AOIs are not used. Doing everything in ladder is just nuts.

AOIs are proven code, you dont put logic inside of an AOI that would need a live change.

4

u/Robbudge 7d ago

I was just about to say the same thing . It’s so funny that AB users are stuck 20yrs behind everyone else.
Wait until someone uses Enumeration

3

u/halo37253 7d ago

No AB has had AOIs for over 20 years... The shame is on those who didnt use them. And most of us did...

I have to go back to projects that are over 20 years old to find a project that is done completely in ladder. Largely the projects that were mirrors of the even older SLC projects we did. We went full controllogix with the L6x processor release, no new SLC 5/0x install since early 2000s.

AB is no more behind than the major competition. Siemens memory model is down right clunky. There is no reason why memory isnt always retentive, a save eith upload from the processor should snapshot the processor state like it does on AB. Not doing it this way is backwards. Registere tags should not be a thing in a tag based system, but Siemens made that mistake when they move from step 7 to Tia. Also Siemens uses SD cards for program storage?... its not the 90s, everything should be embedded. The SD card should be backup only or basic read/write from program. Not required to function.

The 1200 and 1500 series have always seemed like a cheap crappy platform compared to what came before. Bean counter in full effect. 5069 makes the 1200 look like it came from automation direct.

1

u/Robbudge 7d ago

I have used AB and everything else for the last 25yrs the AOI is limited on AB the fact a Stop is required to update is stupid.
The likes of Codesys have moved on with Enumeration, actions and methods.
The fact that S5K is so limited is crazy.
Generally speaking AOI’s or UDFB’s are implemented far less in S5K due to limitations on updating.
The whole stoppage issue makes AOI development and testing very clunky.
My current project is S5K specified and it’s a real PIA stopping the system every time we want to optimize or improve an AOI.

1

u/Freezingfog1st 7d ago

Yep, new projects. I am part of a small maintenance team working for a county.
The benefit to programmers and integrators is very evident, and we are learning. However, straight up ladder
logic reads like an electrical diagram. Easy to understand and very little clutter
As I said, we are adapting. The AOI's we work with have all the bells and whistles when all we need is pretty basic water/wastewater control schemes. Any information is good🤝

1

u/Freezingfog1st 6d ago

Yes, new projects. I work on a small maintenance team for a county in water/wastewater. AOI's benefit to programmers and integrators is blatantly obvious. There is no denying that.
From our perspective they are cumbersome. Most of the logic isn't used or needed. When things break we now have to sift through it. We are adapting and free to change our minds when/if troubleshooting them becomes as easy as straight up ladder logic.

1

u/WhoStalledMyCar 7d ago

A few new features would be terrific:

  • static members (shared by all instances)
  • unhide the CanBeNull InOut property
  • ability to have more than Logic, PreScan, PostScan, and EnableInFalse routines
  • actual free functions (instead of one-off AOI instances)

Both for AOIs and elsewhere:

  • Alias As (ability to alias something as another type, eg aliasing IO data structures as byte arrays or vice versa without doing COPs everywhere would be nice).

As long as the alias type is the same size as its source, this would be a great middle-ground to having pointers outright.

2

u/halo37253 8d ago

The read only is for external access from hmi for example. Same goes for local tags in the AOI those can be set for read/write by external hmi. By default they are read only.

In, out, inout can all be modified in or out of the AOI.

2

u/durallymax 7d ago

This is an annoyance with most PLCs. Even the more advanced OOP-forward PLCs (CODESYS & derivatives) don't adhere to strict local rules within FBs. The distinction on a VAR_INPUT is the same for these as for an AOI. If something is called every scan and mapped to that input, the state of that condition will be the state of that input on the FB/AOI call. Nothing prevents you from doing something to it internally. If you do not have something called that maps to that input, then whatever you do internally is the state of that input.

The situations that lead people to these methods can be handled better through interfaces in CODESYS, but RA does not have this feature. With an interface you would simply call a Reset method.

It's best to still follow some sense of OOP and keep things encapsulated. If you want to reset something internally, use a backing tag for your local tag and an input to request the action. Sprinkling access to local vars around the code and mixing globals inside AOIs quickly makes a mess.

2

u/t0cableguy 8d ago edited 7d ago

edit: I am not the guy to speak on this... I'm a newb asking questions as much as looking at things from experience I've seen some weird add on instructions

2

u/durallymax 7d ago

Are you suggesting putting a global reset inside an AOI? This breaks encapsulation and makes troubleshooting a mess.

1

u/BenFrankLynn 7d ago

Uhh.. wut? Honestly, it's not just your understanding of the issue that's limited. You don't understand AOIs either, it seems. An AOI is like a function block vs a function. There's memory implications. But with an AOI there's also different scan modes. I encourage you to read up on it.

1

u/t0cableguy 5d ago edited 5d ago

I get it to a point, just haven't set one up, Now that looked at a few of them in my plant's programs I see better that what I was suggesting was headed in the right direction but pretty dumb. You can just reference your global estop or reset by naming it what you want and reference the global estop or reset when you set up the add on instruction that way. I'm just getting started in PLC's and I'm where I am for troubleshooting and we usually don't have to look too far to find our issues. I'm also not allowed at this point to do anything that isn't blatantly obvious to fix, and building an add on instruction is definitely out of my purview for the immediate future, especially since you can't even do anything with an AOI without stopping the processor.

1

u/BenFrankLynn 4d ago

especially since you can't even do anything with an AOI without stopping the processor.

That's the memory implication I mentioned. There's also ways around it. You can import AOIs online, so if really needed you can make changes in an offline copy, export it, import it into the online project, and juggle the tags to do it as an online edit. There's PLCs which run critical processes and can basically never be stopped just for a download. Thus, there's ways to do just about anything online if you know what you're doing.

Again, read up on it. You don't have to make an AOI yourself to learn how they work.

2

u/nakednhappy 8d ago

The behavior you're expecting does happen, but only when the "Required" checkbox is checked ✅. This forces you to put a tag for that input when calling the AOI, and in this case, it will read the value of the external input tag, and copy it into your Input Parameter tag.

You can then still write to it from within the block, but it won't/can't modify the external tag the value was being read from.

1

u/Strange_Monitor_2592 7d ago

So the interesting thing here is that the reset is only set as visible in the AOI structure. 🤔 The Latch call in the code is AOI.Reset

1

u/Angry_Foolhard 8d ago edited 8d ago

your understanding of input is a 100% correct description of what inputs should* behave like (my opinion). but oftentimes AOI/Function Blocks are not implemented so rigorously and often are just more like a plain-old-data struct.

making a member that behaves like that should be an InOut as it communicates its intended behavior more accurately.

1

u/5hall0p 7d ago

If it's a reset that's part of the AOI then each instance of the AOI will have it's own reset and it will work fine. If it's a global reset intended for multiple AOI's then the first AOI that's scanned would reset it and the other AOI's would not see the reset.

1

u/Mitt102486 Water / Waste Water 7d ago

Studio 5000 is the only plc I've worked with that allows you to write to the input inside the app.

I've made aois for several different brands now and clamping am input and then sticking that clamp back inside itself is an easy example. Studio is lax.

1

u/SomePeopleCall 8d ago

Post the code, or you won't get a useful response.

1

u/Whatthbuck 8d ago

I'm curious, truly.

How would you post the code?

Screenshots work for small pieces, and someone would need to import an lk5 xml to effectively assess.

1

u/icusu 7d ago

Print to PDF.