We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
Rating:
Author: MIKROE
Last Updated: 2024-10-31
Package Version: 2.1.0.7
mikroSDK Library: 2.0.0.0
Category: Magnetic
Downloaded: 61 times
Not followed.
License: MIT license
Speed Sense Click is a compact add-on board that allows you to measure the speed and rotation of a spinning object. This board features the A17501, a dual output differential speed and direction sensor from Allegro Microsystems. It has a high-speed switching bandwidth of up to 40kHz for two different signals. The sensor has two independent output channels with options for high-resolution XOR speed, pulse, and direction protocol.
Do you want to subscribe in order to receive notifications regarding "Speed Sense Click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "Speed Sense Click" changes.
Do you want to report abuse regarding "Speed Sense Click".
DOWNLOAD LINK | RELATED COMPILER | CONTAINS |
---|---|---|
5521_speed_sense_clic.zip [469.72KB] | mikroC AI for ARM GCC for ARM Clang for ARM mikroC AI for PIC mikroC AI for PIC32 XC32 GCC for RISC-V Clang for RISC-V mikroC AI for AVR mikroC AI for dsPIC XC16 |
|
Speed Sense Click is a compact add-on board that allows you to measure the speed and rotation of a spinning object. This board features the A17501, a dual output differential speed and direction sensor from Allegro Microsystems. It has a high-speed switching bandwidth of up to 40kHz for two different signals. The sensor has two independent output channels with options for high-resolution XOR speed, pulse, and direction protocol.
We provide a library for the Speed Sense 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 from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
This library contains API for Speed Sense Click driver.
speedsense_cfg_setup
Config Object Initialization function.
void speedsense_cfg_setup ( speedsense_cfg_t *cfg );
speedsense_init
Initialization function.
err_t speedsense_init ( speedsense_t *ctx, speedsense_cfg_t *cfg );
speedsense_get_speed
This function reads the state of the CHA pin used for speed output protocols.
uint8_t speedsense_get_speed ( speedsense_t *ctx );
speedsense_get_direction
This function reads the state of the CHB pin used for direction output protocols.
uint8_t speedsense_get_direction ( speedsense_t *ctx );
This library contains the API for the Speed Sense Click driver for the speed and direction signal state detection for every magnetic pole pair.
The demo application is composed of two sections :
Initialization of GPIO and log UART.
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
speedsense_cfg_t speedsense_cfg; /**< Click config object. */
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
speedsense_cfg_setup( &speedsense_cfg );
SPEEDSENSE_MAP_MIKROBUS( speedsense_cfg, MIKROBUS_1 );
if ( DIGITAL_OUT_UNSUPPORTED_PIN == speedsense_init( &speedsense, &speedsense_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
log_printf( &logger, "-----------------------\r\n" );
}
This example demonstrates the use of the Speed Sense Click board. The demo application displays the direction of movement and rotation speed (rotations per minute) of the ring magnet with three pairs of rotating poles positioned in the sensor operating range.
void application_task ( void )
{
uint8_t direction = 0, speed = 0;
speed = speedsense_get_speed( &speedsense );
direction = speedsense_get_direction( &speedsense );
if ( start_measure & speed )
{
signal_duration = time_cnt - start_timer;
start_timer = time_cnt;
if ( SPEEDSENSE_DIR_STATE_FWD == direction )
{
log_printf( &logger, " Direction: Forward\r\n" );
}
else
{
log_printf( &logger, " Direction: Reverse\r\n" );
}
log_printf( &logger, " Speed: %.2f rpm\r\n", SPEEDSENSE_CALC_RMP / signal_duration );
log_printf( &logger, " Duration: %lu ms\r\n", signal_duration );
log_printf( &logger, " Time: %lu ms\r\n", time_cnt );
log_printf( &logger, "-----------------------\r\n" );
start_measure = SPEEDSENSE_STOP_MEASURE;
}
else if ( ( !start_measure ) & ( !speed ) )
{
start_measure = SPEEDSENSE_START_NEW_MEASURE;
}
time_cnt++;
Delay_ms ( 1 );
}
The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Other Mikroe Libraries used in the example:
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 MikroElektronika compilers.