LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

continuous measuring of voltage and counter and saving the data

Hi,

 

I'm using a NI USB-6211 device to measure 3 voltages in Diff-Mode, 3 voltages in RSE-Mode and a encoder output from a motor (Faulhaber 1331T006SR with IE-400 encoder), which gives 400 pulses (rectangular signal) per revolution. I am using the attached .vi to measure the signals and save it as text-file. My problem is, that I need to measure the signals with 500Hz sampling-frequency for around half an hour. I need the data, without interruption, to do some analysis on the data afterwards. The mentioned .vi works, if I measure something like 150k points (I set it with the number of samples) which is around 5 minutes. But if I want to measure more points the programm runs for a very long time and doesn't save anything. I tried to put a while-loop around that stuff and to buffer the measurements in an array and write the data stepwise in a file. To test that I've measured a sine-signal and the inputs, but there was always a small gap between the measurements, when the while loop was reentered.

How can I do this? I wouldn't mind writing the data in a binary if this is faster.

 

The vis are for labview 2011 and 2009.

 

best regards,

estanzi

Download All
0 Kudos
Message 1 of 10
(6,600 Views)

Writing to a file doesn't matter if you have seperate loops for Data acquisition and processing. You need to have 2 different loops among one you have to acquire the data as 1 sample per acquisition and run the loop at 500 Hz ( You can use Timed loop for this) and put the data to the Queue. In the other loop you can have it as a normal while loop and read the data from the queue and write it to the file.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 10
(6,598 Views)

But the problem with initialising the DAQ-tasks still takes some time, so if I put it in a loop, there still will be jumps in the sine-signal??

How do I create a timed-loop?

How do I put the data in a queue?

And how do I tell the vi that it has to measure for example 4 million values?

 

Thanks for the answer!

 

regrads,

 

estanzi

0 Kudos
Message 3 of 10
(6,594 Views)

@estanzi wrote:

But the problem with initialising the DAQ-tasks still takes some time, so if I put it in a loop, there still will be jumps in the sine-signal??


You should not put the Initialization into the loop that has to be outside the loop at the beginning.

 


@estanzi wrote:

 

How do I create a timed-loop?

How do I put the data in a queue?

 


You need to go through the basic materials on LabVIEW. Search for Timed loop in LabVIEW help and You may find this to be useful.

 


@estanzi wrote:

And how do I tell the vi that it has to measure for example 4 million values?

 


You can calculate the time for which the loop has to acquire the data based on the required samples then stop the acquisition once the data you expected is obtained.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 4 of 10
(6,587 Views)

You already have separated your setup and data acquistion, so your solution should be fairly straightforward.  As mentioned above, you will be implementing a loop around your data acquisition so you can repetitively take data.  You will also be putting a loop around your file storage, so it can store repetitively.  You will pass data between the loops using a queue (a wire would cause one loop to wait until the other was finished).  This is called a producer/consumer architecture, and if you search these forums you will get many hits.

 

  1. Put a WHILE loop around your actual acquire VIs.  Do not include the start task or clear task VIs inside the loop.
  2. Put a WHILE loop around your file save VI.  Do not include writing the header info, since you only need to do this once.
  3. Create a queue before either of the loops execute.  In the DAQ loop, enqueue your 2D array as you get it.  In the file store loop, dequeue and save data as it comes off the loop.
  4. Change the sample clocks from Finite Samples to Continuous Samples. This will allow you to not miss anything, but it also means your program needs to keep up with the data acquisition.

When you do this, you will run into the problem of how to stop both loops.  Stop the first loop any way you want (e.g. after X number of points, after a certain time, etc.).  When it finishes, enqueue an empty array into the queue.  Stop the bottom loop when it gets an empty array.  Make sure you close the queue reference after the bottom loop exits.  Some other things you may want to do:

 

  1. The file storage VI you are using opens the file, seeks to the end, writes, then closes the file.  Since you are streaming, it would be far more efficient (and your program may not work unless you do this) to open the file before the loop, stream data to it during the loop (use Array to Spreadsheet String for formatting), then close after the loop.
  2. If even this is not fast enough, use TDMS for your data storage.  It will result in a smaller file and will be much faster.  However, it is a binary file, so make sure whatever you are using for analysis can handle it.  You could also convert it from TDMS to whatever you need after your acquisition.  Given your low data rates, you should not need to do this if you do option 1.

Good luck.  Let us know if you have more issues.

0 Kudos
Message 5 of 10
(6,585 Views)

Hi,

 

maybe this helps you to acquire and save your data.

Here you acquire one voltage signal and write it in a TDMS-File.

My example is based on producer-consumer design pattern.

 

You can open the TDM or TDMS file with Excel after having installed the TDM Excel Add-In for Microsoft Excel: 

http://zone.ni.com/devzone/cda/epd/p/id/2944

 

TDM and TDMS Data can of course be opened in NI DIAdem:

http://www.ni.com/diadem/whatis/

 

Producer/Consumer Design: http://www.ni.com/white-paper/3023/en

 

I hope this helps.

 

Best regards

Suse

______________________________
Certified LabVIEW Developer (CLD)
0 Kudos
Message 6 of 10
(6,566 Views)

Hi,

 

sorry for the late answer:

I realized the solution proposed by DFgray partly, but if I set the SampleMode to Continuous, then it doesn't work. I get an error 200560, which seems to be a timing error. How can I avoid it. If the SampleMode is set to Finite Samples and I want to read 1000 samples it works well.

 

Any hints?

Thanks in advance,

 

Stani

Download All
0 Kudos
Message 7 of 10
(6,526 Views)

Full disclosure - I am not a DAQ guru, so take any advice at this point with a grain of salt.  I think it might work if you remove the wait until done VIs.  Remove them and wire the 5s timeout into the acquisition VIs, along with the number of data points you want (same value for both).  If that doesn't work, try modifying your buffer sizes.  Your data rates are relatively low, so you should be able to do this.

 

Good luck!

0 Kudos
Message 8 of 10
(6,520 Views)

Hi,

 

so far this looks like this (see attached vi) and seems to work. I have to do a longterm test and give feedback.

 

Thanks again,

 

estanzi

Download All
0 Kudos
Message 9 of 10
(6,512 Views)

Hi,

 

another Problem:

I have tested this programm with a constant voltage input and a function generator, which provides a rectangular signal as frequency input.

The problem now is, that if I want to measure 60s, I would set it in "time", which changes the stop condition of the acquisition loop to

 

60s * SamplingFrequency (1000Hz) / Number of samples per channel (100) = 600 Iterations

 

But the programm runs sometimes longer than 60s, which seems to depend on the frequency of the function generator. If I set the frequency to the sampling frequency (1000Hz), then it takes 4 times 60s. If I set it to 2000Hz, then it takes 2 times 60s.

I played around with it and guess that to get a frequency the device is averaging over 4 rising edges?

 

Is it the limitation?

How can I make sure that the voltage measurement and the frequency measurement are synchronious?

 

Regards,

 

estanzi

0 Kudos
Message 10 of 10
(6,495 Views)