LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing acquisition frequency during measure

Hello guys,

I need some help with a scientific problem : I have to acquire a voltage with a USB 6361 with a frequency for 2MHz. However, the acquisition is rather long, during at least two minutes. I have to keep a high frequency for the first tens of milliseconds to observe the transient, but I want then to reduce the frequency in order to have not too many points in my file. For example, I would 2MHz for 10ms, then 1kHz for the rest of the acquisition

I have built a state machine for my project where i tried two solutions :

1) The first one is called "calibration" : I have created 2 state (Calibration and Calibration 2) and each one has DAQmx modules to read the voltage. After completing the first acquisition, the second one begins.

The problem with this solution is when I try to measure a signal, for example a pulse of 100ms, some data is lost between the two states, as you can see in the picture below.

Bingle_0-1756301416375.png

2) I have tried to do everything in one state : i tried to change the frequency of the measurement right after the end of the first step and to continue with the same task. The first step of measure works but not the second, I have a timeout error. The state of this method is called 'Test'.

 

I am not an expert at LabView so if you have any idea how to help me, it would be great 🙂

 

0 Kudos
Message 1 of 10
(272 Views)

Hi Bingle,

 


@Bingle wrote:

For example, I would 2MHz for 10ms, then 1kHz for the rest of the acquisition


10ms at 2MS/s gives 20kSamples…

 

  • So set up a continuous AI task to read at 2MS/s
  • read blocks of 20k samples, resulting in 10ms blocks
  • save the first block completely, with all samples to file
  • save the following blocks only after decimation, by reducing the number of samples from 20k to 10 (by a factor of 2000), resulting in an effective samplesrate of 1kS/s…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 10
(265 Views)

To top up what GerdW has shared, you can use Resample Waveforms VI to decimate the waveform before saving it.

-------------------------------------------------------
Applications Engineer | TME Systems
https://tmesystems.net/
-------------------------------------------------------
https://github.com/ZhiYang-Ong
0 Kudos
Message 3 of 10
(219 Views)

Hello GerdW 

 

I think I understand the idea but my competences in labview are really not that great... I tried to use the VI suggested by ZYong but I can't make it work

You say I have to reduce the number of samples but can I do that while the while loop is running ?

 

0 Kudos
Message 4 of 10
(181 Views)

Hi Bingle,

 


@Bingle wrote:

You say I have to reduce the number of samples but can I do that while the while loop is running ?


Sure.

(Maybe using a producer-consumer scheme may help with your data rate…)

 


@Bingle wrote:

I think I understand the idea but my competences in labview are really not that great...

I tried to use the VI suggested by ZYong but I can't make it work


What have you tried?

What does "not work"?

 

Please attach your current VI!

When attaching code: please downconvert when you use a recent LabVIEW version. Most wish for "LV2021 or older", I prefer LV2019…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 10
(172 Views)

Here what I tried in version 19.0.

You can find the "solution" (which is not) in the state "Test". I am not sure that I understand how the VIs 'write waveform to files' and 'Read waveform' work.

I have also looked at producer/consumer architecture but I could not make it works: when i dequeue the waveform, it was not a waveform apparently 😞

 

0 Kudos
Message 6 of 10
(154 Views)

Practical logical question, how long do you plan to capture data such that 2MHz rate results in a really a lot of data?

Are you concerned about file size? is that a constraint or a preference?

IMO, if I got enough diskspace, I just log at 2MHz rate, more data wouldn't hurt you anyway during analysis. Saves me time in code complexity to switch between data rate and during post processing adding the logic to be take into consideration of the sampling rate.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 7 of 10
(147 Views)

Hi Bingle,

 


@Bingle wrote:

You can find the "solution" (which is not) in the state "Test". I am not sure that I understand how the VIs 'write waveform to files' and 'Read waveform' work.


I recommend to use TDMS files, they are made for streaming measurement data into files:

I also changed some other stuff in this case/state.

No need to read "n chan" when you configure only one channel!

 


@Bingle wrote:

I have also looked at producer/consumer architecture but I could not make it works: when i dequeue the waveform, it was not a waveform apparently 😞


When you write a waveform into a queue then the Dequeue function will also output that waveform…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 10
(138 Views)

Ok I think we are almost there and you have been a great help thank you very much. The only thing that remains is the fact that the decimated part doesnt have the right time stamp : as you can see in the picture, you have the stap that last 10ms (as expected), but the value after the step should not represent fews ms but more like second. Do you have an idea of how to give the right time stamp to these values ? 

Bingle_0-1756389829355.png

 

0 Kudos
Message 9 of 10
(117 Views)

Hi Bingle,

 


@Bingle wrote:

Do you have an idea of how to give the right time stamp to these values ? 


Save the first iteration to group1 and the following iterations to group2. Now the waveform properties can differ as they are in different groups…

(And correct the waveform dt in case the decimation function doesn't adjust it on its own.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 10
(82 Views)