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

No comments:

Post a Comment