L293D troubleshooting for IR camera cut control


15 posts
by Nestboxtech » Sun Jan 18, 2015 5:24 pm
Hi,

I've got a mechanical IR cut filter that I'm planning on using to convert the IR PiCamera to a Normal light version depending on the levels of ambient light (+/- external IR LED array). This particular mechanical IR filter I think is based on a solenoid that moves the IR filter when a current is applied. If I connect it 5V and GND, it moves the IR filter one way. To move it back, I need to swop V and GND around. I had the idea of using an L293D ic in the same way as used to run a DC motor forwards or backwards as a way of achieving the same effect of manually swopping the polarity around of the 5v and GND connections.

I've built my bread board as follows, which is based on the following blog post:
http://computers.tutsplus.com/tutorials/controlling-dc-motors-using-python-with-a-raspberry-pi--cms-20051
My main modification is to remove the external batteries for the 'motor Vcc' input and substitue with the 5V supply of the Pi, on the basis that the IR cut filter is activated by connecting directly to the 5V pin and GND.

My layout is as follows:
Image

Code as follows:

Code: Select all
import RPi.GPIO as GPIO
from time import sleep
 
GPIO.setmode(GPIO.BOARD)
 
Motor1A = 16
Motor1B = 18
Motor1E = 22
 
GPIO.setup(Motor1A,GPIO.OUT)
GPIO.setup(Motor1B,GPIO.OUT)
GPIO.setup(Motor1E,GPIO.OUT)
 
print "Going forwards"
GPIO.output(Motor1A,GPIO.HIGH)
GPIO.output(Motor1B,GPIO.LOW)
GPIO.output(Motor1E,GPIO.HIGH)
 
sleep(2)
 
print "Going backwards"
GPIO.output(Motor1A,GPIO.LOW)
GPIO.output(Motor1B,GPIO.HIGH)
GPIO.output(Motor1E,GPIO.HIGH)
 
sleep(2)
 
print "Now stop"
GPIO.output(Motor1E,GPIO.LOW)
 
GPIO.cleanup()


The problem is that I just get 0V across pin 3 and 6 of the L293D.
I can detect voltage changing as per the code in the enabling GPIO lead and both the other two, but cannot get any output to work. Power form the Pi seems okay, and GPIO pins go high / low as they should.

Any ideas - or have a made silly mistake ?
http://nestboxtech.blogspot.co.uk/
Posts: 40
Joined: Fri Apr 11, 2014 9:45 pm
by joan » Sun Jan 18, 2015 6:12 pm
Post a photo of your actual set up.
User avatar
Posts: 12656
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by PiGraham » Sun Jan 18, 2015 6:27 pm
Does this device require voltage reversal to
You should have flywheel diodes across the motor terminals to protect high voltage spikes that result when you turn off the supply to an inductive load. {ETA} Use the L293D not L293, or add extrernal diodes.
See the data sheet: http://www.ti.com/lit/ds/symlink/l293d.pdf

That isn't why this doesn't work, unless high voltages have damaged the L293 already.

What voltage do you measure between GND and 3 and GND and 6? If the enable is high and the input is high the output should be high. To turn the motor you need one side high and the other low.

Actually, it might help if you could measure the voltage on each pin of the L193 for forward and reverse conditions.

I take it the device switches OK if you connect the wires direct to 5V and GND?
Last edited by PiGraham on Sun Jan 18, 2015 6:42 pm, edited 1 time in total.
Posts: 2478
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville
by joan » Sun Jan 18, 2015 6:31 pm
PiGraham wrote:Does this device require voltage reversal to
You should have flywheel diodes across the motor terminals to protect high voltage spikes that result when you turn off the supply to an inductive load. See the data sheet: http://www.ti.com/lit/ds/symlink/l293d.pdf

That isn't why this doesn't work, unless high voltages have damaged the L293 already.

What voltage do you measure between GND and 3 and GND and 6? If the enable is high and the input is high the output should be high. To turn the motor you need one side high and the other low.

Actually, it might help if you could measure the voltage on each pin of the L193 for forward and reverse conditions.

I take it the device switches OK if you connect the wires direct to 5V and GND?

Hopefully the OP is using the L293D as I think that has the fly-back diodes built-in.
User avatar
Posts: 12656
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by PiGraham » Sun Jan 18, 2015 6:41 pm
joan wrote:Hopefully the OP is using the L293D as I think that has the fly-back diodes built-in.


Ah, so it does.
Posts: 2478
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville
by gordon77 » Sun Jan 18, 2015 6:51 pm
joan wrote:
PiGraham wrote:Does this device require voltage reversal to
You should have flywheel diodes across the motor terminals to protect high voltage spikes that result when you turn off the supply to an inductive load. See the data sheet: http://www.ti.com/lit/ds/symlink/l293d.pdf

That isn't why this doesn't work, unless high voltages have damaged the L293 already.

What voltage do you measure between GND and 3 and GND and 6? If the enable is high and the input is high the output should be high. To turn the motor you need one side high and the other low.

Actually, it might help if you could measure the voltage on each pin of the L193 for forward and reverse conditions.

I take it the device switches OK if you connect the wires direct to 5V and GND?

Hopefully the OP is using the L293D as I think that has the fly-back diodes built-in.


The Op said they were.
Posts: 2847
Joined: Sun Aug 05, 2012 3:12 pm
by Nestboxtech » Sun Jan 18, 2015 7:07 pm
joan wrote:Post a photo of your actual set up.


Image
http://nestboxtech.blogspot.co.uk/
Posts: 40
Joined: Fri Apr 11, 2014 9:45 pm
by Nestboxtech » Sun Jan 18, 2015 7:11 pm
joan wrote:
PiGraham wrote:Does this device require voltage reversal to
You should have flywheel diodes across the motor terminals to protect high voltage spikes that result when you turn off the supply to an inductive load. See the data sheet: http://www.ti.com/lit/ds/symlink/l293d.pdf

That isn't why this doesn't work, unless high voltages have damaged the L293 already.

What voltage do you measure between GND and 3 and GND and 6? If the enable is high and the input is high the output should be high. To turn the motor you need one side high and the other low.

Actually, it might help if you could measure the voltage on each pin of the L193 for forward and reverse conditions.

I take it the device switches OK if you connect the wires direct to 5V and GND?

Hopefully the OP is using the L293D as I think that has the fly-back diodes built-in.


Yup, using L293D. Also, it does work if connected directly to 5V and GND.
http://nestboxtech.blogspot.co.uk/
Posts: 40
Joined: Fri Apr 11, 2014 9:45 pm
by gordon77 » Sun Jan 18, 2015 7:34 pm
I cant see a wire on pin 16 of the l293
Posts: 2847
Joined: Sun Aug 05, 2012 3:12 pm
by Nestboxtech » Sun Jan 18, 2015 8:13 pm
gordon77 wrote:I cant see a wire on pin 16 of the l293


Oh for an easy fix ;)
Unfortunate camera angle, new pic below:

Image
http://nestboxtech.blogspot.co.uk/
Posts: 40
Joined: Fri Apr 11, 2014 9:45 pm
by joan » Sun Jan 18, 2015 8:33 pm
Are you sure the L293D is actually making contact with the breadboard? The top pins seem to be inserted one row higher than needed.
User avatar
Posts: 12656
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by gordon77 » Sun Jan 18, 2015 9:40 pm
Can you measure 5v on pin 16?
Posts: 2847
Joined: Sun Aug 05, 2012 3:12 pm
by Nestboxtech » Sun Jan 18, 2015 10:19 pm
joan wrote:Are you sure the L293D is actually making contact with the breadboard? The top pins seem to be inserted one row higher than needed.

arrrgh... this was the problem. I'm such an idiot! Thanks for the help :)

Next step is to integrate this with PiNoir Camera
I can now work on switching the IR cutout based on ambient light and LED array activation.

Many thanks folks
http://nestboxtech.blogspot.co.uk/
Posts: 40
Joined: Fri Apr 11, 2014 9:45 pm
by joan » Sun Jan 18, 2015 10:22 pm
Nestboxtech wrote:...
arrrgh... this was the problem. I'm such an idiot! Thanks for the help :)
...

We have the advantage of making the same mistake before you.
User avatar
Posts: 12656
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by Nestboxtech » Sun Jan 18, 2015 10:31 pm
....so if you could just list them all please ;)
http://nestboxtech.blogspot.co.uk/
Posts: 40
Joined: Fri Apr 11, 2014 9:45 pm