PE Kit Interface with L293D H-Bridge to control small DC motor
dylanz
Posts: 2
Hi,
I'm relatively new to microcontrollers and interfacing them with other electronic components. I purchased the PE Kit and went through the "Labs: Fundamentals" manual with no problem understanding the concepts.
In order essentially to learn more and build a better foundation of knowledge, I tried to create my own H-Bridge using 2 NPN and 2 PNP transistors, resistors and diodes and did not get the results I wanted.
I decided to start a little easier and acquired an L293D IC and wired it up exactly as depicted in the attached diagram (DCControlL293D.jpg). The only difference is that I used 1N914 diodes as opposed to SES5001 diodes.
For EN, I used the 5V from the 5V Regulator in the PE Kit.
For 1A, I used I/O port 14 on the Propeller.
For 2A, I used I/O port 15 on the Propeller.
For VCC1, I used the 5V from the 5V Regulator in the PE Kit.
For VCC2, I used an external 8V Power Supply.
I combined Ground from the 8V Power Supply and Ground from the Propeller (I am assuming in the PE Kit that the 5V and 3.3V Grounds are the same).
Here is the SPIN code test I created to spin the motor first to the right for 10 seconds, then stop, then spin left for 10 seconds, then stop, then repeat...
******************************************************
The problem I run into is that after about a minute of running, where it spins to the right at full speed for 10 seconds, stops, spins left for 10 seconds, stops, etc...it abruptly stops spinning at all. I then tested it without the diodes with the same result.
Does anyone know why I would run into this problem? I would expect that the motor would continue cycling through the right, stop, left, stop, repeat until power ran out.
I do not believe any resistors or capacitors are required for this setup..and am wondering if there is something inherently wrong with the wiring diagram (which I got from the datasheet for the L293D).
Any help would be greatly appreciated!
Many thanks,
Dylan Thompson
I'm relatively new to microcontrollers and interfacing them with other electronic components. I purchased the PE Kit and went through the "Labs: Fundamentals" manual with no problem understanding the concepts.
In order essentially to learn more and build a better foundation of knowledge, I tried to create my own H-Bridge using 2 NPN and 2 PNP transistors, resistors and diodes and did not get the results I wanted.
I decided to start a little easier and acquired an L293D IC and wired it up exactly as depicted in the attached diagram (DCControlL293D.jpg). The only difference is that I used 1N914 diodes as opposed to SES5001 diodes.
For EN, I used the 5V from the 5V Regulator in the PE Kit.
For 1A, I used I/O port 14 on the Propeller.
For 2A, I used I/O port 15 on the Propeller.
For VCC1, I used the 5V from the 5V Regulator in the PE Kit.
For VCC2, I used an external 8V Power Supply.
I combined Ground from the 8V Power Supply and Ground from the Propeller (I am assuming in the PE Kit that the 5V and 3.3V Grounds are the same).
Here is the SPIN code test I created to spin the motor first to the right for 10 seconds, then stop, then spin left for 10 seconds, then stop, then repeat...
******************************************************
PUB L293DTest dira[15..12]~~ repeat outa[14]~ 'Forward outa[15]~~ outa[13]~~ 'Light forward LED waitcnt(clkfreq*10 + cnt) outa[13]~ 'Turn off forward LED outa[14]~ 'Stop outa[15]~ waitcnt(clkfreq*7 + cnt) outa[14]~~ 'Reverse outa[15]~ outa[12]~~ 'Light reverse LED waitcnt(clkfreq*10 + cnt) outa[12]~ 'Turn off reverse LED outa[14]~ 'Stop outa[15]~ waitcnt(clkfreq*5 + cnt)******************************************************
The problem I run into is that after about a minute of running, where it spins to the right at full speed for 10 seconds, stops, spins left for 10 seconds, stops, etc...it abruptly stops spinning at all. I then tested it without the diodes with the same result.
Does anyone know why I would run into this problem? I would expect that the motor would continue cycling through the right, stop, left, stop, repeat until power ran out.
I do not believe any resistors or capacitors are required for this setup..and am wondering if there is something inherently wrong with the wiring diagram (which I got from the datasheet for the L293D).
Any help would be greatly appreciated!
Many thanks,
Dylan Thompson
Comments
HINT: Use the "Code" feature within the Advanced message when posting program code - it preserves the indenting for spin code
Also, you should not need the diodes for a L293D - from spec sheet:
Have you measured how much current the motor draws?
I doubt the code is the problem. I think there is a problem of too much current for either the L293D or you power supply.
It might be a good idea to have your program also light a LED or two (maybe one for each direction). The LEDs would let you know the Propeller is still running the code.
Can you give us some details on the motor you're using?
Duane
Thanks for your responses and suggestions.
@Ron,
I appreciate the tip on posting code. Though I couldn't get to the "Advanced" features, I figured the tags would do the trick.
As far as using the diodes...it was a bit confusing from the L293D datasheet, as it actually indicated they should be present (maybe on a larger motor?)
Anyway, I did remove the diodes yesterday after I ran into the problem with the motor stopping, but apparently there was some left-over charge buildup somewhere preventing the motor from spinning. Not sure what that could be. But this morning after reading your responses, I tried it again (without diodes) and let it run for over five minutes with no issues. Guess the problem was the diodes.
I'd be interested to know why that could have caused a problem...
@Duane,
No, the chip never gets hot, and the motor draws ~83-85 mA current. It's a very small motor. Not sure the exact specs as I pulled it out of an old kit with no documentation.
Thanks for the tip on using LEDs for testing...I should have done that in the first place.
Like I mentioned to Ron, I ran the test again today without the diodes and have no issues at all.
Any idea why that could have caused the problem?
Best,
Dylan
I have some L293Ds coming tomorrow and plan on driving some 12v stepper motors (if my source ever gets them back in stock).
Glad to hear it is working...
- Ron