Arexx 04 – motor control functions – Arduino Robot

Posted by didi | Posted in Arduino Robot AAR-04 | Posted on 04-08-2012

0

In the little freetime I found the last days,  I read a first book about the Arduino in german called “Arduino Praxiseinstieg by Bruehlmann” .

Then I analysed the motor control function of the motor contol ic L293D. It’s pretty simple.  There are some enable inputs on the ic witch are constantly on plus  and for that always enabled. For every motor there is a so called H-Bridge, so that every pin of the motor has one half bridge, which means one switch to + and one switch to  ground.  Two motors, four pins.  If the processor pin is low the ground switch is activ.  If the pin is high the +switch is active, that results to:

  • logic P5  on ==  right motor forward
  • logic P6  on == right motor backward
  • logic P10 on == left forward
  • logic P9 on == left backward

Don’t be confused that  P5 is not on the µC pin5 but on pin 10 and so on …

You can control the logic P5 in two ways, that means go right forward

  1. continous on :  digitalWrite( 5,  HIGH)
  2. controlled :   analogWrite( 5, 200)

The number “200″  can have a range of  0..255   resulting in a voltage  of  0..100%  on the motors.

Here is my first test program,  because I was to lazy to write a lot I made some simple functions,  OK the repetition of delay and motorstop could be another function .. :

/*
Name project:   Motor-Test
Author:         didi 4august2012
Company:        dmemos.de
Discription:
Some tests how to control the motors
*/

void setup()
{
//Setup: Initalization
//pin 10 left foreward
pinMode(10, OUTPUT);
//pin 9 left backward
pinMode(9, OUTPUT);
//pin 5 right foreward
pinMode(5, OUTPUT);
//pin 6 right backward
pinMode(6, OUTPUT);

//Then set the start value of the signals to zero:
analogWrite(9, 0);
analogWrite(10, 0);
analogWrite(5, 0);
analogWrite(6, 0);

//Startup delay:
delay(2000);

}

void loop()
{
rightForward( 220 );
delay( 2000 );
motorStop();
delay( 2000 );

leftForward( 220 );
delay( 2000 );
motorStop();
delay( 2000 );

rightBackward( 220 );
delay( 2000 );
motorStop();
delay( 2000 );

leftBackward( 220 );
delay( 2000 );
motorStop();
delay( 2000 );

forward( 220 );
delay( 2000 );
motorStop();
delay( 2000 );

backward( 220 );
delay( 2000 );
motorStop();
delay( 2000 );

rightFast( 220 );
delay( 2000 );
motorStop();
delay( 2000 );

leftFast( 220 );
delay( 2000 );
motorStop();
delay( 2000 );

}

void motorSet( byte lf, byte lb, byte rf, byte rb)
{ analogWrite(9, lf);
analogWrite(10,lb);
analogWrite(5, rf);
analogWrite(6, rb);
}

void motorStop( )
{ motorSet( 0,0,0,0);
}

void leftForward( byte spd )  // move left forward speed 0..255
{ motorSet( spd, 0, 0, 0 ); }

void leftBackward( byte spd )  // move left backward speed 0..255
{ motorSet(  0, spd, 0, 0 ); }

void rightForward( byte spd )  // move right forward speed 0..255
{ motorSet( 0, 0, spd, 0 ); }

void rightBackward( byte spd )  // move right backward speed 0..255
{ motorSet(  0, 0, 0, spd ); }

void forward( byte spd )  // move forward speed 0..255
{ motorSet( spd, 0, spd, 0 ); }

void backward( byte spd )  // move backward speed 0..255
{ motorSet(  0, spd, 0, spd ); }

void leftFast( byte spd )  // left forward, right back > fast turn
{ motorSet(spd,0,0,spd); }

void rightFast( byte spd ) // left back, right forward > fast turn
{ motorSet( 0,spd,spd,0); }

Troubleshooting :  I needed half an hour to recognize, that the reason for the not working, that means sometimes hanging motors,  is simply the weak supply via USB, with battery it worked without problems.

AREXX AAR 04 first steps

Posted by didi | Posted in Arduino Robot AAR-04 | Posted on 21-07-2012

0

Arexx AAROBOT AAR-04 – the new arduino robot -  the first steps .  This is the test program delivered with the Robot Kit “_04_move.ino”  which you can find in the examples directory and which you have to load via USB into the robot.

Name project:   Example 4, RP6 Motor control
Author:         Egbert Koerhuis
Company:        Arexx Engineering
Discription:
This Example Program shows how to control the Motors.
Make sure that the AAR can __NOT__ move when uploading the program!
After uploading the program, the AAR will wait 2 seconds before the program start.

>>> DO NOT FORGET TO REMOVE THE USB CABLE, after uploading the program.

ATTENTION: THE ROBOT MOVES AROUND IN THIS EXAMPLE! PLEASE PROVIDE ABOUT
1m x 1m OR MORE FREE SPACE FOR THE ROBOT!

You are free to change the code!
*/

void setup()
{
//Setup: Initalization
//pin 10 left foreward
pinMode(10, OUTPUT);
//pin 9 left backward
pinMode(9, OUTPUT);
//pin 5 right foreward
pinMode(5, OUTPUT);
//pin 6 right backward
pinMode(6, OUTPUT);

//Then set the start value of the signals to zero:
analogWrite(9, 0);
analogWrite(10, 0);
analogWrite(5, 0);
analogWrite(6, 0);

//Startup delay:
delay(2000);

}

void loop()
{
digitalWrite(9,LOW); analogWrite(10,200); //##set pin 9 to ground!## set speed left motor 200 foreward
digitalWrite(5,LOW); analogWrite(6,200);  //##set pin 6 to ground!## set speed right motor 200 foreward
delay(5000); //drive for 5000ms
digitalWrite(9,LOW); analogWrite(10,200); //##set pin 9 to ground!## set speed left motor 200 foreward
digitalWrite(6,LOW); digitalWrite(5,LOW); //make a left turn
delay(5000); //drive for 5000ms
digitalWrite(10,LOW); analogWrite(9,200); //##set pin 10 to ground!## set speed left motor 200 backward
digitalWrite(6,LOW); analogWrite(5,200);  //##set pin 5 to ground!## set speed right motor 200 backward
delay(5000);  //drive for 5000ms
digitalWrite(5,LOW); analogWrite(6,200); //##set pin 5 to ground!## set speed right motor 200 backward
digitalWrite(9,LOW); digitalWrite(10,LOW); //make a right turn
delay(5000); //drive for 5000ms
digitalWrite(6,LOW); digitalWrite(5,LOW); //stop motors
digitalWrite(9,LOW); digitalWrite(10,LOW); //stop motors
}

The program is quite simple, so  it’s easy to understand,   every 5s there is an action -  a static pwm,  no control – but you see also how easy the programming is.

Also the first step in  the  PlotRobots project.

Next I’ll have a look at the other example programms.

Arexx AARobot AAR-04 – the Arduino Robot

Posted by didi | Posted in Arduino Robot AAR-04 | Posted on 09-07-2012

0

AREXX AAR-04 kit top view

AREXX AAR-04 kit bottom view

AAR-04 in comparison to the AAR-03

I bought this  Arexx AAROBOT AAR-04 at  http://www.elv.de/ for  49,95€ .   First they said it’s currently not available,  I did’nt cancel the order and I have built the ARX-03 in the meantime – just with the first life sign of the old one the new one arrived.

This robot is even more satisfying my first thougths of a free platform.  While the AAR03 is build in DLR license the new one is complete free and Arduino based :

Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It’s intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.

Arduino can sense the environment by receiving input from a variety of sensors and can affect its surroundings by controlling lights, motors, and other actuators. The microcontroller on the board is programmed using the Arduino programming language (based on Wiring) and the Arduino development environment (based on Processing). Arduino projects can be stand-alone or they can communicate with software running on a computer (e.g. Flash, Processing, MaxMSP).

The boards can be built by hand or purchased preassembled; the software can be downloaded for free. The hardware reference designs (CAD files) are available under an open-source license, you are free to adapt them to your needs.

Source and more information at : www.arduino.cc

Surprisingly the new AAR-04 is complete build, for that not really a kit,  but ready to use and a bit bigger.  For the   PlotRobot-Project more room for extensions.  The surface mounted parts would be a bit difficult to solder for the most amateurs. The mechanics is improved compared to the old -  it looks more robust.  It’s also a good start to get into Arduino programming.