Where the *BLEEP* is that extra blip coming from?
John Kauffman
Posts: 653
I'm experimenting with control of servo by pulse_out instead of servo.h
As check of hardware, program first tests circuit with three uses of servo.h - no problem
Then real test: while() loop sending centering pulse to servo - but servo chatters.
#include "servo.h"
#include "simpletools.h"
int main(void)
{
servo_angle(14, 0); // for 0 degrees (far CCW)
pause(1000);
servo_angle(14, 900); // for 90 degrees (middle)
pause(1000);
servo_angle(14, 1800); // for 180 degrees (far CW)
pause(1000);
while(1){ //loop is creating two pulses. why ???
pulse_out(14,1500);
pause(20);
}
return 0;
}
I ran the propscope on the servo pin and I'm getting attached shot during while() loop.
When goes into loop I'm getting *two* pulses per cycle. First is as expected, 1.5 mSec.
Then there is a .5 mSec low and a .5 mSec high again.
Where is that second pulse coming from?
As check of hardware, program first tests circuit with three uses of servo.h - no problem
Then real test: while() loop sending centering pulse to servo - but servo chatters.
#include "servo.h"
#include "simpletools.h"
int main(void)
{
servo_angle(14, 0); // for 0 degrees (far CCW)
pause(1000);
servo_angle(14, 900); // for 90 degrees (middle)
pause(1000);
servo_angle(14, 1800); // for 180 degrees (far CW)
pause(1000);
while(1){ //loop is creating two pulses. why ???
pulse_out(14,1500);
pause(20);
}
return 0;
}
I ran the propscope on the servo pin and I'm getting attached shot during while() loop.
When goes into loop I'm getting *two* pulses per cycle. First is as expected, 1.5 mSec.
Then there is a .5 mSec low and a .5 mSec high again.
Where is that second pulse coming from?
Comments
Doesn't the servo_angle continue to pulse unless turned off?
Edit: I probably typed too soon. I don't know enough about these functions to be much help.
Sounds perfectly logical, thanks.
Adding this worked: servo_stop();
Adding this caused compile error of to many args: servo_stop(14); so I'll have to figure out how to stop each servo if several are running
Again, thanks for seeing what I missed.
Add this before the loop:
The value 0 disconnects the servo pin from the background driver; the pause(20) allows the servo driver to refresh and disconnect the pin.
Edit: the servo_stop() function shuts down the driver -- all running servos would be affected. Use servo_set() with 0 if you want to do something else with a pin while other servos continue to run in the servo driver.