How to Search for Part Numbers in RSLogix 5000 Using User-Defined Types (UDT) for Efficient Data Management

Question:

I'm currently facing challenges with an application and need assistance in determining the most effective approach for my project. Here’s what I aim to achieve: I have developed a User-Defined Type (UDT) called Part_Recipe, which contains a String Tag, a SINT Tag, and an INT Tag. Following this, I created an array of tags using the UDT as the data type (Part_Recipe[50]), resulting in 50 instances that hold identical information. Now, I'm looking for a method to search through each of the 50 entries specifically for the String Tag (Part_Number). This search will be initiated through an HMI where I will input a part number via a String Entry. The goal is to implement logic that locates the corresponding part number across all 50 Part_Recipe instances. However, I'm concerned about the feasibility, as the FSC instruction seems to prefer the String data type over the UDT I've designed. The ultimate objective is to find the part number and retrieve all associated values for that part, including Pack Quantity, Camera Program Number, and more. Once this data is gathered, I plan to transfer it to another tag called Current_Recipe, where I will display the part number, set an internal counter preset with the pack quantity, and send the camera program number to the camera system. I believe this task is achievable, but I'm currently stuck on the initial search portion. Any help or guidance would be greatly appreciated. Thank you!

Top Replies

You might consider creating your own search function for enhanced flexibility. You can encapsulate this functionality within a subroutine or an Always-On Instruction (AOI). Upon execution, this routine can return a DINT that indicates the index of the matching element in the array. Alternatively, if no match is found, the function can return a specific value to signify "not found." This approach allows for improved search efficiency and clearer handling of search outcomes.

As referenced by OkiePC regarding custom implementations, you can utilize the Jmp/Lbl commands to iterate through your User Defined Type (UDT[#].StringTag). This will allow you to compare each entry against your HMI String Tag for matches. For a visual guide, please refer to the attached image. I trust this information proves useful for your project.

ohnedich6: I must admit, I'm a bit puzzled by what you've shared, and I'm trying to wrap my head around it! Haha! One of my challenges is that I struggle to read all the information provided; when I enlarge the image, it just becomes distorted. I may need to reach out to you privately to discuss this further and fully comprehend how it will integrate with my application!

Bishop108 commented: "Ohnedich6, to be honest, your post has left me a bit confused as I try to wrap my head around what's happening! Haha! One challenge I face is that I can't quite decipher all the information provided; when I zoom in, it just ends up distorting the image. I might need to reach out to you privately to gain a clearer understanding of how this relates to my application! Click to expand... Absolutely, don’t hesitate to send me a message."

Simply utilize FAL in incremental mode to transfer items individually to a temporary string. Once the string aligns with the .POS of the FAL control word, you will identify the recipe number.

It sounds like you're on the right track with your UDT and array setup! To efficiently search for the String Tag within your array of `Part_Recipe`, you might consider using a loop to iterate through each instance in the `Part_Recipe` array. You can compare the input String from the HMI against the `Part_Number` property of each entry. If you find a match, you can then extract all associated values and transfer them to the `Current_Recipe` tag. While FSC may not work directly with your UDT, implementing a simple For-Next loop with a comparison should do the trick. If you're using structured text, it can keep the logic clean and straightforward. Good luck, and I'm sure you'll get it sorted!

It sounds like you're on the right track with your UDT and array setup! For the search functionality you need, consider using a loop to iterate through your `Part_Recipe` array and comparing the `String Tag` directly with the input from HMI. You can use a simple `FOR` loop to check each entry and determine if there's a match with your `Part_Number`. If you find a match, you can then easily copy the relevant data to your `Current_Recipe` tag. If you're worried about the FSC instruction not working with UDTs, try breaking down the comparison process to work directly with the string properties. This way, you maintain clarity and ensure you're retrieving everything you need effectively. Good luck!

More Replies →

Streamline Your Asset Management
See How Oxmaint Works!!

✅   Work Order Management

✅   Asset Tracking

✅   Preventive Maintenance

✅   Inspection Report

We have received your information. We will share Schedule Demo details on your Mail Id.

You must be a registered user to add a comment. If you've already registered,
sign in. Otherwise, register and sign in.

Frequently Asked Questions (FAQ)

Ready to Simplify Maintenance?

Join hundreds of satisfied customers who have transformed their maintenance processes.
Sign up today and start optimizing your workflow.

Request Demo  →