ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Filling an array with serial data in a While Loop

Greetings,

 

I am fairly to new to LabVIEW, but I have a decent understanding of how to get things done. But I am currently stuck.

 

Issue:  I am trying to fill an array with serial data while running a While Loop. Only the first element is filled.

 

                  Specifically, I am running a program that accepts inputs of both pressure and diameter. Diameter is being read in from a Laser Scan Micrometer (Mitutoyo LSM 6200 + 501S). The data is read in using VISA Read, which is as a string. I am attempting to convert the string information into a numeric using scan from string (which, as above, is successful for one element). Then, I want to insert each converted piece of data into an array. I have tried this a few different ways, one attempt is attached, below:

 

I am using a While Loop because I want the program to start by running a DAQ box for pressure while simultaneously controlling a pump and the LSM. Then, once enough data is collected (my stop if True is when the size of the pressure  Array reaches sample rate * sample duration) I stop the LSM, the pump and the VI. Note, this stage of the VI only consists of the Daq box and the LSM. I have yet to buy a pump. 

 

Note also the sampling rate of the LSM is hardcoded into the device itself, but I am inputting an equal sampling rate for pressure. 

 

Every time I run I only get one value for Diameter, yet I fill all of my values for pressure. What am I doing wrong?

 

Thanks for your time,

Matt

0 Kudos
Message 1 of 3
(2,679 Views)

Greetings,

 

I am fairly to new to LabVIEW, but I have a decent understanding of how to get things done. But I am currently stuck.

 

Issue:  I am trying to fill an array with serial data while running a While Loop. Only the first element is filled.

 

                  Specifically, I am running a program that accepts inputs of both pressure and diameter. Diameter is being read in from a Laser Scan Micrometer (Mitutoyo LSM 6200 + 501S). The data is read in using VISA Read, which is as a string. I am attempting to convert the string information into a numeric using scan from string (which, as above, is successful for one element). Then, I want to insert each converted piece of data into an array. I have tried this a few different ways, one attempt is attached, below:

 

I am using a While Loop because I want the program to start by running a DAQ box for pressure while simultaneously controlling a pump and the LSM. Then, once enough data is collected (my stop if True is when the size of the pressure  Array reaches sample rate * sample duration) I stop the LSM, the pump and the VI. Note, this stage of the VI only consists of the Daq box and the LSM. I have yet to buy a pump. 

 

Note also the sampling rate of the LSM is hardcoded into the device itself, but I am inputting an equal sampling rate for pressure. 

 

Every time I run I only get one value for Diameter, yet I fill all of my values for pressure. What am I doing wrong?

 

Thanks for your time,

Matt

Download All
0 Kudos
Message 2 of 3
(2,659 Views)

@MKandPL wrote:

 Every time I run I only get one value for Diameter, yet I fill all of my values for pressure. What am I doing wrong?


You are only showing the data from that iteration.  If you want to combine with the data from previous iterations, you need to store the array in a shift register and use Build Array to add the data to the array.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 3
(2,641 Views)