06-27-2008 02:36 AM
06-27-2008 10:59 AM
Only have time to outline some suggestions:
1. Choose 1 of your counters to generate your timebase to make it easy to experiment with timebases like 1 MHz that aren't directly available on the board. The other measurement counters should be configured to use it as their Timebase.Source signal (can be found in the DAQmx Timing property node.)
2. I assume you want the 5 measurements to start at the same time=0 point, right? You should configure all 5 to use the same signal as a digital "Arm Start" trigger. In LabVIEW, this can be found in the drop-down menu for the DAQmx Trigger property node. I would typically use PFI0 as the trigger signal because this maps to the same pin that I can control via software as digital port0/line0. Thus, no screwdriver work for wiring a signal.
3. If you're buffering 5 measurements, you'll need to configure at least 2 of the tasks to operate in interrupt mode because the board only supports 3 DMA channels. This is yet another DAQmx property node setting.
4. There, now that the prelims are out of the way, here's how to get both pulse widths and pulse start times. It's gonna take a bit of work in software though.
Configure the counters for semi-period measurement. This will cause the tasks to buffer up arrays with alternating values representing high times and low times of the incoming signals. You should be careful and always read even #'s of samples from the buffer, never odd #'s. You'll also need to configure so that you can predict which comes first -- high or low time.
The high times will be your pulse widths, and the cumulative historical sum of *all* the semi-periods up until that high time will be your timestamp.
5. Further description for handling 1 such task. Create a while loop for reading values from the task. Initialize a shift register to a count of 0 to hold your historical cumulative time. (Note: depending on your duration and resolution, you may need to make this a double rather than an integer.) Inside the loop, read an even # of samples from the task, say, 1000. Pass the 1D array into the Reshape Array function to make it 500 rows x 2 columns. Pass that 2D array into a For loop using auto-indexing. Also pass in the value from your outer loop's left-side shift register into an inner loop shift register. The inner loop will index out 1 row at a time. The pulse width will be either index 0 or index 1, depending on your config settings. Index it out and pass it out to the inner loop boundary with auto-indexing. If your pulse width is index 0, the left-side shift register represents the timestamp for the beginning of that pulse. Pass it out to the inner loop with auto-indexing as well. (If pulse width is index 1, you may first want to add the duration of index 0 to the cumulative time.) Finally, add the sum of indices 0 and 1 to the left-side shift register and pass it out to the right-side shift register. Pass this shift register out to the outer loop shift register. Pass the 2 arrays of data (pulse widths and timestamps) out to your main app via queue or something.
That's all the time I've got right now. I realize the info is packed kinda dense, but if you do some further searching on the terms I've brought up, you can hopefully figure out a good share of it. Once you've got it pretty close, post back and I can try to suggest some tweaks.
-Kevin P.
06-27-2008 03:31 PM