Making A Home-Made Raspberry Pi Robot

My Attempt At Making A Home-made Raspberry Pi Robot

Don't be fooled by this cool angle, she runs like a dog!

You will have seen recently that I’ve been playing with a few Raspberry Pi robot kits, the kind that are usually pre-built and just require a bit of code to get you started, most coming with helpful guides and/or downloadable Python files.

But what about going solo and making your own robot almost from scratch?

I tried to accomplish this very task – building a home-made Raspberry Pi robot as a bit of fun, but also as another method of learning how to use motors with the Pi and Python.

The idea to do this came after attending Pi Wars in Cambridge, which made me consider entering my own robot in the next competition – causing me to rush home to buy tracks, motors, chassis plates and all sorts of other parts I couldn’t really afford to waste my money on!

Now I usually write posts about projects I’ve successfully completed, but this time I come to you with a partially completed project with a few ‘snags’, abandoned on the shelf and generally gaining dust at an alarming rate (a recurring theme for my Pi projects in 2015).

However, I thought it could be interesting to share my progress to date and help others see what’s involved. It might end up being the most useless Raspberry Pi blog post ever written, but it may just help someone, somewhere…

Pi Wars Inspiration

As I mentioned above, the inspiration to create my own mini motorised machine was generated through attending the 2014 CamJam Pi Wars event. I saw all sorts of creations made by a wide range of age groups, and was even a judge on the panel.

It was a great day and really went back to the roots of why the Pi even exists – to inspire and help children learn to code.

Raspberry Pi Pi-Wars

Pi Wars – can you name some of the folks here?

Parts & Choices

So – I wanted to build a robot! First I had to get some parts.

I decided I would make a tracked robot as the kits I had used so far all had wheels. I got a 30T Pololu track set and matching 50:1 micro-metal gear motors from Pimoroni, alongside some thin wood plates I would use as a chassis from CraftShapes.co.uk (more on that later).

I also got a few little metal brackets from eBay to hold the idler sprockets in place (see in the picture below)

Pololu tracks

My Pololu tracks and micro metal gear motors

Motor Controller

Motor control was actually the hardest part to decide on. There are LOADS of different options out there, from building your own motor controller on a breadboard, up to advanced add-on board style controllers with all sorts of features, ports and protection.

As always I was tweeting whilst all this was going on, and luckily Ryan from Ryanteck noticed and offered to send me one of the new black editions of his simple motor controller boards – ah the perks of being a blogger!

Ryan convinced me that controlling the motors would be as easy as GPIO on/off, in the same way I would for an LED, so I accepted his kind offer.

Chassis

In trying to make this project a little more interesting, I decided to avoid the pre-drilled template style acrylic robot chassis you see everywhere. Instead I used some thin wood that I had bought from a company called CraftShapes that I had intended to use for a new version of my internet radio project.

I assumed this would work well as the wood is thin and easy to manipulate, so I figured I could screw parts on and stack plates if I needed to. More on this later…

Wood shapes

I had a lot of this pre-cut wood to use after a long (long!) delay with my internet radio project!

Fitting / Method

Well…I didn’t really have a method.

I looked at the parts, worked out where they would go and started drilling! I’m not a complete buffoon though – I did measure the distance between tracks and other parts first (3 times – standard).

This is where I realised my ambition to make a mini robot on a tiny chassis wasn’t quite going to work out with these wooden plates. I’m going to eventually have to add a second raised plate to hold other parts such as the power sources.

The important thing here though, was to make sure the tracks were straight (or it wouldn’t run in a straight line) and the distance between the motor and the runner was right (to ensure the rubber tracks weren’t too tight or slack).

Home-made Raspberry Pi Robot chassis

The tracks and motors fitted – everything looked good at this point…

Power

I decided to avoid attempting to power both the Pi and motors from the same source (I heard it can be inefficient on power), so I got a 6xAA battery pack for powering the motors, and I already had a small RAVPower USB power bank to use for the Pi’s power.

The USB power bank plugs into the Pi, giving the Pi the power it needs (Let’s call it 5V 1 amp), and the battery pack powers the Ryanteck motor board, giving the motors the 9V that they desire. I could have just used the 9V pack to power both the motors AND the Pi – but that would have required something in between to reduce the 9V down to the 5V that the Pi needs.

So I opted for the negative of having a heavy separate power pack for the Pi, with the benefit of not having to mess around with electronics!

DID YOU KNOW? The reason I used a 6 slot AA battery pack is due to the fact that each AA battery provides 1.5V. So here I’m using 6 batteries which is 6x 1.5V = 9V i.e. exactly what the motors need to run.

If I got a larger battery pack with more batteries, the motors may be given too much voltage (similarly, a smaller battery pack would not produce the required voltage). Most of you probably know this already, but I didn’t completely understand it at the time (“Average”). Thanks to Gareth from 4Tronix for explaining this on Twitter.

Robot power pack

Coming together – the chassis, motor controller and power pack.

Wiring the Motor Controller

With the help of a few Google Hangout messages from Ryan explaining what to do (I really am a robotics ‘noob’) I managed to wire up my robot ready for the first dry run.

This is one of the reasons I like the Ryanteck board – it’s very simple, so ideal for robotics beginners such as myself. Ok it doesn’t have loads of features that some people will want, but it gets the job done and is a great way to learn before moving on to anything more advanced.

Ryan explained that I simply needed to hook up the motors to the terminals on the controller board, and that it didn’t matter which way around the cables were, so I connected the motors, trying to be consistent with which sides the coloured wires were attached to the motors, and connected the battery pack to the board as well.

6 wires, that’s all. Done – ready! You’ll also notice I’m using a ProtoPal board with this project – that’s to make adding sensors easy later on.

Raspberry Pi motor controller

My Ryanteck motor controller. 6 wires – done.

Code & Testing

Time to test that the Pi/code is working and the tracks actually move before trying to do any more to the chassis.

Ryan had a test Python script available, so a quick download and FTP to the Pi and we were ready to roll. As I’ve mentioned, the motor board simply works off the GPIO. Here’s a snippet from the code that makes the tracks spin for one second – it’s the same kind of code you would use to run LEDs:

GPIO.output(17,1)
GPIO.output(23,1)
sleep(1)
GPIO.output(17,0)
GPIO.output(23,0)

On the first try it turned out that one of the motors was wired backwards (again, not a problem, nothing will break) so I switched those cables around and everything started to behave as expected. The tracks spun, my robot had motion, and clearly the code was working too. Superb!

Here’s my proud Instagram moment:

It works it works it works! Thanks to Ryanteck for all the help and advice

A video posted by Average Man (@averagemanvspi) on

Running On The Ground

My test showed that my robot worked, but I had to witness it running around on the floor before I could properly call it a robot.

I adjusted the script slightly so that the robot would run for a few seconds in each direction, just to see how it behaved under load (its own weight). Whilst it did technically run, it wasn’t by any means fast, and it seemed to struggle to turn.

Either way, seeing it move across my living room did feel like success, and something I can work on.

Things To Work On

Whilst technically I was happy with my progress so far, there were/are a number of issues to iron out:

  • The robot doesn’t have a lot of grunt. It struggles with certain surfaces and is generally quite slow. These are micro motors so I wasn’t expecting the world, but maybe my power supply or gear ratio is to blame?
  • The robot doesn’t turn very well on the floor. I don’t know if this is a lack of power, poor motor gear ratio (50:1), too much weight, or maybe even the tracks aren’t as straight as I thought?
  • I can only run the robot using a script. I haven’t learnt enough to figure out how to run it ‘freestyle’ with a Bluetooth remote, keyboard or anything else. Can’t be that hard?
  • It’s butt ugly. My tiny chassis and multiple power supplies makes it look a bit weird and isn’t practical for any kind of competition yet.
  • Sensors – I must add some sensors at some point once I’ve mastered basic motion!
Raspberry Pi SR04 sensors

Eventually I’ll add some sensors – a bit like this

Summary

Well that was fun!

Ok so I didn’t really finish it completely, but I did achieve my goal – I have a home made robot that runs. It also gave me a pretty good excuse to spend money and ignore the wife!

It’s not quite up to Pi Wars standards yet, but we all have to start somewhere. I think I’ll work on making the chassis a little more secure, and then research a way of controlling it remotely. After that I’m going to look in to gear ratios in more detail and see if 50:1 ratio motors are really suitable for this application.

Continue reading here: What's Inside The Yellow Motors?

Was this article helpful?

0 0