Counter timing diagram – Sensoray 425 User Manual
Page 9

Page 7
Sensoray Model 425 Instruction Manual
Mode Selection
Each counter channel may be configured for any of
ten valid operating modes (eight counter modes and
two timer modes) through the Counter control port:
Four functional attributes are specified by the mode:
clock source (internal or external), clock multiplier
(x1, x2 or x4), counter input type (quadrature or
single-phase), and count direction.
The clock source, controlled by bit M3, determines
whether the channel will act as a counter or a timer.
When configured as a timer, a channel will count
either up or down at a three megahertz rate. When
configured as a counter, a channel counts pulses from
the external clock source.
The clock multiplier -- relevent only in modes 0
through 7 -- determines the number of count events
per cycle on the “A” phase input. A count event is a
phase state transition that causes a counter increment
or decrement. For example, a “x2” multiplier means
that two count events will occur for each full cycle of
the “A” phase input. See the counter timing diagram
for details.
The counter input type -- relevent only in modes 0
through 7 -- may be configured for either one or two
active phases. A two-phase mode must be specified
when using Quadrature inputs. A one-phase mode
must be specified for single-phase sources.
The Count direction, controlled by bit M2, is
specified as either normal or reverse. Refer to the
timing diagram for details.
Counter Control Port (base + 16, write only) : Set Mode
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
0
0
0
0
0
0
0
0
1
1
A1
A0
M3
M2
M1
M0
A
1
and A
0
specify which counter
is to have its mode programmed:
A
1
A
0
Encoder
00
Channel 0
01
Channel 1
10
Channel 2
11
Not Valid
Mode
Counter Function
M<3:0>
Clk
Phases
Direction
C
o
u
n
te
r
0
0000
x2
2
Normal
1
0001
x4
2
Normal
2
0010
x1
2
Normal
3
0011
x1
1
Normal
4
0100
x2
2
Reverse
5
0101
x4
2
Reverse
6
0110
x1
2
Reverse
7
0111
x1
1
Reverse
T
im
e
r
8-10
1000-1010
Invalid modes
11
1011
3MHz
Down
12-14
1100-1110
Invalid modes
15
1111
3MHz
Up
A
B
1
2
3
4
5
6
7
8
Valid count transitions vs. counter operating mode
Counter Configuration
Valid Count Transitions
Mode
Function
Up
Down
0
Quadrature x2
6, 8
1, 3
1
Quadrature x4
5, 6, 7, 8
1, 2, 3, 4
2
Quadrature x1
8
1
3
Single Phase x1
---
1
4
Quadrature x2
1, 3
6, 8
5
Quadrature x4
1, 2, 3, 4
5, 6, 7, 8
6
Quadrature x1
1
8
7
Single Phase x1
1
---
Counter Timing Diagram
Encoder counters change state (count up or down)
upon detection of a valid input transition. All
possible transitions are shown in the timing diagram
below. For example, transition number 1 specifies a
rising edge on the “A” phase while “B” is held low.
Valid transitions depend on the operating mode. The
table to the right lists valid transitions for each mode.
In mode 0, for example, a counter will count up only
at transitions 6 and 8, and will count down only at
transitions 1 and 3.