Saashin7
Posts: 2
Joined: Mon Sep 18, 2017 5:21 am

I Need Help Running a Motor on a Timer

Mon Sep 18, 2017 6:02 am

Hi, I need help running a motor on a timer. I want the motor to run for ~5 seconds every ~12 hours. I used a tutorial by TutsPlus but it ]didn't really work as planned. I am using a Raspberry Pi 3, L293D motor driver chip, breadboard, wires, 6V battery pack, and a 6V motor. I first tried it and it worked fine, but then when I tried to run the motor for around 5 seconds then stop, then again. It would work the first few times and then stop working. I would have to turn on and off the battery pack a few times then it would work a while, etc. I decided then to solder the wires to the motor. When I tried to run the program, the motor didn't even spin at all. I have no idea what to do so PLEASE HELP ME!

**In the images I have forgotten to connect the battery pack. But even with the battery pack, it doesn't work.**

Article I Used: https://business.tutsplus.com/tutorials ... -cms-20051
Image
Image
Image

:)

gordon77
Posts: 5077
Joined: Sun Aug 05, 2012 3:12 pm

Re: I Need Help Running a Motor on a Timer

Mon Sep 18, 2017 8:19 am

Does the motor work with less than 6v?. The output to it could be as low as 4.2v.

User avatar
OutoftheBOTS
Posts: 711
Joined: Tue Aug 01, 2017 10:06 am

Re: I Need Help Running a Motor on a Timer

Mon Sep 18, 2017 10:13 am

Ok first of all you should read up on how a H-bridge works this will heklp you understand what you need to do. see http://www.mcmanis.com/chuck/robotics/t ... /h-bridge/

So to run your motor you need to set the enable pin to high to turn on the H-bridge then you need to set 1 of the int pins to high and the other int pin to low to spin the motor in 1 direction then set switch witch int pin is high and which is low to spin in other direction.

I did have a read of the datasheet for the h bridge that byour using and it seems that it is designed for 5v logic and requires at least 4.5v for the logic pins, the RPi is a 3.3v system so it will need a level shifter to shift it from 3.3v to 5v.

It is very unusual to just use a h bridge chip like this, usually you will use a complete modual that has all the other needed circuits like this 1 as it will work with logic pins with volatge from 2.4v to 7v see http://www.ebay.com/itm/L9110-H-bridge- ... SwzJ5XdeHY

pcmanbob
Posts: 9612
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: I Need Help Running a Motor on a Timer

Mon Sep 18, 2017 12:49 pm

OutoftheBOTS wrote:
Mon Sep 18, 2017 10:13 am

I did have a read of the datasheet for the h bridge that byour using and it seems that it is designed for 5v logic and requires at least 4.5v for the logic pins, the RPi is a 3.3v system so it will need a level shifter to shift it from 3.3v to 5v.

Actually the L239D will work just fine from the pi using 3.3v gpio .

if you read the data sheet again you will see the the logic supply is 5v as stated but it also says that the high for a logic input is 2.3v minimum and 7v maximum so a 3.3v high from the gpio is sufficient to be registered as a logic high by the L239D.
The 4.5v minimum is actually the minimum voltage for the motor supply.

I have actually driven one of these chips from the pi gpio and they work fine.

You are correct the program as shown wont turn the motor with all outputs high as you said the program needs to set either motor1A or motor 1B low to drive the motor depending which direction the motor is required to run.
Last edited by pcmanbob on Tue Sep 19, 2017 7:52 am, edited 1 time in total.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
OutoftheBOTS
Posts: 711
Joined: Tue Aug 01, 2017 10:06 am

Re: I Need Help Running a Motor on a Timer

Mon Sep 18, 2017 9:44 pm

if you read the data sheet again you will see the the logic supply is 5v as stated but it also says that the high for a logic input is 2.3v minimum and 7v maximum so a 3.3v high from the gpio is sufficient to be registered as a logic high by the L239D.
Thanks for the correction. I did look again and I was looking at supply voltage for the chip Vcc (4.5v - 7v) not the logic high voltage Vih

So you can stwict the motors on and off with the 3.3v but you must supply the chip with 5v for power :)

Saashin7
Posts: 2
Joined: Mon Sep 18, 2017 5:21 am

Re: I Need Help Running a Motor on a Timer

Tue Sep 19, 2017 1:56 pm

Thank you all for you help. I am going to be using an Instructables tutorial to see if it will work. I will be trying it sometime this week.

http://www.instructables.com/id/DC-Moto ... and-L293D/

Return to “General discussion”