How to output two complementary PWM waveforms from PICO microcontroller?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
Jackli
Posts: 80
Joined: Thu Apr 29, 2021 9:11 am

How to output two complementary PWM waveforms from PICO microcontroller?

Post by Jackli » Tue Aug 03, 2021 10:36 am

How to output two complementary PWM waveforms from the PICO microcontroller, by using MicroPython?

pwm_A=PWM(Pin(0))

pwm_A.freq(10000000)

If you use the above two lines, only one way PWM can be output, how to use the code to output two complementary PWM waveforms, one way high when the other is low. And the frequency can reach 1M. This microcontroller is no problem at all.

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: How to output two complementary PWM waveforms from PICO microcontroller?

Post by davef » Tue Aug 03, 2021 10:50 am

Reading the Quick ref suggest to me that you can generate multiple PWM signals.
Is the problem ... that you can't generate two PWM signals at the same frequency, but with the opposite polarity?

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: How to output two complementary PWM waveforms from PICO microcontroller?

Post by davef » Tue Aug 03, 2021 10:56 am

An external inverter is not allowed?

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: How to output two complementary PWM waveforms from PICO microcontroller?

Post by davef » Tue Aug 03, 2021 11:13 am

I am only familiar with the PWM on the ATmega88 so had a look at the PICO datasheet. Doesn't seem to have much to say.
Seems more common to use an external H-bridge driver https://www.tomshardware.com/how-to/dc- ... ry-pi-pico

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: How to output two complementary PWM waveforms from PICO microcontroller?

Post by jimmo » Wed Aug 04, 2021 5:54 am

Jackli wrote:
Tue Aug 03, 2021 10:36 am
How to output two complementary PWM waveforms from the PICO microcontroller, by using MicroPython?
I'm pretty sure this can be done on the RP2040 using phase alignment (see 4.5.2.8 in the data sheet), but it is not exposed by the micropython API.

You might instead be able to do this with the PIO though -- see the pio_pwm.py example at https://github.com/micropython/micropyt ... pio_pwm.py

Post Reply