Beginner
10 min

Manage the operation of two-phase bipolar stepper motors with TB67S269FTG and MK64FN1M0VDC12

Two-phase bipolar stepping motor driver using a PWM chopper

Stepper 4 click with Clicker 2 for Kinetis

Published Mar 15, 2024

Click board™

Stepper 4 click

Dev Board

Clicker 2 for Kinetis

Compiler

NECTO Studio

MCU

MK64FN1M0VDC12

User-friendly solution for controlling bipolar stepper motors featuring advanced technologies that ensure efficient, precise, and noiseless operation

A

A

Hardware Overview

How does it work?

Stepper 4 Click is based on the TB67S269FTG, a bipolar stepper motor driver IC with a translator section from Toshiba Semiconductor. This highly integrated IC offers a very simple bipolar stepper motor control interface, thanks to the integrated translator section. This section controls the output drivers, providing smooth action of the stepper motor. By controlling the current intensity and its decay throughout the rotation cycle, a constant torque is achieved for every position. This IC features a high-efficiency motor current control mechanism (Advanced Dynamic Mixed Decay), which results in the optimal ripple while regulating the motor current. The current is limited by the value of the sensing resistor and a reference voltage at the VREF pins. It is possible to adjust the reference voltage via the onboard potentiometer labeled as torque from 0V to 3.3V, changing the current limit through the motor coils, thus changing the torque. The absolute current limit on this IC is 2A, after which the overcurrent protection is activated. A LOW to HIGH transition

(rising edge) on the CLK pin of the TB67S269FTG IC will perform one rotational step. The direction of the rotation is controlled by the logic state on the CW/CCW pin (routed to the mikroBUS™ AN pin, labeled as DIR). The step size is determined by three pins: DMODE0, DMODE1, and DMODE2. It is possible to work with seven movement step sizes, ranging from full to 1/32 step size. These pins are routed to the DIP switch labeled as STEP MODE, allowing step size to be selected by moving each of them. The ENABLE pin allows the host MCU to turn on or off the output stages of the TB67S269FTG IC. Asserting this pin to a HIGH logic level enables the output stage. The RESET pin is used to reset the electrical angle to the initial position and is active at HIGH. The ENABLE pin is routed to the CS (labeled as EN), while the RESET pin is routed to the RST pin of the mikroBUS™, allowing the host MCU to control the IC via these pins. The TB67S269FTG offers monitoring of the electrical angle and fault condition signaling. These two pins are routed to the SMD jumper labeled as INT SEL.

While in the MO position, the angle monitoring pin will be routed to the mikroBUS™ INT pin. If the jumper is set at the LO position, it will route the LO pin to the INT pin of the mikroBUS™, allowing faulty conditions, such as thermal or overcurrent failure, to be reported. These pins feature a pull-up resistor and will have a LOW logic level when asserted. This Click board™ can be interfaced with 3.3V and 5V MCUs, thanks to an SMD jumper labeled VCC SEL. It is enough to move the SMD jumper to the appropriate position (3V3 or 5V), and the logic voltage level of the communication signals will be properly set for both types of MCUs. The Click board™ is equipped with the input and output screw terminals. The terminal labeled TB1 on the schematic connects the external power supply, which should stay in the range from 10V to 35V. The stepper motor can be connected securely via the TB2 and TB3 screw terminals, with their input terminals labeled as A+, A-, and B+, B-.

Stepper 4 click hardware overview image

Features overview

Development board

Clicker 2 for Kinetis 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 ARM Cortex-M4F microcontroller, the MK64FN1M0VDC12 from NXP Semiconductors, two mikroBUS™ sockets for Click board™ connectivity, a USB connector, LED indicators, buttons, a JTAG programmer connector, and two 26-pin headers for interfacing with external electronics. Its compact design with clear and easily recognizable silkscreen markings allows you to build gadgets with unique functionalities and

features quickly. Each part of the Clicker 2 for Kinetis development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the Clicker 2 for Kinetis programming method, using a USB HID mikroBootloader or an external mikroProg connector for Kinetis programmer, the Clicker 2 board also includes a clean and regulated power supply module for the development kit. It provides two ways of board-powering; through the USB Micro-B cable, where onboard voltage regulators provide the appropriate voltage levels to each component on the board, or

using a Li-Polymer battery via an onboard battery connector. All communication methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, reset button, and several user-configurable buttons and LED indicators. Clicker 2 for Kinetis 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.

Clicker 2 for Kinetis dimensions image

Microcontroller Overview

MCU Card / MCU

default

Architecture

ARM Cortex-M4

MCU Memory (KB)

1024

Silicon Vendor

NXP

Pin count

121

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 4 click accessories 1 image

Used MCU Pins

mikroBUS™ mapper

Direction Control
PB2
AN
Reset
PB11
RST
Chip Enable
PC4
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Step Trigger
PA10
PWM
Angle Monitor / Error Detection
PB13
INT
NC
NC
TX
NC
NC
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

Stepper 4 click Schematic schematic

Step by step

Project assembly

Clicker 2 for PIC32MZ front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Clicker 2 for Kinetis as your development board.

Clicker 2 for PIC32MZ 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 2 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

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 4 Click driver.

Key functions:

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

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

  • stepper4_reset_device - This function resets the device by toggling the RST pin

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 4 Click Example.
 *
 * # Description
 * This example demonstrates the use of the Stepper 4 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 "stepper4.h"

static stepper4_t stepper4;   /**< Stepper 4 Click driver object. */
static log_t logger;    /**< Logger object. */

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    stepper4_cfg_t stepper4_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.
    stepper4_cfg_setup( &stepper4_cfg );
    STEPPER4_MAP_MIKROBUS( stepper4_cfg, MIKROBUS_1 );
    if ( DIGITAL_OUT_UNSUPPORTED_PIN == stepper4_init( &stepper4, &stepper4_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    stepper4_default_cfg ( &stepper4 );
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    log_printf ( &logger, " Move 200 steps clockwise \r\n\n" );
    stepper4_set_direction ( &stepper4, STEPPER4_DIR_CW );
    stepper4_drive_motor ( &stepper4, 200, STEPPER4_SPEED_FAST );
    Delay_ms ( 2000 );
    
    log_printf ( &logger, " Move 100 steps counter-clockwise \r\n\n" );
    stepper4_set_direction ( &stepper4, STEPPER4_DIR_CCW );
    stepper4_drive_motor ( &stepper4, 100, STEPPER4_SPEED_FAST );
    Delay_ms ( 2000 );
}

int main ( void ) 
{
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

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

Additional Support

Resources