Acrob006: Rozdiel medzi revíziami
Zo stránky SensorWiki
Nová stránka: < Previous | Home | Next > < Previous | Home | Next > |
|||
(2 medziľahlé úpravy od rovnakého používateľa nie sú zobrazené.) | |||
Riadok 1: | Riadok 1: | ||
[[Acrob005|< Previous]] | [[Acrob|Home]] | [[Acrob007|Next >]] | |||
== '''Basic movements. Finally!''' == | |||
[[Obrázok:DifferentialKinematics.png|center]] | |||
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ť). | |||
[[Obrázok:ServoAnimation.gif|center]] | |||
Tento program ilustruje použitie základných pohybových príkazov. Všimnite si použitie | |||
knižnice Servo.h: | |||
<source lang="c"> | |||
#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); | |||
} | |||
</source> | |||
<source lang="c"> | |||
#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 */ | |||
</source> | |||
[[Obrázok:ServoConnection.png|center]] | |||
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(); | |||
[[Acrob005|< Previous]] | [[Acrob|Home]] | [[Acrob007|Next >]] | [[Acrob005|< Previous]] | [[Acrob|Home]] | [[Acrob007|Next >]] |
Aktuálna revízia z 12:49, 27. marec 2018
< Previous | Home | Next >
Basic movements. Finally!
![](/sensorwiki/images/1/16/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ť).
![](/sensorwiki/images/4/46/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 */
![](/sensorwiki/images/d/d3/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 >