Google+
Showing posts with label robot. Show all posts
Showing posts with label robot. Show all posts

Monday, 16 June 2014

Line Following Robot

This is a Line Following Robot. It follows a black line that is drawn. It is able to detect the black line through one photocell and one analog light sensor. There is an LED in between the two sensors that gives off red light when the Arduino is powered on. Then, when the light is reflected back, more light is detected when it is reflected on the white surface, compared to when it is reflected on the black surface. Using this, the right and left servo motors move accordingly to turn left or right when the sensors detect white surface rather than black. I used the Parallax BOEBot Robot for Arduino Kit as my base for the robot. Then I placed a breadboard in front of the base to attach all the sensors with the LED to face the black line.
Follow these steps, and you will be able to build your own line following robot! :)

Step 1: Step 1: Parts

Parts needed:
  1. Arduino
  2. Motor Shield (https://www.adafruit.com/products/1438)
  3. LED with 100 ohms resistor
  4. Photo cell with 1K ohms resistor (https://www.adafruit.com/products/161)
  5. GA1A12S202 Log-scale Analog Light Sensor (https://www.adafruit.com/products/1384)
  6. A base for the robot with 2 wheels attached to servo motors ** I used : Parallax BOEBot Robot for Arduino Kit (https://www.adafruit.com/products/749)
  7. A breadboard
  8. A battery with a battery holder
  9. Black marker or black tape with white papers
  10. Tape to tape all the parts together
  11. Wire to connect all the parts (also jumper wires)

Step 2: Step 2: Assemble 1

First, hook up all the sensors!
Connect the photo cell. One end should go to power and the other should connect to the 1K ohms resistor. Then, on the side with the photo cell and the resistor, connect to the analog pin. Next, connect the other end of the resistor to ground. Then connect the LED with the 100 ohm resistor on the breadboard. Finally connect the light sensor to the breadboard according to the label: ground, power, and one analog pin. Then connect all the wires with jumper wires to the Arduino. Make sure that your jumper wires are long enough to reach the Arduino on the base of the robot.
Second, attach the breadboard to the base of the robot.
I used tape since I couldn't really think of anything else, but you can use anything if it is going to be able to attach the breadboard (facing down) to the robot. Then, use more tape to organize the jumper wires.

Step 3: Step 3: Assemble 2

Third, prepare the base of the robot with the motor shield.
I had to screw in the servo motors to the right position. Then, screw in the wheels on the servo motors. To attach the servo motors, find the two servo pins on the corner of the motor shield. Connect the servo motors to the 2 pins. Note the servo number written on the motor shield according to which side of the motor it is attached to (right or left). Then organize the wires around the base so it would not get in the way of the wheels.
Lastly, make the track for the robot.
I used a black marker that I previously owned to draw the black line. To make the line more precise, I first taped the track with the tape that I owned, then I colored the tape with my black marker. Then, I taped the different white papers around to draw a semi-circle track.
Now, you are done! :)

Step 4: Step 4: Code

When working with the code, you will need to adjust the values for the photocell and the light sensor to change directions. To do this, just place the robot with the sensor (comment out the 2 lines of code to attach the servos in the setup) and check the values of the photocell and the light sensor when it is in the middle, right, and left edge of the black line. Then, change the values of the code accordingly for moving the servo motors.

Step 5: Step 5: Move!

When watching at the video, you will notice the Altoid tin that is taped on the Arduino. This is merely just to balance the weight between the breadboard in the front and the Arduino in the back. When the Altoid tin wasn't taped, the robot constantly tipped towards the front when moving.
I hope this was helpful! Have fun building your own line-following robot. If you have any questions or comments, feel free to leave a comment or inbox me! Thank you!
Read More


Sunday, 22 December 2013

Android controlled robot

Based on DFRobot 4x4 robot.
Controlled using Android phone via bluetooth.
As well as being remote controlled by a phone, also has a mode that will search out light.
Because every robot needs flashing lights have LEDs that flash and have no real purpose.
Includes a claw on a pan and tilt that is also controlled by the Android phone.
Using three micro-controllers connected via i2c:
- Romeo by DFRobot came with the robot kit, used for driving the wheels and comms.
- Arduino for display (LED's and LCD display)
- Arduino for controlling the claw.

This is one of those projects that seems never to be complete, the more you work on it the more you think about how you can extend it or make it do more.

Step 1: Assemble Kit platform

Start with the DFRobot 4WD Arduino Powered Mobile Platform with Romeo. http://www.dfrobot.com/index.php?route=product/product&path=37_69&product_id=116 .  I managed to find this and most of the other pieces from http://littlebirdelectronics.com/ if you are not in Australia I am sure there are plenty of web sites you could pick them up from.

Unpack and assemble the base kit.  There are a few choices to make.  I chose to put the wheel encoders on the rear wheels, although it probably does not matter.  I also found the 45mm standoffs to be very excessive, I have some 5mm standoffs so I used them.  The longer standoffs will come in handy later.

I plugged the left encoders into digital pin 2 on the Romeo, and the right encoder into digital pin 3.  The reason being that is where the interrupts are connected on an Arduino.

Next to the power connectors connect the "VIN=M_VIN" this will save you connecting a second power supply.

Ensure all the jumpers are set so that the Romeo uses pins 4, 5, 6 and 7.

The first thing I noticed with this is the battery pack has 2 issues:
1 - When the batteries get half flat they don't have enough grunt to be useful, making 1.2v from rechargeable batteries completely useless.
2 - Changing the batteries is a pain in the neck.

To overcome this I utilised a battery pack that takes 6 AA batteries that I had from a previous project.  This can be mounted behind the rear wheels and held in place with Velcro.

Step 2: Sensors and mounts

The DFRobot kit did come with sensor mounts, however there was not many of them and I was unsure how to use them.  So I decided to make my own.  At Bunnings (large warehouse hardware store here in Australia) I found aluminium angle bends, they came in 1 meter (40") lengths with 10mm (3/8") edges.

I bought 1 length, and using a hack saw chopped it into 25mm (1") lengths, using the sensor mounts that came with the kit as a guide.  Still using the kit mounts as I guide I drilled three holes that will take a M3 bolt.  Then used a grinder and a file to take of the sharp edges.  I made a whole heap of these for future use, however thus far I have only needed 8 for this project.

I bought 2 distance sensor - http://www.pololu.com/catalog/product/1134 .  Using two of the mounting brackets I made and some double sided tape I attached them to the from of the robot, then connected them to digital pin 11 (left) and digital pin 10 (right).  These sensors will allow us to stop the robot running into things, it will also enable us to make the phone vibrate when we get close to things.

Then bought 4 protoboards - http://www.sparkfun.com/products/8886 , 4 X orange LEDs, 4 X 330 Ohm resistors, 4 X 10K Ohm resistors and 4 X light dependant resistors and some header pin outs to make a 4 boards that have a combo of LED and a light sensor.  Originally I used double sided tape to mount these on my mounting brackets, but they kept falling off so I decided to use silicon to stick them on.  Really hot glue might have been a better option, but I don't have any.

The LEDs are just for show and we will come to them later, the light sensors are so we can put the robot in light sensing mode and it will search out light.  So they should be mounted on the sides, as far forward and back and forward as possible.  I also bent the light resistors so they faced out.

Step 3: Romeo shield

Next I needed to make a protoshield, so I got myself a five pack from Freetronics -http://www.freetronics.com/products/protoshield-basic
Note you will still need headers, and optionally capacitor, LED and resistor.

For connecting to the Android phone so we need to add bluetooth, I got one of these - http://www.sparkfun.com/products/582 .  This by defaults waits a long time at start up, this can be changed, and I suggest you do, read the doco on the product you get to find out how.

When the bluetooth is connected to pins 0 and 1 it gets in the way and prevents you programming the Arduino.  The answer to this was to connect the bluetooth power to one of the digital out pins, as the digital pins on a Arduino cannot supply enough amps to power the bluetooth I used a PNP transister as a switch that will turn the bluetooth on and off using the digital pin out.  For this I chose pin 12.

I wanted to know how much charge was left in the battery, so I used a basic voltage divider circuit and analogue pin 0 to to find out how many volts up to 10V the batteries are putting out.  You need two 10K Ohm resisters, put the resisters in series between VIN and GND, connect digital pin 0 to between the two resisters, this will give you a voltage reading up to 5 volts.  Simply double the value and you will have how many volts on the VIN. Alkaline batteries will give almost 1.7 volts when brand new and 1.1 when they are flat, the maths is pretty simple to calculate how much is left in the battery.

I thought while I am checking the volts I might as well check the amps, so I foundhttp://www.pololu.com/catalog/product/1185 and connected it to analogue pin 1.

Lastly I wanted the robot to have the potential to have different modes, to switch between modes I needed a button that when pressed will cycle through the options.  The Romeo does have 7 buttons connected to the analogue pins, however I have used all of the analogue pins for other things, so I needed to add another button to digital pin 8.

Step 4: The upper platform

I needed another 2 Arduino's to be mounted somewhere on the robot.  I found a small sheet of aluminium in a clearance bin at Dick Smith.  I needed to cut it down in size with a jigsaw.  I then marked and drilled enough holes to mount it, and to mount 2 Arduino's on top.

I would have mounted with 5mm standoff brackets, like I did with the microcontroller on the robot base.  However I run out of them, what I did have was a plastic chopping board I picked up from the Reject shop.  I heard these were great for building robots, so I thought I should give it a go.

Before you mount the upper platform I suggest you connect some jumpers to VCC, Gnd, A5 and A6, because they will be a lot harder to plug in later.

Step 5: The Lights

IMAG0220.jpg
There was absolutely no need for it, but I felt the robot needed some lights that will flash.  We have already mounted 4 of them with the light sensor, however we have not wired them up yet.  Also Cylons have them, KITT have them, so I figured I also needed red lights moving from side to side.

This is simply 10 X red LEDs and 10 X 330 Ohm resistors.

Now we get another one of the protoshields we used earlier and mounted two 74HC595 chips on it.  Refer to the Arduino tutorial for the circuithttp://arduino.cc/en/Tutorial/ShiftOut .  I used digital pin 11 for ST_CP (latch pin), pin 12 for CH_CP (clock pin) with data on pin 2.  I also set aside pin 3 for future expansion it could be used on a second set of 74HC595 chips if needed in the future.

Into the first chip connect the LEDs on the light sensor protoshield.  Left front is pin 0, right front is pin 1, left back is pin 2, right back is pin 3.  Pin 6 and 7 of the first chip goes to two of the red LEDs along with the 8 pins of the second chip.

Lights were fun, but seeing what is going on a LCD screen also comes in handy from time to time.  One of my work mates gave me a box of old stuff he was no longer using, in it was a 4x20 LCD display (Thanks Sebastian).  Using the circuit at the Arduino tutorial I built another protoshield -http://arduino.cc/en/Tutorial/LiquidCrystal .

These boards get piggybacked on top of each other and placed on the one Arduino.

Step 6: The claw

Looking at the large square hole in the front of the robot, you have to ask yourself what goes here.  The answer is http://www.dfrobot.com/index.php?route=product/product&path=46&product_id=146 .  (Thanks to Maddy at LittleBird how went to a bit of trouble to get me one of these http://littlebirdelectronics.com/ )

Once the pan and tilt kit is in, it needs to have something attached to it.  There is only one possibility - http://www.sparkfun.com/products/10332

Now you can probably guess what the last Arduino is for.  So time for another protoshield, this time one that I already had lying around with a mini breadboard on top.

Only catch here to be aware of is the servos draw too much power to run of the Arduino 5V VCC power source.  The answer is to use the VIN pin on the Arduino and put it through a 7805 voltage regulator.

I wish somebody had told me how to put the tilt and pan kit together with the claw, I ended up doing it several times before I worked out how to do it.  So here are the important steps in order to avoid rework.
- Put the server into the robot
- Assemble the tilt and pan kit without the servo
- Attach the claw with its servo to the tilt an pan kit
- Attach the tilt an pan to the servo on the robot
- Insert the final servo.

The other big hint is ensure the servo has the full range of motion you wish it to have as you place each servo.  Note you may have to tweak the code to find the centre position of each servo once assembled.

I connected pan to digital pin 9, tilt to 10, claw open and close to 11.

Step 7: Final steps

The three Arduinos need to be connected together.  Ensure the VIN, VCC, GND, A4 and A5 pins are linked to their respective pins on all the Arduino boards.  The first three probably make sense without much explanation, the A4 and A5 are because the boards communicate using i2c which needs these two pins to be connected.

The three boards require their own software:
- the Romeo board gets loaded with the botCntrl2 sketch
- the Arduino that controls the LEDs and LCD gets loaded with botDisplay3 sketch
- the Arduino connected to the pan, tilt and claw gets loaded with the clawControl sketch

To control it all from your mobile phone, you need an Android 2.2 device with accelerometer and bluetooth, and load the botControl application.  To compile this up you will need to set up your development environment by following the instructions on the Android development web sitehttp://developer.android.com/sdk/index.html .  For those not brave enough, the .apk file is included in the bin directory, load this to your phone and run it, it will install the app for you.

To set up you phone after you install the software, on the phone you will need to pair the bluetooth device,  that will be in the phone settings.  Start the app, press the menu button and choose settings, you will need to set which bluetooth device you are connecting to.  You only need to do this once.

Once the app is set up, there is a connect option available when you press the menu.  On screen you should have a button that will toggle between go and hold, and a button that will toggle between controlling the wheels and controlling the claw, plus some buttons to open and close the claw.  Tilt the phone back and forward to move back and forward or control the tilt of the claw.  Tilt the phone phone left and right to move the robot left or right or the pan the claw.

Step 8: The future

There seems to be always something else I want to add to this robot.  Currently the things I would like to do are:
- Controlling with a wii nunchuck would allow moving robot and claw at the same time.
- Instead of dedicating full Arduino boards I could mount just AtMega328P microcontollers and save a lot of space.
- I would love to put a camera on it (both normal camera and infra-red camera), don't know how as Arduino is not powerful enough to drive a camera, and the bluetooth probably isn't quick enough either.
- There really needs to be more distance sensors on the front as it is easy to miss things that are between the sensors.
- The software on the phone has been written so that it should be easily converted to run from a PC.  Would like to do this, however still thinking about the best way to do the user interface.
Read More


Join Us

//go.ad2up.com/afu.php?id=25365

© Copyright 2012, Design by Lord HTML.
​