LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to generate a finite number of output buffer iterations using DAQmx?

I need to generate a waveform for 60 seconds. When I stop the waveform using DAQmx, I need the output of my E-series DAC to be at the end of the output buffer so I can be sure the output is stopped at zero. Right now, if I generate a continuous sinewave and stop it after sixty seconds, the output stops at whatever level it happened to be when the stop was performed. The old DAQ vi's would let you generate a defined number of buffer iterations. Is there any way to generate a sixty second periodic waveform that stops at the end of the output buffer without having to create a 60M sample waveform?
-Devin
I got 99 problems but 8.6 ain't one.
0 Kudos
Message 1 of 23
(5,631 Views)
Billings11,

The problem does not lie in the number of iterations. While doing continuous or single buffered output the DAQ card only outputs the number of values that are in the buffer. What you are seeing is a basic functionality of DAQ cards. When assigned a value to output, they hold that value until a new value is given. Wile outputting a waveform the card updates its output voltage at the specified update rate. When you reach the last value the DAQ card holds it and will not change until it gets its next update (or the card is reset).

There is a way around this. You can append a zero value to the end of your output waveform. This will force the card to go back to an output value of zero when its done.

I have attatched an examp
le of how to do this.
0 Kudos
Message 2 of 23
(5,618 Views)
Thank you for the reply, but forcing the output of my wavefom to zero is not the problem. I create a DAQmx task and load a waveform into the DAQ buffer using DAQmx write.vi, multiple waveforms, multiple channels. I load one period of a periodic waveform. Think of it as a sinewave. I must execute this waveform an even number of iterations so I stop at zero.

Simply forcing the output to zero is not enough. The analog output is being used to drive the motion of a real system, so I cannot jump from some unknown value, say 5V, to 0V instantly. Doing so could do physical damage to my system. I need to know that my analog output stops and the end of the waveform I configured in DAQmx. I know the duration I need to run my waveform, and with the old DAQ vi's I could easily configure a waveform using AO Write and tell it to execute 14,792 iterations.

DAQmx Stop.vi stops the vi at some index on the waveform I configured. Is there a way to know what index my waveform is stopped at? If I knew my waveform was stopped at 5.236V, I could build a ramp to 0V and output that. But I cannot jump from there straight to 0V in an uncontrolled way.
-Devin
I got 99 problems but 8.6 ain't one.
0 Kudos
Message 3 of 23
(5,581 Views)
Just as an addition to my above post to clarify my problem. When I use DAQmx Stop.vi to stop outputting my waveform (pretend its a sinewave) the analog output does not stop at the end of the waveform I configured using DAQmx Write.vi. It stops at some point in that waveform where the DAQ happened to be when the stop command was issued. It effectively stops at some random unknown point on my sinewave. So I don't know what my DAQ is outputting. It often stops at some value like 5V. If I try to do a large step of more than 1V or so (I am working on the +/-10V Range), my motion control system will saturate amplifiers that are driving a motor, and the motor will go unstable. If I knew what index in my waveform I was stopped at I could build a ramp back to zero, but since everything is unknown to me I DAQmx seems to offer no solution. With the old DAQ there was no issue because I could calculate how many iterations I needed the system to run and execute a defined finite number of complete iterations of my waveform.
-Devin
I got 99 problems but 8.6 ain't one.
0 Kudos
Message 4 of 23
(5,581 Views)
Hi Billings,

There is a way to know exactly where the output is at. You can use the DAQmxWrite property node to see how many points have been output. You can check "current write position" and "total samples per channel generated." Using this, you can know at what point the DAQ card is at in the buffer and know the output voltage. From here you can ramp the voltage down and stop the output.

-Sal
0 Kudos
Message 5 of 23
(5,566 Views)
Thanks again for the response Sal, this solution seems like it should work, but it does not. If I look at that property while the waveform is running it gives me good numbers. However, once you stop a DAQmx task (not destroy the task but simply run DAQmx Stop.vi on it) the AO write property "CurrWritePos" gives the last point of the waveform you have been running even though the DAQ actually stopped at some point in the middle of the waveform. (So if you ran a 20000 point waveform it returns "20000"). Also once you stop the waveform the total number of samples generated property gives you "0". I tried this solution this morning. If I were running a very slow waveform this would be close enough. I could, with the waveform running, get the properties for samples generated and current write position, then immediately stop the task, then hope that not too much time went by for the computer to execute the code of stopping the task. If that time delay is short enough the waveform will have actually stopped fairly close to the value I read immediately before stopping the waveform. Then I can build a ramp knowing my current DAQ AO location. I did this this morning with a 5V, 2Hz sinewave. The property node told me I was at an index corresponding to a -4.8V output, but by the time DAQmx Stop.vi actually stopped my waveform a probe showed I was actually at -4.6V. Close enough for a 2Hz waveform.

The problem is this has to work for 1kHz waveforms with 200kHz sample rates. If 250us goes by between the time I read the DAQmx properties and the time I actually stop the task, my DAQ output has gone 90 degrees in phase from my returned buffer position. And this time delay would be unpredictable.

I have asked an NI engineer about this and he is working on it.
-Devin
I got 99 problems but 8.6 ain't one.
0 Kudos
Message 6 of 23
(5,551 Views)
I thought I'd give a little more background of my system as it is a real system and these requirements are not at all fictional. I have a simple DC motor (a galvanometer) on an extremely fast, high gain analog servo. The servo drives the motor with amplifiers on +/- 15V rails. The coil resistance of the motor is 3 ohms. So if the servo tries to put more than 5A into the motor, V=IR and the voltage across the coil will hit 15V and saturate the amplifier. This makes the servo go unstable. I command the servo with an analog voltage from my DAC. The system can handle a 1kHz 5V triangle wave and be just below the 5A limit, and this is a very standard waveform to run on the motor. If I try to go from 5V to 0V in a step, however, the servo will try to put more than 5A through the motor.
-Devin
I got 99 problems but 8.6 ain't one.
0 Kudos
Message 7 of 23
(5,553 Views)
billings11,

No magic bullet here, but maybe some partial help.

First, you started the thread saying, "I need to generate a waveform for 60 seconds." Then you talk about generating a continuous waveform and calling 'DAQmx Stop.vi' after 60 seconds. So I assume you're defining a small-ish buffer and using regeneration to keep repeating it. I don't have hw here to check, but isn't it possible to use regeneration with a finite # of samples? Then you could just set the # of samples to be an integer multiple of the waveform buffer size and the analog output would naturally stop at the end of your buffer, where the waveform is returning to 0 anyway (I assume).

Second idea is more of a pain. If you can't have both regeneration AND a finite # sample output, then configure for finite # of samples where # is an integer multiple of your waveform buffer. Then you'd need to launch a process that keeps feeding chunks of that waveform to the DAQ buffer using 'DAQmx Write.vi' at appropriate times. You'd probably need to experiment to find a good compromise among buffer size, size of feed chunks, feed frequency.

Third comment is a reference to a slightly related thread I was involved in before. I linked in a utility to help make the best fit between output rate, actual waveform period, and buffer size. It's for cases where the waveform period isn't an exact multiple of the output clock period. I originally worked on the idea when dealing with a similar motion-control problem. It helps make a smoother command function when cycling from the last defined point in the buffer back to the first. (BTW, our solution to the problem you're facing was much simpler because we were running real-time and calculating individual AO outputs every loop cycle. That made it easy to generate a ramp to 0 because we automatically knew what the last output voltage was.) Anyway, here's the thread.

-Kevin P.
ALERT! LabVIEW's subscription-only policy coming to an end (finally!). Permanent license pricing remains WIP. Tread carefully.
0 Kudos
Message 8 of 23
(5,536 Views)
Kevin thanks for you comments,

Actually in DAQmx I am not using regeneration at all. After reading your comments I will look into trying that type of method of repeating my buffer if it is possible. Right now I am just defining my buffer with one period of a waveform. Then I simply generate continuous samples and the buffer keeps repeating. Regeneration is disabled. Then I stop the waveform using DAQmx Stop.vi but I don'tknow where I am stopped as I have explained above. I am looking into your other ideas but it seems like its not worrth all the development time for this complex method in DAQmx to do something that took 3 vi's and a division node in traditional DAQ.

Attached is a very simple example of what you can do with traditional DAQ that I have not been able to do with DAQmx. This simple traditional DAQ example will run a waveform for a defined time period and finish at the end of the buffer. If anyone can code this in DAQmx I would be very interested in seeing how you did it. This example is in LV 7.1.
-Devin
I got 99 problems but 8.6 ain't one.
0 Kudos
Message 9 of 23
(5,522 Views)
Hi Billings,

In DAQmx it is quite easy to find out where you are stopped in your analog output buffer. This information can be obtained from the DAQmxWrite property node.

The properties you are looking for are "Current Write Position" and "Total Samples Per Channel Generated." From these two properties it should be easy to find out exactly where in the buffer the output is.

-Sal
0 Kudos
Message 10 of 23
(5,514 Views)