Unstable pwm signals

Hello,
I'm building maze solving robot on arduino uno.

I cant understand why do my motors go with different velocity
I measured them and there is difference between voltage on board (these with pwm signals)
It can be that board is broken?
Is there something i can do more?

there is my code

int motor1pin1 = 2;
int motor1pin2 = 4;
int motor2pin1 = 7;
int motor2pin2 = 8;

int enA = 6;
int enB = 9;


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);


  pinMode(motor1pin1, OUTPUT);
  pinMode(motor1pin2, OUTPUT);
  pinMode(motor2pin1, OUTPUT);
  pinMode(motor2pin2, OUTPUT);
}



void loop() {

		analogWrite(enA, 70);
    analogWrite(enB, 70);


      digitalWrite(motor1pin1, LOW);
      digitalWrite(motor1pin2, HIGH);
      digitalWrite(motor2pin1, HIGH);
      digitalWrite(motor2pin2, LOW );    
  
  
}

it's that 9v battery. Totally inadequate for powering one motor(barely adequate for powering an Arduino, which is much less hungry).

And, if the Battery is just 'for the picture', then your text should clearly tell us what your real power source is, or your drawing should be revised.

According to the scheme used in the project, the robot above does not solve the maze, but rather moves according to programming commands
Delete
analogWrite(enA, 70);
analogWrite(enB, 70);
Place commands using the command
digitalWrite for each drive and direction

For a robot to solve the maze, a distance sensor must be installed.

Dr.Farkad Adnan

u are right, improved diagram here:

I use now digitalWrite(enA,50) in my code as you mention, but i cant control now velocity of motors.
I want to slow down the default velocity of motors by at least half.

Two motors aren't necessarily going to rotate at the same speed just because the same voltage is applied. It would be like trying to control how fast your car is going by how far down you push the accelerator pedal... You have to watch the speedometer...

You can't reliably measure PWM with a multi-meter, but the same PWM should measure the same with the same meter, as long as the power supply voltage is "holding up".

  1. not every motor is manufactured the same
  2. they run faster in one direction
  3. you are using two different PWM frequencies

enA = 980Hz PWM
enB = 490Hz PWM

Use pin 5,6 (both 980Hz) or pin 9,10 (both 490Hz).
Google "arduino Uno pwm frequency".
Leo..

okey i connected enA and enB to 5 and 6 pins (like you said)

problem is still the same ( motors running with different velocity [forward direction])

i measured voltage between motors and there was 3.25v between out1 and out2 on motor1 and 3.75v between out 3 and out4 on motor2

then I changed the connection
and there was 3.75v between out1 and out2 on motor2 and 3.25v between out 3 and out4 on motor1

so it can be that there is something wrong with arduino board? it is not seems like it can be motors or bridge for this moment

Apperently your motors are not identical...
Does one have a few hairs winded up along the axis?

what exactly are you asking?


when it comes to the axis itself - it moves freely

I think you should let it be for now.
Measuring motor voltage is tricky.
Your motors are free running. That brings them in a state where the current they take is very sensitive to the speed of rotation and the speed of rotation is very dependent on the resistance of your gear box. If those are not exactly equal, you are likely to see substancial differences...

at the moment my robot can't even do something as simple as driving straight because this difference makes it go around in circles - what should I do?

Set pwm to the motor that runs too slow a bit higher...
analogWrite(EnX, 90);

Motors (brushes) turn better in one direction.
Can you flip the (yellow) body and the wires of the slowest motor.
Leo..

Brushes are slightly offset from being centered on the armature. This ensures there is an electrical connection to some segment when you try to start the motor. Use motors with the shaft extending on both sides of the motor, so they can turn your wheels at the same speed, the same direction.

OP seems to have a two-motor frame with a swivel wheel.
Leo..

Ah, I see. I also see yellow plastic gear boxes with drive shafts on both sides. So, there is a good chance the motors are turning the same direction, or certainly could be made that way. Has the OP run both motors from one connection controlling PWM?

I suppose OP use different PWM values for steering,
but you want the motors to match as good as you can first.
Leo..

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