Haptic Motor Driver Hook-Up Guide

Pages
Contributors: LightningHawk
Favorited Favorite 5

Internal Trigger Mode

The internal trigger mode allows you to play a waveform or a custom waveform sequence from the ROM waveform memory. In this example we will play all 123 waveform effects by loading them in all eight waveform sequencer registers. This simple sketch will also help you become familiar with the effects library so you can start to build your own custom effects sequences. See page 60 of the datasheet for the full list of waveform effects. Each library -- listed on page 14 of the datasheet -- has its own rated voltage, rise-time and brake-time.

Parts Needed

SparkFun RedBoard - Programmed with Arduino

SparkFun RedBoard - Programmed with Arduino

DEV-13975
$19.95
47
Vibration Motor

Vibration Motor

ROB-08449
$2.15
12
Jumper Wires Premium 6" M/M Pack of 10

Jumper Wires Premium 6" M/M Pack of 10

PRT-08431
$3.95
2
SparkFun Haptic Motor Driver - DRV2605L

SparkFun Haptic Motor Driver - DRV2605L

ROB-14538
$8.50

Hardware Connection

alt text

The hardware consists of the standard I2C connection and the enable (EN) pin must be pulled high.

Arduino Program

language:c
#include <Sparkfun_DRV2605L.h> //SparkFun Haptic Motor Driver Library 
#include <Wire.h> //I2C library 

SFE_HMD_DRV2605L HMD; //Create haptic motor driver object 

void setup() 
{
  HMD.begin();
  Serial.begin(9600);
  HMD.Mode(0); // Internal trigger input mode -- Must use the GO() function to trigger playback.
  HMD.MotorSelect(0x36); // ERM motor, 4x Braking, Medium loop gain, 1.365x back EMF gain
  HMD.Library(2); //1-5 & 7 for ERM motors, 6 for LRA motors 

}
void loop() 
{
  int seq = 0; //There are 8 sequence registers that can queue up to 8 waveforms
  for(int wave = 1; wave <=123; wave++) //There are 123 waveform effects 
  {
     HMD.Waveform(seq, wave);
     HMD.go();
     delay(600); //give enough time to play effect 
     Serial.print("Waveform Sequence:      ");
     Serial.println(seq);
     Serial.print("Effect No.:      ");
     Serial.println(wave);

    if (wave%8==0) //Each Waveform register can queue 8 effects
    {
        seq=seq+1;
    }
    if (wave%64==0) // After the last register is used start over 
    {
        seq=0;
    }
  }
 }