A simple sketch with a servo, driven by "Servo.h" library, does not fit 0-180 degrees, but about 30-40 instead of 0 and 140-150 instead of 180.
Is there any parameter to trim to adjust right angles?
Ciao,
P.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Santiago.
Thanks for your answer.
I modified servo sweep as follows:
/* Sweep by BARRAGAN <http://barraganstudio.com> This example code is in the public domain. modified 8 Nov 2013 by Scott Fitzgerald http://www.arduino.cc/en/Tutorial/Sweep THIS SKETCH HAS BEEN MODIFIED TO SHOW THAT SERVO CONNECTED TO PIN 9 DOES NOT MOVE FROM 0° POSITION UNTIL ANGLE = 45° AND REACH 180° POSITION AT ABOUT 145°*/#include<Servo.h>Servomyservo;// create servo object to control a servo// twelve servo objects can be created on most boardsintpos=0;// variable to store the servo positionvoidsetup(){Serial.begin(9600);// configure serial port @ 9600 bpswhile(!Serial){;}myservo.attach(9);// attaches the servo on pin 9 to the servo object}voidloop(){for(pos=0;pos<=180;pos+=1){// goes from 0 degrees to 180 degrees// in steps of 1 degreemyservo.write(pos);// tell servo to go to position in variable 'pos'Serial.print(pos);// print positionSerial.print(" ");delay(1000);// waits 1s to control the position}Serial.println("");for(pos=180;pos>=0;pos-=1){// goes from 180 degrees to 0 degreesmyservo.write(pos);// tell servo to go to position in variable 'pos'Serial.print(pos);;// print positionSerial.print(" ");delay(1000);// waits 1s to control the position}Serial.println("");}
I verify the sketch and export it in hex form. Then i load firmware in an Arduino Uno with a servo connected at pin 9 as usual.
From the serial monitor I see that servo does not move from o° position until the angle reach about 45° and it reachs 180° position at about 145°.
Maybe there is something wrong in my procedure?
Ciao,
P.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The example looked like was working, but indeed it wasn't working correctly.
I did a bit of reseach and turned out that Servo.h defaults are 0º= 544 uS, 180º= 2400 uS.
SimulIDE servo is: 0º= 1000 uS, 180º= 2000 uS.
So you should configure it like this ( Servo.h line 37 ):
myservo.attach( 9, 1000, 2000 );
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A simple sketch with a servo, driven by "Servo.h" library, does not fit 0-180 degrees, but about 30-40 instead of 0 and 140-150 instead of 180.
Is there any parameter to trim to adjust right angles?
Ciao,
P.
Hi Piero.
The only customizable parameter is servo speed.
But it works for me with Arduino Servo library, check Examples/Arduino/servo-sweep , it uses Arduino servo-sweep example and it goes from 0 to 180.
Maybe it would be useful add properties to set pulse timing, but "standard" is 1mS to 2mS as far as i know.
Regards.
Hi Santiago.
Thanks for your answer.
I modified servo sweep as follows:
I verify the sketch and export it in hex form. Then i load firmware in an Arduino Uno with a servo connected at pin 9 as usual.
From the serial monitor I see that servo does not move from o° position until the angle reach about 45° and it reachs 180° position at about 145°.
Maybe there is something wrong in my procedure?
Ciao,
P.
Yes, you are right.
The example looked like was working, but indeed it wasn't working correctly.
I did a bit of reseach and turned out that Servo.h defaults are 0º= 544 uS, 180º= 2400 uS.
SimulIDE servo is: 0º= 1000 uS, 180º= 2000 uS.
So you should configure it like this ( Servo.h line 37 ):
myservo.attach( 9, 1000, 2000 );
I forgot login :-)
"Thank you"
Ciao,
P.
Thanks to you for reporting.