Beginner
10 min

Enhance your projects to unprecedented levels of precision and control with DRV8825 and TM4C129ENCZAD

Beyond spin and turn: Redefine motion control with us

Stepper 21 Click with UNI-DS v8

Published Nov 10, 2023

Click board™

Stepper 21 Click

Dev Board

UNI-DS v8

Compiler

NECTO Studio

MCU

TM4C129ENCZAD

Transform your projects with our high-performance stepper motor driver, offering unparalleled precision and ease of integration.

A

A

Hardware Overview

How does it work?

Stepper 21 Click is based on the DRV8825, a stepper motor controller integral circuit from Texas Instruments. By integrating two NMOS H-bridges, current sense, and a STEP/DIR interface, the DRV8825 allows easy interfacing with the controller circuit. The STEP/DIR interface provides a simple method for advancing through the indexer table, with the direction determined by the DIR input pin and the indexer traveling for each rising edge on the STEP input pin. It uses three decay modes of operation, fast, slow, and mixed decay, as a highly configurable current regulation. Additional features are overcurrent protection, thermal shutdown, supply voltage undervoltage lockout, and fault condition indication. The host MCU can control the direction and steps of the stepper driver directly through the DIR and STP pins of the mikroBUS™ socket. As a feature of its own, the Stepper 21 Click comes with a VREF potentiometer to set a reference

voltage for winding current on both A and B bridges. The Stepper 21 Click also uses the PCA9538A, a low-voltage 8-bit I/O port expander from NXP Semiconductors, and its standard 2-Wire interface to communicate with the host MCU and control some of the features of the stepper driver. The PCA9538A provides a flexible set of GPIOs, contains an 8-bit register set, and is necessary for interfacing the DRV8825 control pins to the host MUC over the pins-limited mikroBUS™ socket. Besides the standard 2-Wire interface, the host MCU has access to the expander's reset and interrupt lines over the RST and INT pins of the mikroBUS™ socket. The interrupt output is activated when any input state differs from its corresponding input port register state. The I2C address of the expander can be selected over the ADDR SEL jumper with 0 set by default. The expander can also control other features like Sleep mode, home position indication, decay mode

selection, fault indicator triggered by over-temperature and over-current protection, or allow you to turn the stepper driver on or off. Last but not least, the expander controls micro-step modes combination (Mode 0-2), thus allowing the selection of full, 1/2, 1/4, 1/8, 1/16, and 1/32 steps. The Stepper 21 Click supports an external power supply for the DRV8825, which can be connected to the input terminal labeled as INPUT VM and should be within the range of 8.2V to 45V (2.5A), while the stepper motor coils can be connected to the terminals labeled as B+, B-, A-, and A+. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used for further development.

Stepper 21 Click hardware overview image

Features overview

Development board

UNI-DS v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports a wide range of microcontrollers, such as different STM32, Kinetis, TIVA, CEC, MSP, PIC, dsPIC, PIC32, and AVR MCUs regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer over WiFi. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, UNI-DS v8 provides a fluid and immersive working experience, allowing access anywhere and under any

circumstances at any time. Each part of the UNI-DS v8 development board contains the components necessary for the most efficient operation of the same board. An advanced integrated CODEGRIP programmer/debugger module offers many valuable programming/debugging options, including support for JTAG, SWD, and SWO Trace (Single Wire Output)), and seamless integration with the Mikroe software environment. Besides, it also includes a clean and regulated power supply module for the development board. It can use a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector. Communication options such as USB-UART, USB

HOST/DEVICE, CAN (on the MCU card, if supported), and Ethernet is also included. In addition, it also has the well-established mikroBUS™ standard, a standardized socket for the MCU card (SiBRAIN standard), and two display options for the TFT board line of products and character-based LCD. UNI-DS v8 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

UNI-DS v8 horizontal image

Microcontroller Overview

MCU Card / MCU

default

Type

8th Generation

Architecture

ARM Cortex-M4

MCU Memory (KB)

1024

Silicon Vendor

Texas Instruments

Pin count

212

RAM (Bytes)

262144

You complete me!

Accessories

The 28BYJ-48 is an adaptable 5VDC stepper motor with a compact design, ideal for various applications. It features four phases, a speed variation ratio of 1/64, and a stride angle of 5.625°/64 steps, allowing precise control. The motor operates at a frequency of 100Hz and has a DC resistance of 50Ω ±7% at 25°C. It boasts an idle in-traction frequency greater than 600Hz and an idle out-traction frequency exceeding 1000Hz, ensuring reliability in different scenarios. With a self-positioning torque and in-traction torque both exceeding 34.3mN.m at 120Hz, the 28BYJ-48 offers robust performance. Its friction torque ranges from 600 to 1200 gf.cm, while the pull-in torque is 300 gf.cm. This motor makes a reliable and efficient choice for your stepper motor needs.

Stepper 21 Click accessories image

Used MCU Pins

mikroBUS™ mapper

Stepper Direction
PE3
AN
Reset
PB6
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Stepper Indexer
PD0
PWM
Interrupt
PB4
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PB2
SCL
I2C Data
PB3
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

Stepper 21 Click Schematic schematic

Step by step

Project assembly

Fusion for PIC v8 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the UNI-DS v8 as your development board.

Fusion for PIC v8 front image hardware assembly
GNSS2 Click front image hardware assembly
SiBRAIN for PIC32MZ1024EFK144 front image hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
v8 SiBRAIN Access MB 1 - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
NECTO Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Necto image step 7 hardware assembly
Necto image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image hardware assembly

Track your results in real time

Application Output

After pressing the "FLASH" button on the left-side panel, it is necessary to open the UART terminal to display the achieved results. By clicking on the Tools icon in the right-hand panel, multiple different functions are displayed, among which is the UART Terminal. Click on the offered "UART Terminal" icon.

UART Application Output Step 1

Once the UART terminal is opened, the window takes on a new form. At the top of the tab are two buttons, one for adjusting the parameters of the UART terminal and the other for connecting the UART terminal. The tab's lower part is reserved for displaying the achieved results. Before connecting, the terminal has a Disconnected status, indicating that the terminal is not yet active. Before connecting, it is necessary to check the set parameters of the UART terminal. Click on the "OPTIONS" button.

UART Application Output Step 2

In the newly opened UART Terminal Options field, we check if the terminal settings are correct, such as the set port and the Baud rate of UART communication. If the data is not displayed properly, it is possible that the Baud rate value is not set correctly and needs to be adjusted to 115200. If all the parameters are set correctly, click on "CONFIGURE".

UART Application Output Step 3

The next step is to click on the "CONNECT" button, after which the terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.

UART Application Output Step 4

Software Support

Library Description

This library contains API for Stepper 21 Click driver.

Key functions:

  • stepper21_set_step_mode - This function sets the step mode resolution settings.

  • stepper21_set_direction - This function sets the motor direction by setting the DIR pin logic state.

  • stepper21_drive_motor - This function drives the motor for the specific number of steps at the selected speed.

Open Source

Code example

This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.

/*!
 * @file main.c
 * @brief Stepper 21 Click example
 *
 * # Description
 * This example demonstrates the use of the Stepper 21 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.
 *
 * ## Application Task
 * Drives the motor clockwise for 200 full steps and then counter-clockiwse for 400 quarter
 * steps with 2 seconds delay before changing the direction. All data is being logged on
 * the USB UART where you can track the program flow.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "stepper21.h"

static stepper21_t stepper21;
static log_t logger;

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    stepper21_cfg_t stepper21_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.
    stepper21_cfg_setup( &stepper21_cfg );
    STEPPER21_MAP_MIKROBUS( stepper21_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == stepper21_init( &stepper21, &stepper21_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( STEPPER21_ERROR == stepper21_default_cfg ( &stepper21 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    log_printf ( &logger, " Move 200 full steps clockwise \r\n\n" );
    stepper21_set_step_mode ( &stepper21, STEPPER21_MODE_FULL_STEP );
    stepper21_set_direction ( &stepper21, STEPPER21_DIR_CW );
    stepper21_drive_motor ( &stepper21, 200, STEPPER21_SPEED_FAST );
    Delay_ms ( 2000 );
    
    log_printf ( &logger, " Move 400 quarter steps counter-clockwise \r\n\n" );
    stepper21_set_step_mode ( &stepper21, STEPPER21_MODE_QUARTER_STEP );
    stepper21_set_direction ( &stepper21, STEPPER21_DIR_CCW );
    stepper21_drive_motor ( &stepper21, 400, STEPPER21_SPEED_VERY_FAST );
    Delay_ms ( 2000 );
}

void main ( void ) 
{
    application_init( );

    for ( ; ; ) 
    {
        application_task( );
    }
}

// ------------------------------------------------------------------------ END

Additional Support

Resources