- Notifications
You must be signed in to change notification settings - Fork13.3k
Completely Detach Servo#7084
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
dok-net commentedFeb 18, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@obrain17 Your PR is kind of running against my major rework of the waveform generator, PR#7022. But you are certainly on to something here. voidServo::detach(){if (_attached) {startWaveform(_pin,0, REFRESH_INTERVAL,1);delay(REFRESH_INTERVAL /1000);// long enough to complete active period under all circumstances.stopWaveform(_pin); _attached =false; _valueUs = DEFAULT_NEUTRAL_PULSE_WIDTH; }} This way, first, without affecting period, the PWM duty cycle is cut to 0 for the next upcoming period. The waveform gets stopped only after the final real duty cycle has completed. |
dok-net commentedFeb 19, 2020
obrain17 commentedFeb 19, 2020
@dok-net I just inserted your code snippet into my project and the servo rotated smoothly without "jumps" with Anyway your code with controlled ending the waveform within a period makes much more sense than my easy workaround. So I will withdraw/close my PR. Thank you for the good work! |
dok-net commentedFeb 20, 2020
@obrain17 When you close this PR, please open an issue so we can keep track of the work to fix it - mention this PR, too, so the discussion isn't lost. |
Tech-TX commentedMar 5, 2020
Leaving the pin in input after detach() has bad effects with my servo: the servo sees noise from an adjacent pin and slams the 0 stop, groaning loudly. With a low it wouldn't be picking up noise from adjacent signals. I'll take a scope capture later this evening. I've noticed this with your PR, Dirk. |
dok-net commentedMar 5, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
earlephilhower left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@Tech-TX, you might want to replace INPUT with INPUT_PULLUP manually and give your servo a try.
| voidServo::detach() | ||
| { | ||
| if (_attached) { | ||
| pinMode(_pin, INPUT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
INPUT leaves the pin in a high impedance state and subject to noise unless an external pull-up/down resistor is added to the circuit.
INPUT_PULLUP, however, will have a weak pull-to-VCC resistor placed on the pad. Two potential issues are:
- Is "always 1" a valid, safe state for servo control inputs?
- What is the "typical" input impedance of a servo, and how does it compare to the (weak, can't seem to find the exact value) internal pullup?
Tech-TX commentedMar 6, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
obrain17 commentedMar 6, 2020
There are two issues I wanted to fix with my PR:
Anyway 1) is fixed with#7023 (containing the above mentioned code) I will close my PR but create an issue instead so our discussion here does not get lost. |


In current implementation twitches may occur when calling
Servo.detach().This is because after
stopwaveformis performed immediately and then followed bydigitalWrite(_pin, LOW)causing a different duty-factor on the PWM.Completely cutting off the pin with
pinMode(_pin, INPUT)solves this issue.A welcome side-effect is that
Servo.detach()would reallydetach the pin (high impedance) instead of setting it to LOW.