Beginner
10 min

Achieve precise and reliable motion control with TB67S269 and PIC32MZ2048EFM100

Empower your projects with the pinpoint accuracy of our bipolar stepper motor driver

Multi Stepper Click - TB67S269 with Curiosity PIC32 MZ EF

Published Nov 11, 2023

Click board™

Multi Stepper Click - TB67S269

Dev.Board

Curiosity PIC32 MZ EF

Compiler

NECTO Studio

MCU

PIC32MZ2048EFM100

Our bipolar stepper motor driver is purposefully designed to provide accurate and reliable control, ensuring precise motion in applications within office automation, commercial, and industrial sectors.

A

A

Hardware Overview

How does it work?

Multi Stepper Click is based on the TB67S269FTG, a two-phase bipolar stepping motor driver using a PWM chopper (customized by external resistance R2 and capacitor C1) from Toshiba Semiconductor. The TB67S269FTG comes with a built-in clock-in decoder (CLOCK-in controlled), which means that each up-edge of the CLK signal, routed to the PWM pin of the mikroBUS™ socket, will shift the motor's electrical angle per step. It also incorporates a low on-resistance MOSFET output stage, which can deliver a 1.4A current with a motor output voltage rating of 47V, in addition to integrated protection mechanisms such as over-current and over-temperature detection. In addition, it allows from full-step up to 1/32 steps resolution, with the help of which motor noise can be significantly reduced with smoother operation and more precise control. As mentioned, the TB67S269FTG supports various step resolution configurations through its control signals. These control signals are provided through the PCA9555A port expander, which establishes communication with the MCU via the I2C serial interface. This Click board™ also allows a connection of external step-resolution control signals on the onboard header J1 on pins labeled as P1 and P2 for the device's DMODE1 and DMODE2 control. The PCA9555A also allows

choosing the least significant bit (LSB) of its I2C slave address by positioning SMD jumpers labeled ADDR SEL to an appropriate position marked as 0 and 1. The motor A/B channel current output value can be set manually using an onboard trimmer labeled VR1, which sets the reference voltage from 0V to 3.3V. The default configuration of the JP4 jumper is the VREF position that sets both channels' output current via the VR1 trimmer. In this case, avoid position P4 on a jumper JP4 since the VREFA pin requires an analog signal for setting. Also, this Click board™ has a Standby function, activated when all three step-resolution control signals are in their low logic state, used to switch to Standby mode by setting all motor control pins to a low logic state. When the Standby mode is active, the TB67S269FTG stops supplying the power to the internal oscillating circuit and motor output part (the motor drive cannot be performed). In addition to the I2C communication, several GPIO pins connected to the mikroBUS™ socket are also used. The Enable pin, labeled as EN and routed to the CS pin of the mikroBUS™ socket, optimizes power consumption used for power ON/OFF purposes. Also, a simple rotation direction function routed to the AN pin on the mikroBUS™ socket allows MCU to manage the direction of the stepper motor (clockwise or

counterclockwise), while the RST pin of the mikroBUS™ socket initializes an electrical angle in the internal counter to set an initial position. When it comes to angle monitoring, this driver has a dual way of monitoring selected by positioning the SMD jumper labeled as JP5 to an appropriate position marked as P6 or INT, which chooses to monitor via the expander or INT pin of the mikroBUS™ socket. In the case of the selected INT position of the JP5 jumper, the JP10 jumper needs to be unpopulated. Also, it has an additional LED for anomaly indication. Suppose a state such as an overtemperature or overcurrent is detected. In that case, such an anomaly is indicated by a red LED marked as DIAG. Multi Stepper Click supports an external power supply for the TB67S269FTG, which can be connected to the input terminal labeled as VM and should be within the range of 10V to 47V, 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 as a reference for further development.

Multi Stepper Click - TB67S269 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 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.

Multi Stepper Click - TB67S269 accessories image

Used MCU Pins

mikroBUS™ mapper

Rotation Direction
RPB4
AN
Reset
RA9
RST
Enable
RPD4
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Clock Signal
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

Multi Stepper Click - TB67S269 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 Multi Stepper TB67S269 Click driver.

Key functions:

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

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

  • multisteppertb67s269_set_direction - This function sets the motor direction by setting the AN pin logic state.

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 MultiStepperTB67S269 Click example
 *
 * # Description
 * This example demonstrates the use of the Multi Stepper TB67S269 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 steps and then counter-clockiwse for 100 steps with
 * 2 seconds delay before changing the direction.
 * Each step will be logged on the USB UART where you can track the program flow.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "multisteppertb67s269.h"

static multisteppertb67s269_t multisteppertb67s269;
static log_t logger;

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    multisteppertb67s269_cfg_t multisteppertb67s269_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.
    multisteppertb67s269_cfg_setup( &multisteppertb67s269_cfg );
    MULTISTEPPERTB67S269_MAP_MIKROBUS( multisteppertb67s269_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == multisteppertb67s269_init( &multisteppertb67s269, &multisteppertb67s269_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( MULTISTEPPERTB67S269_ERROR == multisteppertb67s269_default_cfg ( &multisteppertb67s269 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    log_printf ( &logger, " Move 200 steps clockwise \r\n\n" );
    multisteppertb67s269_set_direction ( &multisteppertb67s269, MULTISTEPPERTB67S269_DIR_CW );
    multisteppertb67s269_drive_motor ( &multisteppertb67s269, 200, MULTISTEPPERTB67S269_SPEED_FAST );
    Delay_ms ( 2000 );
    
    log_printf ( &logger, " Move 100 steps counter-clockwise \r\n\n" );
    multisteppertb67s269_set_direction ( &multisteppertb67s269, MULTISTEPPERTB67S269_DIR_CCW );
    multisteppertb67s269_drive_motor ( &multisteppertb67s269, 100, MULTISTEPPERTB67S269_SPEED_FAST );
    Delay_ms ( 2000 );
}

void main ( void ) 
{
    application_init( );

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

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

Additional Support

Resources