Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieving pretrigger samples with harware analog triggering

Hello,

Please, aswer the following question. I am using a analog hardware reference trigger while sampling at 200 kS/sec. Whenever a trigger occurs, I need to be able to retrieve about everything in the circular buffer, which I set to be about 20% of the total # of samples I am acquiring. I am using DAQmx Data Acquisition VIs, where I first set up the virtual channel, use Timing Vi, then configure triggering, and finaly I have Start Task, Read, and Stop task in the loop configured for N ch N samples. My question is as follows: Do I start out with a clean circular buffer at every loop iteration or only the first one? I so, does this mean that my trigger is ignored at every iteration before the # of pretriggered samples are acuired? I so, is there a way for me to do a continuous analog triggered acquisition so that I don't loose the whole buffer after every N samples (each iteration). Hopefully there is a workaround. Please let me know if have a misunderstanding of what is going on. Also, sorry for the length.

Thank you in advance,

Alex
0 Kudos
Message 1 of 7
(3,988 Views)
Hi Alex,

A circular buffer is similar to a regular buffer with one exception: when you reach the end of the buffer, you will start over at the beginning instead of stopping.

The circular buffer is not completely cleared at every loop iteration. The data that has been transferred from the FIFO (First In First Out) buffer to the LabVIEW buffer has been cleared. DAQmx does this automatically. Data will not disappear from a buffer. If the data at the beginning of the buffer has not been cleared before new data is written, LabVIEW will generate an overwrite error.

Reference triggers establish a reference point in a set of input examples. Data acquired before the reference point in pretrigger data. Data acquired after the reference point is post trigger data. You must have at least 2 pretrigger samples when using a reference trigger.

For your application, I would recommend using a retriggerable start trigger. You can set the DAQmx read to acquire a specific number of samples after a trigger. There is a good example of this in the
LabVIEW example finder. In the LabVIEW example finder: go to Hardware Input and Output>>DAQmx>>
Analog Measurements>>Voltage>>Acq&Graph Voltage-Int Clk-HW Trig Restarts.vi.

Regards,
Hal L.
0 Kudos
Message 2 of 7
(3,957 Views)
Hal,

Thank you for your reply. Please clarify the following.

I looked in the folder you have specified and was not able to find the 'Acq&Graph Voltage-Int Clk-HW Trig Restarts.vi'. There were similar files, but not this one.
1. When we say "circular buffer", we mean "LabView buffer" right?
2.You said that the data does not disappear after the required # of postrigger samples are acquired, and the task starts over at the next iteration. However from the Help file, I quote:

"... Once the acquisition begins, the DAQ device writes samples to the buffer. After the DAQ device captures the specified number of pretrigger samples, the DAQ device begins to look for the reference trigger condition. If the reference trigger condition occurs before the DAQ device captures the specified number of pretrigger samples, the DAQ device ignores the condition... ..When the reference trigger occurs, the DAQ device continues to write samples to the buffer until the buffer contains the number of postrigger samples desired."

->So does this imply that for example if I specified 'x pretrigger samples' and 'y samples per channel' the trigger condition will be ignored every time until x number of pretrigger samples are acquired (since I am starting and stoping the task at each iteration)?

I have attached my program. There is a lot of other unrelated to my question stuff, but I just wanted you to see how I set up my tast and triggering.

You help is much appreciated,
Alex

Message Edited by Alexch on 06-16-2005 10:28 AM

Message Edited by Alexch on 06-16-2005 10:28 AM

0 Kudos
Message 3 of 7
(3,954 Views)


@HAL L wrote:
Hi Alex,

A circular buffer is similar to a regular buffer with one exception: when you reach the end of the buffer, you will start over at the beginning instead of stopping.

The circular buffer is not completely cleared at every loop iteration. The data that has been transferred from the FIFO (First In First Out) buffer to the LabVIEW buffer has been cleared. DAQmx does this automatically. Data will not disappear from a buffer. If the data at the beginning of the buffer has not been cleared before new data is written, LabVIEW will generate an overwrite error.

Reference triggers establish a reference point in a set of input examples. Data acquired before the reference point in pretrigger data. Data acquired after the reference point is post trigger data. You must have at least 2 pretrigger samples when using a reference trigger.

For your application, I would recommend using a retriggerable start trigger. You can set the DAQmx read to acquire a specific number of samples after a trigger. There is a good example of this in the
LabVIEW example finder. In the LabVIEW example finder: go to Hardware Input and Output>>DAQmx>>
Analog Measurements>>Voltage>>Acq&Graph Voltage-Int Clk-HW Trig Restarts.vi.

Regards,
Hal L.




Hal:

I am working in C++ with NI-DAQmx C API; I don't have Labview. I looked up the documentation for retriggerable start trigger property in the cdaqmx help book (I wish they would make this available as a PDF). The (very brief) description seems to imply that this is for counter pulse generation:

>Specifies whether to enable retriggerable counter pulse generation. When you set this property to
>TRUE, the device generates pulses each time it receives a trigger. The device ignores a trigger
>if it is in the process of generating pulses.

Is it also useful for an analog input operation? How about analog output?

Thanks!
John Weeks

WaveMetrics, Inc.
Phone (503) 620-3001
Fax (503) 620-6754
www.wavemetrics.com
0 Kudos
Message 4 of 7
(3,940 Views)
Hi Alex,

The circular buffer is the PC buffer. This is not technically the LabVIEW buffer. There are 3 buffers used overall:
-the FIFO buffer (first in first out)
-the PC buffer
-the ADE (application development environment), or LabVIEW buffer.

Data is sent to the FIFO buffer and then is transferred to PC buffer. Both the PC buffer and the ADE Buffer are on the RAM (Random Access Memory). The data will be sent from the FIFO buffer to the PC buffer and finally to the ADE buffer. The data on the ADE buffer is the data that is displayed in LabVIEW. All of this is done automatically.

Data does not dissappear from the FIFO buffer, but is transferred to the PC buffer. It is important to note that you will not lose data on the FIFO buffer. When your post trigger data is acquired, it is sent from the FIFO buffer to PC buffer, so it will not be on the FIFO buffer anymore.

For the reference trigger: you are correct. If all of the pretrigger samples have not been acquired, then LabVIEW will ignore the trigger. This is why I am recommending a start trigger. The start trigger will wait for the trigger and then acquire the data. If you have a retriggerable start trigger, then you can acquire the data you want, wait for the next trigger, and then acquire that data. You will not have to worry about pretrigger samples.

I noticed that you were using NI-DAQ version 7.2. Our latest version of this driver is NI-DAQ 7.4. I would encourage you to download this. Here is a link to the download, which also has a list of new and improved features for the latest version of this driver:
http://digital.ni.com/softlib.nsf/websearch/90B60D5899BCCCDB86256FC700581B89?opendocument&node=132050_US .

I also took a look at your code. I recommend that you change the reference trigger to a start trigger. The while loop will make it retriggerable.

Regards,
Hal L.
0 Kudos
Message 5 of 7
(3,927 Views)
Hi John,
The retriggerable property that you are referring to is only for counter applications. In the LabVIEW example mentioned above, the VI simply has the [DAQmx Start >> DAQmx Read >> DAQmx Stop] sequence in a loop. So there is a distinct possibility that you could miss trigger edges if they occur just after the acquisition is complete, and the program is executing the DAQmx Stop command or the following DAQmx Start command. If you are interested in retriggerable AI or AO applications in which missing an edge would be a problem, there is a solid workaround. You can use the retriggerable property of the counter to trigger a pulse train, and use that pulse train as the sample clock for the AI or AO. I've done this in the past with great success.
-Alan A.
0 Kudos
Message 6 of 7
(3,918 Views)
Thanks, Alan.

I have already implemented a system like the start->trigger->stop->start again in my C code. If a customer ever needs more a more robust method I will keep your retriggered counter method in mind.

Thanks!
John Weeks

WaveMetrics, Inc.
Phone (503) 620-3001
Fax (503) 620-6754
www.wavemetrics.com
0 Kudos
Message 7 of 7
(3,913 Views)