Go Down

Topic: L298 H-bridge motor controller (Read 12962 times) previous topic - next topic

joshuajestelle

Hi all,

I seem to have found lots of questions about this topic, around various forums, but no answers that have helped me get things working.

I'm trying to drive a simple DC motor by using a L298 H-bridge (http://www.st.com/stonline/products/literature/ds/1773/l298.pdf) and my Arduino.

I've been following the schematics here, which seem to make sense to me:
http://www.pyroelectro.com/tutorials/l298_control/schematic.html

Yet both my output pins, that go to the motor, always seem to display the same voltage, which is whatever is coming in as my power supply voltage.  This is the same whether I hook up 2 AA batteries to the power supply or try to use Vcc from the Arduino.

Any ideas what I might be doing wrong?

Many thanks,
Josh

Daniel2

#1
Jul 13, 2008, 07:51 pm Last Edit: Jul 13, 2008, 07:51 pm by Daniel2 Reason: 1
Hey

sounds like a power supply problem.

The L298 needs two supplies: 5V for logic (take from arduino) and something higher for the motor supply.

The specs say that the motor supply needs to be at least 5V or so; 3V from 2xAA batteries is not going to do it. Try connecting 9V or 12V as the motor supply, and double check your wiring too. Avoid using the Arduino 5V supply as motor power, as it can bring noise back to the Arduino, and it's also not rated for much current.

joshuajestelle

Hmmm, thanks  for your help.

I've since tried a 9V rechargeable RC-car battery, and still seeing the same behavior.

I've double, and triple checked the wiring, and even tried two different L298 chips, in case of a bad chip.

I'm still confused :(  Any further advice, or simple suggestions on how to wire this thing up to make sure my H-bridge is functioning properly will be greatly appreciated.

Thanks!
Josh

Are you actually providing the proper control signals to the driver?

joshuajestelle

Quote
Are you actually providing the proper control signals to the driver?


That there, is a very good question  :-/
I thought it was as simple as providing HIGH to one of the inputs and LOW to the other, but I seem to be beginning to understand that's not the case?

roypardi

Are you pulling up the enable pin (or setting it HIGH through either digitalWrite/analogWrite if the enable pin on the H-bridge is connected to your arduino)? Unless the enable pin is HIGH there is no current flowing to your output pins.

Also maybe having a common ground between your motor supply and the arduino supply.

That's all I can think of.

joshuajestelle

Quote
Are you pulling up the enable pin (or setting it HIGH through either digitalWrite/analogWrite if the enable pin on the H-bridge is connected to your arduino)? Unless the enable pin is HIGH there is no current flowing to your output pins.


Yup :(  Enable pin is set to high, reading 4.8V

Quote
Also maybe having a common ground between your motor supply and the arduino supply.


Tried it :(

Thanks for the help guys... I'll keep poking at this and I'm sure I'll eventually figure it out.   :'(

hj43us

What happens if you disconnect the 298? Are then your output pins acting as expected? Did you set them as outputs on setup?

I do agree it should be quite straightforward circuit.

Grumpy_Mike

Sorry if this is too much of an insult but have you connected all the earths on the unit together. These are the points marked with that triangular type symbol and should all be connected to the 0v line. I say this because my students often didn't understand that was what the symbols meant.

Another consideration is that sometimes motor drivers require a load in order to function properly.  Can you try taking the measurements with a load such as a resistor (or a motor, but this might make the readings slightly noisier) across the driver outputs?  By the way, make sure you choose a resistor or motor that won't demand more current than the driver can safely deliver.

- Ben

blamski

hi

i've been digging around the forums looking for that puzzling connection between the L298 and arduino, and thought best to pull up an old post rather than start a new one.

i'm using another L298 based driver kit to (hopefully) drive a 12V 2A motor. i know i've made the kit up correctly but haven't yet been able to get the motor to respond.

so far i have:
12V going to the voltage in on the board
pin 2 on the arduino going to en on the board
pin 9 PWM on the arduino going to IP1 on the board
ground from the 12V supply tied to ground on the arduino

i'm doing my testing using maxuino and max/msp and have set pin 2 to high and have tried using both a digital high and PWM from pin 9 - so far without luck.

can anyone point out to me the mistake i'm making or the thing i'm missing out?

cheers

gbulmer

#11
Apr 19, 2010, 05:17 pm Last Edit: Apr 19, 2010, 05:21 pm by gbulmer Reason: 1
Just for giggles, try this:

Wiring:
Arduino           L298
digital pin A -> Input 3
digital pin B -> Input 4
PWM P -> Enable B

Sketch:
setup() {
  pinMode(A, OUTPUT);
  pinMode(B, OUTPUT);
}

loop() {  
  digitalWrite(A, HIGH);
  digitalWrite(B, LOW);
  analogWrite(P, 128);
  delay (500);
}

You can choose A, B, and C, but they must be different, and C must be a PWM pin.

This is the simplest way to debug these type of things that I've found.
As long as the two Input's are different, something should happen.

HTH
GB

WARNING - this code is unVerify'ed and untested

gbulmer

Looked at the datasheet for the L298D, and they recommend
RS1 = RS2 = 0.5 [ch937]
for the sense resistors.

They explicitly say
Quote
1.1. POWER OUTPUT STAGE
The L298 integrates two power output stages (A ; B).
The power output stage is a bridge configuration and its outputs can drive an inductive load in common or differenzial mode, depending on the state of the inputs. The current that flows through the load comes out from the bridge at the sense output : an external resistor (RSA ; RSB.) allows to detect the intensity of this current.


This may be a problem too. What value resistor (if any) is connecting 'Sense' to ground?

HTH
GB

blamski

hhhmmm... sense resistors. i'm not using any...

this is the driver board - http://bloat.me/tfCD. it has motor power in, power out for two motors, IP x 2 and EN for each motor and regulated 5V out. is it this 5V out which i need to connect back to the ground? doesn't seem to make much sense.

here's a schematic for the board too


gbulmer

From my reading of the datasheet, I don't believe it needs sense resistors. But if if they're there, they need to be low enough to conduct all the current through the load (motor) to ground without dropping too much voltage (or constraining current).

The http://www.pyroelectro.com/tutorials/l298_control/schematic.html link has a 10 ohm resistor in that ground path.
I was raising the sense resistor to folks attention because it likely makes matters worse, or more confusing.

HTH
GB

Go Up