stepper16  2.0.0.0
Main Page

Stepper 16 click

Stepper 16 Click is a compact add-on board that contains a micro-stepping stepper motor driver. This board features the NCV70517, an SPI and I/O configurable motor driver for bipolar stepper motors from ON Semiconductor.

click Product page


Click library

  • Author : Luka Filipovic
  • Date : May 2021.
  • Type : SPI type

Software Support

We provide a library for the Stepper16 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 Stepper16 Click driver.

Standard key functions :

Example key functions :

Example Description

This example showcases the device's ability to control the motor.

It initializes the device for control and moves the motor in two directions in a variety of speeds and step resolutions for 360 degrees.

The demo application is composed of two sections :

Application Init

Initializes UART and SPI communication modules, and additional

pins for motor control, resets device, set's default configuration, and reads its ID and sets

void application_init ( void )
{
uint16_t read_data = 0;
log_cfg_t log_cfg;
stepper16_cfg_t stepper16_cfg;
// Logger initialization.
LOG_MAP_USB_UART( log_cfg );
log_cfg.level = LOG_LEVEL_DEBUG;
log_cfg.baud = 115200;
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
stepper16_cfg_setup( &stepper16_cfg );
STEPPER16_MAP_MIKROBUS( stepper16_cfg, MIKROBUS_1 );
err_t init_flag = stepper16_init( &stepper16, &stepper16_cfg );
if ( init_flag == SPI_MASTER_ERROR )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
stepper16_default_cfg ( &stepper16 );
check_error( &stepper16 );
stepper16_generic_read( &stepper16, STEPPER16_REG_SR4, &read_data );
check_error( &stepper16 );
log_info( &logger, "DEV ID: %d ", ( read_data >> 3 ) );
log_info( &logger, "REV ID: %d ", ( read_data & 3 ) );
log_info( &logger, " Application Task " );
stepper16_set_dir( &stepper16, 1 );
}

Application Task

First it move motor clockwise for 360 degrees in medium speed and

full step resolution. Then changes direction and moves motor for 180 degrees in slow speed and quarter step, and additional 180 degrees in fast speed and 1/16 step resolution.

void application_task ( void )
{
static uint8_t direction = 1;
log_printf( &logger, "> Move 360deg in CW direction.\r\n" );
check_error( &stepper16 );
direction = !direction;
stepper16_set_dir( &stepper16, direction );
Delay_ms( 500 );
log_printf( &logger, "> Move 180deg in CCW direction.\r\n" );
check_error( &stepper16 );
Delay_ms( 1000 );
log_printf( &logger, "> Move 180deg in CCW direcion.\r\n" );
check_error( &stepper16 );
direction = !direction;
stepper16_set_dir( &stepper16, direction );
Delay_ms( 2000 );
}

Note

Device is powered by externam VM so for communication to work Click

board should be connected on power supply from 6V to 29V. At the start of application user should reset device and read it's Status register 1 to clear it. After that it can communicate with device and control it noramaly.

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.Stepper16

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.


STEPPER16_STEP_RES_QUARTER
#define STEPPER16_STEP_RES_QUARTER
Definition: stepper16.h:90
stepper16_init
err_t stepper16_init(stepper16_t *ctx, stepper16_cfg_t *cfg)
Stepper16 initialization function.
STEPPER16_SPEED_FAST
#define STEPPER16_SPEED_FAST
Definition: stepper16.h:101
STEPPER16_REG_SR4
#define STEPPER16_REG_SR4
Definition: stepper16.h:68
stepper16_t
Stepper16 Click context object.
Definition: stepper16.h:137
application_task
void application_task(void)
Definition: main.c:91
stepper16_set_step_resolution
void stepper16_set_step_resolution(stepper16_t *ctx, uint8_t step_res)
Set step resolution.
STEPPER16_MAP_MIKROBUS
#define STEPPER16_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: stepper16.h:120
stepper16_move_motor_angle
void stepper16_move_motor_angle(stepper16_t *ctx, float degree, uint8_t speed)
Move motor in angle value.
stepper16_set_dir
void stepper16_set_dir(stepper16_t *ctx, uint8_t value)
Set direction.
stepper16_hard_reset
void stepper16_hard_reset(stepper16_t *ctx)
Resets device.
STEPPER16_STEP_RES_FULL
#define STEPPER16_STEP_RES_FULL
Stepper16 step resolution.
Definition: stepper16.h:88
stepper16_generic_read
err_t stepper16_generic_read(stepper16_t *ctx, uint8_t reg, uint16_t *data_out)
Stepper16 data reading function.
application_init
void application_init(void)
Definition: main.c:50
stepper16_default_cfg
err_t stepper16_default_cfg(stepper16_t *ctx)
Stepper16 default configuration function.
STEPPER16_SPEED_MEDIUM
#define STEPPER16_SPEED_MEDIUM
Definition: stepper16.h:100
STEPPER16_SPEED_SLOW
#define STEPPER16_SPEED_SLOW
Definition: stepper16.h:99
stepper16_cfg_t
Stepper16 Click configuration object.
Definition: stepper16.h:168
stepper16_cfg_setup
void stepper16_cfg_setup(stepper16_cfg_t *cfg)
Stepper16 configuration object setup function.
STEPPER16_STEP_RES_1div16
#define STEPPER16_STEP_RES_1div16
Definition: stepper16.h:92