Skip to content
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

How do you immediately stop a servo's movement? #11

Open
flyingw88 opened this issue Nov 7, 2019 · 13 comments
Open

How do you immediately stop a servo's movement? #11

flyingw88 opened this issue Nov 7, 2019 · 13 comments

Comments

@flyingw88
Copy link

I am using the Maestro controller to control animatronics for Halloween and Christmas displays. I had a problem where the display got stuck and the servo kept trying to move it. This is real bad for the servo.

I can detect that the servo did not reach its commanded position, but I cannot figure out how to stop it immediately.

I appreciate any ideas. Thanks,

Paul

@FRC4564
Copy link
Owner

FRC4564 commented Nov 9, 2019 via email

@flyingw88
Copy link
Author

flyingw88 commented Nov 9, 2019

Thanks Steve,

Thanks for the quick response.

I set the channel to go OFF on startup and error in the Maestro Control Center.

I did not get it work for me yet, but I am not sure of the syntax for the close() case. Is the correct among the possibilities I've listed below?

close()
close(0) # for servo 0
servo.close
servo.close(0) # for servo 0
servo.usb.close

Take care, Paul

@flyingw88
Copy link
Author

Found a good solution: After detecting that the servo has not reached its commanded, position, use its current position to set the new position - it stops about where it got jammed.

Thanks, Paul

@vcalukovic
Copy link

Hi @flyingw88 ,

I think I have a similar issue as you had. Would you mind sharing your code for fixing this? You don't turn off the servo port or use PWM changes to control this, but allow for further position changes to be initiated, right?

Thanks!
Vera

@flyingw88
Copy link
Author

flyingw88 commented Apr 30, 2021 via email

@vcalukovic
Copy link

vcalukovic commented Apr 30, 2021 via email

@flyingw88
Copy link
Author

flyingw88 commented Apr 30, 2021 via email

@vcalukovic
Copy link

Hi Paul,

Unfortunately it doesn't fix my problem - the shutter I'm controlling keeps vibrating despite claiming that it's not moving.
Thanks a lot though! It's always good to see others' code for inspiration.

Best,
Vera

@flyingw88
Copy link
Author

flyingw88 commented Apr 30, 2021 via email

@vcalukovic
Copy link

Good point, will try that!
Thanks!
Vera

@FRC4564
Copy link
Owner

FRC4564 commented May 3, 2021

Sorry I'm late to the conversation, but I may be able to provide a bit of insight that could helpful.

The Maestro is controlling servos by sending a Pulse Width Modulated signal about 50 times a seconds. The width of the pulse is what the servo interprets for positioning. Standard pulse widths range between 1 and 2 milliseconds to represent the servos extreme positions, and a pulse width of 1.5 milliseconds represents center.

The Maestro can only send PWM signals to the servo--There is no return signal that indicates the actual servo position. The Maestro can, however, estimate the servo position based on the PWM signal it is sending. When you use the Maestro's Speed and Acceleration parameters, you can slow the change in the PWM output, and if the servo is able to move freely and keep pace with the PWM change, then the Maestro can reasonably predict where the servo is positioned.

This estimation fails to work if the servo motion is impeded or fully stalls. The Maestro will continue to adjust the PWM signal to reach the Target position, unware that the servo is no longer moving in sync with the change. The only way to truly know the servo's position is from some other feedback sensor. That could be a potentiometer or a limit switch, for instance (which the Maestro can actually read on another channel, if wired properly). A current sensor can be used to provide feedback on impeded movement or stall condition, but won't provide any positioning information.

One option you can consider is to disable the servo once you 'think' you have reached the target position. To do this, the servo needs to stop receiving the PWM signal. This will stop the servo motor, so it will no longer stutter or attempt to keep pushing. You can do this by setting the channel's target to 0 (ex: m.setTarget(0,0)).

Hope that helps.

Steve

@vcalukovic
Copy link

Hi Steve,

Thanks for your explanation! I've tried using servo.setTarget(chan, 0) when the behaviour appeared, but this resets the target position to zero (where there is a chance of jamming again), not stop the jamming at the initial target position. I also tried this by setting the speed to unrestricted, which resulted in the same behaviour as when a speed was specified.

I will try to add a current sensor or something else I can use as switch. Will get back to you on the results.

Thanks for the suggestions!
Vera

@zombieregime
Copy link

You could run a wire back down the servo cable to another channel and read in the analog reading off the servos internal potentiometer supposing the voltages agree. This will give you closed loop absolute positioning. However, as said above, basic servos and basic servo control is strictly one way. The green dot in the control center is the position the controller is currently sending (the current PWM duty cycle). There is no possible way for the controller to know where the servo is or what it is doing (in a stock unmodified state), there is also no provision within a stock servo to report where it is in its sweep. This is a common misconception with servos and servo controllers. The servos only read the duty cycle (percentage of high to low across a period of time) it receives on the signal wire (1ms is always high, some percentage of the time between 1ms and 2ms being high with a definite high resetting the timing at 2ms, or there is a high edge every 2ms followed by 1ms high then the actual position value encoded as the percent it stays high before the next high edge 2ms from the last high edge). So, if the signal is to goto 50% of the sweep, the signal would be 1ms high, plus 0.5ms high (1.5ms total), then 0.5ms low, before transitioning back to high at 2ms total time from last raising edge starting the 1ms high stage over again. The servo then takes this duty cycle, compares it to what it reads on the potentiometer via an internal ADC, and activates an H-bridge to drive the motor in the direction of the new position. The slow easy movement is a trick achieved by transmitting small changes in the position. As far as the servo is concerned it will just flip the motor on full bore in the direction it needs to go. Its just that the new position is so close it only pulses the motor for a short period. But the motor is indeed driven full power. Its the position the controller is feeding it that makes it appear to be slow and soft.

Basically, servos be dumb out of the box, but there are ways of making them smarter ;)

Sidenote: if you're getting jitters and you're absolutely positive you are not over loading the servo, there isnt something trying to drive it off position(like trying to pull/compress something elastic, ie foam), and you're not sitting against an end stop, try a clip on ferrous core around the servo wire near the servo. Wrap the wire around the core once before clipping it. Typically jitters (if not due to over loading) are caused by EMI on the signal wire confusing control circuitry inside the servo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants