LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting access to 2D arrays elements

Hello everyone,

 

do u know how can I get access to each element of 2D array independly? I mean by that, I want to pick every number from row ([1] [2] [3]), and after this from next row, to use this as variables in my project. I always need to read whole row with 3 number inside, so it shouldnt be hard. I managed to save data into csv file with GerdW(user) help and he gave me hint to use 2D Array but every time I try to do this 2D Array is shown as indicator and there are no links to plug to variable. In internet I found only only info about 1D arrays...

 

Any help will be useful!

Download All
0 Kudos
Message 1 of 15
(2,350 Views)

Its hard for me to believe that I cant really find any information about picking very element of saved Array for further processing. I mean what is point of creating 2D data array if you cant access but just display... There must be a way.

0 Kudos
Message 2 of 15
(2,338 Views)

Sorry, your question is very confusing and maybe hints at poor understanding of LabVIEW and arrays. Did you do the training resources? LabVIEW does not really have "variables", so please also clarify what you mean. Please define all your other ambiguous terms such as "plug in", "access", etc.).

 

Your two independent code fragments operate in parallel on the same file. I am sure you should define an execution order. To append a new row to a file, you don't even need to read it.

 

Please explain exactly what you want to do:

  • What is the purpose of the upper three controls?
  • What is the purpose of the lower code fragment?
  • What should the program do?
  • Why do you have two path controls if both contain the same file? Can they sometimes differ?
  • etc.

 

 

To operate on all array elements one at a time in memory order, simply reshape to a 1D array with a size of the product of the 2D dimension sizes and autoindex on a FOR loop.

0 Kudos
Message 3 of 15
(2,321 Views)

I will try to explain this on screenshot It will be easier I think.

0 Kudos
Message 4 of 15
(2,318 Views)

@Krzysztof_Orzel wrote:

I will try to explain this on screenshot It will be easier I think.


No, that does not explain anything!

 

  • What is the purpose of the color code for the rows?
  • You still have the upper code that has no meaning here.
  • Why do you need three indicators? Wouldn't a 1D array indicator with three elements be more elegant? (what if the rows have 100 elements in the next project? 😮 )
  • What do you expect to happen if the program runs? (timing, etc.)
  •  
0 Kudos
Message 5 of 15
(2,315 Views)

This code is just prototype to implement this in main project. I just want to make it work... I want to pick every number from each row (there are n rows and always 3 collumns = 3 numbers) and do smth with it. My main project is about controlling robot with ni softmotion module. So this is algorithm.

 

 

1. Push button : Save 3 positions of robots axes into into csv. (axis position is expressed in degrees)

2. After You have enough robot movements read them and split so they can be wired to coresponding axises.

 

every push of button is 1 save and every push of another button is 1 read from previously loaded csv. Ofc Before u start reading data you need to import ALL robot movements.

 

 

 

0 Kudos
Message 6 of 15
(2,313 Views)

Can we assume that all values are integers? (currently, they are!)  If so, why are they orange and why do you inflate your file with all these meaningless zeroes and decimal delimiters?

 

This would read your file and display one rows at a time every .5 seconds until all rows are processed. You can easily substitute your timing and processing for the indicator.

 

altenbach_0-1639436665038.png

 

I really think you should start with the basic tutorials!!!!

0 Kudos
Message 7 of 15
(2,307 Views)

Im sorry you cant understand me in a way I want you to.

The zeros are not meaningless. Zeros stand for robot homing so

 

Row1 : Homing, Values:0 degrees,0 degrees,0 degrees

Row2 : Move in axes, Values:10 degrees, 20 degrees, 20 degrees

Row3 : Move in axes, Values:20 degrees, 20 degrees, 20 degrees

Row4 : Move in axes, Values:10 degrees, 40 degrees, 20 degrees

Row5 : Homing, Values:0 degrees,0 degrees,0 degrees

 

I need to read every row and PICK every value from current row to wire this into ni soft motion function block.

I cant just display this, I need to wire this values. 

0 Kudos
Message 8 of 15
(2,302 Views)

You are still only showing integers. I meant the decimal delimiter and anything behind it seems meaningless.

Anything that can be displayed in an indicator can also be processed further.

 

You really (really!!!!) need to start with the basic tutorials. Learn about the principles of dataflow. Learn about simple state machines, etc.

0 Kudos
Message 9 of 15
(2,296 Views)

I have 3 function blocks

 

every row of array contains 3 values, first value is for first function block so the second and third, these values are wired to position.

 

The problem is I cant pick these values as values which FITS to this they are always presented as some kind of array... 

0 Kudos
Message 10 of 15
(2,289 Views)