Building a Self Balancing Robot

Things have been rather quiet lately, many apologies for the lack of posts over the past few years.
The PlotBot machine I built last year worked well up until I burnt out the supply to the Arduino Uno. Now its time for a new project, and I promise to keep you guys updated more regularly as I progress through the project.

Over the summer I brought myself the RepRap Pro Fisher Delta 3D Printer, which I’ve enjoyed playing with.

Its time to do something useful with it!

Un-successful robots printed on the Fisher Delta

Un-successful Robots!

A 3D Benchy printed on the Fisher Delta

Looking Ship Shape!

Using the Fisher Delta to print parts, I intend to build a 2 wheeled self balancing robot. This series of blog posts will be structured in such a way as that i follow the format of a Bachelor of Engineering Project Report. First I will start with a Literature Review, looking into the history and research behind self balancing robots, and the different technologies that can be used. I will look at the different processing platforms that I can use and the different connectivity / communication methods I can use to talk to the robot.

After the Literature Review I’ll be describing my intended technical approach to building the robot, followed by the challenges faced and how they were resolved. The final post will be a conclusion as to how the project progressed, and what I would be looking to change if I decide to make a new version.

PlotBot: Building the Gondola

Next stage of the build is to work out how to hold the pen. Some people call this the gantry or holder, I’ll be calling mine the gondola.
I decided to use lollipop sticks for this, they have a similar length to whiteboard maker pens, reasonably light weight and at only 50p for a pack of 50 sticks and it was an obvious choice!

IMG_20140908_133959

Clamping the Sticks for drilling

Having cut a few sticks down to size I then clamped them together to drill a thread hole through them using my trusty dremel.

IMG_20140908_134639

Lining them up for gluing.

IMG_20140908_135225

First one clamped down.

With the first side clamped in place and the wood glue drying things are starting to take shape.

IMG_20140908_195723

Sides nearly finished.

IMG_20140909_110614

And the finished gondola! look forward to a video of the first test draw in a couple of days . . . things are a bit shaky!

PlotBot: Building the Machine

With the research all done, I started thinking about how I wanted to build my PlotBot.
Having looked at the other designs, I found they were either mounted on a wooden frame and then a piece of paper is taped onto the wooden panel, or they draw directly onto a surface like glass or a wall. Given that the aim is just to make something that catches peoples eye, rather than making posters or drawings for people, I think the best course of action would be to use a whiteboard. I can get one reasonably cheaply, and the mounting is pretty much already sorted.

the Mountings

The whiteboard and mountings.

Once I had bought a whiteboard (600mm x 450mm) I started lining up the parts I had as to how I would mount them.
I had also bought 2 Pololu 1204 Stepper Motors and an Adafruit Motorshield v2 (AFMSv2). I did have a few concerns with these parts combined together, in that the motors only draw 600mA and the motorshield provides 1.2A per channel, therefore the motors might get a little hot if they start drawing more than they should – but we’ll see how it goes!

rough positioning

Roughly lining up the parts on a sheet of acrylic.

To mount the acrylic sheet to the whiteboard I used two of the mounts supplied with the whiteboard secured on the top of the sheet. These then hook onto the edge of the whiteboard, and the mounts on the side are adjustable to “lock in” the sheet to the sides of the board. Finally I decided to neatly mount the arduino and AFMSv2 in the center of the acrylic sheet.
Drawing up where to cut

Whiteboard Mounting     Arduino Mountings

IMG_20140813_134431     IMG_20140813_110556_1

I picked up two remote control car wheels at a local hobby store, along with 50m of fishing line, which would form the basis for my reels.IMG_20140819_220854

I found some nuts in the garage that fitted the inside of the wheel, and used Araldite (metal glue) to fill the gap around the stepper motor shaft hoping that this wouldn’t go wrong.

IMG_20140819_181748IMG_20140820_180654

IMG_20140820_180634

Araldite’s in, I was a little bit messy dripping it everywhere!

 With the luck of the gods, after leaving it 24 hours to cure I was able to punch the stepper motor shaft out of the nut, leaving a nice shaped hole. The advantage of this method being that I can very easily remove the reels and use the steppers in other projects.  

IMG_20140819_220909

IMG_20140819_221038  IMG_20140819_221322

Now that I have the reels mounted on the steppers, I was able to complete the main build; mounting the steppers onto the acrylic sheet, and winding the fishing line onto the wheels – happy days!

IMG_20140903_141549

IMG_20140903_141638  IMG_20140903_141609

 

 

 

PlotBot: Brief

So as time draws on we are getting closer to the start of the new academic year, and of course that means Fresher’s Fair!
At Kent we have several creative societies including SpaceSoc and their “Build a Rocket” sessions, Engineering Soc  with their focus on robotics, and TinkerSoc who want to help people build without limits.
With TinkerSoc it has become somewhat of a tradition to build and showoff a project at the fresher’s fair. In previous years we have had a laser engraver making custom name tags and furbies singing bohemian rhapsody, basically something to grab peoples attention and imagination.
Having seen a number of vertical plotters online I have decided now is the time to build one.

The standard vertical plotter is made up of 2 stepper motors, a servo, a motor controller and a microcontroller. By providing a stream of polar coordinates to the robot, the two motors can be wound in and out to move a pen across the whiteboard. This produces drawings where the pen never leaves the surface however that does not limit the styles of drawings that can be produced. Drawings can be developed further by adding a server or linear actuator to the pen carriage in order to push the pen off the drawing surface, thus allowing mush more freedom to implement different drawing styles.

Obviously we cannot draw above, or on either side of the motors, however the effectiveness of the plotter changes depending on the position of the pen carriage.
As such the most effective drawing area is a rectangle in the centre of the drawing surface with the tension on a cord being too low on either side, and the resolution is too low at the top due to the large angles. (http://2e5.com/plotter/V/design/

image

 

There have been a great many vertical plotters in the past, a great list can be found at plotterbot.com.
Overall there seem to be two different styles of drawing with vertical plotters.

Single line, where the pen never leaves the surface, is technically less challenging and can provide great results however you can be left with the odd scrawl across the surface that you didn’t want.

Multi line, where the pen can be lifted/pushed away from the surface, allows much more flexibility with regards to what can be drawn as the robot won’t scrawl connecting lines across the surface however does add the extra complexity of having a servo or linear actuator to push the pen carriage away from the surface.

Bearing in mind the saying, the more complex it is, the more likely it is to break.

 

Tinkerlog’s “Der Krizler” is definitely one of the more popular V-plotters out there, drawing on glass to amuse passers-by.

ATAT

 

Dan Royer’s Makelangelo is a very impressive V-plotter. Commercialised as a kit, it’s reliability has been tested extensively!

Makelangelo 2.5

 

And probably the oldest V-plotter around from 1988 developed at MIT using lego!

 

 

Hameg 203-4

As usual you can find some great bargains on eBay!

A few weeks ago I brought my first oscilloscope, a Hameg HM203-4, on eBay for £14.51, quite a deal I think. It was sold as “For parts or not working” as the seller didn’t know anything about oscilloscopes  or how to use them.

The Hameg HM203-4

The Hameg HM203-4

P1010452

I do love that there is a warning about the X Ray dosage!

Although it was sold on eBay as good condition, one of the buttons was missing. Fortunately I was able to see it inside the casing and so wasn’t too worried.

P1010457

So its time to crack it open and see what’s inside . . . Just two screws on the back and the whole metal chassis slides off.

P1010453

just two screws on the back

With the metal chassis removed we get our first glimpse into the home of the magic smoke. Just as I had hoped the missing switch was just a case of the shaft having popped out of the holder, I wonder what happened. . .

P1010456

P1010459

P1010461

A nice easy fix =]

So now that is fixes, here are some specs. Its a dual channel scope with a bandwidth of 20 MHz its not the fastest beast out there but then its not the slowest either, backed up by a max input sensitivity of 2mV/cm. One feature I’m interested to try and think might be pretty good for me as a student is the component tester. to make matters even better its apparently recommended for the training of engineers, perfect.

P1010462

What a pretty board

P1010463

P1010470

Poles Poles Poles, and a little bodge 🙂

P1010466

I was amazed to find capacitors without venting on the top!

P1010474

At least the CRT was made in 1983.

Troubleshooting

So far I have built the cloud chamber and have moved on to testing. It came as no surprise that it didn’t work first time and the problem is obvious, cooling. The heat sink I am using is not up to the job of cooling the Peltier coolers, again no surprise as it is about 6 years old.

I attempted to solve this with more fans.

WP_20130427_002[1]

The heat sink still reaches about 40 degrees which is about 10 degrees to much, the next step will be to clean the 6 years worth of dust from it and if that fails a new(er) heat sink may be in order.

Progress Update

Previous Post

So finally enough of my parts arrived to start building 🙂

WP_20130317_001[1]

So far I have:

An old cpu fan, a 500ml pot, thermal paste, a TEC1-12710 cooler, a TEC1-12709 cooler, an old ATX power supply (450W), glue, a knife, some metal, some uranium glass, a torch, scissors, nuts and bolts.

If you are interested in building this project yourself I would recommend waiting until I have it working properly. 🙂

This first part is the same as the the first part of the Instructables link in my first post and has been proven to work.

To start off I measured out a hole for the 12709 in the base of the pot, the coolers are 4cm by 4cm, and put it to one side. Next I cleaned and put thermal paste on the cpu fans heat sink.

Cpu heatsink

The paste should form a complete layer as thin as possible on the heat sink. The cooling is by far the most important and difficult part of this project and is very prone to going wrong. Place the 12710 cooler on top of the thermal paste, with the heat sink orientated as in the picture and the 12710 cooler on top with the wires towards you the red wire should be on the right.

A quick check is now needed, make sure the PSU is unplugged. On the main power connector connect the green cable to one of many black cables, this is the PS on connection and will allow the power supply to fun whilst not connected to a PC.  Plug the CPU red cable to a yellow cable, all yellow cables on all of the plugs are 12V, and connect the black to a black. The same goes for the 12710 cooler, red to yellow, black to black. A useful page http://www.smpspowersupply.com/connectors-pinouts.html

Pin layout

This next part must be done quickly, place a finger on top of the 12710 cooler and plug the power supply in. Make sure air can flow through the fan and turn it on.

If the fan doesn’t spin turn it off and check your wiring, if it still fails to spin unplug the 12710 cooler and use a multimeter to check if there is a voltage being produced by the power supply, if there isn’t make sure the green and black are connected. If there is still nothing then your PSU may be broken check the fuse first though.

If the 12710 cooler gets hot switch it off quick, it is upside down. If it gets noticeably cold then it is set up correctly, turn it off.

Place thermal paste on top of the 12710 cooler same as before as thinly as possible and place the 12709 on top. Both should be orientated the same way, wire colours on the same sides. Now for a check, the set up is the same as before apart from the red wire from the 12709 goes to a red wire in the socket (5V). The cooler should get very cold, around -25 degrees Celsius or better.

Up to this point is the basis of the cloud chamber, from now on this is all experimental and has a high chance of not working properly. Again it is advisable to wait until I have it working before making it yourself.

At this point I went back to my pot, on all the cloud chambers I have seen the dry ice or other coolant is connected to the plastic. This didn’t seem very efficient so I cut a hole in the plastic and mounted it on the cooler.

WP_20130317_003[1]

I used the glue to keep it sealed.

Following this I made sure pressure was applied and the whole thing couldn’t twist by using some nuts and bolts and I fixed a plate, using thermal paste, to the top cooler to give it a larger surface area.

WP_20130318_005[1]

I switched it all on for a test and found that water in the atmosphere condensed and froze on the metal plate, I took it as a successful test 😛

Until my Isopropyl alcohol and thermometer arrives I can’t test it any further.

Peltier Coolers

A Peltier cooler is a small device that is usually put in between a CPU and its heat sink. This is because a Peltier cooler is far more efficient at cooling a CPU down than a heat sink alone. The tec1-12710 and 12709 that where mentioned on my previous post are almost identical except that the 12709 is a lower power than the 12710.

The Peltier coolers are named after the  Peltier effect, a product of the thermoelectric effect. I am not going to go  into detail about either but I will give a brief explanation of how the cooler works. When a temperature gradient is applied to a thermoelectric device a voltage is created. As is often the case in physics what works one way also works in reverse. When a voltage is applied to a thermoelectric device a temperature gradient is created causing one side to be cold and the other hot.

from http://www.laserfocusworld.com/articles/print/volume-43/issue-8/features/cmos-detectors-thin-film-tecs-give-new-life-to-cmos-cooling.html

This is the basic overview of how a Peltier cooler functions. I hope this proves useful 🙂

The Cloud Chamber

I am taking my inspiration from this project here http://www.instructables.com/id/Make-a-Cloud-Chamber-using-Peltier-Coolers/. I plan to start by making a few choice modifications to the design. Once I have it up and running then I will make more drastic changes to the project to see what gives the best result.

First off is some basic concepts on how cloud chambers work. There are three main types of radiation alpha, beta and gamma. The two types we are focusing on is the alpha and beta, this is because these are heavily ionising. The alpha particle has the greatest charge and therefore the greatest ionising power, followed by the beta particle with half the charge of the alpha particle. The ionising properties of the radiation is what allows the cloud chamber to work.

Inside the cloud chamber we create a supersaturated vapour of alcohol by cooling evaporated alcohol down to very low temperatures. This is usually achieved with a chamber of dry ice at the base. As a charged particle, like a Helium nucleus (alpha particle) or electron (beta radiation), passes through the vapour at high speeds it ionises the vapour around it leaving a trail. These are the white lines in the image on the link at the start.

Unlike most cloud chambers I’m using Peltier coolers like the one in the link to cool the alcohol. The advantage of this being that you don’t need dry ice every time you want to run your cloud chamber. So I start off with a rather odd shopping list:

A Tec1-12710, A Tec1-12709, Thermal paste, A CPU fan (bigger the better), A clear plastic pot, Some thin scrap metal, Concentrated alcohol (Isopropyl or similar), Some bolts and screws, A light source (a torch to start with), A computer PSU (above 300W) and a radioactive source.

While a radioactive source is not necessary, as you can detect cosmic rays, I thought I would get one for testing. My source is some uranium glass from eBay although others are available this is a nice alpha source, some fire alarms contain americium which is a strong alpha source and can be used. WARNING! handle with care! Although these sources are rarely dangerous ingesting or mishandling a radioactive source is never a good idea, swallowing glass isn’t the best idea even if it isn’t radioactive.  If swallowed consult a doctor immediately, better safe than sorry.

Almost all the things on the list can be found on eBay or in a dump. If your a student it is worth asking around your labs for parts. Fortunately I have most of the parts from old computers and bits lying around. The rest I managed to obtain for £20 including delivery.

If you want to build this yourself  it may be worth waiting until I have a working product before you buy all the parts as I am making this up as I go. I will also add more detailed part lists as I go.

Tools: Aside from the essential tools (screw driver, hammer, duct tape, etc.)  it is probably useful to have a multimeter and a inferred thermometer although they are not essential.

Okay, after that lengthy post I look forward to starting the project as soon as I receive my parts in about a weeks time!

Starting a VU (Volume Unit) Meter

To keep myself busy at university, I decided to start on a big project. Well big for me anyway.
The end goad being a a VU (Volume Unit) meter, aka a sound level, that can be used either in-line with an audio cable, or used with a microphone.

I am to try to go through this project in a number of research stages, and main 3 test stages.
For the research I want to start with a Light Level Meter. This will just help me to refresh my arduino programming skills, and also just set myself up for when I get hold of a microphone.

Next I will take the same circuit and apply it to audio, using a microphone and using a line-in. In terms of analysing the audio I will first try using a simple analogRead, just the same as the Light Level Meter. I will also look into using FFT (fast Fourier transform) which is used to transform raw audio into a frequency spectrum, which in turn can be outputted to LED displays. This route could end up being very complicated so I will approach that with caution.

The next stage is to research multiplexing and charlieplexing LED’s. This is because I would like the end product to have a LED matrix display,  thus enabling me to potentially display a spectrum of frequency bands. However for the testing I will move back to the Light Level Meter and try to display that data on the LED display.

In terms of the test stages, I will be doing all initial research on breadboards, if all goes to well I will move onto designing an arduino shield, the hope is that this will also work as a Lol (Lots of Lights) Shield. Finally I want to take this to an end product, on its own PCB.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

So enough talking, time to refresh on the very basics.

The Light Level Meter.

This is a very simple circuit, but then that was not the purpose of it.
Each LED was connected to a pin on the arduino, and the central pin of a variable potentiometer is connected to an analogue in pin. I connected an LDR (Light Dependant Resistor) between the variable pot and 5v. The other pin of the variable pot is pulled down to 0v.

Light Level Vs Resistance over a LDR

As the light level decreases, the resistance over the LDR increases, combining this in a basic potential divider circuit means that as it gets darker, the value read in at the analogue pin of the arduino gets higher. This allows me to adjust the LED’s appropriately and also use the variable pot to calibrate the display.

The circuit seen below is the circuit used, with a 330 Ohm resistor in series with every LED as a current limiting resistor.

Light Meter Fritzing Circuit
To program the arduino I used the standard arduino IDE, available from arduino.cc, and I programmed the arduino with the below sketch.

// LED Light Level Meter

int led[10] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12};  // Array of pin numbers for                  the LED’s
int adjust = 5; // Adjustment Pot
int Light, i;

void setup()
{
for (i=0;i<10; i++) // A for loop which goes from 0 to 9, setting
pinMode(led[i], OUTPUT); // each value in the array as an output
Serial.begin(9600); // Turning on the serial output to troubleshoot
}

void loop()
{
Light = analogRead(adjust); // Reading the analogue value of the LDR
Serial.println(Light); // sending the value to the computer for troubleshooting
Light = Light / 100; //reducing the value down to between 0 and 10
Serial.println(Light); // sending the value to the computer again

if (Light == 0) // checking that all LED’s are off if there is no light
{
for(i = 0; i < 10; i++)
{
digitalWrite(led[i], LOW);
}
}

else
{
for(i = 0; i < Light; i++) // Turns on all LED’s between 0 and the light level
{
digitalWrite(led[i], HIGH);
}

for(i = i; i < 10; i++) // turn off the leds above the light level
{
digitalWrite(led[i], LOW);
}
}
delay(100);

}