User avatar
exartemarte
Posts: 376
Joined: Sat Mar 03, 2012 3:51 pm
Location: Middle England
Contact: Website

Re: Driving 2 DC motors using L293D

Sat Dec 21, 2013 8:20 pm

mikronauts wrote:WiringPi also has a soft PWM that can control multiple pins; I used it last week with a L293D - it would also work with the L298
Good point - we're spoiled for choice. I'm using wiringPi for the Pi end of my Pi/Arduino/SPI setup.

alex-okrushko
Posts: 1
Joined: Mon Dec 30, 2013 10:57 pm

Re: Driving 2 DC motors using L293D

Mon Dec 30, 2013 11:04 pm

RPi.GPIO has PWM on any pin for a while now (https://code.google.com/p/raspberry-gpi ... n/wiki/PWM)

User avatar
mobilebaz
Posts: 16
Joined: Sat Sep 28, 2013 8:46 am
Location: IR

Re: Driving 2 DC motors using L293D

Mon Jan 20, 2014 8:06 am

Hi
I've used L293D and TWO motor.
The motors speed is too "slow".
But when I connect the battery directly to the motors speed is "high".
I'm using 4 batteries 1.5 volt.
Please help me.

User avatar
joan
Posts: 15037
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Driving 2 DC motors using L293D

Mon Jan 20, 2014 8:33 am

Get higher voltage batteries. Take care not to feed more than 3.3V to the Pi.

johndough
Posts: 254
Joined: Sun Jan 13, 2013 2:00 pm

Re: Driving 2 DC motors using L293D

Mon Jan 20, 2014 12:39 pm

nvhs wrote:hello you shoul use my motor controller ù_ù

http://nvhs.wordpress.com/project/catsp ... ontroller/

you can make it whit a relay board ù_ù
Hi

Looking at your circuit, I can suggest an alternate way to connect the motor,
which will then give "motor braking".
IE: The motor stops, and locks it's rotor which is beneficial for positioning.


On your relay board you have marked terminal connections A, B & C.

The motor connects directly to terminal C on the first and second relays.
The -ve ZERO volts directly to terminal A on the first and second relays.
Then +ve Xv Supply directly to terminal B on the first and second relays.
If you make the 1st relay the equivalent of Forward, and the 2nd Reverse,
then if the motor runs the wrong way simply reverse those C connections.

The rotor is shorted out and wont rotate freely, whichever relay is then energised will apply a +ve voltage and the rotor will rotate CW or CCW.
NB: Energising both relays TOGETHER will cause the motor to STOP.

User avatar
TonyD
Posts: 451
Joined: Thu Sep 08, 2011 10:58 am
Location: Newcastle, UK
Contact: Website

Re: Driving 2 DC motors using L293D

Mon Jan 20, 2014 1:44 pm

I used this L293D Motor Controller board on my robot car. I used a Wii Bluetooth controller for the joystick.

Image
Tony

User avatar
mobilebaz
Posts: 16
Joined: Sat Sep 28, 2013 8:46 am
Location: IR

Re: Driving 2 DC motors using L293D

Tue Jan 21, 2014 1:09 pm

joan wrote:Get higher voltage batteries. Take care not to feed more than 3.3V to the Pi.
Thank you my friend.

I've used this circuit with 2 motor: (source link)
Image
The motors speed in each directions (clockwise and counter clockwise) slowly.
Motor Power Supply 6V (4 x 1.5) because I'm using the zumo chassis and there is no possibility of adding a battery.

Then I used the circuit following [SN754410 instead I used the L293D]. (source link)
Image
Both motors are moving quickly, but left the motor moves in one direction only. (Only clockwise) the second motor moves in both directions.

What is the solution?

Ravenous
Posts: 1956
Joined: Fri Feb 24, 2012 1:01 pm
Location: UK

Re: Driving 2 DC motors using L293D

Tue Jan 21, 2014 1:42 pm

mobilebaz wrote: Both motors are moving quickly, but left the motor moves in one direction only. (Only clockwise) the second motor moves in both directions.
I can only suggest a dodgy connection somewhere. Can you use a probe, or a voltmeter, directly on the input pins of the chip to check your high/low signals are getting to each of the input pins?

(Note if doing this, be careful with the probe tip not to slip and get it between two pins on the IC. It is possible to short something out if that happens.)

User avatar
mobilebaz
Posts: 16
Joined: Sat Sep 28, 2013 8:46 am
Location: IR

Re: Driving 2 DC motors using L293D

Tue Jan 21, 2014 2:13 pm

Ravenous wrote:
mobilebaz wrote: Both motors are moving quickly, but left the motor moves in one direction only. (Only clockwise) the second motor moves in both directions.
I can only suggest a dodgy connection somewhere. Can you use a probe, or a voltmeter, directly on the input pins of the chip to check your high/low signals are getting to each of the input pins?

(Note if doing this, be careful with the probe tip not to slip and get it between two pins on the IC. It is possible to short something out if that happens.)
Grateful
I will test with a voltmeter.

alexellis
Posts: 53
Joined: Tue Nov 26, 2013 10:00 am
Location: United Kingdom
Contact: Website

Re: Driving 2 DC motors using L293D

Tue Jan 21, 2014 11:06 pm

mikronauts wrote:WiringPi also has a soft PWM that can control multiple pins; I used it last week with a L293D - it would also work with the L298
exartemarte wrote:
LaWFuLEviL wrote: How do you use the L298N H-Bridge to control two motors from one PWM pin on RPi ????
I probably wouldn't - see below. The little buggy in the picture is using an Arduino Nano, with multiple pwm's, and an L293D. What I had in mind when I answered the question above was just to combine the enable inputs for the two motors and connect them both to the one available PWM o/p on the Pi. I haven't actually done this, but I can't see why it shouldn't work. In principle both motors will run at the same speed: in reality they're unlikely to be perfectly matched so there will a slight difference.

Nowadays, if I needed to control two motors from the Pi without additional hardware (apart from the motor driver) I'd try Joan's pigpio. I used it to control multiple servos and it was fine.

I am currently playing with a PI/Arduino combo (using spi, but that could change), which I hope will serve for most of my robotics projects.
@LaWFuLEviL

I use the RPIO.PWM library to control motors and servos from any GPIO pin on the PI. I've used it in a car with servo/ESC combination - just connect output pin to the signal pin of the device. I used it to control a pan/tilt setup with 2x9g servos and a rover type car which has two motors connected to an L298n.

I have a class/module that you could try? Should be self-explanatory.

Code: Select all

from RPIO import PWM	#motor control

class navigation:
	backLeft = 18
	backRight= 23

	forwardLeft = 25
	forwardRight = 24

	def init(self):
		PWM.setup()
		PWM.init_channel(0)

	def forwards(self, moveSpeed):
		PWM.add_channel_pulse(0, self.forwardLeft, 0, moveSpeed)
		PWM.add_channel_pulse(0, self.forwardRight, 0, moveSpeed)
	def clearForwards(self):
		PWM.clear_channel_gpio(0, self.forwardLeft)
		PWM.clear_channel_gpio(0, self.forwardRight)
		
	def backwards(self, moveSpeed):
		PWM.add_channel_pulse(0, self.backLeft, 0, moveSpeed)
		PWM.add_channel_pulse(0, self.backRight, 0, moveSpeed)

	def clearBackwards(self):
		PWM.clear_channel_gpio(0, self.backLeft)
		PWM.clear_channel_gpio(0, self.backRight)

	def turnLeft(self, moveSpeed):
		PWM.add_channel_pulse(0, self.backRight, 0, moveSpeed)
		PWM.add_channel_pulse(0, self.forwardLeft, 0, moveSpeed)
	def clearLeftTurn(self):
		PWM.clear_channel_gpio(0, self.backRight)
		PWM.clear_channel_gpio(0, self.forwardLeft)

	def turnRight(self, moveSpeed):
		PWM.add_channel_pulse(0, self.backLeft, 0, moveSpeed)
		PWM.add_channel_pulse(0, self.forwardRight, 0, moveSpeed)
	def clearRightTurn(self):
		PWM.clear_channel_gpio(0, self.backLeft)
		PWM.clear_channel_gpio(0, self.forwardRight)

ankita061
Posts: 3
Joined: Mon Feb 08, 2016 7:21 am

Driving 2 DC motors using L293D

Mon Feb 08, 2016 7:41 am

hi, i am using motor driver ic board to control movement of robot but i found problem,when i am using l293d(st) its working well,but when i am using l293dne(texas instument) its not working. can you tell me why.

Return to “Interfacing (DSI, CSI, I2C, etc.)”