This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DRV2605L: Need help with the setWaveform for DRV2605L

Part Number: DRV2605L
Other Parts Discussed in Thread: DRV2605

Hello,

Can someone please explain to me what is happening here, especially the highlighted section drv.setWaveform?

The source of this code is 'Arduino library for Adafruit DRV2605L Haptic Controller':

#include <Wire.h>
#include "Adafruit_DRV2605.h"

Adafruit_DRV2605 drv;

void setup() {
  Serial.begin(9600);
  Serial.println("DRV test");
  drv.begin();
   
  // I2C trigger by sending 'go' command
  drv.setMode(DRV2605_MODE_INTTRIG); // default, internal trigger when sending GO command

  drv.selectLibrary(1);
  drv.setWaveform(0, 84);  // ramp up medium 1, see datasheet part 11.2
  drv.setWaveform(1, 1);  // strong click 100%, see datasheet part 11.2
  drv.setWaveform(2, 0);  // end of waveforms
}

void loop() {
    drv.go();
    delay(1000);
}

  • Hi Suraj,

    DRV2605L has an internal waveform library. Each waveform in the library has an identifier, that goes from 1 to 123; the list of effects included can be found in data sheet section 11.2: www.ti.com/.../drv2605.pdf

    In addition this device has a waveform sequencer, where you store pointers to the effects you want to play in sequence, up to 8 effects. Details on how the sequencer can be used are in data sheet section 7.5.8.2.5: www.ti.com/.../drv2605.pdf

    Once you have configured the waveform sequencer with the effects you want to play from the library, you can use any trigger to start the effect sequence, in the case of the code above, "GO" register is used as trigger.

    The red code lines are basically doing the following: The first argument is the slot in the waveform sequencer (it can go from 0 to 7), the second argument is the effect identifier that can go from 1 to 123.
    drv.setWaveform(0, 84); Sets effect with identifier 84 to the first slot in the waveform sequencer
    drv.setWaveform(1, 1); Sets effect with identifier 1 to the second slot in the waveform sequencer
    drv.setWaveform(2, 0); Sets a 0 in the third slot of the waveform sequencer, that indicates the end of the effect sequence

    Best regards,
    -Ivan Salazar
    Applications Engineer - Low Power Audio & Actuators