Go Down

Topic: [HELP] Set the speed of 2 DC motors with H-Bridge (Read 1 time) previous topic - next topic

UKHeliBob


I buyed it, here's a link:
http://my.safaribooksonline.com/getfile?item=ODMvZDlpY3B0L20vZ2VzOTg4Mzk5NjI1c2FzcjdhaWxjZW90dC9odHBvdG9tcmxjdW1zeW9yb2Vyc2VhZ2VwZTNlaWx5Z3JpYW55bXMzNjcwMTIuZ24ubGFtanBn
Evrything the same, except that I connected the ENB to Pin6 and added a second motor.

That link does not work for me.

Does each motor work as expected when it is the only one being controlled ?

A thought.  Have you got anything using interrupts, such as a sensor using timer 2, attached to the Arduino ?
I had problems with motor control when I added a ping sensor to my buggy. (Arduino Uno)  It stopped PWM working on pins 3 and 11 because its library uses timer 2 which is also used for PWM on those pins.  I had to switch the enable pin of one motor from pin 3 to pin 10.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Mats2006

OK, the picture is in the attach.
Yes, you can control one motor, but then the other one does nothing.
And no, I don't use any sensor, just a button and a few LED's :)

ash901226

try moving the enable switch to another free PWM pin. that should give you the speed control you need


AWOL

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.


UKHeliBob


OK, the picture is in the attach.
Yes, you can control one motor, but then the other one does nothing.
And no, I don't use any sensor, just a button and a few LED's :)

Looking at your code and judging by the names used for the Arduino pins you have not wired your circuit the same as the example circuit.  That will not matter as long as you have wired the enable and inputs of the H bridge to the pins that the names in your code suggest.  ie

Arduino pin  H bridge
5                2  IN1 - motor A
4                7  IN2 - motor A
6                 1 Enable motor A

3               10 IN3 - motor B
2               15 IN4 - motor B
7                 9 Enable motor B

I suggest that you check this carefully just in case.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Go Up