Now that we have BOB robot hardware, we need software. This is made a lot easier
since we are using an "OOPic for Brains".In developing BOB's control software
I wanted to use the latest "6.0" version of the OOPic compiler. It's still
in Beta release at the time that I'm writing this, but it seems stable enough
for BOB. Since this version of the compiler has a better grasp on the C
syntax, these programs will look a lot closer to a real C program than those for
the 5.0 compiler. The only downside is that these programs WILL NOT work
with the 5.0 compiler. So you better download the [OOPic]
6.0 compiler!.
The first thing I always do with new hardware is to define any external
device interfaces. With the OOPic this means creating a list of the
various I/O Line assignments. The trick is to do this RIGHT AWAY and put
the assignments right at the top of the program. Once you do your
assignments, write some tests programs to verify them.
So, here are the I/O assignments for BOB. Notice that I've adopted a
consistent naming convention, and the assignments always appear at the top of my
programs. The naming convention is: IO_ + FUNCTION_ + POSITION
//-------------------------------------------------------
// BOB I/O Port definitions
//-------------------------------------------------------
Const IO_LINE_LEFT = 3; // Left Fairchild Analog Reflective sensor
Const IO_LINE_MID = 2; // Middle Fairchild Analog Reflective sensor
Const IO_LINE_RIGHT = 1; // Right Fairchild Analog Reflective sensor
Const IO_PROXIMITY_LEFT = 8; // Left Sharp Digital Prox sensor
Const IO_PROXIMITY_RIGHT = 9; // Right Sharp Digital Prox sensor
Const IO_PROXIMITY_REAR = 10; // Rear Sharp Digital Prox sensor
Const IO_LED1 = 12; // General Purpose LED 1
Const IO_LED2 = 13; // General Purpose LED 2
Const IO_LED3 = 14; // General Purpose LED 3
Const IO_LED4 = 15; // General Purpose LED 4
Const IO_LED_GROUP = 1; // LED I/O Group 1 (Lines 8-15)
Const IO_LED_NIBBLE = 1; // LED I/O High Nible (Lines 12-15)
Const IO_MOTOR_LEFT_FWD = 24; // Left Motor H-Bridge High
Const IO_MOTOR_LEFT_REV = 25; // Left Motor H-Bridge Low
Const IO_MOTOR_LEFT_PWM = 18; // Left Motor PWM control
Const IO_MOTOR_RIGHT_FWD = 26; // Right Motor H-Bridge High
Const IO_MOTOR_RIGHT_REV = 27; // Right Motor H-Bridge Low
Const IO_MOTOR_RIGHT_PWM = 17; // Right Motor PWM control
Const IO_ENCODER_LEFT_FRONT = 31; // Left A I/R optical interruptor
Const IO_ENCODER_LEFT_BACK = 30; // Left B I/R optical interruptor
Const IO_ENCODER_RIGHT_FRONT = 29; // Right A I/R optical interruptor
Const IO_ENCODER_RIGHT_BACK = 28; // Right B I/R optical interruptor
Now that I have my I/O assignments, I can start writing some simple programs to
test the various BOB functions.
Since I plan to save each of my test programs, I decided on a naming
convention. You'll see this convention on all my future programs:
PBot_ + BotName + -Sequence_ + Compiler Version + . osc
So my first test program will be called: PBot_BOB-A_VC6.osc
Since each program will need it's own description, I've given them each their
own page. The list below summarizes each program and jumps off to their
respective description. I've also included the source code for all of my
programs on the [download page], just click on
the program's file name if it's a hyper link.
- BOB Lesson A: LED Test.
It makes sense to start with the most basic and/or the most useful robot
function. For BOB this means checking out the LED indicators.
Once I know these work, then I can use them to help me test all the other
functions.
- BOB Lesson B: Proximity Sensor (Eye) Test.
Here we'll verify that the three Eyes work by hooking them up to three of
the LEDs. Eyes are great for finding opponents or preventing BOB from
running into walls.
- BOB Lesson C: Motor Drive Test.
Next we'll make sure we can control BOB's wheels. We'll ensure that
the correct wheel is turning in the right direction, and that we can vary
the speed. Then we'll have him drive around without bumping into
things.
- BOB Lesson D: Line Sensor and SUMO BOB.
By adding the Line sensors we have all the elements for a Sumo robot.
See how we can put all the pieces together.
- BOB Lesson E: Optical Wheel Encoders.
Now that we can turn the wheels, it's important to see that we can measure
the rotation using BOB's optical encoders. This is one thing that sets
BOB apart from any robot that uses hacked Servos to drive the wheels. Wheel feedback lets us consider closed loop position and speed control
- BOB Lesson F: Closed Loop Position
Control using the Optical Wheel Encoders.
I investigate a simple commanded position wheel driver for BOB. The
main program can set speed and position, and Virtual Circuits do the rest.
- BOB Lesson G: Closed Loop Speed Control using the Optical Wheel Encoders.
I investigate a simple PID Wheel Speed controller for BOB. The main
program can set a speed range of +/- 128 and Virtual Circuits adjust the
wheel drives to hold that speed.
The Next Step
Well, the obvious next step is to write some more programs. I better
get cracking :)
Web content is copyright © PhilBot.com
2005, Deep Creek Lake, MD.
Contact: Phil Malone 301.387.2331, webmaster
@
PhilBot.com