LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Graphing & Execution Speed with 2 A/I Channels and 1 A/O Channel

Hello,

 

I am using Windows XP, a NI PCI-6024E DAQ board, and Labview 2011.

 

I have a Concept 2 model C rowing ergometer ("erg"). The erg is fitted with sensors providing two analog voltage inputs: one from a Lego 2838 motor, and one from a solenoid on the flywheel of the erg. I am trying to output a voltage signal based on the 2 inputs. I have two main issues:

 

1. The waveform charts for Motor Voltage, Flywheel Voltage, Handle Velocity and Brake Voltage Output only plot the 1000 samples collected on each iteration of the while loop. How can I display a graph with a full time history for each of the aforementioned parameters?

 

2. I also have an issue with the speed at which the program is executed. Ideally, the voltage output would update every 10ms. However, decreasing the number of samples (for example 100 samples for a 1000 Hz sample rate) gives terrible resolution on my "RPM Flywheel" graph, which is dependent on the number of peaks detected in a sample set. The flywheel averages around 400 RPM, so this is a limiting factor on the number of peaks detected. One idea I'm considering is to have different number of samples collected for each input in the DAQ, and then update the output voltage data based on the changes in motor voltage data. Could I program Labview to collecte data at a rate of 1k Hz and 1k number of samples for the flywheel, but collect the motor voltage data at a rate of 1k Hz with 100 samples? Is there a better way to improve the speed of this program?

 

Thanks very much. See attachment for block diagram. 

 

0 Kudos
Message 1 of 6
(2,694 Views)

Hi mkw21,

 

1) To display graphs with a full time history, you need to replace all of the Charts on your front panel with Waveform Graphs and disable the AutoScale X on those graphs.

 

2) To speed up your program you need to replace the DAQ Assistants in your block diagram with standard DAQmx functions.

DAQ Assistant is a quick way to start acquiring data, however it's not the most efficient.

Everything that DAQ Assistant does can be acompished with basic DAQ functions on the

Measurement I/O -> NI-DAQmx pallete.To get started with using the DAQmx functions you can browse through Hardware I/O examples in the Example Finder.

Open up a new LabVIEW VI and then go to Help -> Find Examples -> Hardware Input and Output [folder] -> DAQmx -> Digital Measurements

 

Also, here are some very useful articles and examples you might want to look at:

 

Getting Started with NI-DAQmx: Main Page

 

Learn 10 Functions in NI-DAQmx and Handle 80 Percent of Your Data Acquisition Applications


Multi-Function: Read Analog Input and then Write Signal on Analog Output

 

Synchronized AI AO with Dynamic Clock

Mikhail
RF Toolkits, Product Support Engineer
National Instruments
0 Kudos
Message 2 of 6
(2,669 Views)

Hi Mikhail,

 

Unfortunately, replacing the charts with waveform graphs (and deselecting autoscale x) still only plots the current 1000 samples in the current iteration of the while loop. It does not plot the entire time history.

 

Also, I have started to build the DAQmx block diagram for faster data collection. The links that you recommend were helpful, but I cannot find anywhere how to collect data from the same device with multiple channels, namely ch0 and ch1, at different sampling rates or number of samples. Is this function possible on Labview?

 

Thanks,

0 Kudos
Message 3 of 6
(2,655 Views)

The advice you got was incomplete. A graph does not keep a history. The only way to use a graph is by using a shift register and appending old data with new data by using a build array function. You can quickly run out of memory though and it is an inefficient process. Your chart is probably set for the default of 1024 samples so once you acquire more than that, old data is dropped and replaced with the new. You can change the history with a right click. How long do you intend to run the acquisition? How long is the acquisition loop supposed to run? How many samples will you want to display?

 

You cannot collect data at different sample rates. You have a single A/D with a single convert clock so all channels must use a single task and a single rate. You can, however, decimate the data on certain channels. Changing from the DAQ Assistant will not necessarily make your program run any faster.

0 Kudos
Message 4 of 6
(2,650 Views)

Hello,

 

To solve the sampling rate issue, I now have two PCI boards that are collecting data in two simultaneous while loops.

 

As for the graphing issue, I would like to plot the array of locations of the peaks from the peak collector function for multiple iterations of the while loop. The DAQ is set to run at 1000 Hz with 1000 samples. I want to save the data from about 5-10 iterations of the while loop. The output from "locations" is an array, and for my purposes, upon each iteration of the while loop, there are roughly 20-50 double values collected from the 1000 samples. I tried using Write to File, but I am getting data overflow issues. What is the best way to do this?

 

I am attaching my code, it is a work in progress.

 

Thanks,

0 Kudos
Message 5 of 6
(2,629 Views)

Hi,

 

Here are a few recommendations:

 

1) In your program the "stop" button does not really stop the program. It stops the second (analog input) loop but your first loop keeps going, and it will keep going forever since the timing in your Analog Output task in DAQ Assistant is set to Continuous. So create a functional global variable linked to a stop button that will stop both of your loops simultaneously.

 

2) To start writing to file after 10th iteration of the first while loop you can simply take your iteration index (i) of your loop and check if it's greater than 9 and then feed this result into the "Enable" input of your Write to Measurement File VI.

 

3) As an alternative to using Write to Measurement File VI you can stream your data to a TDMS file ( thus bypassing the Windows and LabVIEW buffers) or simply write your data to a text file. Here is an example how to do this:

[LabVIEW] -> Help -> Find Examples -> Fundamentals -> File input and Output -> Write to Text File.vi

 

 

Mikhail
RF Toolkits, Product Support Engineer
National Instruments
0 Kudos
Message 6 of 6
(2,615 Views)