I've been trying to control some hobby servos using micropython and a esp32 wroom nodemcu board with strange results.
Everywhere I find documentation for hobby servos (I have a MG996R) I find a code like this:
Code: Select all
from machine import Pin, PWM
servo = PWM(Pin(27), freq=50)
servo.duty(55) #or other value
What I also figured is that if I set the frequency somewhere between 800 and 1000 it works but for instance, in a continous rotation servo I can only rotate to one direction and never to the other.
The other non-continous servo is rated for 180 degrees range, the minimum (500us) and maximum pulse width (2500us) but I can barely manage to make it go 40 degrees using these high frequencies. Once again, it works perfectly in the esp8266.
I am fairly new to electronics and micropython and I also don't have an oscilloscope. I appreciate any help you can bring me on how to control the servos on the esp32 since I want to benefit from this board features over the old one.
Thanks!
EDIT: I failed to mention I tried this in two different ESP32 boards from different models and I had the same behaviour. I also tested 3 different servos.