terça-feira, 8 de fevereiro de 2011

Version 1.0

What is it?
A DIY, easy to build robot.

This project originated from our interest to develop an easy to build robot to help students in our classes. It is a tool to teach and learn programming, circuits, electronics, and mechanics.

The development of this project was funded by the Federal Institute of Santa Catarina, in Florianópolis, SC, Brazil, through the I APROEX. Our team is formed by professors Joel Lacerda (Coordinator), Fernando S. Pacheco and Charles B. de Lima, from the Electronics Department in Florianópolis and by the student Luciano Silva do Lago.

Characteristics
This 1.0 version uses Arduino (ATmega328 microcontroller, AVR family), since it is easy to program. The chassis is made of plastic, and electrical connections are done in a terminal strip. To lower the cost, the robot uses standard batteries (AA and 9 V).

Materials

click to enlarge
  • [A] 1 Arduino Duemilanove or Arduino Uno board
  • [B] 2 servomotors (hobby servo 9 g)
  • [C] 1 high density polyethylene (HDPE) sheet. Here, it is a kitchen chopping board :-)
  • [D] 2 wheels. Here, they are from an old printer (paper feed rolls with 5 cm diameter)
  • [E] A small aluminum sheet
  • [F] Jumper wires (AWG 26 to 30)
  • [G] 2 rubber bands
  • [H]  Cable and power connector for 9 V battery
  • [I] 1 9 V battery
  • [J]  1 battery holder (4 AAs)
  • [K] 4 AA batteries
  • [L] 1 terminal strip (12 terminals)
  • [M] 2 micro switches (with lever)
  • [N] 2 LDRs
  • Not shown in the figure
  • 2 plastic spacers (from a computer motherboard)
  • 1 toothpick
  • 1 on/off switch
Tools

click to enlarge
1. Build the chassis
a. Print out the available template (check if the printing scale is 100%; after printing, check the marking "13,6 cm"). Cut out and copy it over the HDPE sheet.


b. Cut out the sheet using the hacksaw (the photo shows a test). It takes around 30 min.


c. Drill the holes using the smaller bit.
d. Drill the bigger holes for the wheels (it is easier to do with a drill press).


e. Finish the cutouts with the chisel. Take care!
f. Sand the edges for a better finish.

2. Modify the servos
a. The rotation of these servos is limited to 180 degrees. To turn them into continuous rotation servos, follow the instructions at the excellent TodBot Blog
If you have any doubt, please contact us.
b. Connect the servos and batteries as shown in the figure.
c. Load the next program into the Arduino IDE to test the servos and to adjust the pulse width.

/*****************************************************************************
 * adjust_servo_rotation
 *
 * Adjust max.pulse and min.pulse to stop the servo with the 90 deg command
 *
 * Fernando S. Pacheco - 2011
 *****************************************************************************/

#include "SoftwareServo.h"

SoftwareServo servo;

void setup()
{
  servo.attach(2); //Arduino pin number in which the servo is connected
  // Test the first servo, save the value of max. pulse, and test the other servo.

  //servoL.setMaximumPulse(XXX);// this is the value we want to find.
  //   Get it, write it above, and remove the comment.
  //servoL.setMinimumPulse(XXX);// para um dos servos que testamos, 
  //   não resolveu mexer só no max. pulse.
  //   Ficou muito baixo e, assim, a velocidade máxima era pequena.
  //   Foi necessário, então, ajustar também o min. pulse

  Serial.begin(9600);
  Serial.println("ServoAdjust/Ajuste do servo");
}

void loop()
{
  for (int maxpulse=500; maxpulse!=3000; maxpulse+=10)  { 
    servoL.setMaximumPulse(maxpulse);
    servoL.write(90);
    Serial.println(maxpulse);
    SoftwareServo::refresh();
    delay(45);
    SoftwareServo::refresh();
    delay(45);
  }
  //Depois de ter um valor aproximado, diminua o incremento do laço e 
  //os valores inicial e final
  delay(500);
}

3. Attach the wheels to the servos
a. Place the servo horn over the wheel and trace its limits
b. Remove the plastic until the horn locks (centered) into place. Use the drill or the chisel.
c. Drill the wheels and fix the servo horn

4. Fasten the Arduino board and switches
a. Thread the spacers on the chassis
b. Fasten the Arduino board
c. Glue or fasten the micro switches. Use the aluminum sheet to make an extended lever

5. Wire the components
a. Make the following connections

6. Fasten the batteries
a. Fasten the batteries with the rubbers and the toothpick
b. Place a small piece of HDPE under the 9 V battery

7. Program the microcontroller
a. Test the sample program.
 
/*****************************************************************************
 * robot_searches_for_light_and_goes_back *
 * Robô vai para a direção com mais luminosidade, a partir da leitura de 
 *  dois LDRs (fotorresistores)
 * Também tem duas chaves na frente para detectar quando bate
 *
 * Código usa os resistores internos de pullup do ATmega
 *
 * Fernando S. Pacheco - 2011
 *****************************************************************************/
#include "SoftwareServo.h"
#define invON LOW
#define invOFF HIGH
#define leftColisionPin  11
#define rightColisionPin 10
#define leftLdrPin A0
#define rightLdrPin A1

SoftwareServo servoL;
SoftwareServo servoR;

int leftCol=invOFF;
int rightCol=invOFF;
int leftLight=0;
int rightLight=0;

void setup()
{
  Serial.begin(9600);
  servoL.attach(2);
  servoR.attach(3);
  servoL.setMinimumPulse(295); //coloque os valores que você obteve no 
  //  teste dos servos. (Insert here the values obtained during servo testing)
  servoL.setMaximumPulse(993);
  servoR.setMaximumPulse(1247);
  pinMode(leftColisionPin, INPUT);
  digitalWrite(leftColisionPin, HIGH); //habilitar os resistores internos de
  //  pullup. (To enable internal pullup resistor)
  pinMode(rightColisionPin, INPUT);
  digitalWrite(rightColisionPin, HIGH); //to enable internal pullup resistor
  pinMode(rightLdrPin, INPUT);
  digitalWrite(rightLdrPin, HIGH); //to enable internal pullup resistor
  pinMode(leftLdrPin, INPUT);
  digitalWrite(leftLdrPin, HIGH); //to enable internal pullup resistor
  //Wait 2 seconds to begin
  delay(2000);
  //Aumenta velocidade vagarosamente / Increment speed slowly
  for (int k=0; k!=90; ++k) {    
    servoL.write(90+k);   //forward/frente em 180 
    servoR.write(90-k); //forward/frente em 0
    SoftwareServo::refresh();
    delay(25);
  }
  }

void loop()
{
  //Segue para frente em velocidade máxima / Go forward at full speed
  servoL.write(180);
  servoR.write(0);
  SoftwareServo::refresh();

  //Lê LDRs / Read LDRs
  leftLight=analogRead(leftLdrPin);
  rightLight=analogRead(rightLdrPin);
  
  if (leftLight > rightLight)  {
    servoL.write(150); 
    servoR.write(70);
  }
  else  {
    servoL.write(110);
    servoR.write(30);
  }
  SoftwareServo::refresh();
  delay(45);  

  //Lê chaves de colisão / Read collision detection switches
  leftCol=digitalRead(leftColisionPin);
  rightCol=digitalRead(rightColisionPin);
  
  //Detecção de colisão / Collision detected
  if (leftCol == invON || rightCol == invON) {
    //Robô para trás / Reverse
    servoL.write(30);   //frente em 180 
    servoR.write(150); //frente em 0

    for (int k=0; k!=10; ++k) {    
      SoftwareServo::refresh();
      delay(45);
    }
    if (leftCol == invON)  {
      //Se bateu à esquerda, vira para a direita / Turn right to avoid collision
      for (int k=0; k!=17; ++k) {
        servoL.write(140);
        servoR.write(140);
        SoftwareServo::refresh();
        delay(45);
      }
    }
    else {
      if (rightCol == invON)  {
        //Se bateu à direta, vira para a esquerda / Turn left to avoid collision
        for (int k=0; k!=17; ++k) {
          servoL.write(40);
          servoR.write(40);
          SoftwareServo::refresh();
          delay(45);
        }
      }
    }
  }  
  SoftwareServo::refresh();
  delay(1);
}

Download the robot source code here.
 
8. Test
a. Enjoy! Modify! Discuss your results!

9. Ideas for future versions
a. Line follower
b. Remote control
c. Use a LiPo battery pack (6 cells; 7,2 V)

Um comentário:

  1. Estou fazendo este robô gostei muito da ideia. Gostaria de mais informações.

    ResponderExcluir