RSLogix 5000 Data Search & UDT

bbishop108

Member
Join Date
Mar 2017
Location
Indiana
Posts
86
Ok, I am having a tough time with an application and figuring out how the best way would be for me. So here is what I would like to accomplish:

I created a UDT(Part_Recipe), and inside this UDT I am storing a String Tag, SINT Tag, and an INT Tag. Then I created my new tag using the UDT as the data type(Part_Recipe[50]) so I will 50 files with the same info.

Now I am trying to figure out how I can do a search within each of the 50 files and just look for the String Tag(Part_Number)in each one of the files. This would be me entering a part number on an HMI (String Entry) but having the logic search for the matching part number in each of the 50 files of the Part_Recipe. I'm not feeling confident it can be done this way as the FSC instruction really only likes the String data type, NOT the UDT type I created.

The goal here is to search for the part number, then load all values for that part (Example: Part Number, Pack Quantity, Camera Program Number...etc. Then all this data will be copied over to another tag (Current_Recipe) where I then display the loaded part number, send pack quantity value to an internal counter preset, and send camera program number to the camera.

I feel this is something that can be done, but I am kinda stuck at the search portion which happens at the beginning. Any and all assistance would be greatly appreciated, Thanks!!!
 
You may want to roll your own search instruction. You could pack it into a subroutine, or AOI and return from it with a DINT representing the found position of the matching array indice or some other value that represents "not found" in cases where there is no match.
 
bbishop108,

Per what OkiePC mentioned about rolling your own, you can use Jmp/Lbl to index through your UDT[#].StringTag and compare it to your HMI String Tag to see if they match. See the attached image for an idea. I hope this helps.

UDT_Search.jpg
 
ohnedich6: I'm not gonna lie, what you have posted has me scratching my head try to fully understand what is going there!!! hehe!

I know one of my problems is I can't quite read all the info listed, enlarging only distorts the image. I may need to pick your brain offline to try and fully understand how this will work with my application!
 
ohnedich6: I'm not gonna lie, what you have posted has me scratching my head try to fully understand what is going there!!! hehe!

I know one of my problems is I can't quite read all the info listed, enlarging only distorts the image. I may need to pick your brain offline to try and fully understand how this will work with my application!

Sure thing, feel free to shoot me a message.
 
Just use FAL in incremental mode to move them one at a time to a temporary string, when string matches the .POS of the FAL control word is the recipe number.
 
Use the FSC (file search and compare) instruction, that's what it's for.

Read the help file on the instruction, that should get you started. Your expression will be something like:

Part_Recipe[FSC_Control_Tag.POS].Part_Number = PartNumberYouAreSearchingFor

If the FSC instruction finds a match, it will halt at that position, and then you know which array element it's in. So then you'll execute a COPy something like:

Source: Part_Recipe[FSC_Control_Tag.POS]
Destination: RecipeTagYouWantTheDataIn
Length: 1
 
Last edited:
Use the FSC (file search and compare) instruction, that's what it's for.

Read the help file on the instruction, that should get you started. Your expression will be something like:

Part_Recipe[FSC_Control_Tag.POS].Part_Number = PartNumberYouAreSearchingFor

If the FSC instruction finds a match, it will halt at that position, and then you know which array element it's in. So then you'll execute a COPy something like:

Source: Part_Recipe[FSC_Control_Tag.POS]
Destination: RecipeTagYouWantTheDataIn
Length: 1

It won't let you do that if the string is a member of a UDT. I just tried it several different ways and I get an error "Invalid array subscript specifier"

EDIT: I take it back. I was using R[1] as the control which was an array of control tags I already had in a running program. This made for nested indices and it didn't like that. I made a new control tag called R1 and it verified.

FSC_within_UDT_000.jpg
 
Last edited:
Use the FSC (file search and compare) instruction, that's what it's for.

Read the help file on the instruction, that should get you started. Your expression will be something like:

Part_Recipe[FSC_Control_Tag.POS].Part_Number = PartNumberYouAreSearchingFor

If the FSC instruction finds a match, it will halt at that position, and then you know which array element it's in. So then you'll execute a COPy something like:

Source: Part_Recipe[FSC_Control_Tag.POS]
Destination: RecipeTagYouWantTheDataIn
Length: 1

Your right, I keep forgetting that Logix can search string.
 
OkiePC: I had mine originally set up the same as your except you have an additional tag listed in the Expression: HMI_Name_Entry=Part_Recipe[R1.POS]NAME
What is that tag "NAME"? What is its data type and is it necessary?
I have a similar program where I am using the FSC instruction and it also does not have anything after the [.POS] portion and it works just fine. When I try doing this same thing again, I either get the Invalid Expression or Invalid array subscript specifier. I am very curious as to how your works while sadly mine does not!!! Thanks
 
OkiePC: I had mine originally set up the same as your except you have an additional tag listed in the Expression: HMI_Name_Entry=Part_Recipe[R1.POS]NAME
What is that tag "NAME"? What is its data type and is it necessary?
I have a similar program where I am using the FSC instruction and it also does not have anything after the [.POS] portion and it works just fine. When I try doing this same thing again, I either get the Invalid Expression or Invalid array subscript specifier. I am very curious as to how your works while sadly mine does not!!! Thanks

The UDT I Created had NAME as the Recipe name text. I often use the word "Title" for UDT members in systems were the word "NAME" is reserved.

There should be a period after the closing bracket around the control position tag and before the UDT member you want to search. In my example, it is
Code:
Part_Recipe[R1.POS].NAME

Make sure that your control tag is not an array tag...that is what had me stuck earlier. The control tag must not be an array, just a standalone tag. I also noticed that when my string tags were all empty, and I first got it to verify and assemble, the EN bit was "stuck" on and the FD bit was not set, but the IN bit was. I put some text in the HMI_Name_Entry and those bits stayed the same. I read the help file which said that the IN bit will go true when a match is found and must be unlatched to continue searching. So I added the Test bit and the Match bit, and threw in some latch and unlatch instructions to tinker with it. Once I unlatched the IN bit and toggled the Test bit again, it appeared to work. I am not sure why the FD bit was not set when all the strings were empty. My little example was just a quick test, so for your real application just be aware that you do need to handle cases like where there might be multiple matches or no matches by looking at the IN bit as well as the POS register and the FD bit.

The other example you describe using the FSC that works is probably dealing with a tag type of STRING rather than a UDT member, so it defaults to the DATA portion of the string tag.
 
Last edited:
This is how I currently have mine and it is not working, I am now getting an Invalid member specifier.....This is how I have my expression:
Part_Select=Part_Data[Control.POS].Part_Recipe.

Part_Select is a string tag that will be the string entry from HMI.
Part_Data is the tag name for using my UDT (Part-Recipe) Part_Data(50)
I used the tag Control as a control type
 
This is how I currently have mine and it is not working, I am now getting an Invalid member specifier.....This is how I have my expression:
Part_Select=Part_Data[Control.POS].Part_Recipe.

Part_Select is a string tag that will be the string entry from HMI.
Part_Data is the tag name for using my UDT (Part-Recipe) Part_Data(50)
I used the tag Control as a control type

So "Part_Recipe" is a UDT member of the tag type STRING, correct?

And Part_Data is a tag of type UDT that includes Part_Recipe as the string portion?
 
Part-Recipe is the UDT, and inside that UDT are the 3 data types mentioned previously (SINT, String, INT). Part_Data is the tag name that contains the UDT as the data type, so Part_Data is the name, then its Part_Recipe[50] for the data type.
 

Similar Topics

First off, I'm a hobbyist-level programmer, and this program isn't controlling anything anything that could even remotely be considered "life...
Replies
18
Views
502
Thank you for any and all responses/help. I have an RSLogix 5000 v20 and a Cognex In-Sight v5.9 spreadsheet (8502P). I can not figure out how to...
Replies
0
Views
118
I have a micrologix 1100 that I am trying to read three data points from it on my safety plc using studio 5000. Any tips or guidance is appreciated.
Replies
4
Views
829
I want transfer my I/O data from schneider (Unity Pro) as a write data and RS Logix 5000 as a read data. I use Ethernet as an communication...
Replies
0
Views
687
Im trying to sum a running "Shift Total" production value and move it into a Month Total value that will continuously update for viewing...
Replies
1
Views
1,529
Back
Top Bottom