jeffrz Posted June 6, 2007 Report Share Posted June 6, 2007 I am trying to make repeated measurements with two counters on a USB-6251. I have a drive signal and two sensors. The sensors activate approximately 350ms after the drive goes high. The frequency of the drive is 2 Hz. A portion of the block diagram is shown below. The measured values are put on a queue and a GUI loop updates a waveform chart (scatter plot) and logs the values to a file. Taking out the GUI and logging doesn't improve the performance. The issue is that the counter is reporting 2 values per drive signal. One is a reasonable value (~325 msec) and the other is zero (which results from a timeout). I have set the timeout to 375 msec. That should be long enough for a normal event and short enough to time out if the sensor doesn't activate before the next drive signal. If I set the timeout longer (~ 550 msec), then I get one "correct" value per drive, but I don't really believe the value. It trends down ever so slightly so that over the course of 100k cycles, the value is clearly incorrect. Any suggestions would be appreciated. - Jeff http://forums.lavag.org/index.php?act=attach&type=post&id=6024 Quote Link to comment
Kevin P Posted June 6, 2007 Report Share Posted June 6, 2007 Several comments in no particular order: 1. It appears that the same 2 edges are being measured in both counter tasks. I'd have thought they'd share the same start edge but measure to different ending edges. 2. You're relying on software timing to keep readings in sync. I think you might better perform buffered measurements. This would require calls to "DAQmx Timing.vi". You'd also want to call "DAQmx Start.vi" directly, rather than counting on the first "DAQmx Read.vi" call to do an auto-start. 3. If you're buffering values with the hardware, you may want to rethink your 'timeout' input and/or # of samples to read at a time. 4. There's still a subtle synchronization issue that could bite you if you aren't careful here. There's a possibility that the drive signal will produce the start edge after one counter task starts but before the other counter task starts. I *think* your device will support sync'ing the start time of the two tasks using an "arm start" trigger. I don't have time to explain it all now, but you can find more info on the NI site, especially the forums there. You'd probably want to generate this trigger edge yourself, perhaps with a DO bit, after both tasks have been started but before you attempt any readings. -Kevin P. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.