LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Updating PLC Array in LabView

I have a project on my hands.

 

I am trying to continously update an array from a Micrologix 1100 PLC in a LabView array, that will ultimately be updating an XY graph as the data points come in.

 

Every 5 milliseconds the PLC is updating a point or pressure value in array of 254 values, 127 points of each. The idea is to update the array in LabView in as close to real time as possible, each time a value changes in the PLC, it should change in LabView. So there are 2 arrays, one that always has new data and one that is continuously being updated.

 

Here are some of my thoughts on it:

 

Fill in the first array, send that in to Insert Array inside of a while loop. Have a shift register on the outside of the while loop, being fed an array constant on the input going into the new array on Insert Array, then being fed on the output the result of the insert array function. One problem is that I am not getting any values out of the shift register. In order to properly index where the new array is put each time, I am trying to have it go and look at the first point to see if it has changed or not and if it is greater, then insert the new updated array starting in that position.

 

My boss says he thinks it is quite simple and would have it figured out in an hour. I have been working on this for about a whole day now and am beating my head against the wall here. Can anyone help?

 

I will post some code up here in a few minutes...

0 Kudos
Message 1 of 6
(3,444 Views)

I have been working with it here. I notice that before I insert my index value of where I am trying to insert the new data, I get my updated array and output arrays to populate, if I try inserting my index value, those arrays come back blank when I run the VI.

 

 

I have attached my vi. Please help me if you would.

0 Kudos
Message 2 of 6
(3,437 Views)

Hi M Boat,

 

I can't be certain without being able to run the code, but using that large of an array and trying to compare the values and then decide to whether or not to write to another array is probably too much logic to run in 5 milliseconds.

 

Are you wanting to overwrite your array to match that of the PLC or do you want to keep building a larger and larger array? If you just want to update values, you should use the Replace Array Subset.vi instead of building an array to delete from your original array so that you can add new values.

 

Some of your subVIs were missing from the attached VI so I can't tell exactly how your reading from the PLC is working. Are you not able to read the entire array at once and that is why you are splitting it into five reads then building an array? This is going to slow down the code operation as well, so if it is possible to read the entire array in at once then that would help optimize the code.

 

You mentioned comparing to see if the first value is larger and then deciding to write, why do you need to do this? Is that an increment value that will tell you if you have received new data or are you only wanting to write if the values are increasing so that you have the maximum values?

 

I would suggest that you go through the Example Finder (Help » Find Examples...) and http://www.ni.com/examples/ to look for programs that are similar to what you are trying to do so you don't have to start from scratch. There are many examples of reading in values from hardware and writing it to arrays/spreadsheets/graphs that you can adapt to use your subVIs that you already wrote to read from your PLC. Instead of trying to reinvent the wheel every time you can build from code that others have already written and make your job a lot faster and easier.

 

Regards,

Peter W.

0 Kudos
Message 3 of 6
(3,421 Views)

First of all you are doing too many reads, You should be able to read the entire file in three reads. You have a maximum of 124 words that you can read at once. Every time that you have to read from the PLC it will slow you down so you need to read these in 124 word chuncks. If you get errors for time out the you need to increase the timeout time. You will not be able to read more than 124 words at a time. I would set the PLC read up in one loop and the data processing in another loop. Have you heard of Producer and cunsumer loops? You need to look into that if you have not. There are examples that ship with LabVIEW.

 

I started making some changes on your code so we can work through the rest. I realize that everthing is not working. I wanted you to see how I would start with this problem. I expect that a 5 msec update rate will be very hard to achieve.

Tim
GHSP
0 Kudos
Message 4 of 6
(3,418 Views)

Another thought occured to me as I was working through you code. You should set up the first 128 words as pressure and the second as points so that you do not have to seperate them in LabVIEW. THat way you can read the first 128 word in one array and the second 128 words in the second array eliminating the time consuming seperating of data points one by one in Labview.

Tim
GHSP
0 Kudos
Message 5 of 6
(3,415 Views)

Here is a more complete thought. If you change the write positions in the PLC then this would give you most of what I think you are doing.

Tim
GHSP
0 Kudos
Message 6 of 6
(3,412 Views)