Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

synchronized retriggerable analog output

How can I generate a retriggerable analog voltage output. I have attached a VI that currently doesn't work.

My aim is to read a digital signal and at the rising edge of that generate the an analog output such as the one in the figure. Timing is important the analog signal should start with hardware timing when the trigger is received. I am using a NI 6341 DAQ with labview.

 

signal.JPG

0 Kudos
Message 1 of 15
(3,936 Views)

Hi,

 

I have run the program on a simulated 6341 device on my computer, and the error code I get is -200262. I am assuming this is the same problem you are having?

 

If you delete the DAQmx Timing property node, and rewire the task line from the DAQmx Timing VI to the trigger VI, it should solve your problem.

 

At the moment, the timing property node is changing all the settings you have just made with the timing VI.

 

Retriggerable AO tasks are not supported with On Demand Timing, or with continuous samples. Your DAQmx timing vi is set up fine using a sample clock and finite samples.

 

Ian S
Applications Engineer CLA
National Instruments UK&Ireland
0 Kudos
Message 2 of 15
(3,921 Views)

Hi Ian,

 

I have deleted the timing property node. Now I get a 201025:

 

"Non-buffered hardware-timed operations are not supported for this device and Channel Type.

Set the Buffer Size to greater than 0, do not configure Sample Clock timing, or set Sample Timing Type to On Demand."

 

I have added a DAQmx channel node to use only on board memory but the error is the same with or without it.

 

I found a VI in the forums which I adapted (see analog_digital_continuous2_mytest). This works and is what I was intending to do, ie output an analog waveform with each trigger of an external signal, but I am not sure if the various property nodes are necessary or how they affect timing.

 

Another question is, if I send a waveform like the one in the figure attached in the previous message, how fast is the rise time from the low voltage to the output?

0 Kudos
Message 3 of 15
(3,913 Views)

kmargaras,

 

Several things I'd like to point out:

1) You have wired 100MHzTimebase as your sample clock source.  This is not going to work.  Since you're using the device's onboard sample clock, the 'rate' parameter will set the rate.  As such, I would recommend that you either leave this input unconnected, or use 'Onboard Clock' as the source terminal.

2) For a HW timed generation, you need to write your samples before your start your task.  This is to ensure that DAQmx can transfer data to your device before it start receiving valid sample clocks.  Without calling write, DAQmx does not know how big of a buffer it needs to allocate to hold data.  As such, you end up with a task without a buffer, which is not compatible with with triggering or retriggering.  Since you have a fixed pattern that you want to output and a known sample clock rate, you should be able to write this pattern before start.  DAQmx will not actually output this data until the task has been started, and a valid trigger is received.

3) You probably don't need to call any sort of write in your loop.  DAQmx should just regenerate from the buffer you write initially each time it receives a new trigger.  I would recommend that you place a call to DAQmxIsTaskDone.vi in the loop.  This will catch any error that occurs.  You'll probably also want to put a time delay in the loop so you don't throttle your CPU.

4) If you final DAQmx is designed to set the output to zero when you're done, I would recommend that you clear your HW timed task and use a 2nd 'on demand' task to do this.  If you have a buffered task, this write will only put data in DAQmx's buffer with no guarantee that it will get written.

5) Remove the DAQmx Timing Property node.  I believe that you have configured the timing VI correctly.

 

I've attached a new version of your VI which should give you a better starting point.

Hope that helps,

Dan

0 Kudos
Message 4 of 15
(3,912 Views)

Hi Dan,

 

Thank you for your suggestions. The VI now works. I am now trying to write the waveform to be send. 

 

My application is camera/strobe light synchronization, so the input values are the camera exposure time, the high time of voltage, the high voltage value and the low voltage value. The low time of voltage is the difference between camera exposure and high time. When the camera fps changes I have to change the waveform and also control the voltage levels at the start of the VI. Although the VI at  the moment reads the waveform from a file that is not practical as I will have to generate multiple files.

 

How can I build the waveform from the input values?

 

Best regards,

Kostas

Download All
0 Kudos
Message 5 of 15
(3,896 Views)

Kostas,

 

I'm having a bit of trouble wrapping my head around the timing requirements of the waveform you need to generate.  I'll give you my general approach for this type of problem.

 

1) Pick a sample clock rate.  You're going to want to pick the at least the lowest rate that gives you the proper resolution for your waveform.  If you need .5 ms resolution, then your sample clock rate will need to be at least 2 kHz.  For this discussion, we'll just use 2 kHz as our sample clock rate.

 

2) Now that you have a sample clock rate, divide your waveform up into sections.  If low time is X, you need to generate (X * 2000) samples of low voltage.  If high time is Y, you'll need to generate (Y * 2000) sample of high voltage.  Do this for each section of the waveform you need to define.  You can use the 'initialize array' function to create an array of data that corresponds to each section of your waveform.

 

3) Assemble your final waveform.  You have arrays containing each section of your waveform, now append these sections together in the order necessary to create the waveform you write to your analog output buffer.

 

Hope that helps,
Dan

0 Kudos
Message 6 of 15
(3,889 Views)

Hi Dan,

 

Thanks for your input, I have now the VI working. The key timing requirement is that the analog output starts and remains in synchrony with the digital edge at PFI15. The input at PFI15 is a camera exposure signal and the analog output controls the intensity of a strobe light. 

 

Should I have any concerns that the synchronization may be distrubed for any reason with this VI?

 

Best regards,

Kostas

0 Kudos
Message 7 of 15
(3,866 Views)

In general, I think this is looking pretty good.  Here are the issues I see:

 

You are setting the DAQmx Timing VI's 'samples per channel' in put to equal your rate.  This means that your analog output generation is going to be 1 second long.  I would use the size of the array you build to set this.  This will ensure that the the generation can be restarted as soon as the previous generation is done.  Without this, I presume you stand the chance to miss triggers.

 

One last minor point: Your  6341 generates its AO sample clock by dividing down a 100 MHz clock.  DAQmx will coerce the rate specified to the nearest divisor of 100 MHz to the rate you specify.  It might be advisable use the DAQmx Timing property node read back the rate after setting it with the DAQmx Timing VI.  This will give you the coerced value, which you can use for your calculations.  You can then use the DAQmx Timing property node to re-set your number of samples.

 

I've made the relevant changes and re-attached your VI.  Hope that helps,

Dan

0 Kudos
Message 8 of 15
(3,845 Views)

Hi Dan,

 

I receive an error now with code 200018, when the camera fps is set to 100. At 70 it works. Perhaps this is a limitation of the buffer size?

 

"DAC conversion attempted before data to be converted was available.

Decrease the output frequency to increase the period between DAC conversions, or reduce the size of your output buffer in order to write data more often. If you are using an external clock, check your signal for the presence of noise or glitches."

0 Kudos
Message 9 of 15
(3,839 Views)

Kostas,

 

What value are you using for Rate, and how big is your buffer? If you are getting triggers at a rate equal to your camera's FPS, does your analog generation fit between two subsequent exposure signals?

 

In general this error would occur if you weren't transferring data from the host computer to your 6341 fast enough, however I don't see any reason this should be occurring.

 

Dan

0 Kudos
Message 10 of 15
(3,836 Views)