Electronics > Electronics

L298N motor driver

<< < (2/3) > >>

jkerns:
Right Pin 4 is the source of current / voltage to run the motor. In your case that would be the 6V supply.

Pin 9 is the logic supply - that would typically be the 5V or 3.2V regulated logic power from your Arduino.

Note - from the data sheet
Symbol     Parameter                 Test Conditions            Min.        Typ. Max. Unit
VS            Supply Voltage (pin 4) Operative Condition    VIH +2.5        46       V

The supply voltage needs to be 2.5V higher than your logic high values (pins 5, 7, 10, 12) If you are using 6V to supply the motors, then you would want these voltages to be down at the 3.5V range (minimum voltage on these pins is 2.3V) . If your Arduino is kicking out 5V on the digitial outputs you could put a voltage divider in the connection between the Arduino and the L298N. Also, it doesn't hurt to put 10K or so between the L298 and the Arduino so when you let the smoke out of the L298 you don't take the Arduino with it. So, to do the voltage divider from 5 volts it would be:

Arduino pin ----------- 10K --------+------------L298
|
|
22K
|
Ground

Check my math. And check to make sure you don't overload the Arduino I/O pin.

You can't use an electrolytic capacitor on the DC motor pins if you are going to run it in both directions because each wire will sometimes be + and sometimes - and the electrolitic cap is polarized - it only works one way. Ceramic caps would be better. Off the top of my head I woud guess about .1uF but you probably want to do some more research on that.

jwatte:

--- Quote ---powering it with 9 V battery
--- End quote ---

The 9V battery can only give about 100 mA of current before it starts to sag noticeably.

You may find that the 9V battery can't drive your motors effectively. If that happens, you could use a four-AA battery pack instead for the motor, and forego the regulator entirely.

You could also just wire 9V directly to the motor, and instead of burning it off with a regulator, just set the PWM duty cycle to something lower. If you set the PWM to 128-out-of-255, and have 9V motor power, the motors will see an effective 4.5 volts.

The EMI capacitor used on the motor terminals is typically in the range of 10 nF to 100 nF, and should be a high-voltage ceramic capacitor. For your case, a 25V ceramic with 10 nF capacitance would probably be about right.

jkerns:

--- Quote from: jwatte on April 23, 2013, 11:55:31 AM ---
--- Quote ---powering it with 9 V battery
--- End quote ---

You could also just wire 9V directly to the motor, and instead of burning it off with a regulator, just set the PWM duty cycle to something lower. If you set the PWM to 128-out-of-255, and have 9V motor power, the motors will see an effective 4.5 volts.
--- End quote ---

That solves the problem of keeping the supply voltage higher than the logic voltage as well. Forget my suggestion.

jim:
i have made the necessary changes.. attached is the final working circuit of L298N

i would like to know the purpose of the two 100nF capacitors and the 1n4007 diodes.. i know that the diodes are to protect the motors but how?

why is 1n4007 diode better than 1n4001?

thank you

jkerns:
The capicitors filter out noise caused by the digital circuit switching to reduce the impact of the switching on the devices in the circuit

DC motors are, essentially, big coils of wire - inductors. When current is flowing through the coils, it builds up a magnetic field. When you shut off the current, the magnetic field collapses. However, that colapsing magnetic field is like having a wire move through a magnetic field - it generates a current.  But, if you have opened up the circuit to turn off the power to the motor, where is that current going to go? With nowhere to go, it can result in high voltages that can damage componants. The diodes give that current a place to go (back to your power source) without causing damage.