setting PWM timers

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

setting PWM timers

Post by OutoftheBOTS_ » Sat Jan 29, 2022 10:20 am

I need to drive my h-bridges fro my motors at a freq of about 40,000Hz and also drive a servo at a freq of 50Hz

I have been driving my robot around fine using the H-bridges at 40,000Hz but I am now adding the control of a servo and when I create the PWM for the servo at 50Hz it also changes the the freq of the H-bridge freq to 50Hz which is to slow.

How can I select which timer is used for each PWM instance??

I have had to go back to old firmware as the newer versions couldn't create PWM at 50Hz
this is the firmware that I have gone back too
Capture.PNG
Capture.PNG (11.44 KiB) Viewed 5418 times

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: setting PWM timers

Post by Roberthh » Sat Jan 29, 2022 12:58 pm

There is a PR #8210 fixing the PWM bug not allowing frequencies below 611 Hz. It is waiting for getting approved & merged by Damien.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: setting PWM timers

Post by OutoftheBOTS_ » Sat Jan 29, 2022 9:51 pm

Roberthh wrote:
Sat Jan 29, 2022 12:58 pm
There is a PR #8210 fixing the PWM bug not allowing frequencies below 611 Hz. It is waiting for getting approved & merged by Damien.
Thanks.

I have found a work around for my current needs. I Found that v.16 will do a freq of 50Hz for the servo so I am using it. To be able to drive my servo and motors I stop the motors and change the freq to 50Hz then set the servo position then set duty to 0 then change the freq back to 40,000Hz for my motors then drive agaian. This way I can operate both just not at the same time.

Robert I look forward to your PR when both freq can be used at the same time and low freq can be used as well

prathode
Posts: 5
Joined: Tue Feb 01, 2022 1:16 pm

Re: setting PWM timers

Post by prathode » Fri Feb 04, 2022 9:32 am

OutoftheBOTS_ wrote:
Sat Jan 29, 2022 9:51 pm

Thanks.

I have found a work around for my current needs. I Found that v.16 will do a freq of 50Hz for the servo so I am using it. To be able to drive my servo and motors I stop the motors and change the freq to 50Hz then set the servo position then set duty to 0 then change the freq back to 40,000Hz for my motors then drive agaian. This way I can operate both just not at the same time.

Robert I look forward to your PR when both freq can be used at the same time and low freq can be used as well
@OutoftheBOTS_ Can you share link for the work you found, it might be helpful to me as I am looking for example to work with PWM timers accessed periodically with uneven duty cycles.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: setting PWM timers

Post by Roberthh » Fri Feb 04, 2022 10:11 am

Pwm on esp32 is now fixed.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: setting PWM timers

Post by OutoftheBOTS_ » Fri Feb 04, 2022 7:57 pm

Roberthh wrote:
Fri Feb 04, 2022 10:11 am
Pwm on esp32 is now fixed.
Thanks Robert, I downloaded v.18 and tested it and it worked perfectly for me :)

Post Reply