Sunny Affairs

Rolling the Spaughts!!

Friday Apr 04, 2008

This post will get you started to build your own applications with Sun SPOTs, in case you haven't started yet.

I received a Sun SPOT kit in the month of February. I had been badly waiting to get my hands on the Sun SPOTs, and it took me no time to unpack it and try out the Bounce demo which it is preloaded with. I had a little trouble to configure Leopard cause quite a few things have changed from Tiger. But after spending some time with the SunSPOTWorld forum, I managed to get it running on my Notebook. Soon enough I decided to make a small Sun SPOT controlled car, maybe because it is one of the easiest and fun-filled application. Thankfully Anil had also made a car and blogged about it.

I soon contacted a few of my friends (Jyotirmoy and Rupak) and started off with the project as soon as one of them got over with his GRE exam. There were a few goals that I had set for this project. Firstly, it should be different. Of course, when you use a Sun SPOT to build any kind of robotic application, it does end up to be different. But in this case I wanted to make it a lot smaller than the other robotic moving vehicles that others in my college have developed before. Secondly, I wanted this robot it run on 3 wheels, like an auto. Most of the robotic cars have four wheels because they are heavy and unstable on three wheels. Also, I wanted to incorporate speed variation in this car. I wanted to be able to speed it up and slow down as an when required. Now most of the cars that the students of my institute make is used for robo-wars and similar contest, and thus they end up being big and bulky. Usually they weigh around 2 kgs. My final goal was to be able to close the SunRoof even after this project, which means I should not be soldering any wire to my SunSPOT, because I got only one.

To make the car small and light, we decided to use only one motor to drive both the real wheels. Also we had the speed variation in mind, so we purchased a 500 rpm geared DC motor that can work on a voltage range of 6V to 24V. Also the motor had a good torque. We used a L293D current driver to drive the motor. Since the car is going to be small and light, we decided to use big rear wheels that would help it move on many surfaces. I also purchased a small toy bike for the front wheel and a stepper motor (PM25L-024) to give it a precise left and right turn. Also to drive the stepper motor we purchased a ULN2004 current driver. Thankfully, this current driver was able to drive the stepper motor with a 9V cell and a 3V control signal from the D0-D4 lines. Speed variation was a tricky part. I had purchased a motor controlled potentiometer to vary the voltage input to the DC motor, but since this component is very bulky, I did not want to use it. Eventually, Jyotirmoy found a way to vary the speed of the DC motor using a PWM input and varying it duty-cycle. Sun SPOT sdk also gives a easy function setPWM() for a PWM output on the I/O pins. Anyways everything worked out and here is our car:



It weighs about half a kilogram and has a turning radius of about 8 inches.

Perhaps the most difficult part was to use this setup without soldering anything with the Sun SPOT. I was unable to find any solder-less connector in the market, so I had to do lots of hit and trial. What finally worked out really well is this: I purchased a 20-wire ribbon with a 20 pin female connector at the end of the wire. For the Sun SPOT, instead of using a 20-pin male connector, I used 2 10-pin male connectors. Using pliers I bent the pins and then forced them into the female connector. This made it firm and also kept a firm connection with the eDemo board. There is neither any slipping, nor any loss of connection. It worked out brilliantly. This is how I did it:




Here is the schematic (click to enlarge):



And finally here is the source code. I have used multithreading to make sure everything runs seamlessly including the light indicators and the communication. Before running the code, make sure you replace the mac addresses in the code with the one you are using. The Client.java acts as the remote, while the Server.java acts as the car-controller. Do point out any scope for improvement.

Find more pictures of the Sun SPOT controlled car here.

[2] Comments
Like this post? del.icio.us | furl | slashdot | technorati | digg
Comments:

Good work Souvik, So when will you be deomonstrating it in college.

Posted by 59.94.244.38 on April 05, 2008 at 11:57 PM IST #

I have already demonstrated it in College on 1st April. I was holding on to my blog post, cause I wanted to demonstrate it first before putting it on my blog.

Posted by Souvik Das Gupta on April 06, 2008 at 11:37 AM IST #

Post a Comment:
  • HTML Syntax: NOT allowed