indexcounter  2.0.0.0
Main Page

Index Counter click

Index Counter Click is a simple prototyping high precision Hall-Effect switch solution with direction detection.

click Product page


Click library

  • Author : MikroE Team
  • Date : May 2020.
  • Type : GPIO type

Software Support

We provide a library for the IndexCounter Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.

Library Description

This library contains API for IndexCounter Click driver.

Standard key functions :

Example key functions :

  • This function returns a state of the direction DIR ( AN ) pin.

    uint8_t indexcounter_get_dir ( indexcounter_t *ctx );

  • This function returns a state of the speed SPD ( RST ) pin.

    uint8_t indexcounter_get_speed ( indexcounter_t *ctx );

Examples Description

This application enables usage of Index counter click board which can be used to measure rotational speed.

The demo application is composed of two sections :

Application Init

Initilaziation of GPIO and write log.

void application_init ( void )
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info(&logger, "---- Application Init ----");
// Click initialization.
INDEXCOUNTER_MAP_MIKROBUS( cfg, MIKROBUS_1 );
indexcounter_init( &indexcounter, &cfg );
}

Application Task

This is an example which demonstrates the use of the Index Counter click board. This example shows the direction of movement, Rotations Per Minute ( RPM or speed ) of the three pairs of rotating poles positioned in the sensor operating range. Results are being sent to the Usart Terminal where you can track their changes.

Note

Additional Functions :

  • void log_display ( float rpm_val ) - The function displays all results and a float value with a comma with two decimal places.

The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.

Other mikroE Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.IndexCounter

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. The terminal available in all Mikroelektronika compilers, or any other terminal application of your choice, can be used to read the message.


log_display
void log_display(float rpm_val)
Definition: main.c:50
time_cnt
uint32_t time_cnt
Definition: main.c:43
INDEXCOUNTER_ONE_MIN_CONV_MS
#define INDEXCOUNTER_ONE_MIN_CONV_MS
Definition: indexcounter.h:82
indexcounter_get_dir
uint8_t indexcounter_get_dir(indexcounter_t *ctx)
Get state of the direction pin function.
start_timer
uint32_t start_timer
Definition: main.c:45
INDEXCOUNTER_SPEED_ENABLE
#define INDEXCOUNTER_SPEED_ENABLE
Definition: indexcounter.h:79
application_task
void application_task(void)
Definition: main.c:105
pulse_ms
uint32_t pulse_ms
Definition: main.c:44
n_pole_pairs
uint8_t n_pole_pairs
Definition: main.c:42
indexcounter_init
INDEXCOUNTER_RETVAL indexcounter_init(indexcounter_t *ctx, indexcounter_cfg_t *cfg)
Initialization function.
indexcounter_cfg_setup
void indexcounter_cfg_setup(indexcounter_cfg_t *cfg)
Config Object Initialization function.
speed_state
uint8_t speed_state
Definition: main.c:40
INDEXCOUNTER_MAP_MIKROBUS
#define INDEXCOUNTER_MAP_MIKROBUS(cfg, mikrobus)
Definition: indexcounter.h:61
dir_state
uint8_t dir_state
Definition: main.c:39
speed_rpm
float speed_rpm
Definition: main.c:46
enable_speed
uint8_t enable_speed
Definition: main.c:41
application_init
void application_init(void)
Definition: main.c:80
INDEXCOUNTER_SPEED_DISABLE
#define INDEXCOUNTER_SPEED_DISABLE
Definition: indexcounter.h:80
indexcounter_get_speed
uint8_t indexcounter_get_speed(indexcounter_t *ctx)
Get state of the speed pin function.
indexcounter_cfg_t
Click configuration structure definition.
Definition: indexcounter.h:108