LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

missing triggers on USB6218

 Hi,

I have a  USB6218 and I am trying to collect some finite samples of analog voltages everytime a trigger is receieved - trigger takes place at 15 Hz. The code also tries to save the measurements.
When i run the VI, i can see that some triggers are being missed. Is this because the VI takes a longer time to collect the sample and save it and misses the trigger??

Any help would be appreciated. Thanks.
0 Kudos
Message 1 of 5
(3,045 Views)
here is a screenshot of the VI
0 Kudos
Message 2 of 5
(3,044 Views)

Hello Sachmo,

In order to do the type of acquisition you've described I would implement a retriggerable pulse generation to use as the analog input sample clock.  By generating this retriggerable pulse train from your counters you can make a finite number of measurements at a specified rate each time you receive an external trigger.  As your current program is written you are acquiring continuously at a rate of 21,600 Hz after you receive the first (start) trigger on PFI3--all subsequent triggers on this line are ignored since generation has already started.  There is an example program you can look at by opening LabVIEW and going to Help» Find Examples...  Then navigate to this example Hardware Input and Output» DAQmx» Synchronization» Multi-function» Multi-Function-Ctr Retrigg Pulse Train Generation for AI Sample Clock.vi.

If you take a look at the comments on the example's block diagram it will explain the VIs execution.  I believe that this will fit your application much better; you can start with this example to do the data acquisition and add your file I/O and analysis to accomplish your goal.

I hope this helps get you started, and feel free to post back if you have more questions.

Have a great night!

Brooks
0 Kudos
Message 3 of 5
(3,011 Views)
Thanks Brooks. I did go through that vi. The triggers that the vi ,that i posted earlier , recieves trigger at 15 Hz. The sampling rate is set so that it finishes all its sample acquisition
before it recieves another trigger. When I use the retriggerable option in my vi, I got an error saying that it didnt support it.

But, i configured the example vi with my inputs/outputs but it is still missing triggers and is actually triggering out of control!!
0 Kudos
Message 4 of 5
(3,005 Views)

Hello Sachmo,

I think that maybe I misinterpreted what you're trying to do.  In your VI you have specified PFI0 as the external sample clock and PFI3 as the start trigger.  In my first post I though you only had an external trigger with an internal sample clock.  If this is the case let me know and I can show you how the example works.  Assuming you have both an external sample clock and trigger to use you're approach is correct, but there are a couple things I would recommend changing. 

1.  Instead of configuring the task for continuous samples I would recommend setting the DAQmx Timing VI for finite samples and specifying the number of samples.  This way the acquisition will automatically stop after the number of samples you want have been acquired.

2.  Put a DAQmx Start Task VI both right after the DAQmx Trigger VI and after the DAQmx Start Task VI inside you're for loop.  As your code is written you are using the DAQmx Read to auto start the VI.  The problem with doing this is that your task has to be started in order for it to receive a start trigger.  Thus you may miss samples if you're code hasn't started the task again.  By adding a DAQmx Start Task VI before the loop you're task will be armed and waiting for the first trigger.  Then, inside the loop you'll read 960 samples, stop the task, and then immediately re-arm the task so that it is waiting on your next trigger.  You want to start the task as soon as you stop it because any triggers that are received while the task is running or stopped will just be ignored.  When you take this approach you should also add a DAQmx Stop Task VI after the for loop and before the DAQmx Clear Task VI to stop the last iteration of the task.

3.  On an unrelated note, I noticed that your progress bar never hits 100%.  I think you can fix this by incrementing the iteration terminal before you calculate the percent of completion.  You can easily do this by right clicking on the wire and going to Insert» Numeric Pallet» Increment.  The reason this will fix it is because the loop iteration terminal starts at 0 and not 1.

I hope this helps and please post back if you'd like me to explain anything in more detail.

Cheers,

Brooks
0 Kudos
Message 5 of 5
(2,977 Views)