LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview vi that takes data and populates a list/array

Hello everyone, I was assigned to create a device that acquires voltages. I found a Data Acquisition box that does just that (not from NI, so I had to use activeX).

Although I am only electrical, and don't have too much experience with programming, I tried a VI that could capture this data.

The following is something that works but does not do exactly what I need. It only acquires the data for a specific channel selected manually using a numeric control and displays it on "data" digital indicator. What I have been trying to do is do the channel change automatically, starting from channel 0 to 6 (increment by 1), and each time populating some kind of array or list with this value until all 7 readings are taken. I tried For Loop, which seems easier to use, with a zero as a starting constant, but as hard as I try, it won't work. I would appreciate any help on the matter.

 

voltage.jpg

0 Kudos
Message 1 of 7
(2,681 Views)

Wire your data into an indexing tunnel on the while loop and it will output an array.

Capture.PNG

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 2 of 7
(2,669 Views)

Thank you Aputman, how about adding a conter starting at zero, take the data, place in array and increase to 1, and so on until 7?

0 Kudos
Message 3 of 7
(2,661 Views)

@joshorola wrote:

Hello everyone, I was assigned to create a device that acquires voltages. I found a Data Acquisition box that does just that (not from NI, so I had to use activeX).

Although I am only electrical, and don't have too much experience with programming, I tried a VI that could capture this data.

The following is something that works but does not do exactly what I need. It only acquires the data for a specific channel selected manually using a numeric control and displays it on "data" digital indicator. What I have been trying to do is do the channel change automatically, starting from channel 0 to 6 (increment by 1), and each time populating some kind of array or list with this value until all 7 readings are taken. I tried For Loop, which seems easier to use, with a zero as a starting constant, but as hard as I try, it won't work. I would appreciate any help on the matter.

 

voltage.jpg


Your image is pretty useless, because we cannot see most of the code (It is hidden in other frames of the stacked sequence structure!) The use of stacked sequences typically is discouraged. Don't use them!

 

Also your while loop is unecessary, because it only iterates once. If you would remove the while loop, nothing would change.

 

Since you know the number of channels (and thus iterations) before the loop starts, a FOR loop is correct. We cannot tell what you did wrong unless you show us what you tried.

 

Please attach your actual VI. Thanks

0 Kudos
Message 4 of 7
(2,656 Views)

Hi Altenbach, this labview programming seems pretty interesting, I will do my best to find a way to learn it so I can avoid these problems you refer to.

I am attaching the actual vi. 

I did not do this earlier becasue it does not really perform what I need, which is automatically start from zero as the input channel from the data aquisition device, populate the value in a table of sorts, increment the count by one, and repeat the process untill all channels have been read.

 

0 Kudos
Message 5 of 7
(2,642 Views)

Invoke nodes execute top to botton, so you should first select the channel and then get the data.

 

If you wire in and out of the nodes, the execution is determined by dataflow. No sequence structure needed.

 

Here's how it could look like:

 

 

 

Of course you would resize the array indicator to show the desired number of elements. If you don't know how to create an array indicator on the front panel, simply wire to the edge of the FOR loop as shown, then right-click the new tunnel and "create indicator".

 

(Of couse you would need to add error handling, etc. too. The reference is in a shift register to protect from the scenario where the for loop interates zero times. This ensure that a valid reference exits on the right even if the FOR loop does not execute)

Message 6 of 7
(2,630 Views)

Thank you so very much, I will spend time understanding this layout and will give it a try. Your help is highly appreciated!

0 Kudos
Message 7 of 7
(2,613 Views)