How does it work?
Counter Click is based on the LS7366R, a 32-bit quadrature counter with a serial interface from LSI Computer Systems. It is a CMOS counter with a direct interface for quadrature clocks from incremental encoders. It also interfaces with the index signals from incremental encoders to perform various marker functions. This counter can be configured to operate as a 1, 2, 3, or 4-byte counter. It can also be programmed to work in several counting modes such as Modulo-N, Non-recycle, Range-limit, or Free-running mode.
This Click board™ features a 2×5 header (2.54mm pitch) with pins to interface the LS7366R inputs, VCC, and a few GNDs, which are basically the power supply pins of the Click board™ itself. The VCC and GND pins can power the quadrature incremental encoder. This header also includes ENCA and ENCB, the input A and B pins of the LS7366R, to directly apply the quadrature clock outputs from incremental encoders on them, and Index (ENCI) pin, a programmable input driven directly by an incremental encoder’s index output.
The LS7366R uses a standard 4-wire SPI serial interface to communicate with the host MCU over the mikroBUS™ socket. The counter is enabled when EN input is in a high logic state; otherwise disabled with low logic level. In addition, this Click board™ features interrupt over INT pin that can be configured to use LFLAG or DFLAG over the LF and DF solder jumpers with DFLAG set by default. This way, users can choose LFLAG, an open drain latched output, or DFLAG, an instantaneous push-pull output, thus using these outputs to flag Carry, Borrow, Compare, and Index occurrences.
This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the PWR SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. However, the Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used, as a reference, for further development.
Specifications
Type
Rotary encoder
Applications
Can be used for measuring RPM and speed of DC motor shafts, reading incremental encoders, and more
On-board modules
LS7366R – quadrature counter from LSI Computer Systems
Key Features
32-bit counter, programmable functional modes, SPI serial interface, A and B pins for quadrature clock outputs from incremental encoders, index signal directly from incremental encoders, ability to use Carry/Borrow/Compare/Index flag occurrences, low power consumption, and more
Interface
GPIO,SPI
Feature
No ClickID
Compatibility
mikroBUS™
Click board size
M (42.9 x 25.4 mm)
Input Voltage
3.3V or 5V
Pinout diagram
This table shows how the pinout on Counter Click corresponds to the pinout on the mikroBUS™ socket (the latter shown in the two middle columns).
Onboard settings and indicators
Label | Name | Default | Description |
---|---|---|---|
– | PWR | – | Power LED Indicator |
– | PWR SEL | Right | Logic Level Voltage Selection 3V3/5V: Left position 3V3, Right position 5V |
LF | LF | Unpopulated | Open Drain Latched Programmable Interrupt Jumper |
DF | DF | Populated | Instantaneous Push-Pull Programmable Interrupt Jumper |
Counter Click electrical specifications
Description | Min | Typ | Max | Unit |
---|---|---|---|---|
Supply Voltage | 3.3 | – | 5 | V |
Resolution | – | 32 | – | bit |
Count Frequency | – | – | 40 | MHz |
Software Support
We provide a library for the Counter Click as well as a demo application (example), developed using Mikroe compilers. The demo can run on all the main Mikroe development boards.
Package can be downloaded/installed directly from NECTO Studio Package Manager (recommended), downloaded from our LibStock™ or found on Mikroe github account.
Library Description
This library contains API for Counter Click driver.
Key functions
-
This function reads CNTR, using click object.
-
This function reads STR, using click object.
-
This function reads OTR, using click object.
Example Description
This application measures the speed and the position of the DC motor shafts.
void application_task ( void )
{
count = counter_read_cntr( &counter );
log_printf( &logger, "Counter: %ldrn", count );
speed = ( float ) ( count - count_old ) / 3600.0;
speed *= 6.283185;
log_printf( &logger, "Speed: %.4f Rad/srn", speed );
count_old = count;
log_printf( &logger, "-------------------------rn" );
Delay_ms( 1000 );
}
The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager (recommended), downloaded from our LibStock™ or found on Mikroe github account.
Other Mikroe Libraries used in the example:
- MikroSDK.Board
- MikroSDK.Log
- Click.Counter
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all Mikroe compilers.
mikroSDK
This Click board™ is supported with mikroSDK – Mikroe Software Development Kit. To ensure proper operation of mikroSDK compliant Click board™ demo applications, mikroSDK should be downloaded from the LibStock and installed for the compiler you are using.
For more information about mikroSDK, visit the official page.