Page 1 of 1

driving two 3.3v motors

Posted: Mon Sep 24, 2012 7:50 am
by step1041
Hi,

I am looking to build a simple RC car using the Raspberry Pi and and two 3.3v motors(one to drive, the other to steer). The concept I had in mind was to adapt This Arduino Project to the Pi. The way this works is through PWM outputs of the Arduino to drive an IC chip which would then tell the motors what to do while using external batteries for power. I read that there is only one PWM output on the Pi but there is software alternatives. I was wondering what is the best way to go about this project based on that information in both software and hardware to get me going in the right direction.

Thanks :)

Re: driving two 3.3v motors

Posted: Mon Sep 24, 2012 12:14 pm
by techpaul
About 10 years ago I bodged a floppy disk drive (3.5 inch) into an RC car, only one driection forward from drive motor, and steering from head actuator, and from RC controller.

See Floppybot :D

Re: driving two 3.3v motors

Posted: Mon Sep 24, 2012 12:51 pm
by simplesi
I've managed to simply PWM one motor using a normal GPIO port (Via a buffer of course) with a simple Python loop putting motor on - sleep for x 100ths of a sec and then motor off and sleep for (100- x) 100ths of a sec so unless you need really fine control then you could do one yourself and one using the PWM output (not tried using the PWM output but I hear it is there ready and willing to be used :) )

Simon

Re: driving two 3.3v motors

Posted: Mon Sep 24, 2012 2:44 pm
by Grumpy Mike
Software PWM solution here:-
https://projects.drogon.net/software-pw ... pberry-pi/

But you could outsource your PWM to an external hardware chip if you want. However that might be too advanced for you at the moment because you then have to interface to that chip.

Re: driving two 3.3v motors

Posted: Mon Sep 24, 2012 3:33 pm
by step1041
Alright thanks guys i'm really just looking to turn them on or off based on a command via software. i don't need anything incredibly specific for timing. Also would the circuit in the link be ok for the Raspberry Pi to handle?

Re: driving two 3.3v motors

Posted: Tue Sep 25, 2012 12:08 pm
by Grumpy Mike
step1041 wrote:Alright thanks guys i'm really just looking to turn them on or off based on a command via software.
In that case do you need PWM?

Re: driving two 3.3v motors

Posted: Tue Sep 25, 2012 1:34 pm
by step1041
Grumpy Mike wrote:
step1041 wrote:Alright thanks guys i'm really just looking to turn them on or off based on a command via software.
In that case do you need PWM?
I'm not that sure exactly what PWM entails, but I am taking a guess that I don't need it if all I am doing is sending HIGH and LOW values.

Re: driving two 3.3v motors

Posted: Tue Sep 25, 2012 3:37 pm
by gordon@drogon.net
step1041 wrote:
Grumpy Mike wrote:
step1041 wrote:Alright thanks guys i'm really just looking to turn them on or off based on a command via software.
In that case do you need PWM?
I'm not that sure exactly what PWM entails, but I am taking a guess that I don't need it if all I am doing is sending HIGH and LOW values.
To simply turn them on/off, then you don't need PWM.

PWM will turn them on and off very quickly - the net effect is that with the right amounts of on & off, you can then control the speed. If you want to control the speed, then PWM is a very popular way to do it.

-Gordon

Re: driving two 3.3v motors

Posted: Tue Sep 25, 2012 3:43 pm
by step1041
Yeah for now just on/off. i may end up doing a speed adjustment in the futre, but i will deal with that when the time comes. I currently have an H-bridge working on an Arduino with the two motors, so soon i will adapt it to the Raspberry Pi.

Re: driving two 3.3v motors

Posted: Tue Sep 25, 2012 4:49 pm
by step1041
I do have one more question regarding the project. After some research it can be easy to fry the entire Raspberry Pi with voltage spikes, and i believe motors are notorious for this sort of thing. So what would you guys recomend to protect the Raspberry Pi from the whole circut?

Re: driving two 3.3v motors

Posted: Tue Sep 25, 2012 5:11 pm
by gordon@drogon.net
step1041 wrote:I do have one more question regarding the project. After some research it can be easy to fry the entire Raspberry Pi with voltage spikes, and i believe motors are notorious for this sort of thing. So what would you guys recomend to protect the Raspberry Pi from the whole circut?
Any H-Bridge chip should provide enough protection. You can go overboard building in all sorts of protection, but really - opto isolators? Fine if controlling mains, but for low voltage stuff, just use an H bridge.

-Gordon

Re: driving two 3.3v motors

Posted: Tue Sep 25, 2012 5:19 pm
by step1041
gordon@drogon.net wrote:
step1041 wrote:I do have one more question regarding the project. After some research it can be easy to fry the entire Raspberry Pi with voltage spikes, and i believe motors are notorious for this sort of thing. So what would you guys recomend to protect the Raspberry Pi from the whole circut?
Any H-Bridge chip should provide enough protection. You can go overboard building in all sorts of protection, but really - opto isolators? Fine if controlling mains, but for low voltage stuff, just use an H bridge.

-Gordon
Great! Thanks a lot Gordon!

Re: driving two 3.3v motors

Posted: Tue Sep 25, 2012 7:58 pm
by robotworkshop
If you already have it working on an Arduino why not just leave it there and let the Arduino handle a lot of the other I/O as well. Can't you plug the USB connection from the Arduino into the RaspBerrry Pi USB port and then access the Arduino as a serial device? Just send higher level commands to the serial port and get the responses back (if you need them for certain operations).

I'm doing something similar with my Raspberry Pi where it is used as the higher level controller and then it is connected via USB to a pair of Parallax Propeller boards to handle all the I/O. I get the best of both worlds that way.

Robert

Re: driving two 3.3v motors

Posted: Wed Sep 26, 2012 4:13 pm
by step1041
What I was hoping to use the Pi over the Arduino is so I can easily connect a wireless USB adapter. Eventually it would be nice to have it controlled over a network/internet on a mobile device or another computer. Plus it makes a good learning experience, its just nice to have a start.