TOP Contributors

  1. MIKROE (2784 codes)
  2. Alcides Ramos (405 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (133 codes)
  5. Bugz Bensce (97 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (141704 times)
  2. FAT32 Library (74779 times)
  3. Network Ethernet Library (59224 times)
  4. USB Device Library (49227 times)
  5. Network WiFi Library (44999 times)
  6. FT800 Library (44537 times)
  7. GSM click (31203 times)
  8. mikroSDK (30104 times)
  9. microSD click (27586 times)
  10. PID Library (27543 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

DC Motor 12 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.13

mikroSDK Library: 2.0.0.0

Category: Brushed

Downloaded: 321 times

Not followed.

License: MIT license  

DC Motor 12 Click is a compact add-on board with a brushed DC motor driver. This board features the TB9054FTG, a PWM-type, dual-channel, H-bridge, brushed DC motor driver from Toshiba Semiconductor. The TB9054FTG is rated for an operating voltage range from 4.5V to 28V, with the motor controlled directly through a PWM signal or SPI serial interface. In addition, this driver allows a dual configuration with two motors with 5A current ratings per channel or one 10A channel drive in a Parallel mode of operation. It also has complete diagnostic and protection capabilities supporting robust and reliable operation.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "DC Motor 12 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "DC Motor 12 Click" changes.

Do you want to report abuse regarding "DC Motor 12 Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


DC Motor 12 Click

DC Motor 12 Click is a compact add-on board with a brushed DC motor driver. This board features the TB9054FTG, a PWM-type, dual-channel, H-bridge, brushed DC motor driver from Toshiba Semiconductor. The TB9054FTG is rated for an operating voltage range from 4.5V to 28V, with the motor controlled directly through a PWM signal or SPI serial interface. In addition, this driver allows a dual configuration with two motors with 5A current ratings per channel or one 10A channel drive in a Parallel mode of operation. It also has complete diagnostic and protection capabilities supporting robust and reliable operation.

dcmotor12_click.png

Click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Oct 2022.
  • Type : SPI type

Software Support

We provide a library for the DC Motor 12 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for DC Motor 12 Click driver.

Standard key functions :

  • dcmotor12_cfg_setup Config Object Initialization function.

    void dcmotor12_cfg_setup ( dcmotor12_cfg_t *cfg );
  • dcmotor12_init Initialization function.

    err_t dcmotor12_init ( dcmotor12_t *ctx, dcmotor12_cfg_t *cfg );
  • dcmotor12_default_cfg Click Default Configuration function.

    err_t dcmotor12_default_cfg ( dcmotor12_t *ctx );

Example key functions :

  • dcmotor12_get_motor_current DC Motor 12 get motor current function.

    err_t dcmotor12_get_motor_current ( dcmotor12_t *ctx, float *current );
  • dcmotor12_set_ch1_operation_mode DC Motor 12 set ch1 operation mode function.

    err_t dcmotor12_set_ch1_operation_mode ( dcmotor12_t *ctx, uint8_t mode );
  • dcmotor12_set_cm_sel_pin DC Motor 12 set cm sel pin function.

    err_t dcmotor12_set_cm_sel_pin ( dcmotor12_t *ctx, uint8_t state );

Example Description

This example demonstrates the use of DC Motor 12 Click board by controlling the speed of DC motor over PWM duty cycle as well as displaying the motor current consumption.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the Click default configuration.


void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    dcmotor12_cfg_t dcmotor12_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.
    dcmotor12_cfg_setup( &dcmotor12_cfg );
    DCMOTOR12_MAP_MIKROBUS( dcmotor12_cfg, MIKROBUS_1 );
    if ( DCMOTOR12_OK != dcmotor12_init( &dcmotor12, &dcmotor12_cfg ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( DCMOTOR12_OK != dcmotor12_default_cfg ( &dcmotor12 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

    log_info( &logger, " Application Task " );
}

Application Task

Changes the operation mode and motor speed by setting the PWM duty cycle and then calculates the motor current consumption for that speed. All data is being logged on the USB UART where you can track changes.

void application_task ( void )
{
    if ( DCMOTOR12_OK == dcmotor12_set_ch1_operation_mode ( &dcmotor12, DCMOTOR12_MODE_OUTPUT_OFF ) )
    {
        log_printf ( &logger, " MODE: OFF\r\n" );
        Delay_ms ( 1000 );
        Delay_ms ( 1000 );
        Delay_ms ( 1000 );
    }
    if ( DCMOTOR12_OK == dcmotor12_set_ch1_operation_mode ( &dcmotor12, DCMOTOR12_MODE_FORWARD ) )
    {
        dcmotor12_set_cm_sel_pin ( &dcmotor12, DCMOTOR12_PIN_LOW_LEVEL );
        for ( uint16_t duty = 0; duty <= DCMOTOR12_CONFIG56_DUTY_PERIOD_MAX; duty += 100 )
        {
            float current;
            log_printf ( &logger, " MODE: FORWARD\r\n" );
            if ( DCMOTOR12_OK == dcmotor12_set_ch1_duty_period ( &dcmotor12, duty ) )
            {
                log_printf ( &logger, " Duty: %u\r\n", duty );
            }
            if ( DCMOTOR12_OK == dcmotor12_get_motor_current ( &dcmotor12, &current ) )
            {
                log_printf ( &logger, " Current: %.3f A\r\n\n", current );
            }
            Delay_ms ( 500 );
        }
    }
    if ( DCMOTOR12_OK == dcmotor12_set_ch1_operation_mode ( &dcmotor12, DCMOTOR12_MODE_BRAKE ) )
    {
        log_printf ( &logger, " MODE: BRAKE\r\n" );
        Delay_ms ( 1000 );
        Delay_ms ( 1000 );
        Delay_ms ( 1000 );
    }
    if ( DCMOTOR12_OK == dcmotor12_set_ch1_operation_mode ( &dcmotor12, DCMOTOR12_MODE_REVERSE ) )
    {
        dcmotor12_set_cm_sel_pin ( &dcmotor12, DCMOTOR12_PIN_HIGH_LEVEL );
        for ( uint16_t duty = 0; duty <= DCMOTOR12_CONFIG56_DUTY_PERIOD_MAX; duty += 100 )
        {
            float current;
            log_printf ( &logger, " MODE: REVERSE\r\n" );
            if ( DCMOTOR12_OK == dcmotor12_set_ch1_duty_period ( &dcmotor12, duty ) )
            {
                log_printf ( &logger, " Duty: %u\r\n", duty );
            }
            if ( DCMOTOR12_OK == dcmotor12_get_motor_current ( &dcmotor12, &current ) )
            {
                log_printf ( &logger, " Current: %.3f A\r\n\n", current );
            }
            Delay_ms ( 500 );
        }
    }
}

Note

The Click board swiches should be set as follows: SW 1-2-3-4 : H-H-L-L This sets the Click board as a SPI controlled single-channel device so the motor should be connected to OUT1/2 and OUT3/4.

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.DCMotor12

Additional notes and informations

Depending on the development board you are using, you may need USB UART Click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.


ALSO FROM THIS AUTHOR

Altitude 2 Click

0

Altitude 2 Click is a high-resolution barometric pressure sensor Click board™. It provides very accurate measurements of temperature and atmospheric pressure, which can be used to calculate the altitude with a very high resolution of 20cm per step. Besides that, the device also includes features such as the ultra-low noise delta-sigma 24bit ADC, low power consumption, fast conversion times, pre-programmed unique compensation values, and more.

[Learn More]

1-Wire Switch Click

0

1-Wire Switch Click is a compact add-on board that allows you to switch a device remotely using a 1-wire signal. This board features the DS2413, a dual-channel programmable I/O 1-Wire switch from Analog Devices.

[Learn More]

Pressure 19 Click

0

Pressure 19 Click is a compact add-on board that contains a board-mount pressure sensor. This board features the MLX90817, a factory-calibrated absolute pressure sensor delivering ratiometric analog output from Melexis Technologies. The MLX90817 comes with a configurable host interface that supports I2C serial communication and configurable signal processing (the user is allowed to process the output signal in analog or digital form). It measures pressure from 0.2 up to 3bar with a pressure accuracy of ±33mbar. Its DSP-based architecture using a 16bit microcontroller provides outstanding performance in terms of initial accuracy and assures operation in a temperature range of -40°C to +120°C, ensuring stable operation under extreme conditions.

[Learn More]