11-30-2006 11:46 AM
12-06-2006 02:59 AM
12-06-2006 01:20 PM
I could only look at the doc, not the code, because my network PC is far from my LV PC. As shown in the doc, the position measurement task IS buffered -- that's the purpose of the "Sample Clock." You can expect to find a call to "DAQmx Timing.vi" in the code to implement buffered acquisition.
You definitely CAN use buffered mode for a linear encoder position measurement. I configure most of my buffered encoder measurements (even with rotating shafts) this way and then read raw counts. If I want to convert to degrees for a chart, I scale it myself.
(Aside: early testing when DAQmx first came out showed some kinda strange treatment of some of the angular encoder inputs as I played around with initial counts, pulses per rev, and X1,X2,X4 decode modes. It didn't act like I expected, and I couldn't even figure out how to predict exactly what it would do. Was initial count a scaled value or not? How would it interact with the X1,X2,X4 setting? Would it round to the nearest discrete angle based on integer multiples of 360/ppr? I really haven't gone back to give it a good workout in later versions of DAQmx because I'm content dealing with the data in raw counts.)
-Kevin P.
12-07-2006 11:20 AM
12-07-2006 11:58 AM
Typically, (and sometimes necessarily), a sample clock signal used for counter measurements would be connected to a counter GATE pin. For the specific case of "encoder" measurement on the 6602, the Z-index signal must be physically wired to the counter's default GATE pin, so the sampling clock signal would need to be physically wired to the GATE pin of a different counter. Having wired the sample clock signal to a single GATE pin, both of the 2 counter measurement tasks can programmatically specify that their sampling clocks come from that single pin.
The M-series board offers more flexibility in programmatic PFI signal routing than the 6602. You can pretty much wire to any PFI pin and then programmatically specify which pin to use as Input (SOURCE) and which as Sample Clock (GATE). I still typically adopt the convention of using default pins whenever possible.
The terminology for counters can be a bit confusing. In my opinion, the old traditional NI-DAQ was a little more cryptic at first glance but much more consistent overall. The new DAQmx terminology tries to hide implementation details more, but in the process generates multiple aliases to the same pin assignment, depending on how you're using it.
A quick rundown. A SOURCE edge causes the count register to increment. Under DAQmx, this may be referenced as an "Input" or a "Timebase" terminal, depending on the measurement mode. When counting edges, it's an Input. When measuring period or frequency, it's a Timebase. Whatever it's called, the natural behavior at the counter hardware is to increment a count register on each active edge.
A GATE edge can cause a count value to be stored in the acquisition buffer. Under DAQmx, it may be referenced as a "Sample Clock" source when counting edges. When measuring period or frequency it may be a "Channel" or an "Input terminal." Again, whatever it's called, the behavior at the board level is to store an instantaneous count value into the data acq buffer on each active edge.
[There are exceptions, of course. The GATE pin is also used for "Pause Triggering", and can also be used to reset the count register for position measurement with Z-indexing enabled. And so on.]
-Kevin P.