Just call it a “DistanceHat”…

[Update: 06/01/09]

- Added the source code to my Arduino sketch
- Found some interesting info on linearising the output from the sharp sensors
- Hack-a-day has an article on the very same subject
- I found the SensorWiki - What a great site!

So…

  1. You can’t buy any new parts
  2. You can’t be bothered getting your robot driving around the house
  3. You want a ‘quick win’ to make you feel better about going back to work tomorrow
  4. You just happen to have a Bare Bones Board Arduino clone and an old Sharp infrared distance sensor sitting around

What do you do? Well if you are me you first make this thing and then make a youtube video about it because one of your New Years Resolutions was to “get famous” hehe :)

Anyway, introducing the SUPER-INFRARED-DISTANCE-SENSING-HAT-MO-TRON! — Otherwise known as the DistanceHat.

This is not a difficult project. In fact it is perfectly suited to people starting out with microcontrollers who want to get something done and possibly impress their parents with how smart they are (in my case I told my fiancé that I was curing blindess of course). It does require you to have an Arduino and a Sharp distance sensor but, man, my grandma has that stuff in her house! (Ed: she doesn’t). And anyways this is Ausrobotics, you need to get that stuff STAT!!!

 

So how does it work? Well…

The Sharp distance sensor outputs an analog voltage on its output pin that is related to the sensor’s distance to a surface. This output value seems to be non-linear (although I must admit I did possibly blow the sensor slightly while mucking around beforehand - gulp) and is more accurate at short distances. Also the distance reported can be change depending on the surface itself - reflective objects -may- return misleading values.

The Arduino (in this case a Bare Bones Board Arduino clone from Modern Device Company) reads the voltage from the distance sensor using one of its analog input pins and converts the value into a beep delay value. The distance sensor reports 0 when it is not pointing at anything and approx 600 when it is really close to it so the Arduino code maps the value from this to a more logical 100-10000 value (100 being the closest).

The Arduino basically just sits in a loop reading values from the sensor and then beeping if its loop count is greater than the last saved beep delay or if the calculated beep delay is less than the previous beep delay. The reason I didn’t just sleep() in the loop is because if you move very quickly from far away to close the Arduino may still be sleep()ing and you could run into the wall before it wakes up and recalculates the distance.

[viewcode] src=distance_hat.cpp link=yes showsyntax=yes geshi=cpp [/viewcode]
  1. /*
  2. * DistanceHat by Ashemah Harrison
  3. *
  4. * Reads a sharp distance sensor
  5. * and turns the value into light and sound
  6. *
  7. * Originally based off:
  8. *
  9. * AnalogInput
  10. * by DojoDave <http://www.0j0.org>
  11. * http://www.arduino.cc/en/Tutorial/AnalogInput
  12. *
  13. * Use anything below for anything -Ash
  14. */
  15.  
  16. int speakerPin = 8;        // buzzer pin
  17. int potPin     = 0;    // select the input pin for the potentiometer
  18. int ledPin     = 13;   // select the pin for the LED
  19. int val        = 0;    // variable to store the value coming from the sensor
  20. int count      = 0;    // loop count
  21. int mappedVal  = 0;    // converted value
  22. int lastVal    = 0;    // the last value we stored
  23.  
  24. void setup() {
  25. pinMode(ledPin,   OUTPUT);
  26. pinMode(speakerPin, OUTPUT);
  27.  
  28. Serial.begin(19200);
  29. count = 0;
  30. }
  31.  
  32. // Stuff taken from the arduino playground playtone code
  33. void playTone(int val) {
  34. digitalWrite(ledPin, HIGH);
  35. digitalWrite(speakerPin, LOW);
  36. for (count=0;count<=8;count++)
  37. {
  38. digitalWrite(speakerPin, HIGH);
  39. delayMicroseconds(val);
  40. digitalWrite(speakerPin, LOW);
  41. delayMicroseconds(val);
  42. }
  43. digitalWrite(ledPin, LOW);
  44. }
  45.  
  46. // The looooop
  47.  
  48. void loop() {
  49. val = analogRead(potPin);    // read the value from the sensor
  50.  
  51. if(val <= 3) val = 4;
  52.  
  53. mappedVal = (6787 / (val - 3)) - 4;     // this converts the normally non-linear value into a more linear value
  54. /*
  55. This value was directly taken from here:
  56. http://www.acroname.com/robotics/info/articles/irlinear/irlinear.html
  57.  
  58. Ideally you would calc one that makes sense for your sensor but I just copied this one for speed
  59. */
  60.  
  61. mappedVal = mappedVal * 100;                    // This multiplies the value to make it slower
  62.  
  63. // If the loop count if big enough OR the distance is shorter than it was before
  64. if(count > lastVal || mappedVal < count)
  65. {
  66. playTone(2000);                         // play the tone
  67. Serial.println(mappedVal);      // also output the value to the serial port
  68. lastVal = mappedVal;            // store the new value - slightly misleading name sorry :)
  69. count = 0;                                      // reset the count
  70. delay(10);                                      // slight delay
  71. }
  72.  
  73. count++;                                                // increment the count
  74. }
  75.  

The Arduino beeps using a piezo buzzer connected to one of its output pins. The code for the beeping is directly taken from from the bottom of the Arduino Playground code here. It also flashes an LED in time with the beeping for extra dork-factor. Whoooooo! I’m a robot!!!

This code/idea is exactly what you would need if you wanted to add distance sensing to your bot. Now that I have cured blindness around the world I will probably finally get around to adding sensors to Cheapo so that it can drive around the carpet and generally be useless. :) Or maybe I will continue to not do that while dreaming of building this.

Let me know in the comments or forums if you want more information on any aspect of this project.

Happy New Year (and Project)!

(and Merry Xmas as well)

Hey everyone! I hope you guys had a great break and got lots of stuff done (robo or otherwise). I could definitely do with another week before going back to work but ah well… I need to make money somehow and my investments in CitiGroup and Ford seem to not be tracking as well as I would like :)

I have been out of the country and away from my computer for most of the break but today I finally found some time to whip a project together. It’s very simple but fun and might interested someone starting out with microcontrollers (in this case it is using a “Bare Bones Board” Arduino clone as the controller) and sensors.

I’ll have to post the actual article tomorrow as I have put together a quick video intro for it and my vid software has decided that rendering black screens instead of video is the way to go.

Here’s a sneak preview of the finished project… Can you tell that I made it in 20 mins??? (ok 25 mins).

 

Whoooo!

Hello everyone! (Hi Doctor Nick!… nevermind.)

I had better post an update before 2008, not too long left in this year man!

First off, I probably won’t be updating often until next year. I don’t have much time at the moment unfortunately and have heaps on until Jan. Anyone with an account will be able to update however so feel free to jump on and wreck up the place post some great updates about your projects!

Even though I won’t be updating often I am still working on my own projectst slowly as well as following robotics everywhere. Ausrobotics is still fully operational and I want to see it grow massively in ‘09. This year was heaps of fun, the only thing we need is a more focused site and better community involvement. As always I welcome any advice, support, anything from all you guys!

Thanks to everyone that contributed over the year (and last year), next year will be even better. We may even meet up for beers! *gasp*

Site News

Hello everyone. Just a quick update with what is going on with ausrobotics this week and next.

What is going on?

First off, I know the new site is confusing some of you. This seems to be mostly because of the limited functionality available in the current forum and possibly due to the layout of the site.

The main reason I chose WP-Forum as the forum for AR was its seamless integration with the rest of the site. I didn’t want people to have to log-in twice to access the forum and then their development blogs, plus its a bit of a pain to admin two entirely separate systems. Even so, I am not completely happy with it. It keeps throwing up DB errors when I turn on certain features so I have had to disable them (you know, the useful ones like Last Posted Topics etc.).

I am thinking that migrating (again - argh) to PHPBB3 might be a winner. It’s a well known forum and those who love forums will feel right at home. The only issue is that I need a robust way of keeping the two databases in sync. I’m looking around for a solution as we speak and will keep you posted. Till then please keep posting!

 

Any Sydney-side roboteers out there?

Also, Higgsman is looking for fellow robot builders in Sydney if anyone wants to contact him. His MSN details are in this post.

 

Oh yeah, and robot legs…

Honda have used some of the technology from Asimo to develop a pair of extremely uncomfortable looking exoskeletal assistance legs. For some reason I don’t like the groin grabbing aspect of them although it *would* be great to have an instant chair wherever you went… :)

[via Artificial Intelligence and Robotics]

New Stuff

Welcome to the new people m3t304a and chusai who have just joined the site!

I appreciate you taking the time to register guys. Feel free to ask any questions you might have or start blogging about how you are going with your own projects. Actually that is something I need to do as well! :)

I have enabled two new plugins on the site to help you get posting quicker.

1) Easier YouTube, Vimeo, Google Video, etc embedding

The site allowed embedding of videos previously by clicking on the ‘Add media’ buttons in the Post editing page but it wasn’t actually embedding the vids properly (which was mega annoying). Now to embed youtube videos into your site you can just use a shortcode (left and right square brackets with some stuff in between) as explained here: http://wordpress.org/extend/plugins/video-bracket-tag/

2) Lighter Menus Plugin

This plugin simply turns most of the Wordpress admin menus into easy to access drop-down menus. That means you get writing quicker! Most of you probably haven’t even noticed these yet, I bring it up so you know what to hassle me about if anything breaks.

 

In other news… This is why we do this, people. Never forget. :)

In Review

Does anyone have a really large electromagnet?

It was lucky that Terminator 3 was on TV in Melbourne last night because I may soon need to know how to terminate a pack of robot hunter/killers myself if the US Army’s planned Multi-Robot Pursuit System becomes a reality. The system is designed to allow a human operator overseeing the partially autonomous robot “pack” to “to search for and detect a non-cooperative human subject.” - Minority Report anyone? Man, the Big Dog video is unnerving already and that is without pack hunting capability built in!

More from New Scientist

It’s just like a normal Servo motor. Only different.

Need to choreograph your droid’s servos to do something but can’t be bothered writing a simulator or some other control system? Matt as part of Thing-A-Day has a good new article on using a servo motor as an input device. Using a servo in this way allows you to have force feedback or to train motion as they do with industrial robots. Check it out below!

Using a Servo as an input device

Stop press! Robotics has reached it’s peak.

Ok I don’t understand what is going on in this exactly other than:

  1. It is a robot
  2. It pours beer
  3. I think it is initiated by a message over the Pownce network
  4. It pours beer

Air Fish


Awesome motion control and implemention! :) Looks like it could be remade fairly easily. Just got to keep the weight down.

Simple Solar Projects

Solar is the future so get into it now before Shell Mega Oil gets into the game and steals all of the photons. If you are new to solar and wondering how to get started with powering a small project then you could do worse than check out Evil Mad Scientist Laboratories’ new article on solar projects.
I may use some of the techniques in it for one of my planned projects, the “AutoWaterer 5000 Series - Augmented Autonomous Flora Hydration System”. Ok, it’s really a solar powered bucket of water but no-one needs to know that! :)
Check it out!

Pic of the Day

Man I love robotics :)

[Walking Chair: Evolution Hasn't Been Wasted on Places to Sit] via [gizmodo]

Using the site

Getting started with the new Ausrobotics website:

1) Sign-up for an account if you have not already done so! - Once you have signed up you can immediately start blogging about your projects on the main site and in the forum.

2) Sign-in and check out the new authoring control panel - It’s now easier to view and manage your posts and comments from one place.

3) Subscribe to the Ausrobotics feed using your favorite RSS reader @ http://ausrobotics.com/feed/. - That way you can stay in touch with what is going on without even visiting the site!

4) Start talking in the Forums - Got a question about robotics? Start asking and get answers! One thing to note is that you can now easily create forum topics from posts to get the conversation going (See the bottom of the Write Post screen).

5) Get excited because you have a lot of great new features on the way! - Event listings, Project management, member geolocation, email comment subscriptions and more. Go Wordpress! :)

Robo Japan 2008

Well it looks like we launched just in time. Robo Japan 2008 is on at the moment and chock full of robo goodness (like it could be anything else given the words that make up its title).

Lots of service robots in this one but not as many beer droids as I would like. Is there ever? :)

Robo Japan 2008 [via Pink Tentacle]

Ausrobotics II - live and in effect

I am more than happy to announce that Ausrobotics.com v2 is now live.

If you are a member please sign in and have a look around. If you are not a member yet then what are you waiting for?!

Join us today and you will receive a free gift worth more than money can buy! Ok, it’s just that feeling you get when you sign up for something awesome hehe :)

If anyone has an issue with the new site please let me know asap in the comments for this post. I’ll be working on it more during the week to iron out the rough edges.

I’ll also post some more info on how to use it, new features, etc. as soon as I can. I have just run out of time today.

 

Whooo!