Pages: 1 [2]   Go Down
Author Topic: [HELP] Set the speed of 2 DC motors with H-Bridge  (Read 1170 times)
0 Members and 1 Guest are viewing this topic.
East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 114
Posts: 4257
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley


* getfile.jpg (35.81 KB, 582x343 - viewed 16 times.)
Logged

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What do you mean 'PWM pin'?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26290
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What do you mean 'PWM pin'?
http://arduino.cc/en/Reference/AnalogWrite
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you, I'll try tomorrow
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 114
Posts: 4257
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
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.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Pages: 1 [2]   Go Up
Jump to: