08-27-2025 08:47 AM
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.
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 🙂
08-27-2025 09:01 AM
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…
08-27-2025 08:22 PM
To top up what GerdW has shared, you can use Resample Waveforms VI to decimate the waveform before saving it.
08-28-2025 04:41 AM
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 ?
08-28-2025 06:08 AM
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…
08-28-2025 07:42 AM
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 😞
08-28-2025 07:48 AM
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.
08-28-2025 07:57 AM - edited 08-28-2025 07:58 AM
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…
08-28-2025 09:05 AM - edited 08-28-2025 09:06 AM
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 ?
08-28-2025 01:07 PM
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.)