TOP Contributors

  1. MIKROE (2784 codes)
  2. Alcides Ramos (392 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (123 codes)
  5. Bugz Bensce (97 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (140542 times)
  2. FAT32 Library (73026 times)
  3. Network Ethernet Library (58042 times)
  4. USB Device Library (48214 times)
  5. Network WiFi Library (43826 times)
  6. FT800 Library (43295 times)
  7. GSM click (30359 times)
  8. mikroSDK (28987 times)
  9. PID Library (27116 times)
  10. microSD click (26721 times)
Libstock prefers package manager

Package Manager

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]

< Back
mikroSDK Library

Stepper 16 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.12

mikroSDK Library: 2.0.0.0

Category: Stepper

Downloaded: 194 times

Not followed.

License: MIT license  

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.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Stepper 16 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Stepper 16 Click" changes.

Do you want to report abuse regarding "Stepper 16 Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


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.

stepper_16_click.png

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 :

  • stepper16_cfg_setup Config Object Initialization function.

    void stepper16_cfg_setup ( stepper16_cfg_t *cfg );
  • stepper16_init Initialization function.

    err_t stepper16_init ( stepper16_t *ctx, stepper16_cfg_t *cfg );
  • stepper16_default_cfg Click Default Configuration function.

    err_t stepper16_default_cfg ( stepper16_t *ctx );

Example key functions :

  • stepper16_hard_reset Resets device.

    void stepper16_hard_reset ( stepper16_t *ctx );
  • stepper16_set_step_resolution Set step resolution.

    void stepper16_set_step_resolution ( stepper16_t *ctx, uint8_t step_res );
  • stepper16_move_motor_angle Move motor in angle value.

    void stepper16_move_motor_angle ( stepper16_t *ctx, float degree, uint8_t speed );

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;  /**< Logger config object. */
    stepper16_cfg_t stepper16_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.
    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" );
    stepper16_set_step_resolution( &stepper16, STEPPER16_STEP_RES_FULL );
    check_error( &stepper16 );
    stepper16_move_motor_angle( &stepper16, 360, STEPPER16_SPEED_MEDIUM );
    direction = !direction;
    stepper16_set_dir( &stepper16, direction );
    Delay_ms ( 500 );
    log_printf( &logger, "> Move 180deg in CCW direction.\r\n" );
    stepper16_set_step_resolution( &stepper16, STEPPER16_STEP_RES_QUARTER );
    check_error( &stepper16 );
    stepper16_move_motor_angle( &stepper16, 180, STEPPER16_SPEED_SLOW );
    Delay_ms ( 1000 );
    log_printf( &logger, "> Move 180deg in CCW direcion.\r\n" );
    stepper16_set_step_resolution( &stepper16, STEPPER16_STEP_RES_1div16 );
    check_error( &stepper16 );
    stepper16_move_motor_angle( &stepper16, 180, STEPPER16_SPEED_FAST );
    direction = !direction;
    stepper16_set_dir( &stepper16, direction );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
}

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.


ALSO FROM THIS AUTHOR

Nano Power 2 Click

0

Nano Power 2 Click is a very low power voltage comparator, aimed at portable and battery-powered applications. It allows detecting a difference of two voltage potentials, applied on two input pins.

[Learn More]

UT-S 7 SEG R click

0

UT-S 7 SEG R click uses two SMD ultra-thin DSM7UA 7-SEG LED displays, made with the patented technology that delivers thickness of only 2.1 mm. These displays are driven by the MAX6969, a constant current LED integrated driver from Maxim Integrated, which uses the SPI serial interface for communication.

[Learn More]

BLE 12 Click

0

BLE 12 Click is a compact add-on board that provides BT/BLE connectivity for any embedded application. This board features the BM832A, a powerful and highly flexible, ultra low power Bluetooth Low Energy (BLE) module from Fanstel. Based on the Nordic nRF52 SoC, the BM832A supports Bluetooth 5.0 Low-Energy (BLE) connectivity while delivering RF range and performance, debugging and enhanced security features, and low power consumption. It also comes with an ARM Cortex™ M4(F) MCU up to 192kB flash and 24kB RAM, embedded 2.4GHz multi-protocol transceiver, and an integrated PCB trace antenna. This Click board™ is suitable for low-cost Bluetooth low energy applications such as building automation and sensor networks, portable medical, connected home, and more.

[Learn More]