Three M1T's on I2C and only one works

Hi,

i have a project in which a use three M1T’s on I2C connected to my Aruino 33 BLE. The boards all have common GND. The three M1T’s are on a separate powersource (3.3v), the Arduino is powered by USB:

I used the Motoron library to set the Adress to all three M1T’s. Afterwards i did the reset and ran the scan (of the same sketch) to see if the new addresses sticked and they did.

I then used the Motoron sketch I2CSImpleMulti and changed the decimal values of the three motors in the code. I '//" the entrances with mc4.

When i power everything up, only one of the three M1T’s listens to the sketch (at least as i understand it) and switches left/right as i can tell by the led changing green to red and visaversa. On the other two boards only the green led is on and then very dim at that… (i mean the green led that indicates right/left).
The leds of the board on the other side are all yellow (no red leds are lit).

When i change the I2C addresses in the code again and skip the one that worked in the above situation, and just coded two of the three M1T’s, the first one in the code works and the second isn’t.
So the boards are ok, my soldering is ok, something in my understanding of it all isn’t.

Can anyone help me out here?

My code of the three motors:

// This example shows a simple way to control multiple
// Motoron Motor Controllers using I2C.
//
// The motors will stop but automatically recover if:
// - Motor power (VIN) is interrupted, or
// - A temporary motor fault occurs, or
// - A command timeout occurs.
//
// The motors will stop until you power cycle or reset your
// Arduino if:
// - The Motoron experiences a reset.
//
// If a latched motor fault occurs, the motors
// experiencing the fault will stop until you power cycle motor
// power (VIN) or cause the motors to coast.

#include <Motoron.h>

// This code creates an object for each Motoron controller.
// The number passed as the first argument to each constructor
// below should be the 7-bit I2C address of the controller.
//
// You should use the I2CSetAddresses sketch to
// assign a unique I2C address to each Motoron, and then
// modify the list below to match your setup.
MotoronI2C mc1(22);
MotoronI2C mc2(23);
MotoronI2C mc3(27);
//MotoronI2C mc4(20);

// You can call functions directly on each of the objects
// created above (mc1, mc2, etc.) but if you want to write
// reusable code, the function below shows how to do that
// using references, a feature of the C++ language.
void setupMotoron(MotoronI2C & mc)
{
  mc.reinitialize();
  mc.disableCrc();

  // Clear the reset flag, which is set after the controller
  // reinitializes and counts as an error.
  mc.clearResetFlag();

  // By default, the Motoron is configured to stop the motors if
  // it does not get a motor control command for 1500 ms.  You
  // can uncomment a line below to adjust this time or disable
  // the timeout feature.
  // mc.setCommandTimeoutMilliseconds(1000);
  // mc.disableCommandTimeout();
}

void setup()
{
  Wire.begin();

  setupMotoron(mc1);
  setupMotoron(mc2);
  setupMotoron(mc3);
 // setupMotoron(mc4);

  mc1.setMaxAcceleration(1, 80);
  mc1.setMaxDeceleration(1, 300);

  mc1.setMaxAcceleration(2, 80);
  mc1.setMaxDeceleration(2, 300);

  mc1.setMaxAcceleration(3, 80);
  mc1.setMaxDeceleration(3, 300);

  mc2.setMaxAcceleration(1, 80);
  mc2.setMaxDeceleration(1, 300);

  mc2.setMaxAcceleration(2, 80);
  mc2.setMaxDeceleration(2, 300);

  mc2.setMaxAcceleration(3, 80);
  mc2.setMaxDeceleration(3, 300);

  mc3.setMaxAcceleration(1, 80);
  mc3.setMaxDeceleration(1, 300);

  mc3.setMaxAcceleration(2, 80);
  mc3.setMaxDeceleration(2, 300);

  mc3.setMaxAcceleration(3, 80);
  mc3.setMaxDeceleration(3, 300);

  //mc4.setMaxAcceleration(1, 80);
  //mc4.setMaxDeceleration(1, 300);

  //mc4.setMaxAcceleration(2, 80);
  //mc4.setMaxDeceleration(2, 300);

  //mc4.setMaxAcceleration(3, 80);
 // mc4.setMaxDeceleration(3, 300);
}

void loop()
{
  int16_t changingSpeed = (millis() & 2048) ? 800 : -800;

  mc1.setSpeed(1, changingSpeed);
  mc1.setSpeed(2, 100);
  mc1.setSpeed(3, -100);

  mc2.setSpeed(1, 100);
  mc2.setSpeed(2, changingSpeed);
  mc2.setSpeed(3, -100);

  mc3.setSpeed(1, 100);
  mc3.setSpeed(2, -100);
  mc3.setSpeed(3, changingSpeed);

 // mc4.setSpeed(1, changingSpeed);
 // mc4.setSpeed(2, -changingSpeed);
 // mc4.setSpeed(3, changingSpeed);
}

I changed this code from the loop to match the code from mc1 in that loop:

and now it works?!

I don’t understand the code; that’s for sure. Can anyone explain?

Kind regards,

Bart

Don’t bother… i’m a real Noob. I should have read the classes first.
mc3 is the M1T board, the motorindication on that baord is the 1, 2 and 3 in the setSpeed command. So in setSpeed ( 1, 100) , the 1 is the motor number. I use M1T boards that can only drive 1 motor so each setSpeed command should only use (1, … ) and not (2, …) or even (3,…). Silly me…

1 Like