Tuesday, April 20, 2010

The beginnings of a state machine

The Coasterbot continues to progress nicely. I have to enjoy it while it lasts, I'm sure there's some big roadblock waiting out there somewhere. 

I have the framework for a state machine roughed in, I2C works for both sending speeds to the motor controller and receiving speeds from the motor controller (that took a while - Arduino as master sending data or slave receiving data is pretty well documented; I had to make a few educated guesses and try a couple of things to get sending data from the slave in response to a master request to work correctly). Test code and preliminary state diagram are included below. The test code just tests state changes and motor speed send/receive. I'll start writing the real code to implement the behavior described by the state diagram soon.

To make it easier to tell what's going on with the robot, I added 4 LEDs to display the robot's current state in binary (up to 16 states, 0-15). I considered saving a digital port on the master Arduino by just using 3 LEDs (8 states, 0-7), but since the intention is to expand the functionality of this robot at some point, I added the 4th LED. You can't really see it very well in the picture, but each LED is connected from the Arduino to ground through a 330 ohm resistor soldered to the cathode leg.

                    
looks like 10 1/2 to me... .

I do need to come up with better power connections for the IR sensors, they keep falling off. And the start switch appears to be a little sticky. Minor issues. Still looking out for that roadblock....
Brian
The Black Dog

Preliminary state diagram

Coaster Master I2C 04-20-10

Coaster Motor I2C 04-20-10

Monday, April 19, 2010

I2C is easy (with a little help)

One thing I really like about working with the Arduino is the huge amount of sample code available. I was a bit concerned about getting I2C to work for this project, but with resources like the Wire library reference, AbsencesKeith's Electronics Blog, and Near Future Labs, it took about 30 minutes to integrate basic I2C communications into the motor test code I already had. The master Arduino is now sending motor control commands for the slave Arduino to execute. And more importantly, the slave is executing them!

And I was so looking forward to debugging some I2C messages with the Logic analyzer - not!

Brian
The Black Dog
Coaster Master I2C

Coaster Motor I2C

Saturday, April 17, 2010

Sensors connected, let the testing begin!

Got the sensors attached, connected, and tested while watching some of the FIRST Championship matches from Atlanta this morning.


front facing Sharp GP2Y0D810Z0F digital IR and Maxbotix EZ-1 sonar distance sensors 

This robot will find and drive toward obstacles, stopping short of hitting them. The Maxbotix sonar will find distant obstacles and keep the robot on path towards the selected one. The Sharp IR sensors will trigger around 10cm to stop the robot short of contact. After it finds the obstacle, it will spin around and target another. At least that's the theory...

I also found how to embed scrollable text in the blog (use Scribd) which will be handy for the next phase of the project - writing the code for the master and slave Arduinos.

Here's the Arduino code for testing the sensors:
CoasterBot Sensors Test

Sample output:
Test Output



Brian

The Black Dog

Friday, April 16, 2010

It Moves!


I finished most of the major hardware construction for the Coasterbot over the last few days, and got to test drive it this morning. Here's a recap of what's been completed.

Control schematics:
Top layer has master Arduino and voltage regulation, bottom layer has slave Arduino and motor control. No bumper sensors included yet.
The Quad H Bridge I'm using is the SN754410. It's good for 1 amp which is fine for the Lego 43362 motors I'm using. For more details on Lego motor performance, check out the testing done by Philippe Hurbain (Philo). His book 'Extreme NXT' written with Michael Gasperi shown on his home page is excellent, although maybe a bit dangerous to your NXTs...

Drivetrain
The drivetrain is completed on the bottom layer. The top of bottom layer has the motors and motor controls, the bottom has battery pack. Ground clearance is a little low, but this robot isn't intended for rough terrain so it should be OK. I deliberately showed up the Eneloop label on the rechargeable batteries - these work really well and have save me a lot of money compared to alkaline disposables. And kept a lot of batteries out of the landfill.

Test code for the drivetrain just runs the motors from 0% to 100% forward, 0% to 100% reverse, spins clockwise, spins counterclockwise, then repeats.

drivetrain (left), master controller (right) ready to be joined up.


battery pack with 6 Eneloop AA rechargeable batteries
low clearance, this is a smooth surface only robot

Top layer master control
The master control on the top layer is wired on the breadboard and mounted, but it really doesn't do much yet. All the code does is wait for the start switch to be pressed, then flashes the built in LED on the Arduino. The voltage regulator is assembled and tested, so I have 5V for logic and 9V for the motors.

I put the master breadboard on the back half of the top coaster for weight distribution so the robot doesn't fall on it's nose when stopping. It also gives me access to the spindle hole for running wiring between the two layers.

ready to test
every robot builder should have a grid pattern on their kitchen floor

To Do list
Even though the robot rolls, there's still plenty to do:
  • Mount and connect bumpers - either mechanical or digital distance sensors
  • Solder headers on Arduinos for I2C - the analog ports A4 and A5 used for I2C on the Arduino Pro Mini aren't on the edges, so I didn't put headers on them when I put the other headers on. 
  • Test motor balance at various speeds and develop a lookup table for the motor controller. The idea here is internally adjust a given input speed so that both motors turn at the same rate and the robot drives more or less straight. More on this later when I start to do the mapping.
  • Define the I2C messages the master and slave will use for communications. There will probably be a blog entry or two on this subject. And another chance to use my Saleae Logic analyzer!
  • Get I2C working between the master and slave.
  • Master control software for basic obstacle avoidance.
  • XBee communications back to PC for status messages. This is optional, I might just run out of time to do it before the end of the MAKE Coasterbot contest.
  • More stuff I'm sure I haven't considered yet.
But first, it's a beautiful day here in SE Michigan - time to go for a mountain bike ride!

Brian
The Black Dog



Saturday, April 10, 2010

There's an NXT in there somewhere....

The Black Dog Robofest team competed last night. Tied for third in a field of 14 Senior teams, but only the top two teams advanced to the Michigan state championships so the season came to an earlier end than we'd hoped. It's too bad Robofest eliminated the Technical award that could advance you as well, I think we would have won any technical award hands down.

quick, locate the NXT on this robot

"Benson the Otter-bot" summary:
  • Lego NXT control
  • 1 Lego NXT light sensor
  • 3 Lego NXT motors with rotation counters
  • Black Dog designed I2C sensor interface controlling
    • 3 Sharp short range IR distance sensors, converted to digital signals through a BDR designed and built comparator circuit
    • 1 Maxbotix Ultrasonic distance sensor
    • RCX motor through an H bridge built into the I2C expansion board
More details later (Eagle files for I2C board, RobotC code, etc).

Brian
The Black Dog

Thursday, April 8, 2010

Yet Another Project

Kind of ironic, I've been too busy working on robots to keep up with my robotics blog. Things should slow down a little soon - the Black Dog Robofest team competes in their Michigan regional qualifier tomorrow in Ann Arbor, and the Novi High School Frog Force 503 team leaves for the FIRST World Championships in
Atlanta next week. I plan on posting more about what I've learned from mentoring those two teams this year after their seasons are over.

the new project


Even though I've been busy, I couldn't resist taking on another project - the Make Robot Build contest. The challenge is to build a robot that can navigate through a space avoiding obstacles using 2 coaster-ized CDs as the main chassis components. You can read all about the challenge here. The small footprint is a challenge - after looking at the start of my chassis, one of the kids on the Robofest team suggested trying 2 LPs instead. I was surprised they even know what an 'LP' is!

My plan is to stick with a pretty conventional mechanical design - 2 wheel differential drive, PWM speed control, a trailing caster, contact switches for bumpers. For expandability (one of the judging criteria) I'll be using 2 Arduino Pro Minis - one dedicated to motor control, the other for sensor input and overall robot control. At this point, I could do all control using a single Arduino, but once I add sensors and more sophisticated motor control, I want to be able to split up the work. The Arduinos will communicate using I2C or serial - I2C makes it easy to add more nodes on the bus, and I want to learn how to use the Arduino 'Wires' I2C library, but I may go with serial for now if I get short on time.

To keep the cost down to zero, I'm using components already on hand:


I guess it's easy to keep the cost down when you have a lot of stuff lying around already.

The bottom coaster carries the drivetrain - motor battery pack on the bottom, breadboard for the slave Arduino and motor driver, and the drive motors on top. The ball caster attaches to the back of the bottom coaster. There's room on the bottom coaster to add some kind of wheel rotation counters for PID control and
distance measurement in the future.

back view of drivetrain. cross brace between tops of motors for support until top coaster goes on.

bottom view of the drivetrain coaster. got to get some shorter bolts....

The top coaster will carry the master controller and sensors - the second  breadboard on top for the master Arduino and possibly a 5V regulator for logic power; bumper switches and possibly batteries for logic power on the bottom. There's even a nice pre-drilled hole in the middle of the top coaster for passing wires through to the drivetrain controller!

The top coaster will have room for more sensors - IR and/or sonar distance, accelerometer, gyro, compass, vision (OK, I probably have too much stuff 'lying around'). My main interest is in navigation - integrating all the various sensors into a position estimate and mapping the environment around the robot. Eventually that leads to learning how to use the Kalman filter (I haven't seen notation like that since college, and I certainly don't remember it!).

The basic build is relatively straightforward. Coding is another issue....

Brian
The Black Dog