step1041
Posts: 15
Joined: Sun Jul 29, 2012 3:33 am

driving two 3.3v motors

Mon Sep 24, 2012 7:50 am

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 :)

techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: driving two 3.3v motors

Mon Sep 24, 2012 12:14 pm

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
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: driving two 3.3v motors

Mon Sep 24, 2012 12:51 pm

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
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

User avatar
Grumpy Mike
Posts: 939
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: driving two 3.3v motors

Mon Sep 24, 2012 2:44 pm

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.

step1041
Posts: 15
Joined: Sun Jul 29, 2012 3:33 am

Re: driving two 3.3v motors

Mon Sep 24, 2012 3:33 pm

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?

User avatar
Grumpy Mike
Posts: 939
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: driving two 3.3v motors

Tue Sep 25, 2012 12:08 pm

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?

step1041
Posts: 15
Joined: Sun Jul 29, 2012 3:33 am

Re: driving two 3.3v motors

Tue Sep 25, 2012 1:34 pm

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.

User avatar
gordon@drogon.net
Posts: 2023
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website Twitter

Re: driving two 3.3v motors

Tue Sep 25, 2012 3:37 pm

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
--
Gordons projects: https://projects.drogon.net/

step1041
Posts: 15
Joined: Sun Jul 29, 2012 3:33 am

Re: driving two 3.3v motors

Tue Sep 25, 2012 3:43 pm

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.

step1041
Posts: 15
Joined: Sun Jul 29, 2012 3:33 am

Re: driving two 3.3v motors

Tue Sep 25, 2012 4:49 pm

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?

User avatar
gordon@drogon.net
Posts: 2023
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website Twitter

Re: driving two 3.3v motors

Tue Sep 25, 2012 5:11 pm

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
--
Gordons projects: https://projects.drogon.net/

step1041
Posts: 15
Joined: Sun Jul 29, 2012 3:33 am

Re: driving two 3.3v motors

Tue Sep 25, 2012 5:19 pm

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!

robotworkshop
Posts: 24
Joined: Thu Aug 30, 2012 7:19 pm

Re: driving two 3.3v motors

Tue Sep 25, 2012 7:58 pm

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

step1041
Posts: 15
Joined: Sun Jul 29, 2012 3:33 am

Re: driving two 3.3v motors

Wed Sep 26, 2012 4:13 pm

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.

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