Sign in to follow this  
Followers 0
robert_

Arrays

6 posts in this topic

Hello friends, I have a question: what is an array in PLC programming?

Share this post


Link to post
Share on other sites
A series of data of one type. For example integers. Instead of creating labels Data1, Data2, Data3, I can create an array with multiple elements, and then reference them by the one name and element number. So I define Example as an array of 10 integers. Now I have labels Example[0] through Example[9]. They can also be 2D (think spreadsheet, rows and columns) and 3D (add multiple sheets).

Share this post


Link to post
Share on other sites
Wow! I thought I kinda understood arrays, I could work them but it was still a little fuzzy. Thanx immensely for the excellent clarification.

Share this post


Link to post
Share on other sites
Have you ever seen an application that used a 3D array? I would really like to see an application that uses the third dimension.

Share this post


Link to post
Share on other sites
I've got one here that uses a 3d array for controlling a DC electric nutrunner. "Columns" correspond to truck options, "rows" correspond to individual valve program numbers. The "worksheets" correspond to different takt times for the process. Shorter cycle times mean that some work content has to get moved to additional team members. The current implementation in our PLC is terribly inelegant, but it gets the job done, so I haven't changed it.

Share this post


Link to post
Share on other sites
Lets say you have a temperature setpoint profile for an oven that has 20 ramp/soak times and 20 setpoints. You might store that in a 2D array [2][20] with one column for the times and the other for the setpoints. Now lets say you wanted to store 10 different setpoint profiles in memory. Here you could use a 3D array [10][2][20]. If you still have a hard time picturing it then go back to the fact that all the memory in a computer is just a 1-D array. Anything higher is just a mathematical form for accessing a 1-D memory address. Lets say that MyArray is a 10x10x10 3D array. We have defined it as a 3-D array but in the computer MyArray is a chunk of contiguous 1-D memory with 1000 words in it. If in our program, we want to access address MyArray[5][3][7] then the processor will compute the address as 7 + (3*10) + (5*100), or MyArray[537], and go fetch that address. Do you think you could construct an array in a PLC/5 that is addressed with three dimensions using its memory file architecture? The answer is yes, it wouldn't be as easy as a controllogix makes it, but its not really hard either. Now, are you ready for a real mind bender? Assume that you have 5 different ovens. You could use a 4-D array [5][10][2][20] to keep ten sets of profiles for each of the five ovens. I don't know of a PLC compiler that supports a 4-D (or more) array but other computer programming languages can support 4-D, 5-D,or even higher.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0