Intermediate
20 min

Drive and control small stepping motors with the TB67S569FTG and PIC18F57Q43

BiCD constant-current 2-phase bipolar stepping motor driver

Stepper 23 Click with Curiosity Nano with PIC18F57Q43

Published Jul 10, 2024

Click board™

Stepper 23 Click

Dev Board

Curiosity Nano with PIC18F57Q43

Compiler

NECTO Studio

MCU

PIC18F57Q43

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

PIC18F57Q43 Curiosity Nano evaluation kit is a cutting-edge hardware platform designed to evaluate microcontrollers within the PIC18-Q43 family. Central to its design is the inclusion of the powerful PIC18F57Q43 microcontroller (MCU), offering advanced functionalities and robust performance. Key features of this evaluation kit include a yellow user LED and a responsive

mechanical user switch, providing seamless interaction and testing. The provision for a 32.768kHz crystal footprint ensures precision timing capabilities. With an onboard debugger boasting a green power and status LED, programming and debugging become intuitive and efficient. Further enhancing its utility is the Virtual serial port (CDC) and a debug GPIO channel (DGI

GPIO), offering extensive connectivity options. Powered via USB, this kit boasts an adjustable target voltage feature facilitated by the MIC5353 LDO regulator, ensuring stable operation with an output voltage ranging from 1.8V to 5.1V, with a maximum output current of 500mA, subject to ambient temperature and voltage constraints.

PIC18F57Q43 Curiosity Nano double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC

MCU Memory (KB)

128

Silicon Vendor

Microchip

Pin count

48

RAM (Bytes)

8196

You complete me!

Accessories

Curiosity Nano Base for Click boards is a versatile hardware extension platform created to streamline the integration between Curiosity Nano kits and extension boards, tailored explicitly for the mikroBUS™-standardized Click boards and Xplained Pro extension boards. This innovative base board (shield) offers seamless connectivity and expansion possibilities, simplifying experimentation and development. Key features include USB power compatibility from the Curiosity Nano kit, alongside an alternative external power input option for enhanced flexibility. The onboard Li-Ion/LiPo charger and management circuit ensure smooth operation for battery-powered applications, simplifying usage and management. Moreover, the base incorporates a fixed 3.3V PSU dedicated to target and mikroBUS™ power rails, alongside a fixed 5.0V boost converter catering to 5V power rails of mikroBUS™ sockets, providing stable power delivery for various connected devices.

Curiosity Nano Base for Click boards accessories 1 image

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
PA0
AN
Output Enable
PA7
RST
ID COMM
PD4
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Step Clock
PB0
PWM
Interrupt
PA6
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PB2
SCL
I2C Data
PB1
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 Nano Base for Click boards front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Curiosity Nano with PIC18F57Q43 as your development board.

Curiosity Nano Base for Click boards front image hardware assembly
Charger 27 Click front image hardware assembly
PIC18F47Q10 Curiosity Nano front image hardware assembly
Prog-cut hardware assembly
Charger 27 Click complete accessories setup image hardware assembly
Curiosity Nano with PICXXX 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 image step 5 hardware assembly
Necto image step 6 hardware assembly
PIC18F57Q43 Curiosity 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 via Debug Mode

1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.

2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.

DEBUG_Application_Output

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.