Skip to content

esp32/MCPWM: Add motor control MCPWM driver. #12345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

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 and others added 4 commits November 2, 2024 20:02
esp32/mphalport: Add __FUNCTION__,
 __LINE__, __FILE__ info to check_esp_err().

Signed-off-by: Ihor Nehrutsa <IhorNehrutsa@gmail.com>
esp32/MCPWM: Add complementary PWMs.

Signed-off-by: Ihor Nehrutsa <Ihor.Nehrutsa@gmail.com>
Co-Authored-By: bskp <bskp@posteo.ch>
Co-Authored-By: Robert Hammelrath <12476868+robert-hh@users.noreply.github.com>
py/mpprint.h: Rename MP_PRN to MP_DEBUG_PRINT.

Move MP_DEBUG_PRINT_XXX constants upper to the #if MICROPY_INCLUDED_PY_MPPRINT_H/#endif block.

Co-Authored-By: Andrew Leech <3318786+andrewleech@users.noreply.github.com>

py/mpprint.h: Fix typo.

py/mpprint.h: Move HOWTO  upper.

Add gaps between MP_DEBUG_PRINT_XXX levels.
Move `How to use:` upper before #define MP_DEBUG_PRINT().
Print level names instead of the numbers.

Signed-off-by: Ihor Nehrutsa <IhorNehrutsa@gmail.com>

py/mpprint.h: Move HOWTO  upper.

Add gaps between MP_DEBUG_PRINT_XXX levels.
Move `How to use:` upper before #define MP_DEBUG_PRINT().
Print level names instead of the numbers.

Signed-off-by: Ihor Nehrutsa <IhorNehrutsa@gmail.com>

py/mpprint.h: Fix typo.

py/mpprint.h: Rename MP_PRN to MP_DEBUG_PRINT.

Move MP_DEBUG_PRINT_XXX constants upper to the #if MICROPY_INCLUDED_PY_MPPRINT_H/#endif block.

py/mpprint.h: Add MP_PRN() macro.

Co-Authored-By: Andrew Leech <3318786+andrewleech@users.noreply.github.com>
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.

3 participants