Hey.
I’m planning on trying to get an esp32 to control my beer-brewing machine.
It’s got 12 pinch valves in there, which are controlled by servos (mg996r).
They are set by a pwm signal, and originally – when opening or closing the valves, it runs a short 1-2 second period of providing 5v to the servo, and sending the pwm signal. After this, everything goes back down – both the 5v supply, and also the pwm signal. The open/close positions of the servo are neither in a fully open or fully closed position. (5833 is the closed posistion)
I’m trying to figure out what the best way is, to mimic this behaviour :
A:
ledcAttachPin(16,3); ledcWrite(3,5833); delay(1000); ledcWrite(3,0);
Or B:
ledcAttachPin(16,3); ledcWrite(3,5833); delay(1000); ledcDetachPin(16);
with B I do have to reattach the pin with every call, but does it use less memory or power??
Hi Anders.
I’m sorry for taking so long to get back to you.
Your question was lost in so many other question we have here. I apologize for that.
I never did that experiment. But for what I read, servo motors are supposed to receive PWM signals continuously. If you detach PWM, it may hold the position, go to some random position or other unpredictable behavior.
However, I suggest that you experiment both codes and see how your motors behave. But I think the most “correct” way is option A.
Can you test it and then, tell me the results?
Regards,
Sara
Hey – thanks for your reply.
What I was afraid of, was that if I just use option A, then the servo would go to a a third position (corresponding to “0”).
I think what I will end up doing, is use another pin to turn the 5V supply for the servos on/off – then I should be safe.
Anyways, again thanks for your input 🙂
Regards
Anders