Ladder Logic 302: Data Tracking and Structure Data Type

Part_Tracking_Logic
Today’s post is the second “advanced” topic I have covered on PLC ladder logic, The first being toggle circuits.

It is often necessary to track data on individual parts through a machine or production line. If using devices like barcode/datamatrix scanners or RFID tags, tracking parts or pallets is as simple as reading the ID number as it arrives at a station. If it isn’t feasible or economical to use part identification systems, the method shown above is common.

This logic assumes four stations on an indexing conveyor or chassis. The logic itself is quite simple; as the chassis or indexer moves the part it creates an event using a one-shot. This event shifts a Structure (more on that below…) from station 3 to 4 (array element [2] to array element [3]), station 2 to 3, 1 to 2, and finally moves an empty record (NULL_DATA) into station 1 (array element [0]).

It is very important that a one shot is used in the trigger. If not, the data shifts continuously as long as the sensor is made (see scanning…) and the entire array clears in 4 scans (about 50 milliseconds or so depending on the size of your program).

In this example, the data only shifts if the system is in Autocycle. This can be dangerous if the system can be indexed in Manual Mode, since the parts would certainly move if indexed. At the same time, if the trigger were something like a Part Present sensor, inadvertantly making the sensor while doing maintenance could also be a problem.

This example also uses an Array. Arrays are groups of the same type of tag; an array of integers is thus a group of integers dimensioned by the programmer. As an example, a ten element array of integers consists of Integer[0] through Integer[9].

Part_Tracking_Struct

A Structure is a data type defined by IEC 61131 as well as other computer languages such as C++. TypeIn computer programming these can also be called composite data types. In PLC programming languages they are sometimes called UDT (User Data Type) or UDDT (User Defined Data Type).

These are groups of different types of elements placed into the same tag for ease of manipulation. In the logic example at the top of the post it only takes 4 instructions to move all of the product data. If this had to be done by moving strings, reals and integers and setting bits it would take 60 instructions!

If you look carefully at the UDDT you will see that there are 3 more stations mentioned; a robot, a reject station and an outfeed conveyor. Because these stations do not move together like the indexer, the data moves have to be done with different events. An example might be when the robot picks up the part from the Vision station, the data from [3] is moved to [4] and NULL_DATA is moved into [3]. At the same time the UNLD_RBT bit is latched in [4] showing that this part has moved into the robot gripper position. All of the first seven BOOL tags in the structure are used in this way to show where the parts have been. Data such as PROD_NUM and HSNG_NUM can be used as a method of program selection for the vision system and leak tester, while LEAK_RATE might be used for pass fail status or data collection by a SCADA system or PC. l

It is also important to ensure that the “at station” bits that are set in the data structure (the first seven) are unlatched after the data movement. It is important that they are not inadvertently set in the arriving array element before you want them to be.

***************************************************

On a personal note I am well under way on the design of a new simulation and software training program for ladder logic. My intent is to be able to be able to run it in various simulation “modes”; my own generic language similar to what you have seen above as well as Allen-Bradley, Siemens. Omron, Mitsubishi, GE, Modicon and Koyo. If you have any suggestion or want to know more about this project, let me know!

Share
About

Electrical Engineer and business owner from the Nashville, Tennessee area. I also play music, Chess and Go.

2 Comments on “Ladder Logic 302: Data Tracking and Structure Data Type

  1. I am currently starting a program using Q Series Mitsubishi. I will be tracking parts, along with that part I will collect data that needs to stay with a particular part. After this part passes through our machine, I will pass the data to an Active Plant Data collection system. My part would be done. I could use any ladder logic program samples, advise, articles etc.

    • Hi Steve, thanks for visiting my site!

      I don’t do a lot of Mitsubishi programming, but here’s what I found. Mitsubishi’s GX2 software has an option when you start your program called “Structured Ladder”. If you choose this method you can use structured data – like the UDT I describe in this post. The people I have talked to about using this method don’t like it much – apparently the interface is an annoying pink color. Another alternative is to simply lay out your data in sections, map items such as part numbers and results into each section (you can also use bools of the integers within each section). Then use block moves of each group of words and archive your results. This is best laid out in Excel ahead of time. If you need floating point data you will have to move it separately. The technique is similar to what I have outlined in this post though. Sorry I don’t have any examples in Mitsubishi… Good luck!