61131-3: Uses of Arrays

AutomationTechBrian

Lifetime Supporting Member
Join Date
Jul 2013
Location
St. Cloud, MN
Posts
669
I'm working on some 61131-3 training, and while I understand how to insert arrays into the data types, I have a hard time visualizing uses for them.... versus just adding bits to the program. It's that visualization that helps me to retain the information and utilize it when would be useful.

Most of my classroom training has been in "process" programming. I'm working on "motion control" on my own, so I suspect arrays will have some use there. Do you have good examples of where an array is the obvious choice?

Thanks!
 
.... versus just adding bits to the program.

Don't make this a habit please!

Arrays are great for a number of reasons. Just a few:
1. Data Storage, say for recipes. Operator selects recipe 15, and we can point to the recipe array RecipeData[15] to find what we need. Arrays also make it easy to loop through data.

2. Structure! I may have an array of of a control UDT. Program 1 = controlUDT[1], Program 2 = controlUDT[2]...

3. Communications, data which is packed in arrays is more efficient to HMIs an SCADA terminals.


I mostly program with ControlLogix PLCs, and I may have arrays within arrays. Expanding on my example in #2:

ControlUDT[1].Setpoints_Real[0..15]
ControlUDT[1].Setpionts_Int[0..15]
ControlUDT[1].GenericPB[0..10]

The UDT gives me a defined structure, the arrays provide a set amount of options for control. Scale this example into a PLC that has 200 programs, creating an array of ControlUDT[0..200] will create all of the base tags I will need in a program in one quick tag entry.
 
Arrays are great! It helps you not only keep similar data under a common variable name, but also gives you control over iterating over data, and using the [] to index anything you want with let's say a counter.

Arrays are also great because you can do basic movement. For example, you can do copy from a 4 letter string to a 24 letter string manually, if you need to. For example if you need to write stuff in an RFID tag, this becomes important.
 
You shouldn't be teaching this class.

I'm working on some 61131-3 training, and while I understand how to insert arrays into the data types, I have a hard time visualizing uses for them.... versus just adding bits to the program. It's that visualization that helps me to retain the information and utilize it when would be useful.

Most of my classroom training has been in "process" programming. I'm working on "motion control" on my own, so I suspect arrays will have some use there. Do you have good examples of where an array is the obvious choice?

Thanks!
I can think of lots of ways I use arrays for motion control. The main data structure in our motion controller and the 1756-HYD02 and 1756-M02AS is an array of axis structures. What if you have a 6 degree of motion platform. There will be 6 axes.

A very common example is an array of position to move through for a spline or even a set of point to point moves.
http://deltamotion.com/peter/Videos/curvetool.mp4
I use arrays for filters. How many times have we seen
Code:
y(n) = A*y(n-1)+B*x(n).
This is a simple example but the filters can be longer to get a sharper cutoff.
Code:
y(n) = A1*y(n-1)+A2*y(n-2)+B0*x(n)+B1*x(n-1)+B2*x(n-2)
that last filter could be a PID filter if you want.

People use tables for linearizing inputs or outputs. Arrays of coefficients for polynomials. etc

We use arrays to store times, positions, velocities and control outputs for graphing. This makes it easier to tune the system manually.

I better there are many I haven't mentioned.

I know I am a little hard but I have been watch some MIT course ware videos where it is evident the professor has spent 20+ years in a class room but has no real experience. It is a waste of students time and money. There are a lot of videos made by clueless professors. That high bar must be raised.
 
Arrays are also good for look up tables.

Knowledge of arrays, stacks, queues and state machines will get you a long ways down the road in programming.
 
Last edited:
I know I am a little hard but I have been watch some MIT course ware videos where it is evident the professor has spent 20+ years in a class room but has no real experience. It is a waste of students time and money. There are a lot of videos made by clueless professors. That high bar must be raised.


I read Brian's question as one posed by a student looking to improve his skills rather than a professor looking for suggestions on how to teach the concept of arrays. I may be wrong however. I do agree that a professor that needs to ask about arrays should not be teaching the subject.


Agreed with all the suggestions about good use for arrays. Whenever you get a "deja-vu" feeling while writing code, there is a good chance that arrays, udt, aoi could help to prevent duplicate code.
 

Similar Topics

Hello, I have a small programming task that I need help solving. I have to: * Create an analog input (4-20v)and a digital output * The analog...
Replies
45
Views
25,074
I was poking through the Stackoverflow PLC Tag when I saw this answer to a question about converting a Real to a DWord and back again. What...
Replies
8
Views
2,892
I am looking for some expert advice. I have always made function blocks both with inputs and outputs and without inputs or outputs. I make the...
Replies
21
Views
6,714
Hello and happy new year! I would like to further understand who needs to design by this standard and is it a requirement for everyone or only...
Replies
3
Views
1,777
So Ladder is easy to read graphically, most everything can be coded in ladder, and it represents wiring diagrams the closest. SCL and ST are good...
Replies
5
Views
1,717
Back
Top Bottom