This example assumes you are familiar with the Arduino IDE, connection and uploading. If not we suggest you visist www.arduino.cc and read their getting started and learning guides.
The pro-360 servo differs from regular 360 servos in the fact that they can be adjusted or trimmed to a specific center value. All controllers can output a certain center value and these do differ. So to eliminate creep and lock the servos's center this can be set on the servo.
For example.
Using an Arduino, we want to always use the value of 90 to have the servo centered. With a 360 degree servo the center is the full stop mode. To do this we simply write a value of 90 to the servo from the Arduino. The servo is trimmed so that when it receives a value of 90 it stops. Regular servos have their centers set and non adjustable. The value of true center may differ from servo to servo, so we must get this calibration value from the servo and use it to center it. This is explanaied in the Regular servo calibration section.
Project video
In this video it shows how to center the servos to a specific value, then it runs through the demo code below.
The circuit
White wires are shown in grey for clarity.
Make up this circuit on your breadboard. The wire colours are just for clarity on the diagram and do not relate to the jump wire kit colours, however the wires on the servos are true. The circuit connects the Arduino to the servos.
Pay attention to the polarity, and the servo connections. Double check all your connections are correct before connecting power. Short circuits and reverse polarity can damage the Arduino, sensors and servos.
Trimming the servo
Make sure you have configured your servo in this section first.
Demo code
(Arduino only) Enter this code to get the servos moving through it's ranges at different speeds and direction.
#include <Servo.h>
Servo servo;
// BotBuilder 360 Servo demo.
// Active range for CW is 90 Stop - 110 Full speed
// Active range for CCW is 70 Full speed - 90 Stop
// Stop is 90
// Function calls are bbservo_DIRECTION_COMMAND(DURATION, VELICITY)
// DIRECTION: CW, CCW
// COMMAND: slowstart, slowstop, move
// DURATION: The amount of miliseconds you want the movement over, eg. To slowdown over 1 second use 1000
// VELOCITY: The speed of the servo, eg. To drive full speed use 110, to drive half speed use 100 for CW. For CCW use 70 and 80
// Remember that the function for CW and CCW will not work if you use a velocity out of range eg 69 for CW.
// See examples below.
// Remember to make sure your servo is properly calibrated.
// www.botbuilder.co.uk for more information.
void setup()
{
servo.attach(10);
}
void loop()
{
bbservo_cw_slowstart(3000, 110); // Slow down in miliseconds (There are 1000 milliseconds in a second, so to slow over 1 second use 1000.)
bbservo_move(000, 110);
bbservo_cw_slowstop(2000, 110); // Slow down in miliseconds (There are 1000 milliseconds in a second, so to slow over 1 second use 1000.)
delay(1000);
bbservo_ccw_slowstart(3000, 70); // Slow down in miliseconds (There are 1000 milliseconds in a second, so to slow over 1 second use 1000.)
bbservo_move(2000, 70);
bbservo_ccw_slowstop(2000, 70); // Slow down in miliseconds (There are 1000 milliseconds in a second, so to slow over 1 second use 1000.)
delay(1000);
}
void bbservo_ccw_slowstop(int duration, int velocity)
{
int delaytime;
int timedelay;
timedelay = (90 - velocity);
delaytime = (duration / timedelay);
for (int i=velocity; i <=90 ; i++){
servo.write(i);
delay(delaytime);
}
}
void bbservo_cw_slowstop(int duration, int velocity)
{
int delaytime;
int timedelay;
timedelay = (velocity - 90);
delaytime = (duration / timedelay);
for (int i=velocity; i >=90 ; i--){
servo.write(i);
delay(delaytime);
}
}
void bbservo_ccw_slowstart(int duration, int velocity)
{
int delaytime;
int timedelay;
timedelay = (90 - velocity);
delaytime = (duration / timedelay);
for (int i=90; i >=velocity ; i--){
servo.write(i);
delay(delaytime);
}
}
void bbservo_cw_slowstart(int duration, int velocity)
{
int delaytime;
int timedelay;
timedelay = (velocity - 90);
delaytime = (duration / timedelay);
for (int i=90; i <=velocity ; i++){
servo.write(i);
delay(delaytime);
}
}
void bbservo_move(int duration, int velocity)
{
servo.write(velocity);
delay(duration);
}
Testing
Plug in the Arduino via USB (if your Arduino has a power souce jumper, set it to USB). The servo will now start to move through it's ranges at different speeds and direction.