09-30-2014 05:00 PM - edited 09-30-2014 05:02 PM
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.
09-30-2014 05:27 PM
Wire your data into an indexing tunnel on the while loop and it will output an array.
09-30-2014 05:39 PM
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?
09-30-2014 05:58 PM
@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.
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
09-30-2014 06:38 PM
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.
09-30-2014 07:04 PM - edited 09-30-2014 07:10 PM
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)
09-30-2014 07:54 PM
Thank you so very much, I will spend time understanding this layout and will give it a try. Your help is highly appreciated!