Tasmota and Servos

1,886 views
Skip to first unread message

Justin Adie

unread,
Oct 7, 2022, 12:47:53 PM10/7/22
to TasmotaUsers
Dear hive mind

I’m trying to set up a servo motor (for a cat feeder) using an ESP32 and tasmota.  Bare Arduino code works fine.  

I’m running into problems getting tasmota to do its stuff.  I’m following the guide here: https://github.com/arendst/Tasmota/discussions/10443

My set up is below (using a self-compiled 12.1.0.1 version that I use on a number of other esp32s)





NB I am using a PWM frequency of 50Hz as the servo I am using has a pulse width of 20ms. 

Shutter min and max are set at default (Shutter 1: min:90 max:500”}).  PWMRange is unchanged at 0-1023.

The issue I have is the the motion is extremely erratic and not capable of calibration (I’ve spent hours trying before zeroing the settings to record the video here to demonstrate on a clean install:


A snip of the console during the shutter moves is below




Has anyone had success with shutter mode and servos?  If so what am I doing wrong?  (I’ve tried many different values of shutter min and max (shutterpwmrange).  The servo I am using is a small 10KG torque MG996R.  The motor is powered from the high-current USB desk supply powering the ESP32.  The PWM pin is connected directly to the motor.  

Thanks in advance
Justin


Justin Adie

unread,
Oct 7, 2022, 12:49:05 PM10/7/22
to TasmotaUsers
On 7 Oct 2022, at 18:47, Justin Adie <justi...@adieandco.com> wrote:

Dear hive mind

I’m trying to set up a servo motor (for a cat feeder) using an ESP32 and tasmota.  Bare Arduino code works fine.  

I’m running into problems getting tasmota to do its stuff.  I’m following the guide here: https://github.com/arendst/Tasmota/discussions/10443

My set up is below (using a self-compiled 12.1.0.1 version that I use on a number of other esp32s)


<PastedGraphic-1.png>

<PastedGraphic-2.png>


NB I am using a PWM frequency of 50Hz as the servo I am using has a pulse width of 20ms. 

Shutter min and max are set at default (Shutter 1: min:90 max:500”}).  PWMRange is unchanged at 0-1023.

The issue I have is the the motion is extremely erratic and not capable of calibration (I’ve spent hours trying before zeroing the settings to record the video here to demonstrate on a clean install:


A snip of the console during the shutter moves is below


<PastedGraphic-3.png>

Philip Knowles

unread,
Oct 7, 2022, 3:10:44 PM10/7/22
to Justin Adie, TasmotaUsers

Not sure if this is the issue but PWM1-5 are ledc PWMs and 6+ are general purpose PWMs.

 

Sent from Mail for Windows

--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/DA2B294E-3AD0-4E8B-B88C-1DD7FB0C12AF%40adieandco.com.

 

Justin Adie

unread,
Oct 7, 2022, 3:35:46 PM10/7/22
to Philip Knowles, TasmotaUsers
Pushing the relays and PWM to 6 still works in the interface but there is zero movement on the servo. 

I think the shutter mode functionality uses ledcwrite under the hood.

If noone has any experience with this I will write my own driver and be done with it.  Interestingly the servo doesn't work with berry either (porting the C code from a working driver).  Suggests that something in tasmota is interfering and borking things.


Philip Knowles

unread,
Oct 8, 2022, 1:58:59 AM10/8/22
to Justin Adie, TasmotaUsers

Have you tried SetOption15 0?

The ESP32 seems to have both LEDC and MotorPWM but Tasmota defaults to LEDC for 1-5.

Justin Adie

unread,
Oct 8, 2022, 4:30:01 AM10/8/22
to Philip Knowles, TasmotaUsers
Yes.  SO15 stores position doesn't it?   But yes, followed the guidance precisely other than the pwm frequency as my servo is a 20ms type.  

I've got time after the morning caffeine injection to write a "proper" servo driver for tasmota in berry.   If that still doesn't work I will write one in C++.  And if that doesn't work I guess it is something in tasmota interfering with the long pulse times necessary so will give up as this is a one of use case.  I recall having similar problems when I built an automated fish feeder three years ago.  I ended up not using tasmota for that.



Philip Knowles

unread,
Oct 8, 2022, 4:54:46 AM10/8/22
to Justin Adie, TasmotaUsers
I suspect that there's a fight between the PWM driver and the rollershutter. There are options in rollershutter which might conflict with PWM settings. SO15 allows you to use PWM 1-5 for motor control.
The other thing might be to try a different GPIO. The one you're using is also used for things like capacitive sensing. Perhaps try using the Tx, SPI or I2C one to see if it makes a difference.
Or trying 100Hz instead of 50Hz. 20ms is an age to electronics. Clutching at straws.


From: Justin Adie <justi...@adieandco.com>
Sent: Saturday, October 8, 2022 9:29:45 AM
To: Philip Knowles <knowles...@gmail.com>
Cc: TasmotaUsers <sonof...@googlegroups.com>
Reply all
Reply to author
Forward
0 new messages