Hello,
Forgive me if this is a newbie question. I am fairly new to Micropython and embedded development in general. I am developing for the ESP32-WROOM-32D on a custom PCB.
My project has two stepper motors driven by PWM. These motors needs to be driven at different speeds independently. From what I've read, this is not possible with Micropython as all PWM are using a single timer. I'm currently using the Loboris fork of Micropython to get around this limitation, however I also need BLE which Loboris fork does not support.
I also need the motors to run in a separate "thread", but the experimental thread support is causing out-of-memory with the rest of my application running. I'm using uasyncio for the rest of the application tasks, but it can't sleep microseconds and doesn't seem to do the trick for continuously driving the motors.
So I am stuck.
I've looked at the Timer documentation for Wipy, but I don't seem to have the Timer.PWM in Micropython
https://docs.micropython.org/en/latest/ ... timer.html
I've tried rolling my own code to pulse the motors as in this post, but
viewtopic.php?t=3115
Is there a way to make Micropython use separate timers for two PWM signals?
PWM on separate timers
Re: PWM on separate timers
Hello,
I don't think so.
I can't find the information but I have tried to use separate PWM frequencies for steppers motors and finally I have read somewhere that it was not possible on ESP32 boards.
If you can, I am interested to know how do that ...
I don't think so.
I can't find the information but I have tried to use separate PWM frequencies for steppers motors and finally I have read somewhere that it was not possible on ESP32 boards.
If you can, I am interested to know how do that ...
Re: PWM on separate timers
Short version: there is actually a machine.PWM class in MicroPython, but only on ESP32, and it isn't documented. You can see an example here: http://docs.micropython.org/en/latest/e ... modulationignitablemoss wrote: ↑Fri Jul 17, 2020 9:22 pmI've looked at the Timer documentation for Wipy, but I don't seem to have the Timer.PWM in Micropython
There are 8 PWM channels, but like you say, they all run at the same frequency (although each may have its own duty cycle).
Longer version: Coming up with a cross-architecture PWM API is very difficult, because every microcontroller has a different way of doing PWM, and the sharing of resources between pins, timers, channels, etc can get complicated. It's in-progress, and was originally being planned for v1.13 but I'm not sure if that's still the case.
The ESP32 port added it's machine.PWM implementation independently, but this is why it's not documented, as the API will likely change before being "standardised" across all the ports.
The ESP32 does have dedicated "Motor Control" PWM hardware. It's not currently exposed in MicroPython, however https://github.com/micropython/micropython/pull/5818 might be of interest to you.
Re: PWM on separate timers
you could always use two esp32 boards. one for each motor