06-27-2012 09:38 PM
Hello,
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
06-27-2012 09:38 PM
last two pictures....
06-28-2012 01:04 AM
I have tried everything imaginable and have found nothing... please help??
06-28-2012 01:34 AM
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.
06-28-2012 02:04 AM
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.
06-28-2012 01:22 PM
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.
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.
06-29-2012 01:29 AM
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!