<s>
An	O
incremental	B-Algorithm
encoder	I-Algorithm
is	O
a	O
linear	O
or	O
rotary	O
electromechanical	O
device	O
that	O
has	O
two	O
output	O
signals	O
,	O
A	O
and	O
B	O
,	O
which	O
issue	O
pulses	O
when	O
the	O
device	O
is	O
moved	O
.	O
</s>
<s>
Many	O
incremental	B-Algorithm
encoders	I-Algorithm
have	O
an	O
additional	O
output	O
signal	O
,	O
typically	O
designated	O
index	O
or	O
Z	O
,	O
which	O
indicates	O
the	O
encoder	O
is	O
located	O
at	O
a	O
particular	O
reference	O
position	O
.	O
</s>
<s>
Unlike	O
an	O
absolute	O
encoder	O
,	O
an	O
incremental	B-Algorithm
encoder	I-Algorithm
does	O
not	O
indicate	O
absolute	O
position	O
;	O
it	O
only	O
reports	O
changes	O
in	O
position	O
and	O
,	O
for	O
each	O
reported	O
position	O
change	O
,	O
the	O
direction	O
of	O
movement	O
.	O
</s>
<s>
Consequently	O
,	O
to	O
determine	O
absolute	O
position	O
at	O
any	O
particular	O
moment	O
,	O
it	O
is	O
necessary	O
to	O
send	O
the	O
encoder	O
signals	O
to	O
an	O
incremental	B-Algorithm
encoder	I-Algorithm
interface	O
,	O
which	O
in	O
turn	O
will	O
"	O
track	O
"	O
and	O
report	O
the	O
encoder	O
's	O
absolute	O
position	O
.	O
</s>
<s>
Incremental	B-Algorithm
encoders	I-Algorithm
report	O
position	O
changes	O
nearly	O
instantaneously	O
,	O
which	O
allows	O
them	O
to	O
monitor	O
the	O
movements	O
of	O
high	O
speed	O
mechanisms	O
in	O
near	O
real-time	O
.	O
</s>
<s>
Because	O
of	O
this	O
,	O
incremental	B-Algorithm
encoders	I-Algorithm
are	O
commonly	O
used	O
in	O
applications	O
that	O
require	O
precise	O
measurement	O
and	O
control	O
of	O
position	O
and	O
velocity	O
.	O
</s>
<s>
An	O
incremental	B-Algorithm
encoder	I-Algorithm
employs	O
a	O
quadrature	O
encoder	O
to	O
generate	O
its	O
A	O
and	O
B	O
output	O
signals	O
.	O
</s>
<s>
The	O
pulses	O
emitted	O
from	O
the	O
A	O
and	O
B	O
outputs	O
are	O
quadrature-encoded	O
,	O
meaning	O
that	O
when	O
the	O
incremental	B-Algorithm
encoder	I-Algorithm
is	O
moving	O
at	O
a	O
constant	O
velocity	O
,	O
the	O
A	O
and	O
B	O
waveforms	O
are	O
square	O
waves	O
and	O
there	O
is	O
a	O
90	O
degree	O
phase	O
difference	O
between	O
A	O
and	O
B	O
.	O
</s>
<s>
The	O
resolution	O
of	O
an	O
incremental	B-Algorithm
encoder	I-Algorithm
is	O
a	O
measure	O
of	O
the	O
precision	O
of	O
the	O
position	O
information	O
it	O
produces	O
.	O
</s>
<s>
When	O
moving	O
at	O
constant	O
velocity	O
,	O
an	O
ideal	O
incremental	B-Algorithm
encoder	I-Algorithm
would	O
output	O
perfect	O
square	O
waves	O
on	O
A	O
and	O
B	O
(	O
i.e.	O
,	O
the	O
pulses	O
would	O
be	O
exactly	O
180°	O
wide	O
)	O
with	O
a	O
phase	O
difference	O
of	O
exactly	O
90°	O
between	O
A	O
and	O
B	O
.	O
</s>
<s>
Incremental	B-Algorithm
encoders	I-Algorithm
employ	O
various	O
types	O
of	O
electronic	O
circuits	O
to	O
drive	O
(	O
transmit	O
)	O
their	O
output	O
signals	O
,	O
and	O
manufacturers	O
often	O
have	O
the	O
ability	O
to	O
build	O
a	O
particular	O
encoder	O
model	O
with	O
any	O
of	O
several	O
driver	O
types	O
.	O
</s>
<s>
When	O
the	O
driver	O
switches	O
from	O
the	O
low	O
to	O
the	O
high	O
logic	O
level	O
,	O
the	O
load	O
resistance	O
and	O
circuit	O
capacitance	O
act	O
together	O
to	O
form	O
a	O
low-pass	B-Algorithm
filter	I-Algorithm
,	O
which	O
stretches	O
(	O
increases	O
)	O
the	O
signal	O
's	O
rise	O
time	O
and	O
thus	O
limits	O
its	O
maximum	O
frequency	O
.	O
</s>
<s>
Mechanical	O
(	O
or	O
contact	O
)	O
incremental	B-Algorithm
encoders	I-Algorithm
use	O
sliding	O
electrical	O
contacts	O
to	O
directly	O
generate	O
the	O
A	O
and	O
B	O
output	O
signals	O
.	O
</s>
<s>
PCB	O
-	O
and	O
panel-mounted	O
mechanical	O
incremental	B-Algorithm
encoders	I-Algorithm
are	O
widely	O
used	O
as	O
hand-operated	O
controls	O
in	O
electronic	O
equipment	O
.	O
</s>
<s>
Push-pull	O
outputs	O
(	O
e.g.	O
,	O
TTL	B-General_Concept
)	O
typically	O
are	O
used	O
for	O
direct	O
interface	O
to	O
logic	O
circuitry	O
.	O
</s>
<s>
Examples	O
of	O
this	O
include	O
CMMs	O
and	O
CNC	O
machinery	O
,	O
industrial	O
robotics	O
,	O
factory	O
automation	O
,	O
and	O
motion	B-General_Concept
platforms	I-General_Concept
used	O
in	O
aircraft	O
and	O
spacecraft	O
simulators	O
.	O
</s>
<s>
Incremental	B-Algorithm
encoders	I-Algorithm
are	O
commonly	O
used	O
to	O
monitor	O
the	O
physical	O
positions	O
of	O
mechanical	O
devices	O
.	O
</s>
<s>
The	O
incremental	B-Algorithm
encoder	I-Algorithm
is	O
mechanically	O
attached	O
to	O
the	O
device	O
to	O
be	O
monitored	O
so	O
that	O
its	O
output	O
signals	O
will	O
change	O
as	O
the	O
device	O
moves	O
.	O
</s>
<s>
Example	O
devices	O
include	O
the	O
balls	O
in	O
mechanical	O
computer	O
mice	O
and	O
trackballs	O
,	O
control	O
knobs	O
in	O
electronic	O
equipment	O
,	O
and	O
rotating	O
shafts	O
in	O
radar	B-Application
antennas	O
.	O
</s>
<s>
An	O
incremental	B-Algorithm
encoder	I-Algorithm
does	O
not	O
keep	O
track	O
of	O
,	O
nor	O
do	O
its	O
outputs	O
indicate	O
the	O
current	O
encoder	O
position	O
;	O
it	O
only	O
reports	O
incremental	O
changes	O
in	O
position	O
.	O
</s>
<s>
This	O
external	O
circuitry	O
,	O
which	O
is	O
known	O
as	O
an	O
incremental	B-Algorithm
encoder	I-Algorithm
interface	O
,	O
tracks	O
position	O
by	O
counting	O
incremental	O
position	O
changes	O
.	O
</s>
<s>
Typically	O
this	O
calculation	O
is	O
performed	O
by	O
a	O
computer	O
which	O
reads	O
the	O
counts	O
from	O
the	O
incremental	B-Algorithm
encoder	I-Algorithm
interface	O
.	O
</s>
<s>
For	O
example	O
,	O
in	O
the	O
case	O
of	O
a	O
linear	B-Algorithm
incremental	I-Algorithm
encoder	I-Algorithm
that	O
produces	O
8000	O
counts	O
per	O
millimeter	O
of	O
travel	O
,	O
the	O
position	O
in	O
millimeters	O
is	O
calculated	O
as	O
follows	O
:	O
</s>
<s>
In	O
order	O
for	O
an	O
incremental	B-Algorithm
encoder	I-Algorithm
interface	O
to	O
track	O
and	O
report	O
absolute	O
position	O
,	O
the	O
encoder	O
counts	O
must	O
be	O
correlated	O
to	O
a	O
reference	O
position	O
in	O
the	O
mechanical	O
system	O
to	O
which	O
the	O
encoder	O
is	O
attached	O
.	O
</s>
<s>
A	O
proximity	B-Device
sensor	I-Device
is	O
built	O
into	O
some	O
mechanical	O
systems	O
to	O
facilitate	O
homing	O
,	O
which	O
outputs	O
a	O
signal	O
when	O
the	O
mechanical	O
system	O
is	O
in	O
its	O
"	O
home	O
"	O
(	O
reference	O
)	O
position	O
.	O
</s>
<s>
rotating	O
radar	B-Application
antennas	O
)	O
,	O
the	O
"	O
position	O
"	O
of	O
interest	O
is	O
the	O
rotational	O
angle	O
relative	O
to	O
a	O
reference	O
orientation	O
.	O
</s>
<s>
These	O
typically	O
employ	O
a	O
rotary	B-Algorithm
incremental	I-Algorithm
encoder	I-Algorithm
that	O
has	O
an	O
index	O
(	O
or	O
Z	O
)	O
output	O
signal	O
.	O
</s>
<s>
Some	O
incremental	B-Algorithm
encoder	I-Algorithm
applications	O
lack	O
reference	O
position	O
detectors	O
and	O
therefore	O
must	O
implement	O
homing	O
by	O
other	O
means	O
.	O
</s>
<s>
For	O
example	O
a	O
computer	O
,	O
when	O
using	O
a	O
mouse	O
or	O
trackball	O
pointing	O
device	O
,	O
typically	O
will	O
home	O
the	O
device	O
by	O
assuming	O
a	O
central	O
,	O
initial	O
screen	O
position	O
upon	O
booting	B-Operating_System
,	O
and	O
jam	O
the	O
corresponding	O
counts	O
into	O
the	O
X	O
and	O
Y	O
position	O
counters	O
.	O
</s>
<s>
Incremental	B-Algorithm
encoders	I-Algorithm
are	O
commonly	O
used	O
to	O
measure	O
the	O
speed	O
of	O
mechanical	O
systems	O
.	O
</s>
<s>
This	O
may	O
be	O
done	O
for	O
monitoring	O
purposes	O
or	O
to	O
provide	O
feedback	O
for	O
motion	B-Algorithm
control	I-Algorithm
,	O
or	O
both	O
.	O
</s>
<s>
Widespread	O
applications	O
of	O
this	O
include	O
speed	O
control	O
of	O
radar	B-Application
antenna	O
rotation	O
and	O
material	O
conveyors	O
,	O
and	O
motion	B-Algorithm
control	I-Algorithm
in	O
robotics	O
,	O
CMM	O
and	O
CNC	O
machines	O
.	O
</s>
<s>
Incremental	B-Algorithm
encoder	I-Algorithm
interfaces	O
are	O
primarily	O
concerned	O
with	O
tracking	O
mechanical	O
displacement	O
and	O
usually	O
do	O
not	O
directly	O
measure	O
speed	O
.	O
</s>
<s>
Consequently	O
,	O
speed	O
must	O
be	O
indirectly	O
measured	O
by	O
taking	O
the	O
derivative	B-Algorithm
of	O
the	O
position	O
with	O
respect	O
to	O
time	O
.	O
</s>
<s>
The	O
position	O
signal	O
is	O
inherently	O
quantized	B-Algorithm
,	O
which	O
poses	O
challenges	O
for	O
taking	O
the	O
derivative	B-Algorithm
due	O
to	O
quantization	B-Algorithm
error	O
,	O
especially	O
at	O
low	O
speeds	O
.	O
</s>
<s>
If	O
the	O
position	O
signal	O
is	O
sampled	B-Algorithm
(	O
a	O
discrete	O
time	O
signal	O
)	O
,	O
the	O
pulses	O
(	O
or	O
pulse	O
edges	O
)	O
are	O
detected	O
and	O
counted	O
by	O
the	O
interface	O
,	O
and	O
speed	O
is	O
typically	O
calculated	O
by	O
a	O
computer	O
which	O
has	O
read	O
access	O
to	O
the	O
interface	O
.	O
</s>
<s>
In	O
such	O
cases	O
,	O
the	O
software	O
will	O
take	O
into	O
account	O
the	O
relationship	O
between	O
counts	O
and	O
desired	O
distance	O
units	O
,	O
as	O
well	O
as	O
the	O
ratio	O
of	O
the	O
sampling	B-Algorithm
period	I-Algorithm
to	O
desired	O
time	O
units	O
.	O
</s>
<s>
For	O
example	O
,	O
in	O
the	O
case	O
of	O
a	O
rotary	B-Algorithm
incremental	I-Algorithm
encoder	I-Algorithm
that	O
produces	O
4096	O
counts	O
per	O
revolution	O
,	O
which	O
is	O
being	O
read	O
once	O
per	O
second	O
,	O
the	O
software	O
would	O
compute	O
RPM	O
as	O
follows	O
:	O
</s>
<s>
When	O
measuring	O
speed	O
this	O
way	O
,	O
the	O
measurement	O
resolution	O
is	O
proportional	O
to	O
both	O
the	O
encoder	O
resolution	O
and	O
the	O
sampling	B-Algorithm
period	I-Algorithm
(	O
the	O
elapsed	O
time	O
between	O
the	O
two	O
samples	O
)	O
;	O
measurement	O
resolution	O
will	O
become	O
higher	O
as	O
the	O
sampling	B-Algorithm
period	I-Algorithm
increases	O
.	O
</s>
<s>
This	O
technique	O
avoids	O
position	O
quantization	B-Algorithm
error	O
but	O
introduces	O
errors	O
related	O
to	O
quantization	B-Algorithm
of	O
the	O
time	O
reference	O
.	O
</s>
<s>
An	O
incremental	B-Algorithm
encoder	I-Algorithm
interface	O
is	O
an	O
electronic	O
circuit	O
that	O
receives	O
signals	O
from	O
an	O
incremental	B-Algorithm
encoder	I-Algorithm
,	O
processes	O
the	O
signals	O
to	O
produce	O
absolute	O
position	O
and	O
other	O
information	O
,	O
and	O
makes	O
the	O
resulting	O
information	O
available	O
to	O
external	O
circuitry	O
.	O
</s>
<s>
Incremental	B-Algorithm
encoder	I-Algorithm
interfaces	O
are	O
implemented	O
in	O
a	O
variety	O
of	O
ways	O
,	O
including	O
as	O
ASICs	O
,	O
as	O
IP	B-Architecture
blocks	I-Architecture
within	O
FPGAs	B-Architecture
,	O
as	O
dedicated	O
peripheral	O
interfaces	O
in	O
microcontrollers	B-Architecture
and	O
,	O
when	O
high	O
count	O
rates	O
are	O
not	O
required	O
,	O
as	O
polled	B-General_Concept
(	O
software	O
monitored	O
)	O
GPIOs	B-Architecture
.	O
</s>
<s>
Incremental	B-Algorithm
encoder	I-Algorithm
interfaces	O
use	O
various	O
types	O
of	O
electronic	O
circuits	O
to	O
receive	O
encoder-generated	O
signals	O
.	O
</s>
<s>
Incremental	B-Algorithm
encoder	I-Algorithm
interfaces	O
typically	O
employ	O
Schmitt	O
trigger	O
inputs	O
to	O
receive	O
signals	O
from	O
encoders	O
that	O
have	O
single-ended	O
(	O
e.g.	O
,	O
push-pull	O
,	O
open	O
collector	O
)	O
outputs	O
.	O
</s>
<s>
In	O
normal	O
operation	O
,	O
glitches	B-Error_Name
(	O
brief	O
pulses	O
)	O
may	O
appear	O
on	O
the	O
status	O
outputs	O
during	O
input	O
state	O
transitions	O
;	O
typically	O
,	O
the	O
encoder	O
interface	O
will	O
filter	O
the	O
status	O
signals	O
to	O
prevent	O
these	O
glitches	B-Error_Name
from	O
being	O
erroneously	O
interpreted	O
as	O
lost	O
signals	O
.	O
</s>
<s>
Depending	O
on	O
the	O
interface	O
,	O
subsequent	O
processing	O
may	O
include	O
generating	O
an	O
interrupt	B-General_Concept
request	I-General_Concept
upon	O
detecting	O
signal	O
loss	O
,	O
and	O
sending	O
notification	O
to	O
the	O
application	O
for	O
error	O
logging	O
or	O
failure	O
analysis	O
.	O
</s>
<s>
An	O
incremental	B-Algorithm
encoder	I-Algorithm
interface	O
largely	O
consists	O
of	O
sequential	O
logic	O
which	O
is	O
paced	O
by	O
a	O
clock	O
signal	O
.	O
</s>
<s>
Typically	O
this	O
synchronization	O
is	O
performed	O
by	O
independent	O
,	O
single-signal	O
synchronizers	O
such	O
as	O
the	O
two	O
flip-flop	B-General_Concept
synchronizer	O
seen	O
here	O
.	O
</s>
<s>
At	O
very	O
high	O
clock	O
frequencies	O
,	O
or	O
when	O
a	O
very	O
low	O
error	O
rate	O
is	O
needed	O
,	O
the	O
synchronizers	O
may	O
include	O
additional	O
flip-flops	B-General_Concept
in	O
order	O
to	O
achieve	O
an	O
acceptably	O
low	O
bit	O
error	O
rate	O
.	O
</s>
<s>
In	O
software-based	O
interfaces	O
,	O
A	O
and	O
B	O
typically	O
are	O
connected	O
to	O
GPIOs	B-Architecture
that	O
are	O
sampled	B-Algorithm
(	O
via	O
polling	B-General_Concept
or	O
edge	O
interrupts	B-Application
)	O
and	O
debounced	O
by	O
software	O
.	O
</s>
<s>
Incremental	B-Algorithm
encoder	I-Algorithm
interfaces	O
commonly	O
use	O
a	O
quadrature	O
decoder	O
to	O
convert	O
the	O
A	O
and	O
B	O
signals	O
into	O
the	O
direction	O
and	O
count	O
enable	O
(	O
clock	O
enable	O
)	O
signals	O
needed	O
for	O
controlling	O
a	O
bidirectional	O
(	O
up	O
-	O
and	O
down-counting	O
)	O
synchronous	O
counter	O
.	O
</s>
<s>
Typically	O
,	O
a	O
quadrature	O
decoder	O
is	O
implemented	O
as	O
a	O
finite-state	B-Architecture
machine	I-Architecture
(	O
FSM	O
)	O
which	O
simultaneously	O
samples	O
the	O
A	O
and	O
B	O
signals	O
and	O
thus	O
produces	O
amalgamate	O
"	O
AB	O
"	O
samples	O
.	O
</s>
<s>
In	O
this	O
regard	O
,	O
each	O
AB	O
sample	O
is	O
effectively	O
a	O
two-bit	O
Gray	B-Device
code	I-Device
.	O
</s>
<s>
This	O
can	O
happen	O
if	O
the	O
encoder	O
speed	O
is	O
too	O
fast	O
for	O
the	O
decoder	O
to	O
process	O
(	O
i.e.	O
,	O
the	O
rate	O
of	O
AB	O
state	O
changes	O
exceeds	O
the	O
quadrature	O
decoder	O
's	O
sampling	O
rate	O
;	O
see	O
Nyquist	O
rate	O
)	O
or	O
if	O
the	O
A	O
or	O
B	O
signal	O
is	O
noisy	B-Algorithm
.	O
</s>
<s>
Due	O
to	O
the	O
severity	O
and	O
time-sensitive	O
nature	O
of	O
this	O
condition	O
,	O
the	O
error	O
signal	O
is	O
often	O
connected	O
to	O
an	O
interrupt	B-General_Concept
request	I-General_Concept
.	O
</s>
<s>
From	O
an	O
application	O
's	O
perspective	O
,	O
the	O
fundamental	O
purpose	O
of	O
an	O
incremental	B-Algorithm
encoder	I-Algorithm
interface	O
is	O
to	O
report	O
position	O
information	O
on	O
demand	O
.	O
</s>
<s>
In	O
more	O
complex	O
systems	O
,	O
the	O
position	O
counter	O
may	O
be	O
sampled	B-Algorithm
and	O
processed	O
by	O
intermediate	O
state	B-Architecture
machines	I-Architecture
,	O
which	O
in	O
turn	O
make	O
the	O
samples	O
available	O
to	O
the	O
computer	O
.	O
</s>
<s>
This	O
mechanism	O
results	O
in	O
atomic	B-General_Concept
operation	I-General_Concept
and	O
thus	O
ensures	O
the	O
integrity	O
of	O
the	O
sample	O
data	O
,	O
which	O
might	O
otherwise	O
be	O
at	O
risk	O
(	O
e.g.	O
,	O
if	O
the	O
sample	O
's	O
word	O
size	O
exceeds	O
the	O
computer	O
's	O
word	O
size	O
)	O
.	O
</s>
<s>
In	O
some	O
cases	O
the	O
computer	O
may	O
not	O
be	O
able	O
to	O
programatically	O
(	O
via	O
programmed	B-General_Concept
I/O	I-General_Concept
)	O
acquire	O
position	O
information	O
with	O
adequate	O
timing	O
precision	O
.	O
</s>
<s>
At	O
higher	O
encoder	O
speeds	O
and	O
resolutions	O
,	O
position	O
measurement	O
errors	O
can	O
occur	O
even	O
when	O
interrupts	B-Application
are	O
used	O
to	O
demand	O
samples	O
,	O
because	O
the	O
encoder	O
may	O
move	O
between	O
the	O
time	O
the	O
IRQ	B-General_Concept
is	O
signaled	O
and	O
the	O
sample	O
demand	O
is	O
issued	O
by	O
the	O
interrupt	B-Application
handler	O
.	O
</s>
<s>
To	O
overcome	O
this	O
limitation	O
,	O
it	O
is	O
common	O
for	O
an	O
incremental	B-Algorithm
encoder	I-Algorithm
interface	O
to	O
implement	O
hardware-triggered	O
sampling	O
,	O
which	O
enables	O
it	O
to	O
sample	O
the	O
position	O
counter	O
at	O
precisely-controlled	O
times	O
as	O
dictated	O
by	O
a	O
trigger	O
input	O
signal	O
.	O
</s>
<s>
This	O
is	O
important	O
when	O
the	O
position	O
must	O
be	O
sampled	B-Algorithm
at	O
particular	O
times	O
or	O
in	O
response	O
to	O
physical	O
events	O
,	O
and	O
essential	O
in	O
applications	O
such	O
as	O
multi-axis	O
motion	B-Algorithm
control	I-Algorithm
and	O
CMM	O
,	O
in	O
which	O
the	O
position	O
counters	O
of	O
multiple	O
encoder	O
interfaces	O
(	O
one	O
per	O
axis	O
)	O
must	O
be	O
simultaneously	O
sampled	B-Algorithm
.	O
</s>
<s>
Consequently	O
,	O
when	O
the	O
position	O
counter	O
is	O
sampled	B-Algorithm
in	O
response	O
to	O
a	O
trigger	O
signal	O
,	O
the	O
computer	O
must	O
be	O
notified	O
(	O
typically	O
via	O
interrupt	B-Application
)	O
that	O
a	O
sample	O
is	O
available	O
.	O
</s>
<s>
This	O
allows	O
the	O
software	O
to	O
be	O
event-driven	B-Application
(	O
vs	O
.	O
polled	B-General_Concept
)	O
,	O
which	O
facilitates	O
responsive	O
system	O
behavior	O
and	O
eliminates	O
polling	B-General_Concept
overhead	O
.	O
</s>
<s>
To	O
avoid	O
this	O
problem	O
,	O
some	O
incremental	B-Algorithm
encoder	I-Algorithm
interfaces	O
provide	O
a	O
FIFO	B-Operating_System
buffer	O
for	O
samples	O
.	O
</s>
<s>
As	O
each	O
sample	O
is	O
acquired	O
,	O
it	O
is	O
stored	O
in	O
the	O
FIFO	B-Operating_System
.	O
</s>
<s>
When	O
the	O
computer	O
demands	O
a	O
sample	O
,	O
it	O
is	O
allowed	O
to	O
read	O
the	O
oldest	O
sample	O
in	O
the	O
FIFO	B-Operating_System
.	O
</s>
