TOP Contributors

  1. MIKROE (2752 codes)
  2. Alcides Ramos (372 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (90 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 (139064 times)
  2. FAT32 Library (71594 times)
  3. Network Ethernet Library (56989 times)
  4. USB Device Library (47330 times)
  5. Network WiFi Library (43006 times)
  6. FT800 Library (42297 times)
  7. GSM click (29777 times)
  8. mikroSDK (27874 times)
  9. PID Library (26858 times)
  10. microSD click (26129 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 18 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: 170 times

Not followed.

License: MIT license  

DC Motor 18 Click is a compact add-on board that contains a brushed DC motor driver. This board features the TB9051FTG, an automotive PWM-type single-channel H-Bridge DC brushed motor driver from Toshiba Semiconductor.

No Abuse Reported

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

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

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

  • Information
  • Comments (0)

mikroSDK Library Blog


DC Motor 18 Click

DC Motor 18 Click is a compact add-on board that contains a brushed DC motor driver. This board features the TB9051FTG, an automotive PWM-type single-channel H-Bridge DC brushed motor driver from Toshiba Semiconductor.

dc_motor_18_click.png

Click Product page


Click library

  • Author : Luka Filipovic
  • Date : Aug 2021.
  • Type : PWM type

Software Support

We provide a library for the DCMotor18 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 DCMotor18 Click driver.

Standard key functions :

  • dcmotor18_cfg_setup Config Object Initialization function.

    void dcmotor18_cfg_setup ( dcmotor18_cfg_t *cfg );
  • dcmotor18_init Initialization function.

    err_t dcmotor18_init ( dcmotor18_t *ctx, dcmotor18_cfg_t *cfg );
  • dcmotor18_default_cfg Click Default Configuration function.

    err_t dcmotor18_default_cfg ( dcmotor18_t *ctx );

Example key functions :

  • dcmotor18_set_speed_percentage Set speed output percentage.

    err_t dcmotor18_set_speed_percentage ( dcmotor18_t *ctx, float speed_percentage );
  • dcmotor18_set_enable Set enable pin state.

    void dcmotor18_set_enable ( dcmotor18_t *ctx, uint8_t state );
  • dcmotor18_read_an_pin_current Read AN pin current.

    err_t dcmotor18_read_an_pin_current ( dcmotor18_t *ctx, float *data_out );

Example Description

This example application showcases ability of Click board to control DC motors using PWM modulation in both directions and different speeds.

The demo application is composed of two sections :

Application Init

Initialization of MCU communication modules (PWM, ADC, UART) and additioal gpio for control of the device. Then sets default configuration that enables device to control the DC motor.


void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    dcmotor18_cfg_t dcmotor18_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.

    dcmotor18_cfg_setup( &dcmotor18_cfg );
    DCMOTOR18_MAP_MIKROBUS( dcmotor18_cfg, MIKROBUS_1 );
    err_t init_flag  = dcmotor18_init( &dcmotor18, &dcmotor18_cfg );
    if ( PWM_ERROR == init_flag )
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }

    dcmotor18_default_cfg ( &dcmotor18 );

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

Application Task

Drives motor in one direction from 0 to 100% of the speed using PWM, and then returns it back to 0. Then changes the rotation direction and repeats the process of increasing and decreasing acceleration.


void application_task ( void ) 
{
    static int8_t duty_cnt = 1;
    static int8_t duty_inc = 1;
    float speed = duty_cnt / 10.0;
    static uint8_t direction = 1;

    dcmotor18_set_direction( &dcmotor18, direction );
    dcmotor18_set_speed_percentage ( &dcmotor18, speed );

    if ( dcmotor18.direction )
    {
        log_printf( &logger, "<<< " );
    }
    else
    {
        log_printf( &logger, ">>> " );
    }
    log_printf( &logger, "Speed: %d%%\r\n", ( uint16_t )( duty_cnt * 10 ) );

    if ( 10 == duty_cnt )
    {
        duty_inc = -1;
    }
    else if ( 0 == duty_cnt )
    {
        duty_inc = 1;
        direction = !direction;
    }
    duty_cnt += duty_inc;

    Delay_ms ( 1000 );  
}

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

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

SwipeSwitch Click

0

SwipeSwitch Click is capacitive touch, gesture, and proximity sensing Click board™, which is equipped with the IQS266, an integrated trackpad controller circuit which features ProxSense® and IQ Switch® technologies. This IC consists of a 2x3-channel capacitive trackpad controller, and a single self-capacitive proximity sensor, which can be used to wake up the device. This ensures very low power consumption, as the device is able to stay in the Sleep mode when not used. The IQS266 can detect a number of various configurable swipe and tap gestures. An Automatic Tuning Implementation (ATI) feature ensures an optimized performance in various conditions.

[Learn More]

Proximity 2 click

5

Proximity 2 clickâ„¢ features MAX44000, an IC that integrates an ambient light as well as a proximity sensor. The IR proximity detector is matched with an integrated IR LED driver (for the onboard high power infrared LED). Proximity 2 clickâ„¢ communicates with the target board microcontroller through mikroBUS I2C (SCL, SDA), and INT lines.

[Learn More]

Proximity 19 Click

0

Proximity 19 Click is a compact add-on board designed for precise proximity sensing in various applications. This board features the RPR-0720, a digital optical proximity sensor from ROHM Semiconductor. The RPR-0720 integrates an infrared VCSEL (IrVCSEL) and an IC with an I2C interface, featuring a detection range adjustable from 1 to 15mm and an ambient light canceling function. The board uses a 2-wire I2C interface for communication, supporting up to 400kHz frequency clock, allowing control over sensor functions such as operating mode, interrupt system, and offset/threshold adjustments.

[Learn More]