Skip to content

The Carbot Challenge

September 2, 2014

 

 

 

 

14-09-02 carbot original

A couple of years ago I made a wall-racer that I called Carbot.  It was based on a little radio controlled car that I had converted to be driven by an arduino via a pololu motor controller.  The earliest version had a single front facing ultrasonic sensor and later ones had a side-facing sensor as well.  The idea was to have it race around a little arena keeping a fixed distance from the wall.  The arduino version worked well and it was one of the thought-experiment targets for the olduino.

It needs to be independently powered, of course, and my best bet for that is to use the original olduino.  It doesn’t have the arduino rails or hardware SPI but I don’t think I need either of those.  At first blush, the barebones olduino fits like a glove on the chassis.
14-09-02 carbot II-1

It should be just a matter of connecting the motor controller to equivalent pins on the olduino and adapting the arduino code.
14-09-02 motor controller 14-09-02 pololu md08a

Looking at the controller hookup in the original carbot, I see that I need six output pins (circled below) in addition to an output and an input for the ultrasonic.  You need three control pins for each motor e.g. AIN1, AIN2, and PWMA.  AIN1 and AIN2 set the direction for the motor AIN1=+V and AIN2=0V is one direction, AIN1=0 and AIN2=+ is the other direction; PWMA is a pulse-width-modulated speed pin – the higher the duty cycle the faster the motor spins.  The olduino doesn’t have PWM but I figure I can fake it in software.

14-09-02 controller hookup

below is one of the early arduino carbots that bears out those connections.

int yled=7, rled=8, gled=9;
int pwma=10,ain1=17,ain2=18; //drive left motor in1+ and in2- control direction
int pwmb=11,bin1=16,bin2=15; //drive right motor in1+ and in2- control direction
void setup() {                
  // initialize the digital pin as an output:
  pinMode(yled,OUTPUT);pinMode(rled,OUTPUT);pinMode(gled,OUTPUT);
  pinMode(pwma,OUTPUT);pinMode(ain1,OUTPUT);pinMode(ain2,OUTPUT);
  pinMode(pwmb,OUTPUT);pinMode(bin1,OUTPUT);pinMode(bin2,OUTPUT);
}

void loop() {
 goforward(2);
 delay(100);
 turnright(); 
while(true);
//  turnright();
  delay(1000);
 }
 
 void goforward(int howlong){
 digitalWrite(gled,HIGH);
 setdirection(ain1,ain2,bin1,bin2);
// digitalWrite(pwma,HIGH); digitalWrite(pwmb,HIGH); //turn on both motors
analogWrite(pwma,128); analogWrite(pwmb,128); //turn on both motors

 delay(howlong*1000);
 digitalWrite(gled,LOW);
 digitalWrite(pwma,LOW); digitalWrite(pwmb,LOW); //turn off both motors 
} 
 void turnright(){
 digitalWrite(gled,HIGH);
 setdirection(ain1,ain2,bin2,bin1);
// digitalWrite(pwma,HIGH); digitalWrite(pwmb,HIGH); //turn on both motors
analogWrite(pwma,128); analogWrite(pwmb,255); //turn on both motors
 delay(1000);
 digitalWrite(gled,LOW);
 digitalWrite(pwma,LOW); digitalWrite(pwmb,LOW); //turn off both motors 
} 
void  setdirection(int d1,int d2,int d3,int d4){ //set the motors to counter-rotating
  digitalWrite(d1,HIGH);
  digitalWrite(d2,LOW);
  digitalWrite(d3,HIGH);
  digitalWrite(d4,LOW);
}

 

This seems pretty straightforward – more later.

 

Advertisements

From → Uncategorized

2 Comments

Trackbacks & Pingbacks

  1. Carbot is Alive! | olduino
  2. Time for a cleanup! | olduino

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: