Mini vibration motor induction issues

I try to control two mini vibration motors

via music software called pure data.
One motor is controlled via pwm pin (I'm sending numbers between 0 -255) and the other one is controlled via digital pin (Sending 0 or 1)

one motor is effected the other meaning if I'm changing the pwm it will interact and effect the other motor.
How can I avoid that? (the end project will include 4 motors for digital pins and another 4 motors for pwm pins)

here is the schematics:

and here is the arduino code that receiving the data from pure data:

const int NUM_PWM_MOTORS = 3;
const int pwm_motor_pins[] = {3, 10, 11};

const int NUM_DIGITAL_MOTORS = 3;
const int digital_motor_pins[] = {4, 2, 4};

const char pwm_motor_ids[] = {'A', 'B', 'C'};
const char digital_motor_ids[] = {'X', 'Y', 'Z'};

void setup() {
  for (int i = 0; i < NUM_PWM_MOTORS; i++) {
    pinMode(pwm_motor_pins[i], OUTPUT);
  }
  for (int i = 0; i < NUM_DIGITAL_MOTORS; i++) {
    pinMode(digital_motor_pins[i], OUTPUT);
  }
  Serial.begin(115200);
}

void loop() {
  if (Serial.available() > 0) {
    char id = Serial.read();
    int state = Serial.parseInt();
    for (int i = 0; i < NUM_PWM_MOTORS; i++) {
      if (id == pwm_motor_ids[i]) {
        analogWrite(pwm_motor_pins[i], state);
        break;
      }
    }
    for (int i = 0; i < NUM_DIGITAL_MOTORS; i++) {
      if (id == digital_motor_ids[i]) {
        digitalWrite(digital_motor_pins[i], !state);
        break;
      }
    }
  }
}

Use a separate, well regulated power supply for the motors, capable of supplying more current than required by all three motors running at full power.

Diode voltage drop is strongly current-dependent, so diodes are not useful as voltage regulators in this case.

1 Like

which 3V3 or 3V you recommend? can I use voltage regulator to step the voltage down from 5V to 3V ?

*I have noticed that the interference and cross talking is not happening when using only pwm pins. (Although I tried only two motors. not sure what will happen with 8 )

Pololu has an excellent selection. For 8 motors, pick a regulator that can handle 10-20X the normal running current for one motor.

Do not use the Arduino 5V output for motors!

so if one motor rated for 80mA of current and I would like to control 8 motors -
8*80mA = 640mA * 10 = 6.4A power supply?

Do not use the Arduino 5V output for motors!

I know!

10X 80 mA is 0.8A. 20X 80 mA is 1.6A. Go with the latter.

this is only for 1 motor isn't it?
I am talking about 8 motors

For eight motors, the power supply should to be able to handle significantly more current than required when all eight of them are running together.

Engineers typically double the maximum for a safety margin. 2X8 = 16, rounding to 20 for additional safety, suggests that the motor power supply should be able to provide at least 20x0.08A = 1.6 Amperes.

I don't think I can explain it more clearly.

I can't use one power supply for all 8 motors?

if so it should be able to provide 1.6 Amperes * 8 motors = 12.8A ?

That is EXACTLY what post #8 is saying.

ONE 3.3V power supply, capable of providing 1.6A, can easily power eight motors.

Perhaps you need another cup of coffee?

I do need.. I got it now! thanks!

Hi,
is the same project and problema?

please do not duplicate post.
So you duplicate our efforts.

same project different issue. I thought is better to open a new topic for that. I am sorry if it is not the case.
Shall I delete the post and paste to here my question from there?

Lets get your schematic correct for a start.
Show the correct pins in the schematic and correct numbers of motors.

Have you got tried some simple code to see if this is a hardware fault?

Tom... :smiley: :+1: :coffee: :australia:

here is the correct code using only two motors and the correct schematics using only one motor:

code:

 const int NUM_PWM_MOTORS = 1;
const int pwm_motor_pins[] = {9};

const int NUM_DIGITAL_MOTORS = 1;
const int digital_motor_pins[] = {8};

const char pwm_motor_ids[] = {'A'};
const char digital_motor_ids[] = {'X'};


unsigned long heartbeatMillis;
int heartbeatLED = 13;

void setup() {
  
  for (int i = 0; i < NUM_PWM_MOTORS; i++) {
    pinMode(pwm_motor_pins[i], OUTPUT);
  }
  for (int i = 0; i < NUM_DIGITAL_MOTORS; i++) {
    pinMode(digital_motor_pins[i], OUTPUT);
  }
  Serial.begin(115200);
  pinMode(heartbeatLED,OUTPUT);
}

void loop() {
  checkHeartbeatTIMER();
  motorsControl();

}


void motorsControl()
{
  if (Serial.available() > 0) {
    char id = Serial.read();
    int state = Serial.parseInt();
    for (int i = 0; i < NUM_PWM_MOTORS; i++) {
      if (id == pwm_motor_ids[i]) {
        analogWrite(pwm_motor_pins[i], state);
        break;
      }
    }
    for (int i = 0; i < NUM_DIGITAL_MOTORS; i++) {
      if (id == digital_motor_ids[i]) {
        digitalWrite(digital_motor_pins[i], !state);
        break;
      }
    }
  }
}
void checkHeartbeatTIMER()
{
  if (millis() - heartbeatMillis >= 500ul)
  {
    //restart this TIMER
    heartbeatMillis = millis();

    //toggle the heartbeatLED
    digitalWrite(heartbeatLED, !digitalRead(heartbeatLED));
  }

} 

schematic:

If I'm using both motos with pwm pin (analogwrite) I have no interference between the two. it Just happening when using one motor with digital pin and the other with pwm

What happens in this case?

Note you are using 3 fwd biased diodes to get your 3V3.

What voltage do you measure on the 3V3 when operating each motor separately?
What voltage do you measure on the 3V3 when operating each more together but with different signals? eg. fault mode.
Sorry but need to see signal flow when troubleshooting.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Hi,
Is this to do with this?

Can I suggest you get ONE problem at a time fixed with the SAME project?

Tom... :frowning_face: :coffee: :coffee: :+1: :australia:

Yes. I will focus now on the problem using multiple motors and the interfaces between them.

I wire up now 4 motors on breadboard. When I control all of them via analogWrite (pwm) - sending numbers between 0 -255 I have no interference between motors. each one is working individually without an issue.

When I change two motors to be controlled by digital pins and I'm sending for example 500ms ON - 500ms OFF - 500ms ON - 500ms Off etc ; the moment I'm changing the value of one of the pwm motors - moving the number from one value to another it will interference the two digital motors and they will act differently from their sequence.

what it can be?

edit: I have noticed another thing :

The interference between motors is happening only when I'm toggling the digital motors between on and off. When I switch ON the digital motor and leave it ON any change in the pwm motor will not effect it. So the interference is happening only when toggling on and off the digital motor.

I read both threads and this was also my conclusion.

It is OK to have multiple topics on the same project if each is about a distinct subject matter. If you do that, you must be careful to manage the scope of the discussion to prevent the two topics from converging into overlap on the same subject matter, as they have a tendency to do. If discussion starts to stray into the territory of the other topic, then redirect the participants over to the other to continue that discussion.

No, don't do that. But if you think it is better to merge the two existing topics into a single topic I would be happy to do that for you. The choice is yours.

Regards,
pert

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.