Page 1 of 1

Basic motor control

Posted: Thu Sep 11, 2014 1:02 pm
by alpeace89
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

Re: Basic motor control

Posted: Thu Sep 11, 2014 1:24 pm
by joan
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.

Re: Basic motor control

Posted: Thu Sep 11, 2014 3:28 pm
by BMS Doug
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.

Re: Basic motor control

Posted: Thu Sep 11, 2014 4:16 pm
by Ravenous
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.

Re: Basic motor control

Posted: Thu Sep 11, 2014 4:39 pm
by mikronauts
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/

Re: Basic motor control

Posted: Fri Sep 12, 2014 10:54 am
by alpeace89
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

Re: Basic motor control

Posted: Fri Sep 12, 2014 11:00 am
by Ravenous
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.

Re: Basic motor control

Posted: Fri Sep 12, 2014 11:22 am
by joan
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.

Re: Basic motor control

Posted: Fri Sep 12, 2014 12:16 pm
by mikronauts
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

Re: Basic motor control

Posted: Fri Sep 12, 2014 9:40 pm
by hampi
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.

Re: Basic motor control

Posted: Fri Sep 12, 2014 10:00 pm
by joan
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.

Re: Basic motor control

Posted: Sat Sep 13, 2014 7:47 am
by hampi
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.

Re: Basic motor control

Posted: Sat Sep 13, 2014 7:56 am
by joan
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).