From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.


Showing results for 
Search instead for 
Did you mean: 

generating n samples works while continuous generation does not work



I am working an a vi that sweeps through a predefiend interval of voltages and frequencies. I want to test piezo tubes for power consumption and log some data.


When I set DAQ Assitant4 (it generates the output waveform) to n samples, my program cycles through the voltages and frequencies ok, although generating, say a sine wave at 1V, 1Hz for two seconds will create a gap between the two cycles of this 2 second sine wave. But if I use continuous samples, it will only output a sine wave say at 1V, 1Hz, but won't output say 1V, 2Hz next and so on......


I have attached 4 pictures showing the program outputting some waveforms using n samples and continuous samples.


The n samples pictures show the small delay I talked about in between say the two cycles of the 1 Hz wave in "n samples sine wave 2 seconds.bmp"


I would like to make "continuous samples sine wave 2 seconds each 1Hz and 2Hz.bmp" look like "n samples sine wave 2 seconds each 1Hz and 2Hz.bmp" because when I use continuous samples, the tiny delays go away...

You can see that in "continuous samples sine wave 2 seconds each 1Hz and 2Hz.bmp" the output shows the 1Hz and 2Hz wave, but the measured voltage only shows the 1Hz wave. I can't figure out why the next wave never gets sent out to my NI cDAQ-9178..... I used an osciloscope to verify that ony the 1HZ wave is sent out....


Anyone have any ideas??

Also, if it was possible to remove that tiny delay I spoke about when I use n samples, that would be great too!


Thank you

0 Kudos
Message 1 of 7
0 Kudos
Message 2 of 7

I have tried everything imaginable and have found nothing... please help??

0 Kudos
Message 3 of 7

Have you tried checking whether any of the DAQ assistants are generating an error?  Put an indicator on the Error Out terminal from the DAQ assistant and see if it reports anything.  If so, that may help identify the problem.  I'm going to guess, without any testing, that the problem is that when you set the task for continuous generation, you cannot then update the signal without first stopping the task, at least if you insist on using the DAQ assistant.  If there's an error that suggests that this is the case, save the Task Out in a shift register and stop the task before restarting it.

0 Kudos
Message 4 of 7

I will try the error message indicator.


I don't know how to restart the DAQ Assistant for voltage generation. I tried using it standalone in a clean VI and once I pressed the stop button, the voltage output stopped completely even though the stop button became false again. It should have started generating the output again right after a false - true - false transistion???


So how would I go about restarting the task?


Thanks.. this may be the solution i hope. 

0 Kudos
Message 5 of 7

I put together a quick test to duplicate your situation, as shown below, and it generates error -50103, "The specified resource is reserved."  What this means is that the analog output is already busy generating continuous samples so it can't be used again until the first generation task is stopped.

DAQ cont gen error.png

The best solution here is to get rid of the DAQ assistant and learn to use the DAQmx VIs.  They're not that difficult and will give you much more control.  You'll need to create the DAQ task once when the code starts, maintain it in a shift register, and write new values to it each time you generate a new waveform.  Clear the task when the program terminates.


If you don't want to do that, you could store the task reference from "task out" in a shift register and use DAQmx Clear Task to clear previous task prior to starting the next one.  You already have the DAQ assistant in a single-iteration For Loop (why?) so adding a shift register to store the task is simple.


Why does your code contain several useless loops that do nothing but wait?  Might as well just multiply the wait time.  Also, putting "Wait for Next Ms Multiple" inside a while loop may not get you the wait time you expect, since it's waiting just for the next time the computer clock reaches a multiple of that value, which could be very quickly for the first iteration.

0 Kudos
Message 6 of 7

After 80 hours I got it working.... I will post my solution soon with details 🙂

I'm not sure if its entire correct or proper but it works for now.


Thank you!

0 Kudos
Message 7 of 7