12-08-2006 08:49 AM
12-08-2006 08:54 AM
12-08-2006 09:38 AM
12-08-2006 09:45 AM
12-08-2006 09:56 AM
12-08-2006 09:58 AM
12-08-2006 10:56 AM
Shot in the nearly dark: have your tried performing your counter read in 32-bit integer format rather than the 64-bit double precision floating point I saw in the attached c code? And have you tried doing this as an on-demand peek at the counter register rather than as buffered hw-timed acquisition?
I would think that a simple on-demand request for a 32-bit integer would be the best way to minimize the amount of driver code that executes. When you request floating point, the driver performs scaling. When you do buffered acquisition, the driver manages stuff for you. I'd think that a simple on-demand peek at the counter's instantaneous count register value would be the closest you can get to a no-op driver-wise.
I only do LabVIEW in Windows so I don't know the c syntax for the driver calls, and I've never even used, let alone installed or maintained, Linux. But I've done a lot with encoders and would like to probe just a bit more on that stuff too.
First, I've used a 6259 in several apps to directly interface to a quad encoder using X4 decoding. The board handles it well, and I'm surprised you needed an interface chip to create up pulses and down pulses. I'm not 100% sure, but I think that in two-pulse encoder mode, you can choose the "active edge" for both the Up and Down pulses. Rising edge is typically the default, but many counter measurements allow you to specify a falling edge as active if you choose.
Here's one dirtly little secret about Z-index pulses that I'm pretty certain is still true on the M-series boards. The reset operation is NOT edge-sensitive as some of the docs suggest. It's state-sensitive. It is also not configurable for polarity (last I knew) -- reset happens during high state only. When I hardwired it to high (5V) so there would never be an edge and then rotated a quad encoder, the count would go 1,2,3,0,1,2,3,0,1,2,3,0,... Further, the reset only happens at a specific phase combination of the A,B channels which you must specify. If the Z-index pulse is short and happens during the wrong phase -- no reset. If the Z-index pulse is long and lasts through several cycles of the specified A,B phase -- multiple resets.
It's also possible to configure the Z-index to reset to a value other than 0. Under LV and Windows, the default reset value is 0, but perhaps if unspecified in your environment, the default reset value may be unpredictable? Could this somehow explain the case where you had positive numbers which kept oscillating around some value? As to the constant large negative number -- not to ask a dumb question, but are you sure you saw ALL the digits of precision? The raw count value is an unsigned 32-bit integer. When you decrement below 0, you get a bit pattern of 32 high bits. Maybe the driver (dumbly) interprets this as -(2^31) rather than as -1? It may then convert to floating point degrees based on -(2^-31). You might need to look at 10-12 digits of precision on your floating point value to detect whether it's changing. My earlier comments about reading in 32-bit integer format would be an even better check.
A lot of guesswork here, hope some turns out useful. Personally, I think the Z-index issues are more likely a problem than the AUX input. I could easily believe that the driver may also be part of the problem -- converting from int to floating point might do some dumb stuff like I outlined above -- in fact, I'm not so sure it doesn't do that under LabVIEW and Windows. I've long had the habit of reading counter values as U32's and doing all my own scaling. See if it helps to dis the driver and do unbuffered on-demand 32-bit integer reads.
-Kevin P.
12-08-2006 12:25 PM
12-08-2006 01:04 PM
Briefly:
1. At least using drivers for LabVIEW on Windows, the default setting for Z-index reset is NOT enabled. It must be enabled explicitly.
2. If Z-index reset IS enabled, then it'd happen every time Z is in high state while A,B are in their "specified" state combo. I *think* the default combo is A-high, B-high.
3. Z-index might happen only for +dir and not for -dir in a two-pulse-encoder mode, depending on the A,B phase combo settings. For example, if configured for A-low, B-high with your active-low pulses, then +dir would have B always high and A generating low pulses to increment count. The Z-index might also be high with the right A,B phase. But in the -direction, you'd have A always high and B generating low pulses to decrement count. When Z goes high, A,B phase wouldn't be as specified so no z-index reset would happen.
4. Agreed that if Z-index reset happens at all, it should reset to the same value each time. I don't think this can be purposely changed on-the-fly after the task starts running even if you try.
5. A sudden jump from positive oscillations to a large negative value seems inexplicable to me too.
6. Another troubleshooting thought. Count the UP pulses with one counter and the DOWN pulses with another. Use simple edge-counting mode and 32-bit integer reads. Wire to the counters' source pins. Do something like rotate +2 revs, -4 revs, +2 revs and see if you wind up back at 0. Look for increments on the wrong counter at the wrong time.
7. You mentioned that the chip provided helpful filtering. Perhaps some of the odd behavior is caused by spiky noise that isn't fully filtered out? Noise can be tricky, and it may be partly a coincidence that the Windows box was less susceptible (different physical location, different case & power supply, etc.)
-Kevin P.
12-08-2006 01:22 PM