vibromotor4  2.0.0.0
Main Page

Vibro Motor 4 click

Vibro Motor 4 Click is a compact add-on board that makes an ideal solution for adding simple haptic feedback in any design. This board features the G1040003D, a coin-sized linear resonant actuator (LRA) that generates vibration/haptic feedback from Jinlong Machinery & Electronics, Inc. Driven by a flexible Haptic/Vibra driver, the DRV2605, G1040003D vibrates in the Z-axis, which is perpendicular to the face of the vibration motor. It draws a maximum of 170mA while producing the highest G force/vibration energy of 2 GRMS.

click Product page


Click library

  • Author : Nenad Filipovic
  • Date : Aug 2021.
  • Type : I2C type

Software Support

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

Standard key functions :

Example key functions :

Example Description

This library contains API for Vibro Motor 4 Click driver. The library initializes and defines the I2C bus drivers to write and read data from registers and PWM module.

The demo application is composed of two sections :

Application Init

The initialization of I2C and PWM module, log UART, and additional pins. After the driver init and then executes a default configuration and configures Vibro Motor 4 Click boardâ„¢.

void application_init ( void )
{
log_cfg_t log_cfg;
vibromotor4_cfg_t vibromotor4_cfg;
// Logger initialization.
LOG_MAP_USB_UART( log_cfg );
log_cfg.level = LOG_LEVEL_DEBUG;
log_cfg.baud = 115200;
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
vibromotor4_cfg_setup( &vibromotor4_cfg );
VIBROMOTOR4_MAP_MIKROBUS( vibromotor4_cfg, MIKROBUS_1 );
err_t init_flag = vibromotor4_init( &vibromotor4, &vibromotor4_cfg );
if ( I2C_MASTER_ERROR == init_flag )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
Delay_ms( 100 );
vibromotor4_soft_rst( &vibromotor4 );
Delay_ms( 100 );
vibromotor4_default_cfg ( &vibromotor4 );
Delay_ms( 100 );
vibromotor4_set_duty_cycle( &vibromotor4, 0.0 );
Delay_ms( 100 );
vibromotor4_pwm_start( &vibromotor4 );
Delay_ms( 100 );
log_info( &logger, " Application Task " );
Delay_ms( 100 );
}

Application Task

This is an example that shows the use of a Vibro Motor 4 Click boardâ„¢. Changing duty cycle applied in order to get different vibrations. Results are being sent to the Usart Terminal where you can track their changes.

void application_task ( void )
{
static int8_t duty_cnt = 0;
static int8_t duty_inc = 1;
float duty = duty_cnt / 10.0;
vibromotor4_set_duty_cycle ( &vibromotor4, duty );
log_printf( &logger, "> Duty: %d%%\r\n", ( uint16_t )( duty_cnt * 10 ) );
Delay_ms( 1000 );
if ( 5 == duty_cnt ) {
duty_inc = -1;
} else if ( 0 == duty_cnt ) {
duty_inc = 1;
}
duty_cnt += duty_inc;
}

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

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.


vibromotor4_cfg_t
Vibro Motor 4 Click configuration object.
Definition: vibromotor4.h:317
vibromotor4_pwm_start
err_t vibromotor4_pwm_start(vibromotor4_t *ctx)
Vibro Motor 4 start PWM module.
vibromotor4_init
err_t vibromotor4_init(vibromotor4_t *ctx, vibromotor4_cfg_t *cfg)
Vibro Motor 4 initialization function.
vibromotor4_default_cfg
err_t vibromotor4_default_cfg(vibromotor4_t *ctx)
Vibro Motor 4 default configuration function.
vibromotor4_cfg_setup
void vibromotor4_cfg_setup(vibromotor4_cfg_t *cfg)
Vibro Motor 4 configuration object setup function.
vibromotor4_soft_rst
err_t vibromotor4_soft_rst(vibromotor4_t *ctx)
Vibro Motor 4 software reset function.
application_task
void application_task(void)
Definition: main.c:76
VIBROMOTOR4_PROPERTY_ENABLE
@ VIBROMOTOR4_PROPERTY_ENABLE
Definition: vibromotor4.h:349
vibromotor4_t
Vibro Motor 4 Click context object.
Definition: vibromotor4.h:297
application_init
void application_init(void)
Definition: main.c:33
VIBROMOTOR4_MAP_MIKROBUS
#define VIBROMOTOR4_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: vibromotor4.h:283
vibromotor4_set_mode
err_t vibromotor4_set_mode(vibromotor4_t *ctx, uint8_t mode_sel)
Vibro Motor 4 sets the desired mode function.
vibromotor4_set_duty_cycle
err_t vibromotor4_set_duty_cycle(vibromotor4_t *ctx, float duty_cycle)
Vibro Motor 4 sets PWM duty cycle.
vibromotor4_enable
err_t vibromotor4_enable(vibromotor4_t *ctx, vibromotor4_property_mode_t pr_mode)
Vibro Motor 4 enable the device function.