WalTer the EDU Robot.

WalTer was developed to allow me and my students to explore robotics without spending a lot of time or money. It is quick and dirty.
The body is a RadioShack 270-1805 project box. The box has card guides on the long sides to hold the processor and H-Bridge cards. An open slot remains for expansion. The unit is powered by 6 AAA rechargeable cells.

The drive and motors are a TAMIYA Double Gearbox setup for a 344:1 reduction. Blue painters tape keeps lint and pet hair out of the gearbox. The wheels are also from TAMIYA. A ball caster from Tamiya has been added to the front but is not shown in this photo.
The PIC16F88 processor is the Business Card Computer that I built for GP tinkering. It has an unused I2C socket.NOTE: I have since designed a card specifically for WalTer. The power and ICSP programming port have been moved. The mapping between the processor pins and connectors has also changed.
The H-Bridge uses all 8 bits of port B. Two of these bits are used to program the the PIC. This is done with the robots power off but the H-Bridge moves the robot about 1/4 inch once during programming. Might be better to disconnect the H-Bridge to program.
The H-Bridge is David Cook's Miss Motor. It uses 6 2N2222A's and 4 2N2907A transistors. In theory the transistors can deliver 800 mA going forward and 600mA going backwards.
This is my first attempt at painting the top side of the PCB. The paint worked well as did the toner transfer for the parts placement graphics. But when I attempted to clear coat the graphics with acrylic spray it melted the toner. Live and learn.Note: This board has been redesigned to include status lighs for each drive transistor.
The CCS C code to drive WalTer is straight forward. I did not have much luck with the CODE or PRE tags so the formating is ugly.
A set of defines are used to form PORTB values to drive the H-Bridge.
// Port B bits
#define Q11 0x01
#define Q12 0x02
#define Q13 0X04
#define Q14 0x08
#define Q01 0x10
#define Q02 0x20
#define Q03 0x40
#define Q04 0x80
// these defines specify what to do on PORTB to get a desired action
#define COAST 0
#define LEFT_AHEAD Q11+Q14
#define RIGHT_AHEAD Q01+Q04
#define AHEAD LEFT_AHEAD+RIGHT_AHEAD
#define LEFT_BACK Q12+Q13
#define RIGHT_BACK Q02+Q03
#define BACK LEFT_BACK+RIGHT_BACK
#define BREAK_HI Q02+Q04 + Q12+Q14
#define BREAK_LO Q01+Q03 + Q11+Q13
#define SPIN_LEFT LEFT_AHEAD+RIGHT_BACK
#define SPIN_RIGHT LEFT_BACK+RIGHT_AHEAD
A program is a series of move() commands.
void main()
{
int i;
//setup
setup_adc_ports(NO_ANALOGS);
PORTB=0;
set_tris_b(0xFF); // all inputs
#use FAST_IO(B)
set_tris_b(0x00); // all outputs
while(1)
{
move(25,AHEAD,100,100);
move( 7,BREAK_HI,100,100);
move(40,SPIN_LEFT,100,100);
move(40,BACK,70,70);
move(40,AHEAD,100,75);
move(40,SPIN_RIGHT,100,100);
}
set_tris_b(0xFF); // all inputs
}
The move() command generates the signals sent to the H-Bridge. It reject commands that would short out the H-Bridge.
// command to move robot
void move(int duration, // duration of command
int _val, // one of the motion defines
int powerLeft, // % power for left motor
int powerRight) // % power for right motor
{
int val, i, j;
val = _val;
// test for the 2 _val's that will blow the H-Bridge
if ((val & Q01) && (val & Q02))
{
PORTB = 0;
return;
}
if ((val & Q03) && (val & Q04))
{
PORTB = 0;
return;
}
// send the PWM signals to the H-Bridge
for (i=0; i -lt- duration; i++)
{
for (j=0;j -lt- 100;j++)
{
if (j == 0) // start hi part of PWM
{
val = _val;
PORTB = val;
}
if (j == powerLeft) // start low part for left
{
val = val & 0x0F;
PORTB = val;
}
if (j == powerRight) // // start low part for right
{
val = val & 0xF0;
PORTB = val;
}
delay_ms(1);
}
}
PORTB = 0; // done with cmd so stop both motors
}
0 comments:
Post a Comment