# Position and velocity from accelerometer

Started by November 8, 2007
```Jerry Avins <""jya\"@ieee,org"> writes:
> [...]
> The way incremental encoders are connected by the unwary, the "CW" and
> "CCW" pulses don't occur at the same shaft angle, but are offset by
> half a quantized angle increment.

Are you referring to what used to be called "optical shaft encoders?"
The one I used some 27 years ago had two signals, A and B. Both are
square waves when the shaft is rotated at a constant angular velocity.
The phase of B leads A by 90 degrees in one direction and lags A by
90 degrees in the other direction.

My up/dn detector was a D flip-flop with the clock being the A signal
and the B feeding the D input.

> For reciprocating motion, that can
> lead to a slow drift.

I think I see this - if the shaft is in just the wrong position, you'll
get a positive edge on A for rotation of X radians and a negative edge
for a rotation of -X radians. If you're using positive-edge triggering
based on the A signal, you'll miss the -X rotations. (X is less than
one angular quantization step).

> For an unfortunate small-amplitude oscillation, it can lead to a
> disastrous false indication of continuous motion.

You mean if the A signal was glitching? Yeah, I see that.

> My circuit (and a more complicated state machine) give CW and CCW
> pulses at the same shaft position. The difference is the direction
> from which that position is approached. That solves most of the
> annoying difficulties that seem small enough to let slide until they
> become large ones when the brass show up for a demo.

I couldn't decode your state table in the adjacent post. For one thing,
what's the difference between "CW"  and "cw"?
--
%  Randy Yates                  % "She tells me that she likes me very much,
%% Fuquay-Varina, NC            %     but when I try to touch, she makes it
%%% 919-577-9882                %                            all too clear."
%%%% <yates@ieee.org>           %        'Yours Truly, 2095', *Time*, ELO
http://www.digitalsignallabs.com
```