Intermediate
30 min

Achieve superior performance in every brushed application with TB67H400AFTG and PIC18F57Q43

Unlock the motor's true capabilities

DC MOTOR 7 Click with Curiosity Nano with PIC18F57Q43

Published Feb 13, 2024

Click board™

DC MOTOR 7 Click

Dev Board

Curiosity Nano with PIC18F57Q43

Compiler

NECTO Studio

MCU

PIC18F57Q43

Seize the opportunity to optimize your motorized system. Employ an alternative mode of this solution to use H-Bridges in parallel, receiving twice as much power!

A

A

Hardware Overview

How does it work?

DC MOTOR 7 Click is based on the TB67H400AFTG, a PWM chopper-type brushed DC motor driver from Toshiba Semiconductor. This IC uses a proprietary BiCD manufacturing process, allowing this IC to be powered by a wide range of supply voltages, from 10V up to 47V. Due to the MOSFETs' very low ON resistance, the TB67H400AFTG can deliver up to 4A of current to the connected load. However, many external parameters affect both the maximum voltage and the current specifications, especially when the connected load is complex, such as the DC motor. This IC offers an alternative mode, where it can use its internal H-Bridges in parallel, offering twice as much power for a single motor. Before attempting to connect a single DC brushed motor, please refer to the datasheet of the TB67H400AFTG for precise connection instructions. DC MOTOR 7 click requires an external power supply for operation. The optimal voltage that should be used is 24V. Although the TB67H400AFTG driver has thermal and overcurrent protection, it is a temporary measure. A short-circuit at the output terminal may damage the Click board™. There are two output terminals used to connect DC motors and a power supply input terminal, where the external PSU can be connected, with respect to the polarity marked on the Click board™ itself (bottom side). Brushed DC motors are typically made with only two conductors to supply the motor with power, so even controlling the direction can be

challenging in some situations. Therefore, a specialized driver circuit is required. The TB67H400AFTG utilizes two sensing resistors (one for each channel) and an internally generated PWM signal to regulate the current through the motor. This results in better efficiency and less heat dissipation and provides control over the motor's torque, direction, and speed. Each motor is driven by the internal H-Bridge, which is controlled by the control logic section of the TB67H400AFTG IC. The motor control logic section regulates the current by opening and closing the specific MOSFETs of the H-Bridge, allowing the current through the coils to rise to a certain point (charging) to circulate between the coils and the driver until a specified point of time reached (slow decay), and then to return the remaining energy to the power supply (fast decay). The whole cycle is timed by pulses of the PWM signal derived from the internal oscillator. The TB67H400AFTG exposes six control pins to the microcontroller (MCU): PWMA, PWMB, INA1, INA2, INB1, and INB2. By changing the logic states on these pins, the MCU can control both connected motors independently. Besides a detailed explanation of the operating modes, the TB67H400AFTG datasheet also provides a truth table that explains the effects of logic states on these pins. Since the TB67H400AFTG IC has six different control pins, an additional port expander IC is required to access all these pins.

The PWMA and PWMB pins are routed to the mikroBUS™ RST and PWM pins, respectively, while the rest of the control pins (INA1, INA2, INB1, and INB2) are accessible via the PCA9538A, an 8-bit I2C port expander by NXP Semiconductors. In addition, the HBMODE pin used to select the single or dual operating mode (Large Mode or Small Mode) and the TBLKAB pin used to set the blanking interval are also available over the PCA9538A IC. Logic states on the PCA9538A pins can be easily set over the I2C interface, allowing to quickly change states on all the control pins of the TB67H400AFTG IC using a single command over the I2C interface. Please note that the state of the HBMODE pin should not be altered once the Click board™ is powered up and initialized. The slave I2C address of the PCA9538A can be changed. Two LSB of the I2C address can be set to 0 or 1 by switching SMD jumpers on the Click board™. This allows four different 7-bit I2C addresses to be selected from 0x70 to 0x73. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the SMD jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. However, the 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.

DC MOTOR 7 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

DC Gear Motor - 430RPM (3-6V) represents an all-in-one combination of a motor and gearbox, where the addition of gear leads to a reduction of motor speed while increasing the torque output. This gear motor has a spur gearbox, making it a highly reliable solution for applications with lower torque and speed requirements. The most critical parameters for gear motors are speed, torque, and efficiency, which are, in this case, 520RPM with no load and 430RPM at maximum efficiency, alongside a current of 60mA and a torque of 50g.cm. Rated for a 3-6V operational voltage range and clockwise/counterclockwise rotation direction, this motor represents an excellent solution for many functions initially performed by brushed DC motors in robotics, medical equipment, electric door locks, and much more.

DC MOTOR 7 Click accessories image

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Motor A Channel Short-Brake Control
PA7
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Motor B Channel Short-Brake Control
PB0
PWM
NC
NC
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

Click board™ Schematic

DC MOTOR 7 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 DC MOTOR 7 Click driver.

Key functions:

  • dcmotor7_set_port - Functions for set port

  • dcmotor7_go_to_stand_by_mode - Function for setting the motor in stand mode

  • dcmotor7_set_pwm_motor_b - Function for set PWM value for motor B

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 
 * \brief DcMotor7 Click example
 * 
 * # Description
 * This application is a dual brushed DC motor driving.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initialization driver init, enabled all output port, sets H-Bridge operation mode and Motor Digital tblk
 * 
 * ## Application Task  
 * Set the motor A and the motor B to rotate clockwise and in the Counte clockwise direction, 
 * and between the change of direction, the motor stops the motor.
 * 
 * *note:* 
 * VM input - 10 V (min) to 47 V (max)
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "dcmotor7.h"

// ------------------------------------------------------------------ VARIABLES

static dcmotor7_t dcmotor7;

// ------------------------------------------------------ APPLICATION FUNCTIONS

void application_init ( void )
{
    dcmotor7_cfg_t cfg;

    //  Click initialization.

    dcmotor7_cfg_setup( &cfg );
    DCMOTOR7_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    dcmotor7_init( &dcmotor7, &cfg );

    dcmotor7_default_cfg( &dcmotor7 );
}

void application_task ( void )
{
    dcmotor7_set_motor( &dcmotor7, DCMOTOR7_MOTOR_A, 0, 1 );
    dcmotor7_set_motor( &dcmotor7, DCMOTOR7_MOTOR_B, 0, 1 );
    Delay_ms( 500 );
    
    dcmotor7_motor_stop( &dcmotor7, DCMOTOR7_MOTOR_A );
    dcmotor7_motor_stop( &dcmotor7, DCMOTOR7_MOTOR_B );
    Delay_ms( 2000 );
    
    dcmotor7_set_motor( &dcmotor7, DCMOTOR7_MOTOR_A, 1, 0 );
    dcmotor7_set_motor( &dcmotor7, DCMOTOR7_MOTOR_B, 1, 0 );
    Delay_ms( 500 );
    
    dcmotor7_motor_stop( &dcmotor7, DCMOTOR7_MOTOR_A );
    dcmotor7_motor_stop( &dcmotor7, DCMOTOR7_MOTOR_B );
    Delay_ms( 2000 );
}

void main ( void )
{
    application_init( );

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

// ------------------------------------------------------------------------ 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.