Servo library

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
User avatar
dhylands
Posts: 3246
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Servo library

Post by dhylands » Sun Sep 04, 2016 8:29 am

The Servo library only gives 10 usec resolution.

If you use something like this:
https://github.com/dhylands/upy-example ... py#L10-L13
then you can get 1 usec resolution (at 50 Hz or 100 Hz).

User avatar
deshipu
Posts: 1348
Joined: Thu May 28, 2015 5:54 pm

Re: Servo library

Post by deshipu » Sun Sep 04, 2016 9:12 am

Of course that will only work with a single servo, and only on the specific board you are using. Also, servos have a dead band (to avoid oscillations), so they won't react to small changes in the duty cycle length anyways.

User avatar
pythoncoder
Posts: 3707
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Servo library

Post by pythoncoder » Mon Sep 05, 2016 7:36 am

deshipu wrote:...servos have a dead band (to avoid oscillations)...
In which case the designer of their control system should be shot ;) A dead band really shouldn't be necessary!
Peter Hinch

User avatar
deshipu
Posts: 1348
Joined: Thu May 28, 2015 5:54 pm

Re: Servo library

Post by deshipu » Mon Sep 05, 2016 7:44 am

What can I say, those are cheap servos, this has been a traditional solution in the "industry" for decades, and they can't really say what load/inertia they will have to handle (to tune the PID properly). Smart servos are probably better designed, but they use a completely different protocol, usually based on half-duplex UART.

mflmartin
Posts: 17
Joined: Sat Jul 23, 2016 7:30 pm

Re: Servo library

Post by mflmartin » Sun Jan 01, 2017 11:26 pm

Hi!

I have 2 questions:

Can you control a 360 degrees servo with this driver?

And, could we control 2 or more servos with an ESP-12 for instance?

Thanks!


Sent from my iPhone using Tapatalk

User avatar
deshipu
Posts: 1348
Joined: Thu May 28, 2015 5:54 pm

Re: Servo library

Post by deshipu » Mon Jan 02, 2017 9:31 am

mflmartin wrote: Can you control a 360 degrees servo with this driver?
You can control any servo that takes a standard servo PWM signal. Continuous rotation servos usually do.
mflmartin wrote: And, could we control 2 or more servos with an ESP-12 for instance?
Since the MicroPython's PWM class works with 8 of the GPIO pins, you can control up to 8 servos. Technically it would be possible to control up to ten, if you re-used the serial pins, but the PWM class doesn't work with those currently.

mflmartin
Posts: 17
Joined: Sat Jul 23, 2016 7:30 pm

Servo library

Post by mflmartin » Mon Jan 02, 2017 10:35 am

Thanks!

And, from your experience, if I wanted to know the position of a continuous servo motor or dc motor, what would you use? A homing switch with a hall effect magnet for instance?
I want to make an analog clock, but I want to be able to know where the handle are (or where their start position is). What do you think?

Thanks!

User avatar
deshipu
Posts: 1348
Joined: Thu May 28, 2015 5:54 pm

Re: Servo library

Post by deshipu » Mon Jan 02, 2017 11:23 am

You would use encoders of some kind, but I really don't have much experience with this, so can't recommend anything. At this point you might consider using a stepper motor or even a normal DC motor, as the servos don't really give you much, since you need to do your own PID control loop with your own encoder anyways.

mflmartin
Posts: 17
Joined: Sat Jul 23, 2016 7:30 pm

Re: Servo library

Post by mflmartin » Mon Jan 02, 2017 11:37 am

deshipu wrote:You would use encoders of some kind, but I really don't have much experience with this, so can't recommend anything. At this point you might consider using a stepper motor or even a normal DC motor, as the servos don't really give you much, since you need to do your own PID control loop with your own encoder anyways.
I see. Thanks for the guidelines, and, of course, the driver!! Image.


Sent from my iPhone using Tapatalk

User avatar
pythoncoder
Posts: 3707
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Servo library

Post by pythoncoder » Mon Jan 02, 2017 11:43 am

An easy way might be to use a standard 180 degree servo and gear it up 2:1. The only snag is that at (say) 11.59 the clock's hand would sweep through 354 degrees backwards to get to 12.00.
Peter Hinch

Post Reply