how to make your first robot report

63
Home How to make your first robot By fritsl @ January 30, 2008 Learn how to make a robot, no skills needed, very, very easy. Time to build: 2 hours URL to more information: http://picasaweb.google.com/fritslyneborg/Let... Cost to build: $85 Actuators / output devices: 2 geared motors CPU: Picaxe Power source: 4 AA batteries Programming language: Picaxe basic Sensors / input devices: Sharp IR Target environment: indoor

Upload: ramki-m

Post on 12-Apr-2017

200 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: How to make your first robot report

Home

How to make your first robot 

By fritsl@ January 30, 2008

Learn how to make a robot, no skills needed, very, very easy.

Time to build: 

2 hours

URL to more information: 

http://picasaweb.google.com/fritslyneborg/Let...

Cost to build: 

$85

Actuators / output devices: 2 geared motors CPU: Picaxe Power source: 4 AA batteries Programming language: Picaxe basic Sensors / input devices: Sharp IR Target environment: indoor

Page 2: How to make your first robot report

 

Attachment Size

shbotvideoprogram.bas 5.43 KB

How_To_Make_Your_First_Robot.pdf 2.36 MB

This tutorial is the easiest way in the world to give you a fast start into building robots.

 Welcome :)

Everything here is so easy, that after you have gone through it, you can make a robot in a couple of hours. Why can't you do that now?

Because there are so many little things you need to know. This is an attempt to let you know exactly all these little things, and nothing more. Fast, and based on 2 years of experience of what people need to know to get started. If you hurry, you can run through this, and be robot builder in a couple of hours. But expect to use a good weekend - Learning takes time - even though it is very easy, it just takes some time, all the little things to get to know :)

There are other "How to get started building robots" out there. This one is focusing on getting you around everything extremely fast. You need no knowledge of ... anything. And you will learn everything... well, the basics of everything ;)

All images in high-res here.

Materials needed

It used to be a hassle to buy the materials, because not one single webshop was carrying everything needed, and you had to buy from several shops.

Good news is that LMR have started a cooperation with Solarbotics, one click get's you all the parts:

You can get everything needed for the project here, in "The LMR Bundle"

- And if you buy it there, you even support us, so we can keep hosting letsmakerobots.com

Everything you need can also be found in webshops, and via Google, if you do not want to buy the LMR bundle. And as it is sold in webshops, you can get it where you are, in any country.

 

No matter from where you get it, the following is what you will need:

(The following is all included in the bundle)

 

1 PICAXE-28 Project Board

The 28 pin project board is like a game of Mario Bros; Fun and full of extras and hidden features, making you want to play over and again. It is an extremely good board to get you started, and it can be used for a fantacillion different projects, don't get me started :)

Page 3: How to make your first robot report

 

Male "snap off" Header Pins,  at least 10 pins on a strip

Many times the boards that you buy just have holes in them, and that makes it hard to plug something in / on. One way to overcome this, is to solder wires into the holes. Another is to add these pins, so you can plug on wires, like with the servo and female headers shown below. "Why don't they just put pins in all the holes from the factory", you may ask. Well, I don't know. Maybe to give us the option. It is also possible to solder female headers onto the board, perhaps this is why.

You get these in long rows, and simply break them apart with your fingers.

 

Page 4: How to make your first robot report

3 Shorting Blocks, Top Closed

Put these over 2 pins next to each other, and there is a connection between them!

 

5 or more Female-Female Header Jumper cables

Yes. These are nice. When I started this hobby a couple of years ago, these where really hard to get. Now they are everywhere, and that is really good. Most things in this new robot-hobby of yours have pins (or you solder some in ;) - and by using these jumpers, you can make quick connections without soldering. Nice!

Page 5: How to make your first robot report

 

1 USB PICAXE Programming Cable

You write your robots programs on your computer. Plug this cable into the robot, and transfer the program. Unplug, and the robot runs the program by itself.

 

1 PICAXE-28X1 IC

This chip is a Microprocessor. That is often explained as "A computer in a chip". It can be placed in the board described above, after that, it can be programmed from your computer via the programming cable.

Your program can tell the controller to "listen for inputs", "think about them", perhaps make some calculations or look in some datas, and make outputs to something like the motor driver below.

It is chosen here, because it is quite strong, yet very easy to program, as you will see below.

Page 6: How to make your first robot report

 

1 L293D Motor Driver IC

I will describe this later, when we install it below :)

 

1 DIL 330 x 8 resistor array

The Yellow chip! It is very dull, just a row of little resistors. You will be using it to set your board up for servos.

Page 7: How to make your first robot report

 

1 Standard servo

A Servo is a cornerstone in most robotic appliances. To put it short it is a little box with wires to it, and a shaft that can turn some 200 degrees, from side to side.

The microcontroller can decide to where the shaft should turn, and stay there. Like go to "3 o'clock". That is it pretty handy; You can program something to physically move to a certain position. Next thing (after this project) could be to let one servo lift another servo. You would then have what is referred to as 2 DOF ("Degrees of Freedom"). But let's start with one ;)

You may wonder why my servo has that white pin, where yours might have a flat disc, a cross, or something. It does not matter, servos comes with all kinds of "servo horns". We just need something there to glue the head on to!

Page 8: How to make your first robot report

 

1 Sharp Analogue InfraRed Range Finding System (AERS) with cable

+++++++++Note:+++++++++

SHARP has discontinued their opto-electronic product lines, and as such the GP2D12 sensor described here has become obsolete afte we made this. Supply is running out everywhere, and we are working on solutions. For the time being you can (or we will do so for you, if you buy the kit) replace the GP2D12 with an GP2Y0A02YK Long Range Distance sensor. The GP2Y0A02YK's do not sense as close as the GP2D12's but they have a much farther range 20 - 150cm. We did some measurements and found that these sensors can actually reliably measure approx 16 - 180cm.

You can use the GP2Y0A02YK sensor in place of the GP2D12 to achieve better range, with not much change from the GP2D12. The pinout and voltages are exactly the same with the only change being that the GP2Y0A02YK sensors do not do as well in the close range.

Thanks for understanding, we are working on a fix.

++++++++++++++++++++++++

The one "eye" sends infra red light. The other sees the reflection of this (if there is one), and the unit returns the distance to the object in front of it. It has 3 wires (make sure you get the cable for it, or it can be a little hard to hook up). You give it power on 2 of the wires, and the third one plugs into the microcontroller, and tells it the distance.

 

1 4 x AA Battery Holder if you are using rechargeable batteriesor 1 3 x AA Battery Holder if you are using non-rechargeable batteries

(See more below, regarding batteries, and why the difference - Point is that you need as close to 5V as possible, one way or the other, and you can use something completely different in terns of batteries if you want. As long as it is just about 5 Volts.)

Page 9: How to make your first robot report

 

2 Geared motors and wheels to fit

It is very important that your motors have gears. You want a slow robot; Go for high ratios, like 120:1 or higher, as a slow robot is so much more fun in the beginning, because you can see what it is doing.

Apart from that, there is not much to say. Well, that would be, that there are many ways of moving and steering. This way of only using 2 wheels, is sometimes referred to as "skid steering". And it is worth remarking that if you'd like to add belt tracks later on, the basics are the same ;)

 

Page 10: How to make your first robot report

1 Roll of double sided foam tape

Oh yes! If there is something you cannot fix with this tape, it is because you are not using enough! It is a very, very fast way of sticking 2 items together. In fact we will be using it to make this entire robot! Depending on the make, of course, it is also reasonably easy to take apart again.

Paint stirring sticks, this tape, and a melt glue gun is the backbone for most of my fun with robots :)

 

1 Heat shrink tube (5 mm approx)

Sometimes you do need to solder 2 wires together. For instance the Sharp IR Range finder; It comes with straight up wires on the plug. What you do, is cut one of the female cables (above) in 2 parts, solder them together.. but before that, you cut a little piece of this heat shrink tube to slide over the place without insulation. Then with a lighter, you can quickly heat up the tube, and it shrinks to fit.

That is so much smarter than using tape ;)

Page 11: How to make your first robot report

 

All of the above materials are included in the LMR bundle.

 

 

 

Also needed:

 

Batteries

Either 3 AA Non rechargeable, or 4 AA Rechargeable.

This robot needs 5 Volts. Mainly because the Sharp IR, really feels best on 5.0V, that's what it's made for. Motors and servo would like more, microcontroller could live with 6.0V, but keeping it simple is the core here, so we feed the whole robot with as close to 5.0V as possible. And rather too little than too much, so we make sure not to fry anything, now that this is your first robot ;)

Now, you may know, that normal batteries provide 1.5V. However, you may not know that rechargeable batteries only provide 1.2V!

No matter if you knew that or not, 3 times 1.5V from normal batteries, is 4.5V. If we use 4 times 1.5V we would get 6.0V, which might be a little scary to use on the Sharp, rated for 5.0V.

4 times 1.2V from rechargeables is 4.8V, which is nice and close to 5V. And then it is much cheaper in the long run. So I strongly recommend you to get some rechargeables and a charger.

Tip: The best rechargeables have the highest capacity, measured in "mAh". The 2500 mAh AA-size is a fine battery.

Page 12: How to make your first robot report

 

A Soldering iron and solder

If you are new to soldering, this might interest you.

 

A lighter and a cutter

Lighter for heat shrinking, cutter to.. cut.

Page 13: How to make your first robot report

Tip: If you want to use the cutter to remove plastic from cables, turn it this way; Imagine that you where sticking the cable right into the cutter from where you are now, into the table it is laying on. That way. And not from the table, and out to where you are. Then gently close around the wire, and pull the plastic off.

 

A computer with an internet connection and a free USB port

             

Can be Mac, Linux or PC. The software needed for this is free.

 

 

Nice-to-have tools, though not essential:

 

A multimeter (aka measure-thingey), a wire stripper, and a screwdriver

Page 14: How to make your first robot report

 

 

Ready? Let's make a robot :)

 

Pins in holes!

First unwrap your board (I am sure you already did that :), and then see that it may have some red stuff underneath. That is just there from when they made it; They insert the components on the upper side, and dip the boards lower side into hot solder.. and areas where they don't want solder to be stuck, they have placed that red stuff. So just take it off :)

Let's look at somewhere where we for sure are going to add some pins.. Yes, the motor-outs.

Page 15: How to make your first robot report

The A & B on the board. We will get back to them, but for now, snap off 2 times 2 pins, and plug them in.

It does not matter if you snap off single pins or anything like that. They are simply little metal rods in plastic. Short side down into board.

Use some foam tape to hold the pins in place.

Turn the board around  and solder..

Page 16: How to make your first robot report

And now, tatataaaa.. You can plug in any standard female header, where you used to have a hole :)

Nice, and while you are at it, also solder a pin into analogue port 0, that we are going to use for the Sharp:

Page 17: How to make your first robot report

Then solder a pin into output 0..

And you are done with pin-soldering.

If it was me, I'd just solder pins in all the holes, but you may want to leave that for later. You have soldered all the pins that we need for this project now.

 

Next, general instructions: Extensions and alternations of wires and cables:

Connecting 2 wires "The right way" is almost a religion to some. Here is how I do it :)

Page 18: How to make your first robot report

First, I simply twist together the 2 wires

Then I solder them together, cut some off, if it is too long, and bend it along the side of one of them.

However, BEFORE I do this, I make sure that I have cut off a little piece of heat shrinking tube, and placed it over one of the wires. Then I slide that over..

Page 19: How to make your first robot report

A lighter quickly heats it up. This makes it shrink, hence the name, and it is a perfect insulation.

I don't think you realize how hard it was to take that picture all by myself :) It had to be in focus on the right spot, you know. And yes, the wire got a little burned :p Good shot though, if I may say so myself.

 

From now on, I expect you to just extend wires that are too short, hook up headers on wires when needed, and if you need to connect something to the board, where there is only a hole... you simply add a pin :)

 

Page 20: How to make your first robot report

 

Get it together!

 

Fixing up the motors

Mount the wheels on the geared motors. You may have a completely different set than I do here, but as long as they are geared motors that run fine on a few volts, and some nice wheels, you will be all right.

When you have the wheels on the motors, cut one of the female-to-female wires in halves, take away some of the plastic from the end of the wire, and solder it on. And do the same for the other motor.

Make sure no solder or wires touches the metal on the motor :)

Some wheels come with optional rubber tyres. It can be a good idea to wait with putting on this rubber, because if the robot is stuck, it can just slide, which is nice when testing and developing.

 

Chips in the board!

The Picaxe 28X1 Microcontroller that you have here, and the board, is a pretty amazing and very powerful little package.

I remember how amazed I was that I could actually make this control everything I could imagine, I hope you will get that sensation at some point as well; Seriously, you can make this thing do all sorts of stuff with all sorts of electronics. Even if you know nothing about anything, and electronics is as strange to you, as it is to me.

You can also make it handle your servos, motors, calculations, monitoring distance.. everything a robot needs. And that is what we are going to set it up for now

Page 21: How to make your first robot report

The microcontroller is the long chip. That is the one you program, and then there are inputs and outputs on the board that it can use.

 

Have a look at this page: 28 pin Project Board (AXE020), Picaxe for dummies

 

Now, I do not expect you to read that page now, because I have promised you that you will building building the robot as fast as possible :) However, it is important that you read that page at some point, to learn about the board, and the microcontroller. Promise me to get back to that, make a bookmark for next step ;)

OK, enough talk, insert the long black chip, that is the microcontroller.

Make sure to turn it the right way: It has a marking in one end, and so does the socket. They should match.

 

Now, when you bought the board, it should already have a black chip in it, in the slot where I have placed the yellow chip, in the picture below.

Take up the black chip, and as I did, replace it with the yellow one. It does not have enough pins, but see picture for what end to leave open. (the inner side)

The yellow chip is sitting between the microcontroller and the topmost row of pins on the picture. That row has (as you will know when you read about the board, your bookmark, remember?) the outputs.

We are going to hook up the servo to one of these. Servos are sending a lot of electrical noise back on the line. The Yellow chip is a series of 330 Ohm resistors, that will reduce the amount of noise that is sent back to the microcontroller. It is simply straight lines across, with some resistance between, making the signals travelling both ways a little weaker. So it is there to protect the microcontroller.

Frankly, I have never heard of anyone frying a microcontroller because of servo noise, but since manuals tells us to do this, and the board is prepared for it, we might as well.

I have also heard of black versions of this chip. How boring, but none the less, and yes; You can use it, no matter the colour, if it has the same functionality.

The black chip that was in its place, is a so-called Darlington driver. If you need more info than that, please read the manuals :) But it is a good chip, if you are not hooking up servos right on the board. It is amplifying the signals, so for instance you can hook up a speaker right on it (where we now will be placing a servo) - and using the command "Sound", you can make it beep quite loud, play tunes etcetera. You have got to try that as well! Just not now ;) Disadvantage of using the microcontroller and this board for everything is, that when you want to play with servos, you take out the Darlington, and the fun it provides. But there is more, wait and see!

Last chip is the motor controller, throw that in as well!

When your microcontroller is placed in your board, it can switch power on/off. You could use that to drive motors. However, motors are "rough", and could fry the microcontroller's outputs. And another thing is that if the microcontroller can only turn power on/off, then.. how do you drive backwards?

A motor driver takes care of all this; This little motor-driver-in-a-chip can drive a pair of small motors (600 mA each, for the tech interested), without frying the microcontroller. And furthermore; It can make the motors go backwards. Which is handy when facing a wall :)

Your nice board has a place for a motor driver that can take a pair of small motors, and make them drive both forward and reverse.

The board is set up, so the microcontroller's outputs 4, 5, 6, and 7 are fed into the motor controller, and out comes 2 fine pairs of wires that you can hook up to a pair of motors: Motor A and Motor B. And you just soldered pins into them, how nice.

Page 22: How to make your first robot report

Tip: New chips inNew and unused chips usually have the two rows of legs a little too wide apart. So gently push down the side of the chip towards a table to correct it, before inserting it into a slot. You will understand me once you try to place a new chip in a socket ;)

Tip: Old chips outIt is easy to get a chip out of a socket, by inserting a flat screwdriver below it, push it under, to the far end, and gently push it up.

Fact: Later in your life, you will want the microcontroller to just be a microcontroller. You then buy extra other boards for something like servo control and motor control. These boards will get their commands from the microcontroller. And then your robot can do everything much more powerful, and simultaneously.

However, it is pretty amazing what you can make this set-up do, as you have it right here! Many, many cool robots and other project use far simpler or just this set-up.

 

Make the body.. without a body!

In order to keep this as simple as possible, we are just glueing all the parts together, and call that a robot! Yes.

If you prefer, of course you can make it more advanced than this. Only thing to note as such is that we use 2 central wheels, each with one motor. Driving both forward makes the robot drive forward, and if one is going backwards with one forward, it turns on a plate. If one is still, and the other is driving, it is more like "sliding" to one side.

What you can do, is simply to stick on the motors to the battery holder, using the foamy tape. If the batteries are in there, and the wheels are big enough to have them placed below the axle, the whole thing will simply balance on its own. Quite strange, actually, when I think about it :)

Page 23: How to make your first robot report

Somehow also leave some room for the servo in front. Or stick it on to the front of it all.

Most important is that wheels touch ground, and the rest is more or less in balance. It does not matter if it is tipping a little backwards.

Feel free to make your own design, of course :) If you do not like the balancing part, or cannot make it work, you can just add some smooth "pads", or extra wheels. A pearl, or an old LED could make nice little "third wheels", that usually are placed in the rear of the robot.

Page 24: How to make your first robot report

Now, as you can see, this time, I used the 4-battery holder. Because that is the biggest one, which makes it easier to stick it all on to it.

- But if you are using non-rechargeables, and only should use 3 batteries, here is a tip:

Find an old telescopic antenna, from a radio or something.

Cut off a piece (Here is a tip on how to cut it), and insert it instead of one of the batteries. Bingo ;)

Page 25: How to make your first robot report

OK, next thing is to place the board on the robot, and hook everything up (apart from the Sharp, wait with that).

First: Take out the batteries again (or at least one of them). Just to make sure you don't fry something by accident. We don't have an On/Of on this robot; Batteries in, and it is alive. But we want it dead now, so one battery out! (and not like on next picture, doh!)

Some battery holders have wires (like the one I am using), and some have a clip that fits right onto the clip on the board, as illustrated in the 3 battery holder below. If you have a clip, then hook it up, you are done. If you have wires like me, cut off the clip from the board, and connect black with black and red with red. (and use shorter wires than I did ;)

The + from the battery should go the where the RED is hooked up on the board, from the factory.

Page 26: How to make your first robot report

 

Hook up stuff to the board

 

Hook up the servo

Your servos wires colours may be different, but the hints are; Brown or Black (Ground) to the outside, Red (Volt) in the middle, and yellow or white (Signal) on the inside of the board. These descriptions may make most sense to you, if you have read about the board, as you promised me to do earlier. But for now you can just note the colours, and make sure to plug in your servo the right way around :)

Page 27: How to make your first robot report

 

 

Mount the board, and hook up the motors

With some (more) foam tape, stick on the board to the rest of the robot.

Make sure the mini-jack (the metal ring in one end of the board) is placed so it is easy to plug in a cable, because you will be doing that many times! And be careful to make sure that the bottom of the board does not touch any metal ;) That would cause short circuits.

Hook up the motor wires, into the A&B-pins that you soldered on earlier:

One motor's 2 wires goes to A on the board, the other two wires go to B. It does not matter which motor connects to which output, we will manage the rest in the programming.

Oops, one of my motors wires was too short, so I added little blue extensions from a scrap piece of wire that I found.

Page 28: How to make your first robot report

There is a nice little room to stuff in excess lengths of wires :)

And voilà!

Page 29: How to make your first robot report

 

 

Break out, software

 

(Yes, I know your robot still has no face :)

Page 30: How to make your first robot report

We need to turn the servo to centre.

Of course you could try and do it by hand, and estimate it to be in centre, but the smarter way is to let the microcontroller put the servo to centre. Because then you can mount "the face", facing forward, right where the microcontroller thinks it should be, when facing forward.

You are going to take a "Time-Out" from this tutorial, because you will need to set up your computer to know there is a programming cable attached, and a piece of programming software must be installed.

I cannot help you much with this, as it depends on the type of computer you have got, and what the folks at the Picaxe website have updated after I wrote this.

However, go to

http://www.rev-ed.co.uk/picaxe (or the easier to remember: picaxe.com - that redirects you)

Depending on your OS, you want either the

Free PICAXE Programming Editor or the AXEpad (which is also free, it is just not in the name ;)

Download and install which ever they claim will make you able to program the Picaxe chips!

Then you want to find the part that says

AXE027 PICAXE USB Download Cable

Install the driver and cable as described, and plug the jack into the board.

Insert all batteries in your robot.. wait.. wait.. sniff.. anything smells funny? No sparks, no smoke? No? OK, go on then.

Most versions of the Picaxe programming software have some form of menu item called "Options". Enter that, and look for a page or tab that says "Mode". Some editors even open this very page for you when you first start up the program.

Here you should find a button that says "Firmware" or "Check firmware version". Click that.

Page 31: How to make your first robot report

Now what should happen is that the editor talks to the cable, that talks to the microcontroller, and asks it what kind of a Picaxe chip it is. It should return something like "28X1/40X1", and this should be displayed on the screen for you.

If yes, then good; You have contact. Now somewhere in the same screens, you should be able to set the mode of the editor, set it to 28X1/40X1.

(It is a big mystery to me why this has to happen, by the way; Apparently the editor can see what kind of chip is there, so why on earth can it just not set it by itself?. hmm.. let me know if you find this reason one day ;)

OK, if you get any errors, cannot find the microcontroller or something is reported wrong with the cable, I will have to ask you to lean on Picaxe's help and manuals. It's usually very simple, so try again if something is wrong. Or try from another computer, just to see how it should work, and then try the first one again, and bug track that way.

Now, enter the main programming editor; It is like a big text editor. If no project is open, go to "File"; and open "New Basic" / "New".

In here write this:

servo 0, 150

wait 2

This is your first program, and it is very simple. The first line tells the microcontroller that there is a servo on pin 0, and that it should be put in the centre (center) position, which is 150.

The next line tells it to think about life for 2 seconds (which gives the servo time to turn).

And after this, the microcontroller will stop doing anything at all, it will go zombie!

Write it in, and transfer the code to the microcontroller. That is done on some systems by pressing F5. No, wait, I think it is so on all systems. On all that I can test from here anyway :) You could also click "Program".

You should be told that the program is transferring, and then magic should happen; The servo should turn to the centre position.

Perhaps it did not do much, but that may be because it was already in centre.

Try to hold down the "Reset" switch that is placed on the board, while turning the servo to one side. Then let go of the reset, and it should turn back in place.

Perhaps you do not think it is centre, but it is. But maybe your servo "horn" is just mounted awkward. In the middle of it, there is a screw. Unscrew and take of the horn, make sure the microcontroller did put the servo in centre, and then screw on the "horn" (disc, or what ever) again, so it is the way you think it should look like when centred.

Now, let's try to turn the servo to the sides, let's extend the program:

servo 0, 75

wait 2

servo 0, 225

wait 2

servo 0, 150

wait 2

the servo command should only be using values from 75 to 225, which is the most a standard servo can go to either side. Values out of this range are not recommended, may produce funny results.

Page 32: How to make your first robot report

Every time you run this program (you can unplug the cable, take out the batteries, and turn it on again without the cable), it will start from the top. And every time you press reset, it will.

If you'd like it to go in a loop, you can add a label in the top, and in the bottom make it go back to that label. We make up any name for a label, just a single word, followed by a colon, watch:

servofun:

servo 0, 75

wait 2

servo 0, 225

wait 2

servo 0, 150

wait 2

goto servofun

 

 

Now it just goes on and on.. Try to play around some with it, change values etcetera, if you like :)

...

OK, back to building the robot ;)

Plug in the wire to the Sharp, if it was not in from the shop. in other words; Make sure there are 3 wires coming from the Sharp. Your colours may be different, but I have red, black and white, which is pretty meaningful for V, G and Signal.

You may need to add female headers to the wires, like I did below. These can also be in any colour, of course. However, I have soldered 3 of same colours on, so you can trust the ones in my picture  to be leading you to which cable goes to where.

Be careful to check that you are plugging this right in, because the Sharp can fry pretty easily.

In the picture below, you can see what goes to where. The stick and strange set-up is just to make sure you can see the wires and their colours :)

Page 33: How to make your first robot report

 

You should have 3 little black things called Shortening Blocks. What they do is simply connect 2 pins next to each other.

If you don't have any, you can always just use a female-to-female jumper cable instead, like I did on the last one, with a little white cable. The blocks are smart because they don't take up any space, a wire is smart, because it can reach from one end to the other of a board.

As you can see I did on the next picture, connect analogue input 1, 2 and 3 to V, using shortening blocks or female-to-female.

Why this? A brief and not very scientific explanation is; these 4 inputs (0, 1, 2 and 3) are analogue. Which means they measure "how much pressure is on the line". However, they are connected, if they like it or not. And so, a little pressure on one of them

Page 34: How to make your first robot report

actually does something to the next. They are "left floating". By tying the 3 that we do not use to V, they are just returning "full value", and they are not left floating. So the last one, number 0, that we use, is way more accurate.

I have not read documentation that tells you to do this, however, I have at several occasions experienced strange readings, until I tied all unused analogue pins to either ground or V. Oh... and in fact I am writing documentation here (sort of :) So now it is written in the documentation to do this! :)

 

Make sure the servo faces middle, 150!

With a new piece of tape, mount the Sharp IR on the servo horn, facing forward.

 

Tadaa! :)

You're done building the basics!

The design may vary, you may have used other parts etc... But if you have connected as described, here are some tips to get started programming your robot:

 

 

 

Page 35: How to make your first robot report

Programming

Enter this code into your editor, and press F5 while the robot is connected:

main:

readadc 0, b0

debug

goto main

Now take your hand in front of the robot´s head and notice how the variable b0 changes value. You can use the knowledge gained to decide what should happen and when (how close things should get before..)

You may notice how things start to go "wrong" if stuff is too close to the "eyes"; The Sharp is made to work with objects 10-80 cm away. Things that are closer than 10 cm (4 inches) appear to be further way, which can be quite a challenge to program.

You can get many other distance sensors that do not have this problem. However the Sharp is the cheapest, and easiest to program, so that's why I made such a "bad" choice for you, sorry ;) Look around and see what everyone else is using, before you decide on an upgrade.

Now I advise you to put your robot up on a matchbox or similar, as the wheels will start turning.

Enter this code into your editor, and press F5 while the robot is connected:

high 4

low 5

One of the wheels should turn in one direction. Does your wheels turn forward? If so, this is the instruction for that wheel to turn forward.

If the wheel is turning backwards, you can try this:

low 4

high 5

To turn the other wheel, you need to enter

high 6

low 7

(or the other way around for opposite direction.)

What happens here is that by using only the options available to the microcontroller; power on or off (High / Low) on the pins, it is commanding the motor controller to set motor A or B in forward or reverse mode.

 

Page 36: How to make your first robot report

low 4

low 5

low 6

low 7

 

stops all motors

The servo you have already tried.

All the way to one side is:

 

servo 0, 75 wait 2

 

- the other side is: 

 

servo 0, 225 wait 2

- and centre:

 

servo 0, 150 wait 2

Here is a small program that will (should, if all is well, and if you inserted the right parameters for high/low to suit your wiring to the motors) make the robot drive around, stop in front of things, look to each side to decide which is the best, turn that way, and drive towards new adventures. In the code I have made so called remarks: explaining you what is going on.

You can write such comments or remarks yourself in the code, it is a good idea to keep track.

They are written with an apostrophe (or single quote) sign. However, copying this text from here might alter that to something else, and you will have to fix that manually, sorry. Your programming editor has colour codes, that will help showing you what it recognizes as comments and what as code.

 

Symbol dangerlevel = 70 ' how far away should thing be, before we react?symbol turn = 300 ' this sets how much should be turnedsymbol servo_turn = 700 ' This sets for how long time we should wait for the servo to turn (depending on it´s speed) before we measure distance

main: ' the main loopreadadc 0, b1 ' read how much distance aheadif b1 < dangerlevel thengosub nodanger ' if nothing ahead, drive forwardelse gosub whichway ' if obstacle ahead then decide which way is better

Page 37: How to make your first robot report

end ifgoto main ' this ends the loop, the rest are only sub-routines

nodanger:' this should be your combination to make the robot drive forward, these you most likely need to adjust to fit the way you have wired your robots motorshigh 5 : high 6 : low 4 : low 7return

whichway:gosub totalhalt ' first stop!

'Look one way:gosub lturn ' look to one sidepause servo_turn ' wait for the servo to be finished turningreadadc 0, b1gosub totalhalt

'Look the other way:gosub rturn ' look to another sidepause servo_turn ' wait for the servo to be finished turningreadadc 0, b2gosub totalhalt

' Decide which is the better way:if b1<b2 thengosub body_lturnelsegosub body_rturnend ifreturn

body_lturn:high 6 : low 5 : low 7 : high 4 ' this should be your combination that turns the robot one waypause turn : gosub totalhaltreturn

body_rturn:high 5 : low 6 : low 4 : high 7 ' this should be your combination that turns the robot the other waypause turn : gosub totalhaltreturn

rturn:servo 0, 100 ' look to one sidereturn

lturn:servo 0, 200 ' look to the other sidereturn

totalhalt:low 4 : low 5 : low 6 : low 7 ' low on all 4 halts the robot!Servo 0,150 ' face forwardwait 1 ' freeze all for one secondreturn

 

 

Page 38: How to make your first robot report

With some clever programming and tweaking, you can make the robot drive, turn its head, make decisions, make small adjustments, turn towards "interesting holes" such as doorways, all working at the same time, while driving. It looks pretty cool if you make the robot spin while the head is turning ;)

Fun time

You could also attach a lamp or LED to pin 2 & ground, and write (remember LEDs need to turn the right way around)

High 2

 

to turn on the lamp, and 

 

Low 2

to turn it off ;)

- How about a Laser-pen, mounted on an extra servo? Then you could make the robot turn the laser around, and turn it on and off, pointing out places.. you can do anything now :)

Pressing "Help" in the programming editors brings out all sorts of interesting tutorials and info!

 

Perhaps try this:

Pull out the servo, and take up the yellow chip. Insert the Darlington that you took out earlier. Hook up the speaker to the 2 pins above where the servo was, tat is output 1. And throw in the LED, or whatever it was that you found on output 2. Then program it something like this:

 

sound 1, (100, 30)

high 2

wait 1

low 2

sound 1, (105, 60)

 

That should make a sound and turn something on, make a new sound and turn it off again.

 

Page 39: How to make your first robot report

Or the more interesting, make sure the Sharp is still in, hook a speaker up to pin 1, and then program this:

 

noise:

readadc 0, b0

sound 1, (b0, 2)

goto noise

 

Attached is the program I used to make the videos :)

Ce ya!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

By Korel@ Wed, 2010-11-24 04:11

comment_control

Threaded list - expanded

Date - new est f irst

50 comments per page

Save settings

Page 40: How to make your first robot report

Hi, if instead of connecting

Login or register to post comments

Hi, if instead of connecting a speaker I connect a piezo,will I have to use the Darlington chip as well?

Would it damage the MCU if it is connected directly to the resistor array?  Thanks

By TeleFox@ Wed, 2010-11-24 05:42

The Darlington array won't

Login or register to post comments

The Darlington array won't be able to drive a piezo very well at all by itself, since it can only drive an output low - piezo's need to switch between high and low to work. Fortunately piezo speakers are super-low power devices, so you can safetly connect it directly to one of your micro's outputs, or connect it via the resistor array.

By Korel@ Wed, 2010-11-24 14:43

Thanks for your quick and

Login or register to post comments

Thanks for your quick and kind answer Telefox, I just tried the piezo and 2 LED and it worked ok for a few minutes but now the robot is acting weird. I will try to make a few changes inside the code and see if the outputs are ok. Picaxe 28x1 supports LED according to the datasheet. Thanks again :)

By rik@ Wed, 2010-11-24 15:08

series capacitor

Login or register to post comments

You might have better results with a capacitor in series (between output pin and buzzer). 100 micro Farad or more will do it. Those size tend to be polarized, but in this application that makes little difference.

Page 41: How to make your first robot report

By Korel@ Wed, 2010-11-24 17:38

Thanks rik.  Polarized

Login or register to post comments

Thanks rik.  Polarized electrolytic?

By Korel@ Wed, 2010-11-24 21:50

Thanks again guys :)

Login or register to post comments

Thanks again guys :)

By rik@ Wed, 2010-11-24 17:59

electrolytic

Login or register to post comments

The word electrolytic only refers to the kind of dielectric between the capacitor's "plates". But yeah, those are always polarized. That means that you must obey the plus/minus signs for the leads. But this application has no high/low sides for the cap. So forget about it. Just this once.

By fritsl@ Wed, 2010-11-24 21:23

yes

Login or register to post comments

yes

By robotmaster18@ Wed, 2010-11-03 21:43

Page 42: How to make your first robot report

bluetooth

Login or register to post comments

can you somehow connect a bluetooth module to the picaxe to controll it from a pc a cell phone just wondering.

By fritsl@ Wed, 2010-11-03 22:30

Yes, no problem.A) Find the

Login or register to post comments

Yes, no problem.

A) Find the bluetooth module that you would like to use

B) Connect it - and if problems

C) Read the manual. If still problems: Please post a seperate forum post with the questions.

:)

By robotmaster18@ Mon, 2010-10-18 01:05

problem

Login or register to post comments

ignoblegnomethe problem is the code fritsl posted for the SR05 it is not working

By ignoblegnome@ Mon, 2010-10-18 16:05

Page 43: How to make your first robot report

If the code is not working

Login or register to post comments

If the code is not working for you, then something is probably wrong with your set up.

Instead of posting to his forum, please post a new forum question. Provide detail on your set up. Pictures and diagram help. The better information you provide, the better we can help you.

By fritsl@ Mon, 2010-10-18 08:24

A) If you want to reply to a

Login or register to post comments

A) If you want to reply to a comment, click "Reply", not "Post new".

B) I know for a fact that the code is working, as I am using it frequently myself - I look at that page and copy the code every time I have to hook up an SRF05, and that is often :)

By The_Black_Cat@ Sun, 2010-10-17 15:50

How would I hook up a ldr

Login or register to post comments

How would I hook up a ldr

By fritsl@ Mon, 2010-10-18 08:28

This question should be in a

Login or register to post comments

This question should be in a seperate forum post, but the answer is here:

http://letsmakerobots.com/node/1833

:)

Page 44: How to make your first robot report

By The_Black_Cat@ Tue, 2010-10-19 01:12

Thank you

Login or register to post comments

Thank you

By Rahul ANAND@ Sun, 2010-10-17 05:30

does my robot speak

Login or register to post comments

can i make my robot speak specific words.

By rik@ Sun, 2010-10-17 10:53

search

Login or register to post comments

search our site for "speech" or "mp3"

you will need some extra hardware

By robotmaster18@ Wed, 2010-10-13 23:34

programming

Login or register to post comments

the problem is i suck at programing and i wanted to add an sr05 sensor but cant make the code

By ignoblegnome@ Fri, 2010-10-15 17:19

Page 45: How to make your first robot report

Fritsl still has you

Login or register to post comments

Fritsl still has you covered, with this walk through on connecting the SRF05 to the Picaxe-28 project board.

By rockinruler@ Sun, 2010-10-17 05:57

LMR is thah best!

Login or register to post comments

LMR is thah best!

By rockinruler@ Tue, 2010-10-12 08:53

Great tutorial

Login or register to post comments

First of all, I'd like to thank you for posting the tutorial on behalf of the  masses that have come and learnt from here!

Awesome job!

 

There's one thing I wanted to ask. The components are, not extremely, but a bit expensive.

So after I'm done making this bot, what are the other things I can do to take it to the next level ? Like, can I make the bot go wireless or something like that ?

If yes, are can you tell me where can I look on the site to search for things that I can do after building this bot ?

 

Thanks a lot for looking and once again, thank you very much for the magnificent and concise tutorial.

By rik@ Tue, 2010-10-12 10:30

Page 46: How to make your first robot report

The next project using the same components

Login or register to post comments

This tutorial was written (and painstakingly maintained) by Frits as an introduction into robot making. After this project you should have a good idea of what you like about it and what you don't like (as much).

It could be programming. The next logical step would be to reprogram the existing hardware. Give it different behaviour.It could be mechanical building. With little extra hardware you could expand the robot.It could be electronics. Add anything you like. Or make it all work better.

There are no ready made tutorials for all these different paths. But our website is full of inspirational ideas and friendly people wanting to help you.

Although, if you follow this tag link: How to make your first robot, you might find two more fine tutorials by Frits.

By rockinruler@ Wed, 2010-10-13 13:27

Thanks

Login or register to post comments

But our website is full of inspirational ideas and friendly people wanting to help you.

That is very motivating. Thank you. I will surely check the links out :)

By fritsl@ Tue, 2010-10-12 19:17

Thank you, my wingman and

Login or register to post comments

Thank you, my wingman and very talented person rik :D

And just to follow up, rockinruler: You can get many extremely cheap components, like a radio-control for USD 2, or an LED or a servo or.. mix it all with your imagination, and you can make a ton of new robots from the "Start here-kit". Most of my own, and many, many more robots use just these, and a few extra parts. But you can also go the other way, and spend a lot of money - all up to you.

Start doing the first one, and take it from there :)

Page 47: How to make your first robot report

By rockinruler@ Wed, 2010-10-13 13:28

Thanks

Login or register to post comments

Point noted :) Thank you

By robotmaster18@ Fri, 2010-10-08 00:22

so i can put the comments

Login or register to post comments

so i can put the comments you said in the editor

By fritsl@ Mon, 2010-10-11 12:44

What? I do not understand if

Login or register to post comments

What? I do not understand if this is a question or what it is.

By GranTotem@ Tue, 2010-10-05 02:06

Navigation

Login or register to post comments

Great Robot,

Page 48: How to make your first robot report

First of all I would like to thank you for making this guide.

I have been able to succesfuly build it but found one problem. My robot goes forward for about 2 seconds then stops looks around and starts spinning like crazy for about 6 seconds.

Then it repeats, goes forward 2 seconds then backwards 2 seconds then stops looks around and spins.

I checked to see if the code was the same and it is, any ideas of what could be wrong?

By fritsl@ Tue, 2010-10-05 07:43

Sounds like you skipped this

Login or register to post comments

Sounds like you skipped this part: " if you inserted the right parameters for high/low to suit your wiring to the motors"

By GranTotem@ Tue, 2010-10-05 22:13

Thank You for your help

Login or register to post comments

Thank you so much, you have just solved my problems

I had mixed the wires fromm the motors and now that i fixed that eveything is OK

Now one last thing, if I wanted to add an LCD would I add the code before the subrutines or after them?

By Renosis@ Tue, 2010-10-05 23:15

Correct me if I am wrong,

Login or register to post comments

Correct me if I am wrong, but I think you mean LED not LCD. If you want to add an led, you can put the command any where, depending on what you want it to do. Say you want it to be lit up when ever the robot is on, just put it in the beginning. But say you want it to turn on when he is scanning for best path, you would put it under the begining of that sub routine, and then have it shut off at the end of that sub routine. By GranTotem@ Wed, 2010-10-06 00:08

Page 49: How to make your first robot report

LCD

Login or register to post comments

No, I mean an LCD (Liquid Crystal Display)

I want to display, texts, maybe temperature in a screen

Anyways thanks for the tip on hte LED it would be nice to add one

By Renosis@ Wed, 2010-10-06 10:23

Yeah, I was almost certain

Login or register to post comments

Yeah, I was almost certain you meant LED, but I stand corrected. The reason I thought you meant LED is because LCDs are much harder to setup. It would be pretty ambitious to try to set one up at this skill level, best to take small steps. But if you have the confidence that you will be able to do it, then by all means go for it. When i finished my start here robot, I built it again, with a chassis. Then I added a power switch, then I added an LED. Then I played around with better programming, to get it to react differently in various situations. Then I moved on to a robotic arm, and it was a little beyond my skill level. i wasted alot of time and money on that one and eventually dismantled it. Learned alot though. But it was a little discouraging. So now I am working on a simpler project, To try and learn more of the fundamentals, so I actually know how to go about doing things the right way and knowing how to ask the right questions. By hardmouse@ Mon, 2010-11-15 17:32

I hope there's "LIKE" button

Login or register to post comments

I hope there's "LIKE" button in LMR as Facebook! LOL!!!

By fritsl@ Wed, 2010-10-06 10:41

Page 50: How to make your first robot report

Excactly! :)

Login or register to post comments

Excactly! :)

By fritsl@ Tue, 2010-10-05 22:55

Cool that the problem is

Login or register to post comments

Cool that the problem is solved :)

Regarding the structure of your code; That is entirely depending on what you want to do. My best advice is to start by making one thing work at a time. it can never be said enough times. When one thing is working, add the next little thing. Make sure it works, add the next.

There is no rule of the structure as such, people do it different, you will have to find your own ways, using the above procedure, one step (small) at a time :)

And a note; Working with serial is not a good beginners task! There is a lot to learn, it is not easy!

By GranTotem@ Wed, 2010-10-06 01:14

Thanks :)

Login or register to post comments

Now that you mention the dificulty, I have two LCD´s, what would you recommend the PICAXE AXE033 (their serial LCD with clock)

or a basic 16x2 Character LCD.

Again thanks alot for your help :D

By fritsl@ Wed, 2010-10-06 06:31

Seriel or parralel is your

Page 51: How to make your first robot report

Login or register to post comments

Seriel or parralel is your question here. And there is no reason to chose paralel. However, Seriel is, as said, not a good idea for a beginner. Go for the LED instead. One step at a time.

By DanAKAHollywood@ Sun, 2010-10-03 02:21

PICAXE Problems

Login or register to post comments

My PICAXE, provided in the bundle, is giving me a few issues. I can program it just fine but the motors and servo do nothing. When I first apply power, the servo turns a bit and then goes dormant. The Sharp however does work fine when viewing the debugger. Servo is connected to pin 0 with the ground on the outermost pin and power on the center pin. I can post a pic if needed.

By fritsl@ Sun, 2010-10-03 22:58

Sounds like you should have

Login or register to post comments

Sounds like you should have a look at the V2  - http://letsmakerobots.com/node/75 - I think something is not hooked up right on your board. And Servo and Motors both get from V2.. or from V1, if you have the little jumper on the right place.

If you are not sure what I am talking about, post a picture of your board, and we can tell from that.

By DanAKAHollywood@ Mon, 2010-10-04 00:21

Thank you

Login or register to post comments

Hey, buddy, thanks for the reply. I had a good look at my ICs and found out that I had my resistor array and my driver in the opposite slots. The 4116R that is provided in the bundle is black and I wasn't paying enough attention when I inserted it. Everything is good now except that the little bot drifts to the right a bit. I am going to modify the code and try to have him use self-corrective steering to an extent.

By DeusExMachinae@ Wed, 2010-09-29 03:33

Page 52: How to make your first robot report

Built this today

Login or register to post comments

Hey all, been building this for the last two days and finally completed it today. Was a really fun build, not without challenge for someone whos new to robotics!

Its been very useful, but two things.

One of my wheels is not only spinning slower than the other by a small margin, but also appears to not be seated correctly, wobbling at a strange angle. This forces the robot to turn left rather than travel in a straight line.

While not drastic, anyone know an explanation? Ive eliminated the wheel being screwed in too tightly, and my own suspicions lie in a dubious connection to one of the motors. Ive already tried unscrewing it and rescrewing it with no success.

Even with this small problem, the robot is working VERY well, and i expanded on the base code so it could travel at shallower angles and navigate beter than with the base code posted.

The code posted in the tutorial i found difficult to read, so for those who struggle with programming or the logic involved ill post my first version (one before current) which i believe is easier to understand.

One thing to note, is that you may need to play around with servo angles. Mine was centred at 160, due to me unable to get the servo to centre correctly. It works fine for me, but you might need to play around with the numbers, and mess with the order of high/low to get your motors spinning the correct way.

 

Dont be afraid to mess with smaller test programs first, testing each wheel etc.

Symbol dangerlevel = 80 ' how far away should obstruction be before robot reactssymbol turn = 300 ' by how much should the robot turn?symbol servo_turn = 700 ' how long does the robot wait after turning the servo before continuing?

main:

    servo 0, 165

    readadc 0, b0 ' scan ahead!        if b0 < dangerlevel then        gosub wayclear ' if path is clear, continue on        gosub whichway ' if obstacle ahead then decide which way is clear    end if        goto main

wayclear:

    low 4 : high 5 : low 6 : high 7        return

whichway:

    gosub fullstop

Page 53: How to make your first robot report

        'Scan left:                gosub lturn ' look to the left                pause servo_turn ' wait for the servo to be finish turning                readadc 0, b1                gosub fullstop            'Scan right:                gosub rturn ' look to the right                pause servo_turn ' wait for the servo to finish turning                readadc 0, b2                gosub fullstop              'Right or left? Which way is clear? Rmbr that lower values = further away                if b1<b2 then                      gosub body_lturn                    else                    gosub body_rturn                    end if                return        rturn:    servo 0, 110 ' look to the right    return

lturn:    servo 0, 210 ' look to the left    return    body_lturn:    high 4 : low 5 : low 6 : high 7    pause turn : gosub fullstop    return

body_rturn:    high 5 : low 4 : low 7 : high 6    pause turn : gosub fullstop    return                  fullstop:

    low 4 : low 5: low 6: low 7        servo 0, 165        return

 

Page 54: How to make your first robot report

Thanks again, hope thats been useful to someone. If i borrow a friends multimetre and discover a greater resistence on one motor, ill post. In the meantime, if anyones got any theories dont hesistate to reply.

LMR bundle was great.

 

By Solarbotics@ Wed, 2010-09-29 19:56

Solarbotics Motors

Login or register to post comments

Hey guys!

Renosis hit it right on the head - If you're having problems with the motors, the best way to test them is to just hook them up right to a battery (a 9V cell works great). If your motors don't match in speed, then you've probably received a defective unit. Try giving a shout to [email protected] and relay the details of what is going wrong. Our tech will check over a few different problems/solutions, and if it can't be easily fixed we'll replace it for you at no charge (shipping and everything!).

Sorry about the problem, guys. We do our best to screen for busted motors, but the odd one still manages to sneak through. If you suspect one of your parts is broken please feel free to get in touch with us - we hate getting defective components as much as you do.

By DeusExMachinae@ Thu, 2010-11-11 16:13

Thanks for the replies

Login or register to post comments

Just replying to say thanks for the replies, thanks for helping out a mostly clueless newb to robotics :).

Still no luck on getting the motor to run at the same speeds in my current setup, but since its my first robot and its not a major issue or speed difference im pretty content on living with it for now.

Im already planning my next project, and ill post it up when its done. Some kind of concoction of the first and a tracked robot we ll  see how it comes out!

Thanks for replying solarbotics, I have my purchase information so i might just get in contact when i begin to cannibilise my starter bot and have no luck on directly testing the motors. If ive gone over whatever timeframe thats acceptable for a return, then its fine - the bundle was a great package, and a great service was provided overall. WIll definetly be ordering more stuff when needed.

Until then, thanks all.

By Renosis@ Wed, 2010-09-29 17:53

Page 55: How to make your first robot report

Congrats on your first robot.

Login or register to post comments

Congrats on your first robot. I built the starter robot too and had the exact same problem with one motor being slower than the other.  I thought a million different things at different times as to what caused it. I originally thought it was my piss poor soldering job. With all the troubleshooting, I eventually just ended up making it worse. Eventually I bought new motors. Never rebuilt my starter  bot though, felt like I wouldn't learn anything new after the fifth rebuild. That one slow motor was the only thing that really gave me any problems.

 

A good way to test the motor, is too hook them up straight to a battery. If one still turns more slowly, the motor is almost certaintly no good. It is easier to tell how fast the motor is going with the wheels on, but to make sure that your wheel isn't screwed on too tightly and causing problems, you can remove them (not sure if it is even possible to cause problems by screwing it on too tight). I was able to still see the difference with no wheels connected. Also, use your ears, my broken motor, just didn't sound right at all compared to the good one. 

By ignoblegnome@ Wed, 2010-09-29 04:05

Hey, there. Congrats on

Login or register to post comments

Hey, there. Congrats on building your first robot. Go ahead and post your own robot page with your creation! Time to show us what you've done. Share pictures and video if you can.

By The_Black_Cat@ Sun, 2010-09-26 14:04

Hey I can't wait for the lmr

Login or register to post comments

Hey I can't wait for the lmr bundle to arrive

 

 

By rik@ Sun, 2010-09-26 17:30