alpeace89
Posts: 49
Joined: Wed Dec 04, 2013 12:34 am

Basic motor control

Thu Sep 11, 2014 1:02 pm

Hi,

I have been experimenting with RPi for a few months now, and have got to grips with basic Python, GPIO control etc. I want to get into motor control and eventually robotics. There seems to be a huge number of similar board allowing motor control so I was wondering if someone could give me advice on what is best? I am looking for something which will let me get started with basic things very quickly but also allow for later development of projects.

Any help appreciated,

Alex

User avatar
joan
Posts: 14935
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Basic motor control

Thu Sep 11, 2014 1:24 pm

Personally I'd go for the most inexpensive you can find initially. E.g. I have a couple of these http://www.ebay.co.uk/itm/200964675895. The advantage of that sort of model is it's very difficult to wire it incorrectly.

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Basic motor control

Thu Sep 11, 2014 3:28 pm

alpeace89 wrote:Hi,

I have been experimenting with RPi for a few months now, and have got to grips with basic Python, GPIO control etc. I want to get into motor control and eventually robotics. There seems to be a huge number of similar board allowing motor control so I was wondering if someone could give me advice on what is best? I am looking for something which will let me get started with basic things very quickly but also allow for later development of projects.

Any help appreciated,

Alex
depends on the size of the motor you want to control.
My first move was to buy a magician chassis and a L298N board.
Doug.
Building Management Systems Engineer.

Ravenous
Posts: 1956
Joined: Fri Feb 24, 2012 1:01 pm
Location: UK

Re: Basic motor control

Thu Sep 11, 2014 4:16 pm

I was going to suggest a simple one-chip controller like the L293D, but the ones Joan linked above are so cheap it'd be crazy not to try them. They should work with a small/medium size motor fine.

User avatar
mikronauts
Posts: 2783
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Basic motor control

Thu Sep 11, 2014 4:39 pm

I've been using a very inexpensive L9110S driver board with Elf (my 2WD Magician / RoboPi / Raspberry Pi bot)

http://www.mikronauts.com/robot-zoo/elf-2wd-pi-robot/
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

alpeace89
Posts: 49
Joined: Wed Dec 04, 2013 12:34 am

Re: Basic motor control

Fri Sep 12, 2014 10:54 am

joan wrote:Personally I'd go for the most inexpensive you can find initially. E.g. I have a couple of these http://www.ebay.co.uk/itm/200964675895. The advantage of that sort of model is it's very difficult to wire it incorrectly.
I'm particularly interested in this because its so cheap! Do you now where I could get circuit diagrams for this? Or other information about approaching it this way.

Cheers, Alex

Ravenous
Posts: 1956
Joined: Fri Feb 24, 2012 1:01 pm
Location: UK

Re: Basic motor control

Fri Sep 12, 2014 11:00 am

If you don't know anything about H-bridges at all, page 13 of the following might be interesting:
http://www.picaxe.com/docs/picaxe_manual3.pdf
(includes basic L293D circuit, showing basically how it's connected. For picaxe chips but the raspi should work with almost the same connections)

The ones linked to on ebay almost certainly work the same way, they just use different H-bridge chips.

User avatar
joan
Posts: 14935
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Basic motor control

Fri Sep 12, 2014 11:22 am

alpeace89 wrote:
joan wrote:Personally I'd go for the most inexpensive you can find initially. E.g. I have a couple of these http://www.ebay.co.uk/itm/200964675895. The advantage of that sort of model is it's very difficult to wire it incorrectly.
I'm particularly interested in this because its so cheap! Do you now where I could get circuit diagrams for this? Or other information about approaching it this way.

Cheers, Alex
As Ravenous says these motor drivers (at least the sort us hobbyists buy) all work in pretty much the same way.

You connect the two wires from one motor to the driver Motor-A terminals.

You connect two gpios of your choice, say gpios 23 and 24, to driver A-1A, A-1B.

Connect Pi ground to driver ground.
Connect Pi 5V pin to driver VCC.

(If your motor needs more than 5V or more current than the Pi can supply connect your power source -ve to driver ground, power source +ve to driver VCC. Also connect power source -ve to Pi ground).

Set gpio 23 low gpio 24 low, motor stops.
Set gpio 23 low gpio 24 high, motor goes in one direction.
Set gpio 23 high gpio 24 low, motor goes in the other direction.
Set gpio 23 high gpio 24 high, motor stops.

Similarly for a second motor.

User avatar
mikronauts
Posts: 2783
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Basic motor control

Fri Sep 12, 2014 12:16 pm

See http://www.mikronauts.com/robot-zoo/elf-2wd-pi-robot/3/

for how I hook them up.
alpeace89 wrote:
joan wrote:Personally I'd go for the most inexpensive you can find initially. E.g. I have a couple of these http://www.ebay.co.uk/itm/200964675895. The advantage of that sort of model is it's very difficult to wire it incorrectly.
I'm particularly interested in this because its so cheap! Do you now where I could get circuit diagrams for this? Or other information about approaching it this way.

Cheers, Alex
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

hampi
Posts: 223
Joined: Fri May 31, 2013 11:29 am
Contact: Website

Re: Basic motor control

Fri Sep 12, 2014 9:40 pm

joan wrote:You connect two gpios of your choice, say gpios 23 and 24, to driver A-1A, A-1B.

Connect Pi ground to driver ground.
Connect Pi 5V pin to driver VCC.
That might work, but is not exactly correct since RPi GPIO has 3.3 V logic levels and the output high state is usually just enough for valid high state at the 5 V TTL levels. So preferably H-bridge working from 3.3 V logic should be used if such a circuit exists on the market. Otherwise level shifting between RPi and H-bridge.

User avatar
joan
Posts: 14935
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Basic motor control

Fri Sep 12, 2014 10:00 pm

hampi wrote:
joan wrote:You connect two gpios of your choice, say gpios 23 and 24, to driver A-1A, A-1B.

Connect Pi ground to driver ground.
Connect Pi 5V pin to driver VCC.
That might work, but is not exactly correct since RPi GPIO has 3.3 V logic levels and the output high state is usually just enough for valid high state at the 5 V TTL levels. So preferably H-bridge working from 3.3 V logic should be used if such a circuit exists on the market. Otherwise level shifting between RPi and H-bridge.
According to the datasheet logic inputs between 0-0.7V are logic low, 2.5-VCC are logic high.

hampi
Posts: 223
Joined: Fri May 31, 2013 11:29 am
Contact: Website

Re: Basic motor control

Sat Sep 13, 2014 7:47 am

joan wrote:According to the datasheet logic inputs between 0-0.7V are logic low, 2.5-VCC are logic high.
If the RPi outputs are similar to PIC microcontrollers, then the output high voltage is guaranteed to be more than VDD-0.7V=2.6 V. Thus should work, but you have only 0.1 V margin there in worst (loaded) case.

User avatar
joan
Posts: 14935
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Basic motor control

Sat Sep 13, 2014 7:56 am

hampi wrote:
joan wrote:According to the datasheet logic inputs between 0-0.7V are logic low, 2.5-VCC are logic high.
If the RPi outputs are similar to PIC microcontrollers, then the output high voltage is guaranteed to be more than VDD-0.7V=2.6 V. Thus should work, but you have only 0.1 V margin there in worst (loaded) case.
I should perhaps stress that the figures I gave are for the L9110S.

I've never had problems using typical driver boards based on the L293D, L298N, L9119S, etc. although I have read posts from people who say they don't work. The trouble is when things don't work there can be a whole ramp of reasons (and anyone who has been on the forums a while will have seen just how bizarre these reasons can be).

Return to “Other projects”