I tried both p0, p1 and p2. Same results. Rapid movement all the way clockwise than sitting there jittering.
Played with different values of setMinimumPulse and setMaximumPulse but no matter what values I use it either just moves all the way clockwise and jitters there or it locks in place at curent position and jitters there.
The following code makes a flowing movement starting out all the way counterclock wise and moves all the way clockwise, stops and moves back to 0 again.
So I'm fairly certain the servo is fine and not broken since it now move correctly with this hack.
I even went so far doing a excel spread sheet to figure out the max and min values for SoftwareServo based on the pulse0 formula and clockcycles per microsecond for 16MHz (might done my math wrong) and tried out the values it gave me even doubled, quadrupled and halved as well quarted those values for setMax/MinimumPulse to no avail.
Unfortunately do not have a voltage probe tester for the scope at work so can't check what signal is being output from the SoftwaresServo. I put a Hz meter to it and looks like I'm getting a 36Hz signal (think it was) or a pulse every 20ms as I should.
void setup()
{
pinMode(1,OUTPUT);
pinMode(2,OUTPUT);
digitalWrite(1,LOW);
digitalWrite(2,LOW);
for(int startpos = 0; startpos < 100; startpos +=1)
{
digitalWrite(2,HIGH);
delayMicroseconds(1400);
digitalWrite(2,LOW);
delayMicroseconds(1400);
delay(20);
}
}
void loop()
{
// blink LED 3 times before start
for(int blinks = 0; blinks < 3; blinks +=1)
{
digitalWrite(1,HIGH);
delay(1000);
digitalWrite(1,LOW);
}
// sweep 1 counter clockwise
for(int pos = 400; pos < 2300; pos +=10)
{
digitalWrite(2,HIGH);
delayMicroseconds(pos);
digitalWrite(2,LOW);
delayMicroseconds(pos);
delay(20);
}
// blink LED 6 times to tell us done with sweep 1 and start of sweep 2
for(int blinks = 0; blinks < 5; blinks +=1)
{
digitalWrite(1,HIGH);
delay(400);
digitalWrite(1,LOW);
}
// sweep 1 clock wise
for(int pos = 2300; pos > 400; pos -=10)
{
digitalWrite(2,HIGH);
delayMicroseconds(pos);
digitalWrite(2,LOW);
delayMicroseconds(pos);
delay(20);
}
}