Passing An Array and UDT

Just to amplify on Bernie's reply....

AOI Input and Output parameters can only be a single-value tag, such as BOOL, INT, SINT, DINT, & REAL. The tag's value is passed into, or out of, the AOI, just like a JSR/SBR/RET situation.

Anything that is a "structure", containing more than one "value", such as an array, or a UDT, has to be passed "by reference", that means it has to be an In/Out parameter.

The only consequence of "by reference" tags is that their values can be changed during AOI processing by other, higher priority, tasks. In/Out (by Ref) parameters are not "isolated" from external interference. A skilled programmer would know when to use buffering, or interrupt disabling, depending on the application.
 
Yea tried that

what needs passed back is the PRE value
not the entire timer
The UDT contains the timers but their not really an array
they are individual items in the UDT
Now the Timers that are returned are in an array
but I need just the .PRE passed back

I have been able to pass the UDT then inside the AOI
use the .StepxTime in the AOI but it is when trying to
Pass just the .PRE back that it fails
Just passing back the entire timer also fails
As you can see from the attachment I already knew I needed InOut type
as explained in the atachment
 
Last edited:
Let me comment on your image first.

As reflected in Source A of the MUL instructions you have a UDT named, within the AOI, 'Selected Recipe'. It cannot be determined from the image if this instance of a UDT exists only within the AOI or if a reference or address of an instance of a UDT which exists outside of the AOI and has been passed in by defining this an In/Out variable.

If it is an In/Out variable then all the AOI gets is the address of the start of this external UDT. The AOI determines from that and the structure of the UDT where each element is. The UDT is not somehow passed into the AOI.

You also have an array of timers. Again these may exist wholly within the AOI or it is external to the AOI and the reference to the start of the array was passed in by declaring it as an In/Out variable.

Since they don't have a dot (except before the '.PRE') then the timer array is not part of a larger UDT (specifically the 'Selected_Recipe' variable). (Note: Technically a 'Timer' type is a system defined UDT hence the '.PRE' defining one of the elements of this type.)

Now, in the MUL instructions shown, the value in Source A is multiplied by 1000 then sent to the PRESET of the timers. Does this part of the AOI function? When running do you actually see in the specific instance of this AOI the Presets changing with different Source A values?

If the timer array was defined in the AOI as an In/Out variable then the PRESETs of the timers are ALREADY outside of the AOI. If the timer array exists wholly within the AOI then you can easily MOV their presets values into individual DINTs which have been defined as 'Output' type variables or into external DINTs which were defined as In/Out variables.

And another comment: The presets of an array of timers do not form an array of JUST the presets. It is the complete timer structure which is repeated in an array.

I hope this discussion helps a little. I don't have RSLogix 5000 available to help examine the structure of your problem program. But maybe other users can help.
 
Reacting to your description of the timers - 'the UDT contains the timers but their not really an array'

Maybe if you past a PDF of the UDT definition and a PDF of the AOI variable definition it might make more sense.

If the timers are part of the UDT and IT is passed by reference (In/Out variable) then the AOI can access the timers without a separate variable definition for the timers.

An example of a reference to one of the timer presets would be Selected_Recipe.Phase_Step_Timer[2].PRE (or without the [2] if the timers are not part of an array in the UDT. But then how are you treating them as an array within the AOI?

Well, awaiting further information.
 
Looking closer at what you have posted, and correct me if I am wrong, you are using the AOI to populate the PREsets of your sequence timers. The StepTimes are defined in the sequence UDT in seconds, so the MUL instructions are converting these to mS values for use by the sequence timers.

There is no need for the Timers to go into the AOI at all. If you change your MUL instructions destinations to DINT output parameters, flag as "required", then you can achieve the MOVs to the Timer presets in the AOI instruction "box", just specify each timer preset as the out parameter destination for each of the new DINT parameters.

Now, I'm surmising that your sequence logic has a timer for each step... does it need to have any more than one timer ?, and does it need to have a preset ?. Your sequence of (up to) 32 steps would require 32 timers... what if the sequence had 320, or 3,200 steps ? Using a separate timer for each step starts to look like there ought to be a better way.

The sequence control logic I use has only one "StepTimer", with a preset of 2,147,483,647 (max). My actual sequence only needs to test if the StepTimer has reached (or exceeded) the required StepTime, to transition to the next step, and the timer is reset on each step transition. I have an AOI called from my sequence control logic AOI that calculates and populates a UDT that expresses the StepTime as milliseconds, seconds, minutes, and hours (REAL values), so my sequence can do GEQ any one of those...

Of course you may not be able to re-do your logic, but bear this in mind for the future. I could quickly piece together an example of the methods described, but can only go up to V24.
 

Similar Topics

Hello I am writing a small code, I have two problems populating the arrays? I am getting an error Non-existing identifier. I also need help to...
Replies
12
Views
5,927
Though i was working with add-ons for a lot of times recently i am stuck in a simple proble. I have a TAG READ_DATA[502]-INT ARRAY R/W I am...
Replies
2
Views
1,864
I'm using FactoryTalk ME version 13. I'm aware how to pass a parameter file once, but I was wondering if it is possible to do it twice...
Replies
4
Views
155
I inherited a project in which a ME application displays process measurements (temp, pressure, flow, etc) on a PanelView Plus display. The data...
Replies
4
Views
493
My first real attempt at utilising the AOI function in Compactlogix. The issue I'm having is, I have an array of INT[400], but in my AOI I'm only...
Replies
1
Views
454
Back
Top Bottom