Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@IhorNehrutsa
Copy link
Contributor

@IhorNehrutsa IhorNehrutsa commented Aug 31, 2023

If possible, this will be full support for the ESP32 MCPWM peripheral according to the
Motor Control Pulse Width Modulator (MCPWM)

In the future, esp32.MCPWM will allow the development of common cross-port machine.COMPLEMENTARY_PWM, Space Vector PWM, machine.CAPTURE etc.

Based on Basic MCPWM support #5818
Some code is taken from https://github.com/micropython/micropython/blob/master/ports/mimxrt/machine_pwm.c @robert-hh

The py/mpprint.h file from #8050, the ports/esp32/mphalport.c and ports/esp32/mphalport.h files from #10888 will be removed from this PR when development is complete.

@IhorNehrutsa IhorNehrutsa marked this pull request as draft September 3, 2023 18:32
@github-actions
Copy link

github-actions bot commented Sep 5, 2023

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@codecov
Copy link

codecov bot commented Sep 5, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.57%. Comparing base (0e490b7) to head (7964650).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #12345   +/-   ##
=======================================
  Coverage   98.57%   98.57%           
=======================================
  Files         164      164           
  Lines       21345    21345           
=======================================
  Hits        21040    21040           
  Misses        305      305           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@IhorNehrutsa IhorNehrutsa force-pushed the from_pr_5818_MCPWM branch 3 times, most recently from d6e9338 to 95e91aa Compare September 7, 2023 14:57
@IhorNehrutsa
Copy link
Contributor Author

@IhorNehrutsa
Copy link
Contributor Author

Second stage:

m = MCPWM(0, (16,17), waveform=14, deadtime=2**16//8)
print(m)

MCPWM(0, (Pin(16), Pin(17)), freq=5000Hz, duty_u16=32768, deadtime=8192ns=82ticks, resolution_hz=10000000, period_ticks=2000 action=14)
P30922-101742

m.force00()

P30922-101923

m.force10()

P30922-101938

m.force01()

P30922-101953

m.force0_1()

P30922-102041

m.force_10()

P30922-102128

m.force_1_1()

P30922-102144

@IhorNehrutsa IhorNehrutsa force-pushed the from_pr_5818_MCPWM branch 2 times, most recently from 9172bfb to e88200f Compare October 6, 2023 06:05
@projectgus
Copy link
Contributor

This is an automated heads-up that we've just merged a Pull Request
that removes the STATIC macro from MicroPython's C API.

See #13763

A search suggests this PR might apply the STATIC macro to some C code. If it
does, then next time you rebase the PR (or merge from master) then you should
please replace all the STATIC keywords with static.

Although this is an automated message, feel free to @-reply to me directly if
you have any questions about this.

@IhorNehrutsa IhorNehrutsa force-pushed the from_pr_5818_MCPWM branch 5 times, most recently from 4d61f96 to e6218be Compare June 5, 2024 11:44
@IhorNehrutsa IhorNehrutsa force-pushed the from_pr_5818_MCPWM branch 2 times, most recently from 1f41bcd to 7964650 Compare November 2, 2024 18:03
esp32/MCPWM: Add complementary PWMs.

Signed-off-by: Ihor Nehrutsa <[email protected]>
Co-Authored-By: Andrew Leech <[email protected]>
Co-Authored-By: bskp <[email protected]>
Co-Authored-By: Robert Hammelrath <[email protected]>
@PythonKai
Copy link

PythonKai commented Dec 9, 2025

Hello Ihor,
I'm very interested into the MCPWM option on ESP32 port. Unfortunately I can't create (compile) firmware by my self. Is a current firmware for generic ESP32 available include MCPWM ?
Best way for me is an external .py module that can be imported to the ESP flash and used in the standard MPY.
If anybody has an solution, please let me know.
By the way thank you all for the hard work and the great software micropython !!
BR Kai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants