LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx write and for loop

Hi community!

 

I'm building a simple sine wave generator using one channel of my DAQ. I want this generator be similar to lab tools i.e. I want to be able to sweep frequency and change amplitude in real-time.


That's why I can't use "Continuous Sample" because I would need to completely cut my signal, change freq. and/or amp. and restart it.

The only option I see is the "Finite Sample" in a loop. The issue is it takes 50-100 ms to transfer from a data packet to another which ruins my sine wave. This delay is normal because I end DAQmx task on each loop. I tried to play with "DAQmx Timing" and use the same task over and over with a different waveform that I generate in real-time but I could not figure it out. The property "Offset" of DAQmx Write seems promising but I don't know how to handle it yet.

 

I joined my two versions.

 

Any suggestion is appreciated. Thanks!

0 Kudos
Message 11 of 17
(722 Views)

For future reference, you probably should have started a new thread for this question.

 

To change output in real-time without gaps, you *need* to be using Continuous Sampling.  I'd strongly encourage you to start from the shipping example for non-regeneration continous voltage output.  The example lets you make gapless changes to an output waveform in (kinda) real time.

 

You may find that you need to do further refinements to reduce latency from when you make changes on the GUI until you see those changes in the real-world output signal.  The example gives you *some* control over this with the "Number of Samples" where a smaller # can help reduce latency.  A good starting point is to set it to 1/10 the sample rate so you are writing 1/10 sec worth of samples at a time.

 

Start there and come on back if/when you get stuck.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy coming to an end (finally!). Permanent license pricing remains WIP. Tread carefully.
Message 12 of 17
(702 Views)

Thanks for your answer. I tried the example "Voltage (non-regeneration) - Continuous Output.vi". With or without regeneration doesn't make a difference. I see the waveform output updating in real-time in the vi but like in my own vi, the waveform generated on first iteration is repeated for ever at hardware level. I can see it with an oscilloscope. Even if "DAQmx Write" is called repeatedly, the waveform I see in the vi front panel is not taken into account.

 

For me it looks like continuous output absolutely requires that the waveform is built entirely before starting the task. If I stop the task and re-start it on sine amplitude change for instance, the waveform is updated but the latency breaks the sine wave so I have the same issue as in finite sampling. I don't mind if it takes 1 second to update after I change sine amplitude, but I need to keep the integrity of the sine wave.

0 Kudos
Message 13 of 17
(666 Views)

Which DAQ device are you using?  The ones I have familiarity with don't behave the way you describe.

 

Have you tried adding the DAQmx Write property node that lets you set Regeneration Mode (like you did in the vi you posted)?  If not, try that while setting it to "Do NOT Allow...".   Just guessing that maybe you're using a device whose default behavior is to regenerate from local memory on the device, which could explain the lack of change of the real world signal.  Once you set that, you'll *need* to keep writing new data in your loop to prevent a buffer underflow error.

 

 

-Kevin P

 

ALERT! LabVIEW's subscription-only policy coming to an end (finally!). Permanent license pricing remains WIP. Tread carefully.
0 Kudos
Message 14 of 17
(643 Views)

I tried "Do not allow" and "allow" and there's no difference. I joined the vi I'm now using.

 

Here's my hardware info :

AlexDarsigny_1-1685451738175.png

 

0 Kudos
Message 15 of 17
(618 Views)

Is my hardware suited to have what I need? If not, what hardware should I use?

0 Kudos
Message 16 of 17
(599 Views)

Did I hit the limit of DAQmx library ? Any suggestions is welcome.

 

Thanks.

0 Kudos
Message 17 of 17
(563 Views)