When I was invited to take part in the Intel IOT contest I thought it was a great opportunity. First of all, it would give me access to some really awesome hardware and sensors. I'm a maker on a budget, so that was great. I'm also a pretty lousy coder, so I figured this would be a good excuse to buckle down and learn a bit. Since I had little planned for the end of the summer this would give me something to focus on. A deadline is a good stick and prizes are a good carrot, so I entered the contest with high motivation.
I proposed what seemed like a pretty simple robot- a line follower with sensors that would change the parameters of a sound generating sketch and send the audio over bluetooth to amps and devices. I've built line followers and audio projects before, so I figured the bluetooth implementation would be the hard part. This Instructable covers my attempt to build this robot.
Step 1: What Was I Thinking?
I ask myself the same thing. I like synthesizers and DIY audio circuits. My first 'real' circuit was Forrest Mims' stepped tone generator (AKA Atari Punk Console). I like things that make noise and I like unorthodox interfaces. My vision with this robot was have a line follower with several sensors that would interact with objects along the path to change the parameters of music. If the line was a large circle and it was divided equally into quarters and eighths, these objects could be arranged to create beats or musical patterns. Objects could be magnetic to trigger the hall sensor, illuminated to trigger a photocell, bulky to trigger the IR distance sensor or 'be detectable' with a sensor in some way.
I like making cool things out of junk and recycled materials. My friends and family know that so I get lots of weird 'broken' junk. My sister gave me a big box of remote control toys that had been destroyed by my nephews. I was intrigued by one particular chassis from a company called Ridemakerz. It was a jacked up 4WD drive train with big tires. It had fixed wheels and steering was done by varying the voltage to the left or right side motor. Many line followers use the same arrangement, so I put it aside. It had a leaking battery pack, so I cleaned it up and removed the damaged electronics.
The plan was to mount a flat plate to hold the Edison and the sensors on top of the RC chassis. I had some left over plexiglas that was just the right size. I have boxes of recycled and second hand fasteners, so this wouldn't be a challenge.
I had a few ideas about the audio portion of the project. The simplest thing would be to tie analog sensor values to something like the Auduino granular synth. I've been working with algorithmic based music lately and I figured that digital sensors could rotate between several variables in the code to change the musical pattern. Another idea was to use the sensors' digital signals to trigger wave table drum samples to make a spatial drum machine. Really, the possibilities are endless.
Step 2: Preparing the Chassis
While the leaking battery had destroyed the main circuit board and my nephews had destroyed the body, the RC chassis was in surprisingly good shape. I removed everything extraneous- the battery terminals, power switch, battery box and a few plastic covers. I removed the wheels and cut off the protruding plastic 'shock absorbers'. I also removed the side panels to inspect the gear train and remove a few more pieces of non-essential plastic. I reassembled the chassis and started on the platform.
Step 3: Creating a Platform
Here, again, my packrat tendencies saved the day. A few years ago, I salvaged some plexiglas sheets. I had a piece of 7"x7.5" that was the perfect size for the RC chassis. I made some careful measurements of where the Edison would mount and where the platform would connect to the chassis. I also drilled a hole for the motor wires. I ddrew a template on grapf paper and transferred it to the plexiglas. I used brad point drill bits at a moderate speed to drill clean holes.
Step 4: Mounting the Platform
There was a plastic ridge on each side of the chassis where the body connected. I trimmed the plastic flaps off with angle cutters and used the exposed open slots to connect the platform with nuts and bolts.
Step 5: Adding the Motor Shield
I've used the Seeed Studio motor shield from Radio Shack in a few projects before. It's pretty simple and it plugs into the Arduino and works. Since the Edison is mounted on a breakout board with an Arduino footprint, I figured that the Seeed shield would be a more elegant solution than the motor driver board that came in the IOT contest kit. I mounted it and connected the motor wires. Since the RC chassis had an eight cell AA battery pack, I just planned to replace the motor power supply with the same. I had an 8 cell AA battery pack with a 9v connector, so I screwed a 9v battery clip into the motor shield and routed it through the platform to the underside of the chassis.
Step 6: Mounting the Line Finder Sensor and Compass
The chassis had a hollow area between the two front wheels where the RC car's sound module and speaker had been. I routed the line follower sensor through this cavity and mounted it to the front underside of the chassis with two-sided foam tape. This could be adjusted later to fine-tune the sensitivity. I slipped a digital compass module into the same void and routed its wires through the hole in the platform.
Step 7: Mounting the Hall Sensor and a Photoresistor
I was thinking about the sensors I had to choose from and the objects I could use to interact with them. I had a big pile of hard drive magnets that would trigger the Hall sensor nicely. I had some old fashioned wood blocks that would trigger the IR distance sensor and a ton of LEDs for a photosensor. The next consideration was how to mount and position the sensors. Since the magnets were flat, I decided to mount the Hall sensor on a wire arm that stuck out from the side of the robot and pointed down. To keep things simple, I decided to mount a photocell in a dark tube to the same wire arm and trigger it with LEDs taped to coin cell batteries. See the photos above for the specifics.
Step 8: Adding an IR Distance Sensor
Since we had magnets and LEDs along one side of the track I decided to put the wooden blocks on the other. I used two nuts and bolts to mount the IR distance sensor on the opposite side from the Hall sensor and photocell arm. It would need to be fine-tuned later, but for now it was mounted in place.
Step 9: Programming
OK I'll admit, I'm not much of a programmer. I mess around with Arduino and I'm pretty good at mixing and matching other folks code into something that works, but that's about it. Thr Arduino footprint of the Edison fooled me into thinking it would be simple to get a basic sketch running. The set up of the board was way beyond what I was used to. I was lost, but I had a lifeline- my friend Chris is a programmer and offered to program the robot for me. All I had to do was build the hardware.
This doesn't mean I didn't try. I looked at other people's projects and googled all the things I didn't understand, but before long, I had 10 tabs open and my brain started fogging over. I decided to work on the code using an Arduino. I used an algorithmic music sketch and added my own patterns. I modified the code to used push buttons to affect changes in the pattern playing. I planned to use the Hall sensor, photocell and IR distance sensor to control the variables in the pattern. I would also use the digital compass to switch between four different variations on the algorithm. I also found line follower sketch that would work with the Seeed Studio motor shield.
Well, one thing leads to another and we tend to do things at the last minute. The Friday before the deadline rolls around and we get together to finalize what we thought would be a simple project. I decided to plug jumper wires into the wires from the sensors and use a proto shield with a 17x10 breadboard to connect to the Edison. Meanwhile, Chris updated the board and set it up as a web server. By the time we got all that set up I realized that I'd forgotten the motor battery pack. We decided to get together Saturday after work to finish up.
That's when the problems started. We couldn't get the motors to move. I had tested them with the battery pack to the bare wires and they worked fine, they just were not getting power through the shield. I was out of my depth at this point and Chris adjusted the PWM pin jumpers and other tricks to no avail. We eventually conceded and removed the Seeed shield and installed the driver board that came with the kit, even though it didn't fit as nicely. We tested it out on a work stand with the Edison powered from the included wall wart and it worked fine. The fact that the Edison could be programmed wirelessly was awesome, as Chris's bedroom computer had all the right software while the kitchen counter was a better workbench. He got the wheels working, adjusted their power and set up a rudimentary web-based controller using my laptop's arrow keys. By this point it was late and we decided to meet Sunday afternoon to finish up.
By this point we had the Edison communicating with the motors, the next step was to program the line following function. Since the motors were working well on the 12v battery pack, I planned to hook up a 9v battery to run the Edison, which is sceced from 7-18v. We tested the robot in this configuration. It would start in which ever direction you sent it, but it just continued that way until it ran into something. We had the typical 'hardware guy blames the soft ware/ software guy blames the hardware' conversation as we poked around with no results. The final culprit seems to be power. The 9v just wasn't enough to power the board. The Grove motor driver had an interesting feature- in order to save resources it used the last input until a new one was entered. The board would start up and connect, but as soon as we sent a signal to the motor, the bot would start moving, the Edison would die and restart and the bot would go flying into a wall with no new input. We tried changing it around, with 9v to the motors and 12v to the Edison, but that didn't work either- the motors worked, but the board died. It has a lot of awesome features in a tiny package, but the Edison is a bit power hungry for small-scale robotics projects. I'll have to reassess the design and find a battery solution with higher amperage to drive the board. With Arduino it's always the other way around!
So power was our Achilles' heel. That and being a cocky nerd who thinks he can pull off anything at the last minute. We ended up hooking the motor driver back up to the 12v battery pack, plugging the wall wart into a short extension chord and running the Edison from wall power. It was fun and we learned a few things for the next phase of the project.
Step 10: Testing the Chassis and Realizing Where I Went Wrong
So I made three mistakes- I underestimated the complexity of the Edison. The Arduino footprint made me think it would be as simple to use. I had the usual 'hardware guy's' conceit- 'I built it and all the parts are there, now all they have to do is code it. Two major stumbling blocks could have been avoided with better research on my end. I found, all too late, a work-around from someone else who had the same problem with the Seeed motor shield and closer scrutiny of the Edison's specs would have revealed the power supply problem. My third mistake was not bringing in a better programmer earlier. I kept thinking I could just figure it out. I need to go back and learn more from the Arduino side before I tackle a board like this alone.
As for the robot, now that we know what went wrong, we know where to go next. As soon as I find a better battery solution, we can work on the line following function. One thing we noticed is that with the 4WD fixed wheel steering arrangement, it has a wide turning angle. This will limit it's line following ability. One solution is to remove a gear from each side's drive train to make it a 2WD chassis. If that doesn't help, I'll remove the rear wheels and add a single castor wheel in the center rear position. That will make it much more maneuverable.
Rather than using Edison resources to process the audio, we'll probably send the sensor data over the web connection to a software based algorithmic music player or other audio source. This allows for a larger variety of sounds, even individualized phone apps. Since the purpose of this robot is for public outreach and demonstration, the more interactivity the better. People will be encouraged to move the magnets and other objects around and see how it affects the sound. More sensors and object possibilities could be added.
Although I failed to create the robot I proposed, I made a good start and figured out how to turn a $25-30 RC toy chassis (or cheaper used) into a nice robotic chassis and platform. That's a steal compared to a 'robotics' kit. We'll continue working on the robot over the next few weeks and post an update. Keep an eye out at Tampa area maker events.
In the meantime, here's a video of our successful tethered drive train test. Stay tuned!