Index Counter Click
Index Counter Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : MikroE Team
- Date : May 2020.
- Type : GPIO type
Software Support
Example Description
This application enables usage of Index counter Click board which can be used to measure rotational speed.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.IndexCounter
Example Key Functions
- indexcounter_cfg_setup Config Object Initialization function.
void indexcounter_cfg_setup(indexcounter_cfg_t *cfg)
Config Object Initialization function.
Click configuration structure definition.
Definition indexcounter.h:112
- indexcounter_init Initialization function.
INDEXCOUNTER_RETVAL indexcounter_init(indexcounter_t *ctx, indexcounter_cfg_t *cfg)
Initialization function.
Click ctx object definition.
Definition indexcounter.h:99
- indexcounter_default_cfg Click Default Configuration function.
void indexcounter_default_cfg(indexcounter_t *ctx)
Click Default Configuration function.
- indexcounter_get_dir This function returns a state of the direction DIR ( AN ) pin.
uint8_t indexcounter_get_dir(indexcounter_t *ctx)
Get state of the direction pin function.
- indexcounter_get_speed This function returns a state of the speed SPD ( RST ) pin.
uint8_t indexcounter_get_speed(indexcounter_t *ctx)
Get state of the speed pin function.
Application Init
Initilaziation of GPIO and write log.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info(&logger, "---- Application Init ----");
}
#define INDEXCOUNTER_MAP_MIKROBUS(cfg, mikrobus)
Definition indexcounter.h:65
void application_init(void)
Definition main.c:80
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.
{
{
}
{
}
Delay_1ms();
}
#define INDEXCOUNTER_SPEED_DISABLE
Definition indexcounter.h:84
#define INDEXCOUNTER_SPEED_ENABLE
Definition indexcounter.h:83
#define INDEXCOUNTER_ONE_MIN_CONV_MS
Definition indexcounter.h:86
uint8_t dir_state
Definition main.c:39
void application_task(void)
Definition main.c:105
float speed_rpm
Definition main.c:46
uint8_t enable_speed
Definition main.c:41
void log_display(float rpm_val)
Definition main.c:50
uint8_t speed_state
Definition main.c:40
uint32_t start_timer
Definition main.c:45
uint8_t n_pole_pairs
Definition main.c:42
uint32_t time_cnt
Definition main.c:43
uint32_t pulse_ms
Definition main.c:44
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.
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.