stepper22  2.1.0.0
Main Page

Stepper 22 click

PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU

[click Product page](CLICK_PRODUCT_PAGE_LINK)


Click library

  • Author : Stefan Filipovic
  • Date : May 2024.
  • Type : I2C/SPI type

Software Support

We provide a library for the Stepper 22 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.

Library Description

This library contains API for Stepper 22 Click driver.

Standard key functions :

Example key functions :

Example Description

This example demonstrates the use of the Stepper 22 click board by driving the motor in both directions for a desired number of steps.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the click default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
stepper22_cfg_t stepper22_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
stepper22_cfg_setup( &stepper22_cfg );
STEPPER22_MAP_MIKROBUS( stepper22_cfg, MIKROBUS_1 );
err_t init_flag = stepper22_init( &stepper22, &stepper22_cfg );
if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( STEPPER22_ERROR == stepper22_default_cfg ( &stepper22 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}

Application Task

Drives the motor clockwise for 200 full steps and then counter-clockiwse for 200 half

steps and 400 quarter steps with a 1 second delay on driving mode change. All data is being logged on the USB UART where you can track the program flow.

void application_task ( void )
{
log_printf ( &logger, " Move 200 full steps clockwise, speed: slow\r\n\n" );
Delay_ms ( 1000 );
log_printf ( &logger, " Move 200 half steps counter-clockwise, speed: medium\r\n\n" );
Delay_ms ( 1000 );
log_printf ( &logger, " Move 400 quarter steps counter-clockwise, speed: fast\r\n\n" );
Delay_ms ( 1000 );
}

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:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Stepper22

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.


stepper22_default_cfg
err_t stepper22_default_cfg(stepper22_t *ctx)
Stepper 22 default configuration function.
STEPPER22_SPEED_SLOW
#define STEPPER22_SPEED_SLOW
Definition: stepper22.h:296
STEPPER22_MAP_MIKROBUS
#define STEPPER22_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: stepper22.h:352
stepper22_set_direction
err_t stepper22_set_direction(stepper22_t *ctx, uint8_t dir)
Stepper 22 set direction function.
STEPPER22_MODE_QUARTER_STEP
#define STEPPER22_MODE_QUARTER_STEP
Definition: stepper22.h:307
application_task
void application_task(void)
Definition: main.c:67
stepper22_cfg_setup
void stepper22_cfg_setup(stepper22_cfg_t *cfg)
Stepper 22 configuration object setup function.
STEPPER22_ERROR
@ STEPPER22_ERROR
Definition: stepper22.h:424
stepper22_s
Stepper 22 Click context object.
Definition: stepper22.h:372
STEPPER22_DIR_CCW
#define STEPPER22_DIR_CCW
Definition: stepper22.h:282
application_init
void application_init(void)
Definition: main.c:30
STEPPER22_DIR_CW
#define STEPPER22_DIR_CW
Stepper 22 direction setting.
Definition: stepper22.h:281
stepper22_init
err_t stepper22_init(stepper22_t *ctx, stepper22_cfg_t *cfg)
Stepper 22 initialization function.
STEPPER22_SPEED_FAST
#define STEPPER22_SPEED_FAST
Definition: stepper22.h:298
STEPPER22_SPEED_MEDIUM
#define STEPPER22_SPEED_MEDIUM
Definition: stepper22.h:297
STEPPER22_MODE_HALF_STEP
#define STEPPER22_MODE_HALF_STEP
Definition: stepper22.h:306
stepper22_drive_motor
err_t stepper22_drive_motor(stepper22_t *ctx, uint32_t steps, uint8_t speed)
Stepper 22 driver motor function.
stepper22_set_step_mode
err_t stepper22_set_step_mode(stepper22_t *ctx, uint8_t mode)
Stepper 22 set step mode function.
STEPPER22_MODE_FULL_STEP
#define STEPPER22_MODE_FULL_STEP
Stepper 22 step resolution setting.
Definition: stepper22.h:305
stepper22_cfg_t
Stepper 22 Click configuration object.
Definition: stepper22.h:393