05-18-2008 04:58 PM
05-18-2008 05:01 PM
here is a screenshot of the VI05-19-2008 05:34 PM
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!
05-19-2008 07:14 PM
05-20-2008 01:45 PM
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,