Studio 5K: UDTs and Strings as AOI Output Parameters

I think I mis-understood your initial intent: I thought you want to have a complete copy of all Local tags.
Now reading this again, I think you want only specific Logal tags (Strings or UDTs). If so then pointing alias to a first member of that Local structure structure should work.
It will save some memory but most likely will make debugging and understanding by someone else quite a challenge.
I will try it tomorrow, I have a test code that uses a message to read some Local structure.
I will check if I can use this technique instead.
 
I tried it to a Local UDT tag (17K in size) and it works.
While I feel OK to use this for debugging and testing, I would be quite hesitant to use in production versions.
Thank you for sharing ideas.
 
Nice, here's my sample program.

Another proof-of-concept would be copying a local STRING (82 char) to shorter and longer destination STRING types.
 
In my case I don't need any strings, but I can use it for Local AOI UDTs that are exposed to HMI (external access), but are not accessible by the logic. Mostly for debugging and monitoring purposes.
 
New trick: as long as you don’t instantiate an AOI as a program *parameter*, you can tuck your usual message service response buffers (SINT[], etc.) into the AOI and direct the program-scoped message to write to a destination pointer of the buffer within the AOI. Provided your buffer is large enough to handle the largest expected response, you can have a more compact tag database.
 
Last edited:
Here's an update with a simple program and demo AOI using strings.

You can copy an external string into a local string, then copy the local string's contents to another external string.

StringCopyByPointer.PNG
 

Attachments

  • Prog_PtrToStr_Program.zip
    1.4 KB · Views: 7
Last edited:
A screenshot of the AOI setup.

  • The input 'pointer' to the local string just needs to be an alias of the first element of the .DATA array.
  • The output 'pointer' is an alias to the local string's .LEN member.
  • The AOI just maintains the max size of the local string for the external COP to work.

AOIParams.PNG
 
Last edited:
Cool technique, Jeremy.

If you are copying strings of the same data type (String16, for example), I believe that you can do the copy from outside to in with just a single COP:

COP (TestString.LEN, Object.Ptr_StrOut, 9).

where "9" is the number DINTs used by the string datatype. For a String16, 16 characters = 8 DINTs, plus 1 DINT for the LEN = 9.

I don't have a PLC to be able to test this on at the moment though. Can you verify it for me?
 
You're correct. If the STRING type has 82 characters (with length prefix), total length is 88 bytes.

COP(TestString.LEN, Object.Ptr_StrOut, 22)

Produced the correct result when testing.

To make it more robust, The Val_StrSize could be determined within the AOI by:

SIZE(Data[0], 0, tSize) + 4 bytes for length prefix + pad bytes to 4-byte alignment, then divide by 4.

StringPtrs.PNG
 
Last edited:
Thanks.

I recognized that having the SIZE() function inside the AOI makes it more robust. I'm just old school, and don't like to clutter up my AOIs with anything that I don't have to. I dislike InOut parameters because of that. I've used the internal alias technique to pass data "through the AOI wall" before, such as having an Alarm AOI embedded in the my Valve AOI, and then using an alias to expose the Alarm bit and timer preset to the rest of the program.

So unless I really needed to mix string data types, I wouldn't bother with the SIZE() function. And I would be put in the Prescan logic, since the length of the string isn't going to change, and as long as I'm using the same datatype for my write and read, any future programmer who changes the length of the string is going to automatically change both.

Thanks again. One more arrow for the quiver.
 
Careful on prescan.

If you add new objects to an already running controller, their prescan (and size()) won’t be carried out.
 
Sure. The AOI's default value should be set to the right number, so that a new AOI instance has the right number when created online.

Good reminder, thanks.
 

Similar Topics

I've used AOI and User Defined Data Types, but I haven't created one yet. I have a lot of repetitive MOV commands to take a select number of...
Replies
4
Views
374
Hi guys , I'm new with Allen Bradley, but I have experience with Tia portal (s7 1200 ,s7 1500) I want to convert my project from Tia portal to...
Replies
0
Views
19
Hi everyone, I have an issue with installation of Studio 5000 33.00.02 DVD Media disc 2 with View Designer on Windows 11. After installation...
Replies
0
Views
67
Hi all. My maintenance department is clamoring for the ability to look at the PLC programs (and we finally have some who can read it.) I have a...
Replies
10
Views
382
Anyone have problems/solutions with Rehosting Studio 5000 to a new computer. Our IT department successfully Rehosted 2 laptops, but the other 2...
Replies
1
Views
117
Back
Top Bottom