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: Software addressing the DRV2605 waveforms

Part Number: DRV2605L
Other Parts Discussed in Thread: DRV2605,

Both Adafruit and Sparkfun provide software support for the DRV2605 and select waveforms to play like this (Arduino target host):

void loop() {
  Serial.print("Effect #"); Serial.println(effect);

  // set the effect to play
  drv.setWaveform(0, effect);  // play effect
  drv.setWaveform(1, 0);       // end waveform

  // play the effect!
  drv.go();

  // wait a bit
  delay(500);

  effect++;
  if (effect > 117) effect = 1;
}

I'd like to understand the motive and effect accomplished with the drv.setWaveform(1,0) command here (saying "end waveform").

Some questions:

1. Say you write to start one effect waveform.  Does it start right away or first verify there is not already a waveform being played?  Does the "end waveform" write do anything to the status of the previous write - is the previous waveform guaranteed to play full length?

2. What happens if you write one effect waveform and then a 2nd right after, without the "end waveform" write? Do they still sequence correctly and both play out?

3. What would be a scenario where you would want to sequence several effect waveforms?

I'm not really a software guy so I am having a bit of trouble locating the file that contains the definition of drv.setWaveform and drv.go.  Can you point that out to me?  Either Sparkfun or Adafruit example ok.

  • Hi Barry,

    I have found the code you are referring to in your question. I just want to note that this is from Adafruit and not necessarily supported by me.
    1. When you set a waveform, you are assigning a waveform number from the library to the waveform sequencer. The waveform sequencer is divided into 8 sequences, 8.5.8.2.5 of the DRV2605L datasheet. The sequencer will start playing with the first sequence and continue until it arrives at a sequence with no waveform. This is why they are setting '0' to the 2nd sequence (the 1st sequence is 0 and the second sequence is 1). This is only needed if there was previously a waveform in the second sequence because the last 7 sequences should be initialized to '0'.
    2. If you write an effect to the first two sequences, they will play in sequence until there is a '0' in a sequence.
    3. This is an opinion question...it is really up to the end user on when or why they would play multiple effects. Maybe they want a click + ramp up + ramp down.

    If you are on the github, then the definitions are in the .cpp file "Adafruit_DRV2605.cpp" and the header file defines the registers as defined in the datasheet. All communication is through I2C.