Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Using the TCA9548A and DRV2605L breakout boards
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Using the TCA9548A and DRV2605L breakout boards

by aashu1 on Thu Aug 06, 2020 12:01 pm

I am using the TCA9548A I2C multiplexer to communicate with 6 haptic motors. I am using an Arduino Uno to code these components. Each one of these haptic motors is connected to a DRV2605L breakout board, which is then connected to the I2C multiplexer. Since both products are from Adafruit, I was wondering if there is a simple way to communicate to each motor through the I2C multiplexer. So far, I have connected the I2C multiplexer and by running your initial code, have recognized the ports and the DRV2605L breakout boards connected to them. But I cannot get the motors to rotate since I do not know what command to send the I2C multiplexer! I do not know if tcaselect( ) can be used to send a command to one of the 6 vibration motors I am using. Can you please help?
Thank you

aashu1
 
Posts: 4
Joined: Thu Aug 06, 2020 11:25 am

Re: Using the TCA9548A and DRV2605L breakout boards

by adafruit_support_bill on Thu Aug 06, 2020 12:18 pm

Communication with the DRV2605L is via the DRV2605L library.
https://learn.adafruit.com/adafruit-drv ... -1043645-4

You use tcaselect() to select a channel on the multiplexer. Then any DRV2605L commands you send will be directed to the board attached to that channel.

adafruit_support_bill
 
Posts: 78635
Joined: Sat Feb 07, 2009 10:11 am

Re: Using the TCA9548A and DRV2605L breakout boards

by aashu1 on Thu Aug 06, 2020 1:47 pm

I am having problems with the setup. While the setup for the TCA9548A is the same that was used in the testing example, how do I set up the motor before I select the port? Could you please help me out with this?
Thank you

Code: Select all | TOGGLE FULL SIZE
#include "Adafruit_DRV2605.h"
#include "Wire.h"
#include <Wire.h>
extern "C"{ 
#include "utility/twi.h"
}

#define TCAADDR 0x70

Adafruit_DRV2605 drv;

void tcaselect(uint8_t i) {
  if (i > 7) return;
  Wire.beginTransmission(TCAADDR);
  Wire.write(1 << i);
  Wire.endTransmission(); 
}

void setup()
{
  drv.begin();
  drv.selectLibrary(1);
  drv.setMode(DRV2605_MODE_INTTRIG);
 
    while (!Serial);
    delay(1000);
    Wire.begin();
    Serial.begin(9600);
    for (uint8_t t=0; t<8; t++) {
      tcaselect(t);
      Serial.print("TCA Port #"); Serial.println(t);

      for (uint8_t addr = 0; addr<=127; addr++) {
        if (addr == TCAADDR) continue;
     
        uint8_t data;
        if (! twi_writeTo(addr, &data, 0, 1, 1)) {
           Serial.print("Found I2C 0x");  Serial.println(addr,HEX);
        }
      }
    }
}

uint8_t effect = 1;

void loop() {
  tcaselect(0);
  effect=120;
  drv.setWaveform(0, effect);  // play effect
  drv.setWaveform(1, 0);       // end waveform
  drv.go();
}

 
Attachments
TCA_Motor.ino
(1014 Bytes) Downloaded 1 time
Last edited by adafruit_support_bill on Thu Aug 06, 2020 1:48 pm, edited 1 time in total.
Reason: Please use [code] tags when posting code to the forums

aashu1
 
Posts: 4
Joined: Thu Aug 06, 2020 11:25 am

Re: Using the TCA9548A and DRV2605L breakout boards

by adafruit_support_bill on Thu Aug 06, 2020 1:50 pm

how do I set up the motor before I select the port?

You can't. You need to select the port before you can talk to the device.

adafruit_support_bill
 
Posts: 78635
Joined: Sat Feb 07, 2009 10:11 am

Re: Using the TCA9548A and DRV2605L breakout boards

by aashu1 on Thu Aug 06, 2020 1:55 pm

I did select the port before I set up the motor in my void setup(). It's still not working. Can you please take a look and tell me if my command to the motor is wrong in the void loop()??
Thank you

aashu1
 
Posts: 4
Joined: Thu Aug 06, 2020 11:25 am

Re: Using the TCA9548A and DRV2605L breakout boards

by adafruit_support_bill on Thu Aug 06, 2020 2:11 pm

You need to give it some time for the command to run. The loop function is called repeatedly, so you are sending it a continuous stream of commands.

adafruit_support_bill
 
Posts: 78635
Joined: Sat Feb 07, 2009 10:11 am

Re: Using the TCA9548A and DRV2605L breakout boards

by aashu1 on Thu Aug 06, 2020 2:31 pm

Thank you very much for your help! I got it. Turned out I need to add a bit of a delay in the loop and make sure the effect was strong enough to be felt.

aashu1
 
Posts: 4
Joined: Thu Aug 06, 2020 11:25 am

Please be positive and constructive with your questions and comments.