08-06-2014 03:32 PM
Hi all,
Would appreciate some advice: I want to record and display every datapoint written as my analog output. At the most basic level, I'm writing a waveform continuously to my analog output channel (Sample Clock with continuous samples --> DAQmx Write with analog waveform, 1 channel, Nsamples). At some point, the user hits a "stop" button within the VI, and the signal being sent immediately stops.
I need a way of recording what was actually written to the DAQ, and only that. Obviously I have an array containing the voltages sent, but this is a single waveform that is being repeated over and over via hardware timing. I need a record of how many times this waveform was actually written to the DAQ, and what the last value sent was before the DAQmx Write task was halted.
If I were to do this with hardware, I would just connect a wire from my analog output straight to the analog input. It seems like this should be simple to do in LabVIEW though...
Many thanks in advance,
Tracy
08-06-2014 04:27 PM
I'm assuming that you know how long it will take to run a period of your waveform, if that is true then the simplest way would simply be to time for how long the waveform has been running and then calculate backwards the number of periods necessary and the current position. Should be relatively straight forward though I imagine you will want to use the actual clock speed measurement to get the output rate from your DAQ.
08-06-2014 04:28 PM
@ogk.nz wrote:
I'm assuming that you know how long it will take to run a period of your waveform, if that is true then the simplest way would simply be to time for how long the waveform has been running and then calculate backwards the number of periods necessary and the current position. Should be relatively straight forward though I imagine you will want to use the actual clock speed measurement to get the output rate from your DAQ.
That relies on Windows timing which, depending on the rate may be too jittery.
Look in to the "DAQmx Write" property node. It does what you need.
08-06-2014 05:22 PM
Thank you both for your responses.
BowenM --- that sounds like exactly what I need. I see that there is a property "CurrentWritePosition," which indicates the location in the buffer for the next sample. How do I actually access this location in the buffer? I've attached an image of a simplified version of what I'm trying to do. I can't seem to find any examples of how I would actually implement this property to find the most recent voltage sent, so would appreciate any further guidance.
08-07-2014 05:14 PM
tm473 -
Check this out. http://digital.ni.com/public.nsf/allkb/CB86B3B174763C3E86256FFD007A2511
The caveat is that certain cards are not capable of this - the dedicated analog output cards that cannot internally route the signal.
08-08-2014 01:09 PM
Mr.Anderson --- Nice find. Thank you for sharing! Unfortunately it looks like my DAQ doesn't have that option --- I'm using a USB-6212 at the moment. I'm eventually migrating to a PXI-6259 so I'll look into that option then.
In the meantime, would still appreciate any tips on this question, or follow-ups on how to use the "CurrentWritePosition" information to find actual voltages.
08-08-2014 01:16 PM
One approach would be to wire the DAQ output to an input and actuall measure it. There may be some time delay in this.
08-08-2014 05:12 PM
Found a workable solution, on the last post in this thread: http://forums.ni.com/t5/LabVIEW/Is-it-possible-to-generate-a-finite-number-of-output-buffer/td-p/153...
I've attached a very stripped-down version of my code. The main change here is the very simple subVI FindLastVoltageSent. I have a relatively wide tolerance on exact ending voltage sent, so this might prove problematic for an application that needed a perfect fix on the buffer location (there is obviously a slight delay between when "TotalSampPerChanGenerated" is spit out and when the task actually stops).
08-11-2014 04:16 PM
tm473,
I'm glad you now have a solution that works! I know this is a stripped down version, but just for others looking at this thread please make sure you are using DAQmx Clear Task.vi after the DAQmx Stop Task.vi, using the Simple Error Handler.vi to display errors at the end of your code, and only using local variables when you cannot wire to an indicator directly. Thank you for this code.
Best regards,