Pages: [1]   Go Down
Author Topic: Speed and direction control of dc motor using arduino and l298  (Read 1525 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello

I am trying to control both the speed and direction of dc motor using l298. Is speed control possible with l298?

Following is a snippet of my code
 
Counterclockwise:
digitalWrite(9,HIGH); //Enable
digitalWrite(5,HIGH);
digitalWrite(6,LOW);

Clockwise:
digitalWrite(9,HIGH); //Enable
digitalWrite(5,LOW);
digitalWrite(6,HIGH);

This works but the motor rotates at a constant speed!

To vary the speed, if I write analog values to pin 5 to move it counterclockwise, it is not working (I keep pin 6 LOW throughout)! Same thing is happening with pin 6!

Any input is appreciated. Thanks in advance.
Logged

Pottstown, PA
Offline Offline
Sr. Member
****
Karma: 5
Posts: 317
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It seems like your method should work. Perhaps you can try PWM to the ENABLE pin. - Scotty
Logged

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

Thanks scottyjr.

I took a different approach this time and problem is solved!

I am varying the time for which I keep the pins 5 and 6 HIGH. This is taking care of the variation in speed.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
John is Always Victorious
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What sort of speeds are you able to get?

I tried this method using a delay to hold the pin high. The chip runs too fast for the motor, you have to slow it down. And if delay was a variable, you could control the speed. But I burned out my old shield as it did not have any back-emf protection. I have a new shield now but it is not hooked up yet.
Logged

Pages: [1]   Go Up
Jump to: