01-31-2008 11:06 AM
To configure a measurement, specify the initial sensor position through the Initial Angle attribute/property. You also can specify if the Z Input Terminal is used with the Z Index Enable attribute/property. You can configure the reload position on a Z index, and when a Z index position should cause a reload to occur in relation to the A and B signals, by using the Z Index Phase and Z Index Value attributes/properties, respectively.
When performing a single point, or on-demand, displacement measurement, you first arm the counter by calling the Start Task function/VI. Each subsequent read returns the current position of the encoder. If you perform multiple reads without first starting the counter, the counter implicitly starts and stops with each Read function/VI call, and the position is not recorded properly between read calls.
With a buffered displacement measurement, the device latches the current position onto each active edge of the sample clock and stores the position in the buffer. There is no onboard clock for buffered displacement measurement, so you must supply an external sample clock.
01-31-2008 02:23 PM
01-31-2008 02:51 PM
To configure a measurement, you specify the expected range of the input signal. Based on this range, NI-DAQmx automatically picks the internal timebase that provides the highest resolution for your measurement and uses it as the counter timebase. You also can explicitly specify the source of the counter timebase by setting the Counter Timebase Source attribute/property and the rate of the timebase by setting the Counter Timebase Rate attribute/property. For more information on where to connect input signals, refer to Connecting Counter Signals.
To perform buffered time measurements, use the Timing function/VI with the Implicit timing type. After the acquisition begins, NI-DAQmx consecutively measures each sample of the input signal and stores it in the input buffer. Due to this consecutive measurement, the rate of the input signal implicitly determines the rate of the acquisition. Depending on the phase of the input signal in relation to the start of the measurement, the first sample of buffered measurements is often invalid. For instance, if you are performing a buffered period measurement, and you start the measurement when the input signal is halfway through its current cycle, the measured period for the first sample is half its expected value. Subsequent samples indicate the correct values because they are guaranteed to be taken after a full period of the input signal. For this reason, the first sample of buffered period, pulse width, and semi-period measurements often indicates a smaller value than the actual value. For buffered frequency measurements, the first sample often indicates a higher frequency than the actual frequency.
With bus-powered M Series USB devices, such as the NI 6210, NI 6211, NI 6212, NI 6215, NI 6216, and NI 6218, you can take buffered time measurements with the sample clock timing type. After the acquisition begins, your device consecutively measures each sample of the input signal but does not store it to the input buffer unless there is an active edge of the sample clock source signal. Using this timing type, the sample clock rate determines the acquisition rate rather than the input signal. With this buffered time measurement method, all measurements returned are a valid, complete cycle of your input signal. Using this method, you can measure signals that are much faster than your sample rate, which minimizes the amount of data transferred from your device to NI-DAQmx.For non-buffered time measurements, calling the Read function/VI initiates the measurement and returns the next valid sample. Calling the Read function/VI repeatedly does not return consecutive measurements of the input signal.
#################################################################################################################
Essentially, this means that the hardware will work the same and give you a valid measurement, but unlike buffered inputs, 2 read calls do not return 2 buffered data points. The hardware starts, takes a measurement, and stops, and the driver returns that measurment to the user, thus the 2 reads have non deterministic correlation in time. But like I said before, since your just grabbing the oldest sample out of your buffer anyway, it appears that you don't care about how the reads are correlated.
01-31-2008 04:17 PM
Balki,
Thanks for the help. Do you mean like the attached picture? I tried it that way and unfortunately it's slower by about a factor of 3 over doing the buffered measurements.
Thanks
Henri
01-31-2008 04:59 PM
Not sure but here are some speculations:
1. Though not configured for buffered reads, you're still requesting a 1D array of N Samples. I'm really not sure what to expect from the DAQmx Read vi in that case.
2. The Help text balki quoted indicates that an *unbuffered* read will return the NEXT sample. Trouble is, with frequency measurement, the external signal *defines* the sampling interval, so you can't always predect how long you'll need to wait for that next sample. It seems that this mode could slow down your RT loop rate. Even though the Read call has a 'timeout' available, I don't expect *that* will give you very good timing resolution or deterministic timing.
If this is the key factor, I'd point you back to some of my comments earlier in the thread. Maybe you'd benefit by doing a buffered acquisition but specifically reading only the most recent sample(s) that you wouldn't have to wait for.
3. You mentioned RT at the beginning of the thread. I noticed that you're writing directly to an array indicator here rather than a shared variable. I haven't done RT in a few years, but that kind of construct might slow things down when running from the development environment.
-Kevin P.
01-31-2008 09:02 PM
Kevin,
1 - Yeah I guess I wasn't paying close attention, I just deleted the buffered part from my original, thus kept the array. I'll try it again, but somehow don't think that will get me a 3x speed improvement!
2 - Yes you're right it does slow it down quite a bit. Unfortunately reading only the latest sample has very little impact on the speed. I've tried changing the buffered lenght form 1 to 10000 and it has minimal impact. In reality, if I'm reading the buffer fast enough it has to be very small.
3 - the indicator was just a quick and dirty sample, and funny enough has very little impact on the performance of the loop, as compared to the actual reading of the frequency.
I'm pretty much resigned to the fact that I have a very accurate and expensive way of measuring high frequencies at a very SLOW rate! It just seems strange that I would be the first person trying to write a control system with RT using encoders to measure speed?! There seems to be something fundamentally wrong about the way that frequency is measured with Daqmx because it is much slower than just doing counting functions. Also, if you look at my previous post I mention the tremendous performance drop when using certain scaling factors. very strange stuff indeed.
-Henri
02-01-2008 05:31 AM
03-28-2008 12:33 PM
03-28-2008 12:41 PM
02-13-2013 07:53 AM
Were there any updates to the counter code in any subsequent versionso of Labview after 8.5 that might increase the performance of my PID loops? Might consider upgrading the software if that was the case.
Thanks,
Henri