-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
control servo #118
Comments
I think most servos expect a signal that is slower than what you are sending here. The schematic you linked to mentions 20ms, that would be a 50Hz frequency (and not 500Hz). The hmm is typically because the signal is not stable. Servos do expect the signal to be repeated continuously but here I guess it might be coming in too fast. Try reducing the PWM frequency. You can compile with the debug option and then write |
You are right and this makes sense. I set
With the 10x maximum period, I can now set the servo with the 1/10 duty cycle values without the humming. From a pure PWM signal perspective, this makes sense. However, looking at the range of servo inputs, this feels a bit unintuitive. The servo only operates in "high" durations from 1 to 2 ms, so setting anything above 2000us makes no sense for the servo. Maybe it would make sense to configure a minimum and maximum timing (0% and 100%) separately from the signal period, instead of computing one from the other? This way a user can define exactly when the rising and falling edge will take place and at which period, with the maximum frequency still being 1/max-period. |
Servos are just designed this way. They are not measuring the duty cycle of the incoming signal, they measure the duration of an impulse and they need a long silence between impulses to reset their counter. This probably has to do with the electronics of early servos. The wikipedia page gives a little more information:
You said:
pi-blaster was built specifically to do PWM. There already is another project called servoblaster that is dedicated to controlling servos. I built pi-blaster (from servoblaster) because there was no way with servo impulses to get to 100% pwm. Yes we could make pi-blaster more complicated and take a min/max timing (pull requests welcomed!) but you can also easily do that calculation in your code - or take a look at servoblaster instead. |
I try to control a servo using the PWM timings in the range of 1000 us to 2000 us (https://en.wikipedia.org/wiki/Servo_control#/media/File:Servomotor_Timing_Diagram.svg).
I set the maximum steps to 2000 us:
so the duty cycle should be from 0.5 to 1.0. I assume that sending
echo "4=0.5" > /dev/pi-blaster
should turn the servo to -90 deg andecho "4=1"
should turn the servo by 180 deg into the +90 deg position. While the servo moves somehow related to these values, I cannot get it reliably into these -/+90 or 0 deg position (echo "4=0.75"
). The servo also seems to "hum", probably because the PWM signal is sent periodically, while the servo only expects a single up-down edge.Eventually, I would like to control an ESC which would use the same PWM duty cycle settings but with a periodic signal. I am currently using the servo as a simpler component to test the PWM generator.
The original
ServoBlaster
project contains aservodebug.c
to "help debug issues with ServoBlaster". Doespi-blaster
have a similar tool that could help me to debug the signal that is sent out to the servo?The text was updated successfully, but these errors were encountered: