Welcome to Robot Dialogs. This is a place where I will record my progress, mistakes, errors, failures, lessons learned and hopefully occasional success in my designs and implementations of robots and other technical endeavors. I will try to make it as educational, informative and entertaining as I can...

Monday, December 21, 2009

Remote Controlled Turret

This is an update and rehosting of a senior design project completed in Spring 2008 at RIT. It is (to date) my favorite robotics project. Myself and two friends collaborated to create a remote controlled turret that was accessible from anywhere on the web. The project makes use of a 5 gallon air tank at ~80 psi to fire foam (Nerf) darts. One servo operates six rotating barrels which are mounted on two more servos that provide pan and tilt movement. There are two ultra bright LEDs providing light in dark conditions for a top mounted web-cam. An Arduino is used to control the turret, while communicating (via serial over USB) with a web server that hosts the custom web page and live video stream. A modified PC power supply was used to provide the power. Here's a video of the finished turret...

Full System Test

I was in charge of most of the hardware and electrical work, Mike programmed the Arduino (I usually work with other AVR stuff) to take serial commands from a server and run all the servos, lights, etc., and Kyle got the server and client web page all sorted out.

The "update" mentioned at the beginning refers to software, since leaving school (and successfully demoing the turret on a number of occasions) it became evident that our web server based solution was very cumbersome for casual use and a pain to reinstall. So I took it upon myself to create a new JAVA GUI to use on whatever PC the turret was actually connected to (it is almost platform independent...damn you Sun for not supporting serial). I also went on to add some very rudimentary target tracking (blob detection)...but it mostly just spazzes out when I leave it on automatic (image processing in pure JAVA is difficult to bring up to even 10 fps). It was a great opportunity to explore JAVA's support of web-cams and I did a bit of JAVA 3D for the loading screen. Code available below.


I won't go into the gory details here because we did a nice job documenting the project during school. You can get that documentation (and CAD drawings of machined parts) here. Here are more pictures and videos!

Inside Electrical
Back (Modified PC Power Supply)

Pan/Tilt Servos
Barrel Servo and Gears
Design Poster

The only thing not shown in these photos is the clear Plexiglas walls later added to protect the electronics from curious fingers... In the future I will probably modify this to use the spring loaded piston from an electric AirSoft rifle to provide the air power...the tank is kind of annoying. I may also modify it to work with a smaller more appropriately sized power supply...the current solution was free :).

Firing Test
(It can actually fire much more rapidly than this test shows.)

High Torque Servo Pan & Tilt Test - One of the best videos from testing :)

The robot running the pan/tilt system in this video is one of the first I ever built, I use it all the time because it's a great test platform for new sensors and micro-controller code...it is described here.
  • The original project site is here. (Until I get access from the admin (who changed our directory structure) I can't fix all the broken links.)
  • Re-hosted project documentation is here.
  • Mike's post on his site is here.
  • Kyle's site which is frequently broken or redesigned...is here.
  • Java code is available here (licensed under GNU GPLv3). It's not really portable, a bunch is hard coded at the moment and it doesn't extract necessary libraries properly; however, should be easy enough to modify. JAVA 3D and JMF should be installed to used the code. GiovynetSerialPort is also needed.)
  • I'll try to locate the Arduino code, but really if your going to reproduce it you just need serial and PWM servo examples which are abundant. The documents have some decent info on getting a reliable serial protocol defined.
Dear Nerf, Hire me so I can make a commercialized version for everyone :).

    The First

    This post is a retrospective look at the first robot I built solely for myself (back in 2008). I had only helped build one robot before this. It's clear I got a very late start into robotics. Although school did prepare me formally to dive right in, I wish I had been more focused on it when I was younger, I would have really flourished in college. This robot was designed mostly on a whim, but has turned out to be a nice solid prototype, and it is very useful for testing sensors and AVR code...

    The Parts List:
    • Aluminum Chassis, Motor Mounts & Tire hubs - Machined while I was still at RIT when I had access to their machine shop. No original designs are available, I just went in and used what scrap I could find...I'd be embarrassed by providing the true measurements :).
    • Stepper Motors - From Sparkfun...I may replace these some day with cheaper gear motors so I can use these steppers in a CNC/Drill Press.
    • EasyDriver Stepper Motor Driver - Also from Sparkfun...simplest way to drive your steppers...the newest version of this board solves (I think) an issue that my version has with slowly shorting/draining power/whining when offline.
    • Tires - Sparkfun Again...I seem to like these tires.
    • Ball Caster - Another proven Sparkfun product...
    • Voltage Regulator Circuit - This was the second time I had built a voltage regulator circuit, but the first time for a robot. This has proved to be one of the most important circuits to know, understand, and be able to recognize on PCBs.
    • AVR ATMega32 - Since this project, AVR and in particular the ATMega32 has been my preferred micro-controller. I use AVR Studio, AVR Libc, and an AVR ISP mk2 programmer in most of my projects. The only exceptions are the Arduino projects, which are still AVR chips, just in a nice package that have a lot of the repetitious work already done for me.
    • USB to Serial Adapter - Lets me use USB for controlling the robot.
    • 8 AA Batteries & holders - Two sets of four paralleled together to provide enough voltage for the motors (outside the regulator circuit) and for all the electronics and sensors.
    • 6 inch Breadboard - The epitome of a prototyping.
    • Sensors - I've used a number of sensors on this robot, it usually gets used as the test bed for new sensors and circuits.
    Lessons Learned:
    • Always leave an LED wired to a pin somewhere on the micro-controller and a compiled program to blink said LED somewhere in the code repository. Don't assume you've fried you r controller. Check it against a circuit and program that you know will work.
    • Use one type of screw whenever possible (this one has all 4-40 standard hex screws, except the motor mount screws, which had to be metric).
    • Stepper Motors and batteries aren't the best option for a robot...next time gear motors.
    • Have a quick way to turn off your motors (see the jumper at the front with tape sticking up?). When your robot gets to the edge of the table and the suicide feature is enabled...
    • No sharp aluminum corners or edges...cuts hurt.
    Code for this robot changes all the time, so there isn't much point in posting it...besides, it's rarely documented enough for anyone but me.

        Sunday, December 13, 2009

        Hidden Maze Gift

        Okay...this doesn't even remotely fit the robotics theme of the site, but it's a weekend project/gift for a family member. The only rule at my family's gift exchange this year is that the gifts have to be "made". For me this is an excuse to kill a weekend with arts and crafts. I started with the idea of duplicating the brain teaser puzzle below.
        Well that one was easy enough to make...unfortunately it's not as colorful as the original (couldn't find that kind of rope). While looking online at similar wooden brain teasers I saw a picture of a small wooden box. As it turned out the box had a maze inside with the intended goal of getting a small ball through the invisible maze. I was hooked. So I went back to Lowe's grabbed what I needed and got to work. It has some weird dimensions because I had the guys at Lowe's cut the top and bottom before I really had anything designed (I wish I had a table saw...). I've always loved drawing mazes. The one inside this is fairly simple, but any maze is difficult when you can't see it. When I got home this is what I designed (in SketchUp again...).
        After getting it all drawn up and dimensions figured out I went to cutting all 42 of the maze pieces (haha...42...totally unintentional). I then sanded off the edges, laid out a grid on the bottom board, placed all the pieces, glued them on and got ready to put the top on.
        After gluing the top on I stacked ~60 pounds of books on it and let it sit overnight. Then I did some experiments with the stain I bought and some Sharpie markers to figure out if I needed to stain before putting a design on it (to prevent bleeding)...I did. After more sanding and one coat of stain I decided to draw a Celtic knot on the top. I've done quite a few of these on paper before. I was pretty nervous to do it on wood because it has to be inked and that's a lot more permanent on wood. But I followed the steps I always use and was very patient and careful. I managed to get it done without mistakes in just under 4 hours. So it's done now (with several more coats of stain to seal the design) and I have to say it looks pretty damn good. Shiny.The pictures don't do it justice (I really need a real camera) my phone just isn't good enough. I hope the gift is well received...and not too hard to solve :).

        Sunday, December 6, 2009

        The competition that wasn't

        Well unfortunately I was the only person to enter the competition officially, so it was canceled. To appease the robot gods' thirst for robotic mayhem Sparkfun morphed the events this weekend into a robot building/hacking/soccer match shindig. Making the 8 hr drive (one-way) was totally worth it even without the competition. I was able to demo "Spin Cycle" to those attending. Most of the day was spent on a class detailing the steps necessary to build an Ardubot for several people who had never made their own robot before. I've been a loyal customer and follower of Sparkfun.com for at least 3 years. It was great to finally meet some of the people behind the handles.

        I'm frazzled so no more text. Here is a video of my bot in action, and some pics from the trip.

        "Spin Cycle"

        The view from not even a mile away from SparkFun's building. (So...jealous)

        The fancy sign.
        Some nifty robot tracking (webcam+IR LEDs+ projector+codes=awesome).
        The famous giant clock.


        Time for the code... The software portion of this robot was fairly straight forward compared to the electrical and hardware designs. I had several previous robots and experiences to pull from when writing the code. As a result the code is very clean and well documented. There are two languages required to understand the code: JAVA and C (AVR Libc to be precise).


        I used JAVA to create a user interface which would take keyboard input and translate it into serial commands. The UI is very simple. It uses a KeyListener (which is added to all visible components of the UI) to pick up key strokes from the user. When a key is "typed" a string of characters is sent via GiovynetSerialPort1.3 to the XBee Module attached to the PC. The XBee acts a transparent serial cable with the XBee on the robot as the other end of the cable. Any serial data coming from the robot is displayed in the text area...

        I used Giovynet's serial port library for two reasons; first, Sun (JAVA) no longer supports serial ports and second, I've used this library before. This library's documentation leaves something to be desired...but I managed to get enough of it working for now.

        As far as design of the UI and JAVA control code goes I almost always follow the MVC software design model for this type of software. In this case their is no "model" but there is a clearly defined (by name even) 'control' and 'view' portion.

        One notable UI feature is the serial dialog (below) which was created solely to make the initial configuration of a serial connection easier. This and a handy Thread for receiving serial input into the PC are included in SerialTools.jar (w/ source code).
        I didn't comment the JAVA code very well, most of it is simple enough to read through with need for comments.

        C (AVR Libc):

        The micro-controller (an ATMega32) was programmed in a version of C specifically designed for AVR micro-controllers. The program written for the micro-controller is commented very heavily so I wont go into much detail on that. Possibly the most important feature of the program is a 2 second watchdog timer that disables the robot if the connection to the PC is lost (for two seconds). This is one of the first things I programmed and tested...safety first!

        The micro-controller program was used to control the following:
        • Serial Communication w/ PC (command parsing).
        • 2 9A motor controllers (A total of 4 digital inputs, 4 digital outputs, and two PWM channels).
        • 3 (up to 8) IR sensors for line following. (I fried all my sensors but the code was done).
        • 1 Digital output for the weapon's motor's controller.
        • RoboController.jar (archive w/ source not runnable) contains the JAVA code for the controller UI and key-stroke processing.
        • SerialTools.jar (archive w/ source not runnable) contains SerialConnDialog and ReceiveThread.
        • AVR C-Code.zip (for ATMega32) contains code for the robot's micro-controller.

        Final Assembly

        Well I managed to get all the parts purchased, designed and/or fabricated before the weekend of the event. As is often the case with project like this, my designs changed as I searched for parts. You will see below the final designs created in SketchUp (they really are final, based on the bot I took this weekend). I put a great deal of effort into getting exact dimensions in every place I could. In fact the only blatant differences between the drawings and the real robot are in the purchased parts(drill and batteries) which have too many curves to replicate.

        SketchUp Model

        I'm pretty certain no one will want to duplicate this exact design (anyone capable would probably find that boring) ; however, some of the components may be useful. The motors, motor drivers, wheels and hubs are all precisely measured, and could easily be copied into another drawing.
        I've decided on a name: "Spin Cycle" (a suggestion from my older brother). The name stems directly from the previously withheld weapon design. The "weapon" is a shiny stainless steel 14 inch rod from an old ink-jet printer. It weighs (about) 1.5 lbs. It is attached to a Craftsman 14.4 V cordless drill which has had it's handle chopped off. To attach the rod to the motor, I went to the local hardware store and purchased a galvanized steel 3/8" threaded "T" joint and short 3/8" coupler. The "T had to be bored out to 1/2" and finally two small 6-32 set screws added to secure the rod. Inserting a screwdriver into coupler and letting the rod rotate freely turned out to be a very easy way to check if the rod was balanced before tightening the set screws.I designed the following controller circuit (mostly based on the designs in an earlier post) for this motor. The controller takes up only one output pin from the micro-controller because it is only capable of driving the motor in one direction. Four power MOSFETs were used in parallel to increase run-time (by dispersing current and therefore heat). I recycled the big switching diode from the drill's trigger circuit to take care of back-emf when the driver was turned off with the motor still spinning.I left the drill motor and transmission intact so that the internal clutch would slip when the rod starts to spin. This is also safer from the electrical side because it allows the clutch to slip when the rod hits something thereby reducing the likelihood of a motor stall (huge current draw). I estimate that with full battery charge the rod/drill spins at ~200 rpm. It's enough to scare any little plastic robot away.

        I finished the build by filling the house with the sweet smell of spray paint... all the metal components of the chassis were painted with two coats of metal primer and several (I lost track) coats of glossy black paint. I don't know if I'll put any designs or text on it...unlikely.