LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the right way to collect XY data?

Solved!
Go to solution
The way our Labview code works is very poor. We want to do the following: Initialize a DAC, and then in a loop: 1. Read from an ADC or counter. Plot the reading as a point on an XY Graph (DAC setting as x, ADC reading as y) 2. Set the DAC to a new value 3. Wait some amount of time for the equipment to equilibrate 4. Read the ADC again, etc. I don't know a good way to keep the data and send it to the XY graph. Our old program initialized a 2D array, with one column being the DAC ramp and the other holding all zeros. Then, as data was collected, the zeros were updated with the data. This method isn't good, because the graph always showed a flat line graph until all the data was collected, instead of scaling correctly to the bounds of the actual data. Is there an example or a tutorial to help with this concept? I basically understand flow control using error and task, but I don't have a grasp of shift registers and initializing.
0 Kudos
Message 1 of 3
(2,266 Views)

Read about the state machine architecture. That's what you need and store the array in a shift register. A shift register is basically a spot in memory that holds your data (array, numeric value, cluster etc). So, whatever you wire into the shift register will be stored there to be accessed on your next loop iteration. The initializing an array method is fine, and in fact prefered especially on systems where memory management is important (i.e. cRIO, or any RTOS). If you are on a windows machine, you rpobably don't need to worry about this unless your array is going to be massive. Assuming your data is doubles just initialize with NaN instead of 0. Then it won't show the points on the plot.

Message 2 of 3
(2,253 Views)
Solution
Accepted by topic author Rgann

 


@Rgann wrote:
 Our old program initialized a 2D array, with one column being the DAC ramp and the other holding all zeros.

 

You should initialize the 2D array with the ramp for x and the y row containing all NaN. Any point containing a NaN will not be shown on the graph.

 

I usually prefer to keep the x range constant instead of rescaling with every new point, but if you want to keep the x scale tight, you could update the range min and max using property nodes depending on the current insert point.

You already must be using a shift register (or feedback node) to contain your array, so that should be OK as is.

 

Also remember that if the ramp is linearly spaced, you can use a waveform graph. You simply need to set x0 and dx accordingly. (An xy graph is only needed if the points are not spaced equally in x.)

Message 3 of 3
(2,246 Views)