835
Chapter 41 Up/Down Counter
1.Overview
Chapter 41 Up/Down Counter
1. Overview
Triggered by an input signal, 16-bit Up/Down Counter counts up or down within the range of 0 to 65535.
Specifically, Up/Down Counter running in the phase difference count mode is suitable for counting the encoder
pulse of motors and other equipment. When encoder's output signals of phase A, phase B and phase Z are
applied, the counter can achieve precise counting of rotation angles or number of revolutions.
2. Feature
• Format: 16 bit length or 8 bit x 2
• Quantity: 2 for 16 bit (Inputs: AIN0/BIN0/ZIN0, AIN2/BIN2/ZIN2)
4 for 8 bit (Inputs: AIN0/BIN0/ZIN0, AIN1/BIN1/ZIN1, AIN2/BIN2/ZIN2, AIN3/BIN3/ZIN3)
• Count mode: Four types
• Timer mode
Count down the internal clock.
• Up/down count mode
Counting up is triggered by an AIN pin signal.
Counting down is triggered by a BIN pin signal.
• Phase difference count mode (Multiply by 2)
Counting is triggered by the rising edge of a BIN pin signal. Up/Down Counter counts up or down,
depending on the AIN pin signal level.
• Phase difference count mode (Multiply by 4)
Counting is triggered by the rising edge of AIN and BIN pin signals. Up/Down Counter counts up or
down, depending on the ZIN pin signal level.
• Count Source
Internal clock (Timer mode): Peripheral clock (CLKP) divided by 2 or 8
External trigger (Up/down count mode): Edge detection (Rising/falling/both edges/no detection)
• Counting range: Any value between 0 and 65535 can be set.
• Interrupt: Select from the following four types:
(1) Compare-match interrupt
(2) Underflow interrupt
(3) Overflow interrupt
(4) Count direction change interrupt
• Others:
Whether counting is performed or not can be controlled based on the pin input level.
The software can activate or deactivate the counter.
The ZIN pin has two functions: Counter clear and gate.
The count direction flag allows identification of the previous count direction.
/
A/B/Z
Up/Down Counter
Reload/Compare value
Compare-match
Clear
Underflow
Reload
Selection
Edge detection
Internal clock
External input
A/B/Z