Hi
I am new here so I hope I posted where it needs to go! Also coding for the first time in 20 +/- years.
I am trying to use the TCA to control 4 drv2605l for haptic feed back.
I have tried for the past week to find some answers to my problem.
I tried to talk to the forum where I got these to no help. (no further replies either)
All I am looking for is a code that will allow the drv's to work individually.
I've manage to hack some code for function ability. But it only allows one at a time or I have to, it seems reload the code each time and layer it up.
The forum responded back by saying I only have one drv2605 object.
I've looked and can't figure out how to add multiple drv's. The "SeveralThingsAtTheSameTime.ino" doesn't seem to be what I'm after or I can't "see it".
I've assumed it should be straight forward and simple code... One would think it's floating around some where.
I put the code up, but be wary, lol
deleted old code, new code down below in reply
Thanks ahead a time guru's!!
That chip is an I2C chip. It has a fixed address therefore you can not use more than one on an I2C bus without some multiplexing.
How have you wired up your four devices?
thanks for the reply back Mike,
Because of the fixed addresses, I have them going through a tca9548a multiplexer. It's from Adafruit and made for controlling the I2C drv's.
I think I got it working better, I reposted the code it's a little cleaner. I'll edit the other post and delete the old code to save the forum space
I still can't solve having to reload the code each time. I have to upload the code to get the other drv2605's to fire off. They won't all come on at the same time. I remove power and have to start all over again.
#include <Wire.h>
#include "Adafruit_DRV2605.h"
#include <Adafruit_Sensor.h>
#define TCAADDR 0x70
Adafruit_DRV2605 drv2; Adafruit_DRV2605 drv3;
Adafruit_DRV2605 drv4; Adafruit_DRV2605 drv5;
void displaySensorDetails(Adafruit_DRV2605)
{
sensor_t sensor;
//drv->getSensor(&sensor);
Serial.println("-------");
Serial.print ("Sensor: ");
Serial.println(sensor.name);
delay(500);
}
void tcaselect(uint8_t i)
{ if (i > 7) return;
Wire.beginTransmission(TCAADDR);
Wire.write(1 << i);
Wire.endTransmission();
Wire.begin();
}
void setup()
{ Serial.begin(9600);
Serial.println("DRV test");
Serial.println("");
drv2.selectLibrary(1); drv3.selectLibrary(1);
drv4.selectLibrary(1); drv5.selectLibrary(1);
// I2C trigger by sending 'go' command
drv2.setMode(DRV2605_MODE_INTTRIG); drv3.setMode(DRV2605_MODE_INTTRIG);
drv4.setMode(DRV2605_MODE_INTTRIG); drv5.setMode(DRV2605_MODE_INTTRIG);
/* Initialize the TCA SDA/SCL 2-5 */
{ tcaselect(2); Wire.begin(2);
uint8_t effect = (73, 119);
uint32_t wait = .1; // Time between reminders, in seconds
Serial.print("erm2.Effect #"); Serial.println(effect);
delay(wait * .02 * 1000);
}
{ tcaselect(3); Wire.begin(3);
uint8_t effect = (73, 119);
uint32_t wait = .1; // Time between reminders, in seconds
Serial.print("erm3.Effect #"); Serial.println(effect);
}
{ tcaselect(4); Wire.begin(4);
uint8_t effect = (73, 119);
uint32_t wait = .1; // Time between reminders, in seconds
Serial.print("erm4.Effect #"); Serial.println(effect);
}
{ tcaselect(5); Wire.begin(5);
uint8_t effect = (73, 119);
uint32_t wait = .1; // Time between reminders, in seconds
Serial.print("erm5.Effect #"); Serial.println(effect);
}
}
void loop()
{
tcaselect(2);
drv2.setWaveform(0, 83); // play effect
drv2.setWaveform(1, 0); // end waveform
drv2.go(); // play the effect!
tcaselect(3);
drv3.setWaveform(0, 73); // play effect
drv3.setWaveform(1, 0); // end waveform
drv3.go(); // play the effect!
tcaselect(4);
drv4.setWaveform(0, 21); // play effect
drv4.setWaveform(1, 0); // end waveform
drv4.go(); // play the effect!
tcaselect(5);
drv5.setWaveform(0, 52); // play effect
drv5.setWaveform(1, 0); // end waveform
drv5.go(); // play the effect!
}
Thanks again
Grumpy_Mike:
How have you wired up your four devices?
Please supply a schematic.
I still can't solve having to reload the code each time.
With a schematic I could see how and when you are switching the I2C bus.
// I2C trigger by sending 'go' command
drv2.setMode(DRV2605_MODE_INTTRIG); drv3.setMode(DRV2605_MODE_INTTRIG);
drv4.setMode(DRV2605_MODE_INTTRIG); drv5.setMode(DRV2605_MODE_INTTRIG);
You need to switch the I2C bus to the right board before every one of these calls. And every time you send something.
Hey Mike,
Here's a pic from adafruit, It's nearly identical to what I have going on

I did figure out why they weren't all coming on found on another post... need to add drv2,3,4,5 to begin function. so drv*.begin();
I think that helped out big time.
If I run into another problem, I'll post again.
Thanks for helping out