Intermediate
20 min

Drive and control small stepping motors with the TB67S569FTG and PIC32MZ2048EFM100

BiCD constant-current 2-phase bipolar stepping motor driver

Stepper 23 Click with Curiosity PIC32 MZ EF

Published Jul 10, 2024

Click board™

Stepper 23 Click

Dev Board

Curiosity PIC32 MZ EF

Compiler

NECTO Studio

MCU

PIC32MZ2048EFM100

Control bipolar stepping motors in projects that demand accurate positioning and movement regulation

A

A

Hardware Overview

How does it work?

Stepper 23 Click is based on the TB67S569FTG, a BiCD constant-current 2-phase bipolar stepping motor driver IC from Toshiba Semiconductor. The TB67S569FTG features a PWM chopper-type 2-phase bipolar drive system and leverages the BiCD process with MOSFETs for output power transistors. Noteworthy features include the Advanced Dynamic Mixed Decay (ADMD) function for efficient PWM constant-current drive, high withstand voltage, and current capability withstanding voltage of up to 34V operating supplied externally via the VM terminal within a range of 10 to 34V, supporting a maximum operating current of 1.8A per phase (absolute maximum rating of 2A). It also integrates safety mechanisms such as over-temperature detection (TSD), over-current detection (ISD), and low supply voltage detection (UVLO). This Click board™ makes the perfect solution for small stepping motors in various applications such as consumer electronics and industrial equipment. The current value in the PWM constant-current mode is set by the reference voltage obtained by the MCP1501, a high-precision voltage regulator. Also, the current threshold point of the TB67S569FTG, alongside MCP1501, can be set manually using an onboard trimmer labeled VR. The control of the Stepper 23 Click is managed through specific pins on the mikroBUS™ socket: The CLK clock signal, routed to the default PWM position, advances the motor's

current step and electrical angle with each rising edge. The Enable pin, EN pin, controls the activation state of the output A and B stepping motor drive channels. Additionally, the DIR pin determines the rotation direction of the stepping motor, with a HIGH logic level indicating forward rotation and a LOW logic level indicating reverse rotation. Due to the limited number of control pins on the mikroBUS™ for managing the TB67S569FTG, the Stepper 23 Click also incorporates the PCA9555A port expander. This port expander, interfacing via the I2C interface, provides additional control over the TB67S569FTG and its functions. One of the key functions enabled through this port expander is the Decay mode. The selectable mixed decay function allows to switch between four decay modes MIXED, SLOW, FAST, and ADMD (Advanced Dynamic Mixed Decay technology from Toshiba). This optimization enhances the performance and efficiency of the stepping motor. Additionally, the Torque mode pins set the motor's torque by adjusting the logical levels of both TRQ pins. It is possible to set the torque to 100%, 75%, 50%, or 25% without changing the reference voltage level of the current regulator . The RST pin resets the electrical angle in the internal counter to an initial position. Furthermore, the MO pin indicates the achievement of the initial electrical angle position. Besides these functions, the port expander also controls the

DMODE pins, which set the step resolution to full, half-step, quarter-step, 1/8, 1/16, or 1/32. The  Sleep mode function allows switching between power-saving mode (consumes only 0.03uA typical) and normal operation mode. By setting the Sleep mode and then returning to the normal operation mode, it is possible to recover from the forced OFF-state caused by the overheating or over-current detection circuit operation. Alternatively these functions can also be controlled manually via a multifunctional switch, where selecting a particular switch position (1 for Sleep Mode; 2, 3, 4 for Step Resolution Setting) allows for easy and efficient management of the board's operations. The board also includes two LED status indicators: a TSD orange LED for overtemperature conditions and an ISD red LED for overcurrent conditions. The PCA9538A allows choosing the least significant bit (LSB) of its I2C slave address by positioning SMD jumpers labeled as ADDR SEL to an appropriate position marked as 0 and 1, alongside its interrupt feature routed to the INT pin of the mikroBUS™ socket. 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 as a reference for further development.

Stepper 23 Click hardware overview image

Features overview

Development board

Curiosity PIC32 MZ EF development board is a fully integrated 32-bit development platform featuring the high-performance PIC32MZ EF Series (PIC32MZ2048EFM) that has a 2MB Flash, 512KB RAM, integrated FPU, Crypto accelerator, and excellent connectivity options. It includes an integrated programmer and debugger, requiring no additional hardware. Users can expand

functionality through MIKROE mikroBUS™ Click™ adapter boards, add Ethernet connectivity with the Microchip PHY daughter board, add WiFi connectivity capability using the Microchip expansions boards, and add audio input and output capability with Microchip audio daughter boards. These boards are fully integrated into PIC32’s powerful software framework, MPLAB Harmony,

which provides a flexible and modular interface to application development a rich set of inter-operable software stacks (TCP-IP, USB), and easy-to-use features. The Curiosity PIC32 MZ EF development board offers expansion capabilities making it an excellent choice for a rapid prototyping board in Connectivity, IOT, and general-purpose applications.

Curiosity PIC32MZ EF double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC32

MCU Memory (KB)

2048

Silicon Vendor

Microchip

Pin count

100

RAM (Bytes)

524288

You complete me!

Accessories

The 17HD40005-22B stepper motor is a two-phase hybrid motor for high torque, high speed, and low noise performance. It features a 1m wire with optional ports on the connection end and heat shrink tubing to prevent tangling. The motor's D-shaped axle is 22mm in length. This motor operates with a chopping wave constant current drive and has a two-phase 4-wire exciting mode, allowing for both forward and reverse rotation. The power order follows AB-BC-CD-DA, viewed as clockwise from the shaft end. It has a rated current of 1.3A DC, a rated voltage of 2.4V, and a stepping angle of 1.8°, with an insulation grade of B. This stepper motor is ideal for applications requiring precise movement control and reliability.

Stepper 23 Click accessories 1 image

Used MCU Pins

mikroBUS™ mapper

Rotation Direction Control
RPB4
AN
Output Enable
RA9
RST
ID COMM
RPD4
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Step Clock
RPE8
PWM
Interrupt
RF13
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RPA14
SCL
I2C Data
RPA15
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

Stepper 23 Click Schematic schematic

Step by step

Project assembly

Curiosity PIC32MZ EF front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Curiosity PIC32 MZ EF as your development board.

Curiosity PIC32MZ EF front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
Curiosity PIC32 MZ EF MB 1 Access - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Curiosity PIC32 MZ EF MCU Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output

After loading the code example, pressing the "DEBUG" button builds and programs it on the selected setup.

Application Output Step 1

After programming is completed, a header with buttons for various actions available in the IDE appears. By clicking the green "PLAY "button, we start reading the results achieved with Click board™.

Application Output Step 3

Upon completion of programming, the Application Output tab is automatically opened, where the achieved result can be read. In case of an inability to perform the Debug function, check if a proper connection between the MCU used by the setup and the CODEGRIP programmer has been established. A detailed explanation of the CODEGRIP-board connection can be found in the CODEGRIP User Manual. Please find it in the RESOURCES section.

Application Output Step 4

Software Support

Library Description

This library contains API for Stepper 23 Click driver.

Key functions:

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

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

  • stepper23_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 23 Click example
 *
 * # Description
 * This example demonstrates the use of the Stepper 23 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 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.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "stepper23.h"

static stepper23_t stepper23;
static log_t logger;

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    stepper23_cfg_t stepper23_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.
    stepper23_cfg_setup( &stepper23_cfg );
    STEPPER23_MAP_MIKROBUS( stepper23_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == stepper23_init( &stepper23, &stepper23_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( STEPPER23_ERROR == stepper23_default_cfg ( &stepper23 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    log_printf ( &logger, " Move 200 full steps clockwise, speed: slow\r\n\n" );
    stepper23_set_direction ( &stepper23, STEPPER23_DIR_CW );
    stepper23_set_step_mode ( &stepper23, STEPPER23_MODE_FULL_STEP );
    stepper23_drive_motor ( &stepper23, 200, STEPPER23_SPEED_SLOW );
    Delay_ms ( 1000 );

    log_printf ( &logger, " Move 200 half steps counter-clockwise, speed: medium\r\n\n" );
    stepper23_set_direction ( &stepper23, STEPPER23_DIR_CCW );
    stepper23_set_step_mode ( &stepper23, STEPPER23_MODE_HALF_STEP_TYPE_A );
    stepper23_drive_motor ( &stepper23, 200, STEPPER23_SPEED_MEDIUM );
    Delay_ms ( 1000 );

    log_printf ( &logger, " Move 400 quarter steps counter-clockwise, speed: fast\r\n\n" );
    stepper23_set_direction ( &stepper23, STEPPER23_DIR_CCW );
    stepper23_set_step_mode ( &stepper23, STEPPER23_MODE_QUARTER_STEP );
    stepper23_drive_motor ( &stepper23, 400, STEPPER23_SPEED_FAST );
    Delay_ms ( 1000 );
}

int main ( void ) 
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif
    
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

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

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.