From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help getting an array out of a while loop (each iteration adds a data point)

I have to use LabView to get data from two GPIBs. Basically I'm setting the voltage through the program, and getting the input from a picoammeter at that voltage. I have it showing the voltage, current, and loop count, and those show up fine. But it never leaves the loop properly. My file at the end will be full of zeros. I have looked at examples here, and tried some of the fixes. But I couldn't get them to work. This is my first experience with LabView...

Download All
0 Kudos
Message 1 of 7
(3,596 Views)

There are some odd constructs in your code.

 

In 05_01.vi, you have an insert into array, but the index is based on the loop iteration counter divided by an increment, and that is by default 0 on your control.  It is odd to base an index on a calculation, and certainly one that has a floating point result.

 

_Concat.vi is better, but it is still odd to use the i value and Insert Into Array.  You are effectively just appending to the end of the array, so it is much more common and proper to use Build Array.  I estimate 99% of the time I would use Build Array, and 1% or less of the time to I need Insert into Array.

 

It's hard to tell from your description and the rest of your code what you are trying to do.  Are you sure those GPIB functions are always returning values and not erroring out and returning zeroes?  Those GPIB functions are pretty archaic.  It is more common to use VISA functions even for communicating to a device via GPIB.

 

I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours

 

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

Is your goal just to create an array with one piece of data from each time the loop runs? If so, you can just use an auto-indexing output tunnel and LabVIEW basically does it for you - like this:

 

autoindex.png

 

If your goal is something more complex, can you explain more so we can try to help?

0 Kudos
Message 3 of 7
(3,563 Views)

I know it is getting data from the GBIP properly, because I have it reading it out as well and those read fine. And it also sets the Voltage up the way I set it. Also my professor set that part up for me.

Basically what my project is supposed to do is first set the voltage. It then increments the voltage up in increments I set, up to 30 volts. Each iteration it should add two values to an array, one voltage and the current at that voltage. After the loop is done it should export the voltage and current to an excel file that I can plot voltage vs current.

So I set the tunnel to auto indexing?

0 Kudos
Message 4 of 7
(3,549 Views)

Thank you for the tutorials also. I'm a transfer student and everyone else in the class has used LabView for a few years, and this is my first experience with it. 

0 Kudos
Message 5 of 7
(3,547 Views)

Yeah, if that's your use case, you really don't need to do anything tricky with inserting into an array. Wherever you have your voltage (should be a scalar, not array, value), just wire from there into your loop so it makes a tunnel and set it to auto-indexing. Do the same for your current value. Then, outside the loop, you will have two arrays made up of all your voltage values in one array and all your current values in the other array. You can then format these however you like to write to file.

0 Kudos
Message 6 of 7
(3,543 Views)

Look at the ramp function.  It will generate an array of the voltage values.  Feed that into a For Loop using an autoindexing tunnel.  Thing of an Autoindex input tunnel as  "For Each element In array".  Take the current measurement and output that through an auto-indexing tunnel.  Now you'll have an array of currents as well.

0 Kudos
Message 7 of 7
(3,542 Views)