Operácie

Acrob006

Z SensorWiki

< Previous | Home | Next >

Basic movements. Finally!

DifferentialKinematics.png

Robot používa dva modifikované servomotory. Majú trojvodičové pripojenie, dva vodiče slúžia na napájanie, tretí je riadiaci signál. Rýchlosť a smer otáčania sa riadia šírkou impulzu. Pôvodne slúžil na nastavenie polohy v rozsahu 0-180 stupňov. Po úprave signál pre 90 st. motorček zastaví, 180 roztočí max. rýchlosťou jedným smerom a 0 max. rýchlosťou druhým smerom (TODO: upraviť knižnicu z polohy na rýchlosť).

ServoAnimation.gif

Tento program ilustruje použitie základných pohybových príkazov. Všimnite si použitie knižnice Servo.h:

#include <Servo.h> // this program uses the Servo library
Servo LeftServo;   // create servo object to control both servos

 void setup() 
{  LeftServo.attach(9);    // attaches the servo on pin 9 to the servo object 
 } 
void loop() 
{ 
  LeftServo.write(0); 
            delay(2500);    
  LeftServo.write(90); 
            delay(2500);    
  LeftServo.write(270); 
            delay(2500);                
}
#include <Servo.h> // this program uses the Servo library

Servo LeftServo;   // create servo object to control both servos
Servo RightServo;  // a maximum of eight servos can be created 

#define FAST  50   // try to change these values during the test
#define SLOW   5

 void setup() 
{ 
 LeftServo.attach(9);    // attaches the servo on pin 9 to the servo object 
 RightServo.attach(10);  // attaches the servo on pin 10 to the servo object 
} 
 
void loop() 
{ 
 // FAST FORWARD
  LeftServo.write(90 + FAST);    // value 90 is in middle, i.e. stop   
 RightServo.write(90 - FAST);    // mirrored position       
            delay(1500);         // go fast forward for  1,5 s 

 // SLOW FORWARD
  LeftServo.write(90 + SLOW);    // test varying speed of movement
 RightServo.write(90 - SLOW);           
            delay(1500);                       

  LeftServo.write(90 - FAST);    // FAST BACKWARD
 RightServo.write(90 + FAST);           
            delay(1500);                       

  LeftServo.write(90 + FAST);    // ROTATE (PIVOT) RIGHT
 RightServo.write(90 + FAST);           
            delay(1500);                       

  LeftServo.write(90 - FAST);    // ROTATE (PIVOT) LEFT
 RightServo.write(90 - FAST);           
            delay(1500);                       

  LeftServo.write(90);           // STOP both motors
 RightServo.write(90);            
        
              for(;;);           // stop the program operation here

}   /* End of Loop */
ServoConnection.png


You may notice that Your motors not stop after the last command. You can either calibrate sensors using the screwdriver and small trimer inside the motor which is accessible through small opening in the side of the motor, or You can simply switch off the motor using the detach method

LeftServo.detach();
RightServo.detach();


< Previous | Home | Next >