From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

recording pretriggered data

I am using LabVIEW to record acceleration-time data.  I am using AI Start.vi to set the trigger, and I am also trying to use the pretrigger node to try to record 22 scans before the trigger, but the pretrigger record is not working.  Is there some other way to do this?  Thank you for your time.
0 Kudos
Message 1 of 10
(2,915 Views)

Hello Tek,

We need some more information about the problem in order to help.  By record, do you mean that you are saving the data to file?  If so, are you able to acquire pretrigger samples but not save them to file?  Or, are you not able to acquire the pretrigger samples.  Also, what hardware are you using?  Do you get an errors when running the program?

If the problem is with the acquisition, try the LabVIEW examples Acq&Graph Voltage-Int Clk-Dig Ref.vi for NI-DAQmx. 

Please let us know,

Laura

0 Kudos
Message 2 of 10
(2,907 Views)

Yes, I am saving the data to a .txt file.  It appears that I am not able to aquire or save pretriggered data, but I know that it is definitely not saving the 20 scans of pretriggered data to the .txt file.  I don't know how to tell if I'm aquiring the pretriggered data, but I know that it is not showing up in the acceleration-time graph.  I do not get errors while running the program, but the program does stop when the buffer is full.  We are aquiring data at 100,000 samples/sec for about 2.5 seconds right now.  I am using the NI DAQ card 6062E.  When I get back to the lab I will try to run the example you recommended.  Please let me know anything else you can think of.

Tek

0 Kudos
Message 3 of 10
(2,901 Views)
Hello Tek,

It hard to tell exactly what could be the problem, but like Laura said, I would recommend starting with an example program that shows how to implement a reference trigger, and use that as a tool for troubleshooting or even building your application from.  Also, are you trying to implement an analog or digital trigger in your application?  For programming analog input with a digital reference trigger, take a look at the following two shipping examples (found in LabVIEW Example Finder under Help >> Find Examples).

Using NI-DAQmx functions:
Cont Acq & Graph Voltage - Int Clk - Dig Ref.vi
located under Hardware Input and Output >> DAQmx >> Analog Measurements >> Voltage

Using Traditional NI-DAQ functions:
Acquire N Scans Digital Trig.vi
located under Hardware Input and Output >> Traditional DAQ >> Analog Input >> General

Give these examples a try and compare them to your program to see if your implementing the reference trigger in the same way.  If you are still experiencing trouble, reply to this post and hopefully we can help you out.

Regards,
Travis G.
0 Kudos
Message 4 of 10
(2,886 Views)
I looked at the examples.  You had mentioned programming analog input with a digital reference trigger.  I am trying to use an analog trigger.  I have attached my vi.  Maybe you could take a look at the AI Start.vi to see if I have everything setup correctly.  Maybe I just don't understand exactly what the pretrigger does.  I thought that it would record a certain number of scans prior to recording triggered data.  In our case, those pretriggered scans should be zero, but the text file created by my vi does not show any initial zeros...that is why I don't think the pretrigger is working.
0 Kudos
Message 5 of 10
(2,881 Views)
Hello Tek,

I didn't realize that you were performing continuous acquisition after your trigger.  For a continuous acquisition, you cannot acquire pretriggered samples.  See this post for more information about why these two operations are mutually exclusive.  To acquire pretriggered samples, you must be performing a finite acquisition task.  With a triggered finite acquisition task, you specify a number of samples to acquire before and after a trigger occurs.  The task is started, and data is continuously acquired into a circular buffer.  The buffer size equals the number of pretrigger plus the number of post trigger samples.  Therefore, when the trigger occurs, the acquisition finishes out the buffer and the data is then transferred into LabVIEW.  For a continuous acquisition, the pretriggered samples would be overwritten as the acquisition continues, and those values would be lost.  Sorry for the confusion, but check out the workarounds described by Sal and Jeremy in the above linked post.

Regards,
Travis G.
0 Kudos
Message 6 of 10
(2,867 Views)
Travis,
Thank you for the info.  I think I've decided that rather than go about it the way the post suggests, I'm just going to change from continuous aquisition to a specified amount of aquired data.  From reading up, it appears that I need to change the number of scans to aquire node on the AI Start VI from "0" to something else.  A "-1" seems that it would simply fill the buffer size (Does that include pretrigger data?).  Any other suggestions for making the switch from continuous aquisition?  I've attached my original VI again for reference.  Thank you for your time.
-TEK
0 Kudos
Message 7 of 10
(2,855 Views)

Hi TEK,

There is an example that uses NI-DAQ with a finite acquisition and analog triggering in the NI Example Finder.  It is called Acquire N Scans Analog Hardware Trig.  It uses -1 on the AI Start, but specifies the number of scans to acquire in the AI Config VI.  The number of scans to acquire should be the total data you are getting returned, pretrigger scans + post trigger scans. 

Please take a look at this example and see if it answers your questions.

Regards,

Laura

0 Kudos
Message 8 of 10
(2,843 Views)
I really appreciate everyone's help, but so far, nothing has worked.  Acquire N Scans Analog Hardware Trig.vi is basically what I want, but even when I tried to use the example with our settings (buffer size = 750,000, scan rate = 200,000), it did not work.  In my VI I changed the AI Start to "-1" and the buffer size in AI Config to control the number of scans to aquire but this causes my VI to completely stop working properly.  It does not plot, and the stop button no longer works.  In theory, this method should have worked, so I don't understand what I am doing wrong.  Does anybody have any other suggestions?
0 Kudos
Message 9 of 10
(2,835 Views)

Hi Tek,

What didn't work about the example?  Have you seen any error messages when trying to run the different VIs? 

I took the example that I recommended and ran it just fine with your settings.  What channel are you specifying for the analog trigger?  You can specify either a number, which corresponds to the analog input channel that you would like to receive your trigger from (this could be the same channel you are acquiring from) or PFI0 if you are using the AI Start Trig channel.  I could use the example with either setting.  You may need to increase your timeout above what the example has set to make sure that you have time to get the trigger and then acquire all 750,000 samples at 200,000 samples per second.  Also, be sure to use an analog level you are sure that your trigger will pass while you are testing this VI. 

Please take a look at these settings and let us know if you need help.

Regards,

Laura

0 Kudos
Message 10 of 10
(2,819 Views)