Intermediate
20 min

Drive and control small stepping motors with the TB67S569FTG and PIC32MX470F512H

BiCD constant-current 2-phase bipolar stepping motor driver

Stepper 23 Click with 6LoWPAN clicker

Published Jul 10, 2024

Click board™

Stepper 23 Click

Dev. board

6LoWPAN clicker

Compiler

NECTO Studio

MCU

PIC32MX470F512H

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

6LoWPAN Clicker is a compact starter development board that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It comes with an onboard 32-bit PIC microcontroller, the PIC32MX470F512H from Microchip, a USB connector, LED indicators, buttons, a mikroProg connector, and a header for interfacing with external electronics. Along with this microcontroller, the board also contains a 2.4GHz ISM band transceiver, allowing you to add wireless communication to your target application. Its compact design provides a fluid and immersive working experience, allowing access anywhere

and under any circumstances. Each part of the 6LoWPAN Clicker development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the 6LoWPAN Clicker programming method, using USB HID mikroBootloader, or through an external mikroProg connector for PIC, dsPIC, or PIC32 programmer, the Clicker board also includes a clean and regulated power supply module for the development kit. The USB Micro-B connection can provide up to 500mA of current for the Clicker board, which is more than enough to operate all onboard and additional modules, or it can power

over two standard AA batteries. All communication methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, reset button, and several buttons and LED indicators. 6LoWPAN Clicker is an integral part of the Mikroe ecosystem, allowing you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

6LoWPAN clicker double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC32

MCU Memory (KB)

512

Silicon Vendor

Microchip

Pin count

64

RAM (Bytes)

131072

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
RG9
AN
Output Enable
RD6
RST
ID COMM
RE5
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Step Clock
RB8
PWM
Interrupt
RD0
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RD10
SCL
I2C Data
RD9
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

Stepper 23 Click Schematic schematic

Step by step

Project assembly

PIC32MZ clicker front image hardware assembly

Start by selecting your development board and Click board™. Begin with the 6LoWPAN clicker as your development board.

PIC32MZ clicker front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
Micro B Connector Clicker 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
Flip&Click PIC32MZ 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

1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

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

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.

/*!
 * @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.