19 s826_countermoderead, 20 common applications, S826_countermoderead – Sensoray 826 User Manual
Page 50: Common applications

XS
Index source.
0
External IX input, normal polarity.
1
External IX input, inverted.
2-7
ExtOut from counter channel 0-5 (e.g., 3 = ExtOut from channel 1).
8-15
Internal tick generator: 8 = 0.1 Hz, 9 = 1 Hz, 10 = 10 Hz, 11 = 100 Hz, 12 = 1 KHz, 13 = 10 KHz, 14 = 100
KHz, 15 = 1 MHz.
Return Values
If the function succeeds, the return value is zero.
If the function fails, the return value is an error code.
7.3.19 S826_CounterModeRead
The S826_
Counter
ModeRead function returns a counter channel's operating mode.
int S826_CounterModeRead(
uint board, // board identifier
uint chan, // channel number
uint *mode // operating mode
);
Parameters
board
826 board number. This must match the settings of the board's dip switches as described in section 2.2.
chan
Counter channel number in the range 0 to 5.
mode
Buffer that will receive the channel operating mode, as defined in “S826_CounterModeWrite”.
Return Values
If the function succeeds, the return value is zero.
If the function fails, the return value is an error code.
7.3.20 Common Applications
This section shows simple examples of how to configure and operate counter channels for common applications. In
most cases there are other ways to configure the counters to achieve similar functionality, and numerous variations are
possible that are not discussed here.
Encoder Interface
Monitor a quadrature-encoded device (e.g., incremental encoder) using x4 clock multiplier. Capture a snapshot at any
time by calling S826_CounterSnapshot.
Register
Value
Mode
0x00000070
Event Counter
Count pulses applied to the ClkA input. Capture a snapshot at any time by calling S826_CounterSnapshot. Reset the
counts to zero by calling S826_CounterPreload.
826 Instruction Manual
45
Counters