LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Looking for elegant way to slice the array

Hi, 

 

I'm relatively new to the LabVIEW community. I'm developing a vi to read tags from an Ethernet/IP device (AB CompactLogix PLC). The output of the Ethernet/IP read tag function is an array. I need to use each array element as a numeric display on the front panel. I know I could use the array index function to achieve this, but the array size is 128. So I wonder whether there is an elegant way to accomplish this.

 

Thanks in advance. 

Jimmy

0 Kudos
Message 1 of 10
(1,933 Views)

@jimmythedolphin wrote:

Hi, 

 

I'm relatively new to the LabVIEW community. I'm developing a vi to read tags from an Ethernet/IP device (AB CompactLogix PLC). The output of the Ethernet/IP read tag function is an array. I need to use each array element as a numeric display on the front panel. I know I could use the array index function to achieve this, but the array size is 128. So I wonder whether there is an elegant way to accomplish this.

 

Thanks in advance. 

Jimmy


Is there a "sensible" way to break them up into 2D arrays?  Like maybe they can be grouped, and each group have a tab?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 10
(1,887 Views)

@jimmythedolphin wrote:

I need to use each array element as a numeric display on the front panel. I know I could use the array index function to achieve this, but the array size is 128.


If I understood correctly, you are trying to create numeric indicators programmatically for each of the array elements. Please correct me if I am wrong.

 

0 Kudos
Message 3 of 10
(1,862 Views)

That is correct! This is what I'm trying to do. 

0 Kudos
Message 4 of 10
(1,839 Views)

Bill, 

 

That is a good thought. I can group similar elements into the same column, but I still need to index each element into a numeric indicator. I wonder if it can be done programmatically instead of using the array index function 128 times. 

 

Thanks,

Jimmy

0 Kudos
Message 5 of 10
(1,838 Views)

It is not possible to create indicators programmatically-- each indicator present in the front panel has to be created manually.


Could you explain why you need every array element displayed in a single indicator? Perhaps we can find a workaround.
Nevertheless, if it is indispensable to have 128 numeric indicators, you do not need to call the index array function every time, just extend it.

afort_1-1666461363409.png

 

 

0 Kudos
Message 6 of 10
(1,814 Views)

I think this might be the way to do it, extending the array index function 128 times rather than calling the array index itself for 128times. 

 

I don't need 128 elements to display to a single numeric indicator; each element will correspond to one numeric display on the front panel. 

 

Thanks for the suggestion!

Jimmy

0 Kudos
Message 7 of 10
(1,780 Views)

You can maybe reshape the array to a 2D array with 8 columns and 16 rows, for example, then display it in a table.

0 Kudos
Message 8 of 10
(1,777 Views)

If you want 128 elements on the FP, where you set each one up where you want, I would suggest doing something like this:

 

Set values.png

 

 

Some comments:

 

  1. It's a snippet, so you can download it and then drag it into a BD to get the code.
  2. It takes the label of the control in order to know which index in the array to use to update that control.
  3. I have used the control index to update the control, but you could also use the control reference and the Value property (which is not very efficient).
  4. In this case, the label is just the number. You could also have the labels have a more unique formatting and update the scan string to match.
  5. This does this for all the controls in the current VI. You could use something like the Static VI Reference I placed there (but didn't connect) or a an input to a subVI to move this code to a subVI.

___________________
Try to take over the world!
0 Kudos
Message 9 of 10
(1,754 Views)

Here's what I had in mind.

 

altenbach_0-1666538174838.png

 

Keep the array in a shift register and you can update any element by using "replace array subset" and the 2D indices calculated from the original 1D index.

Message 10 of 10
(1,736 Views)