Skip to content
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

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

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.

@github-actions
Copy link

github-actions bot commented Sep 5, 2023

Code size report:


@codecov
Copy link

codecov bot commented Sep 5, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.39%. Comparing base (8809ae7) to head (e88200f).

Current head e88200f differs from pull request most recent head e6218be

Please upload reports for the commit e6218be to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12345      +/-   ##
==========================================
- Coverage   98.39%   98.39%   -0.01%     
==========================================
  Files         161      158       -3     
  Lines       21204    20939     -265     
==========================================
- Hits        20864    20602     -262     
+ Misses        340      337       -3     

☔ 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

@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 4 times, most recently from e604434 to 4d61f96 Compare June 5, 2024 11:40
IhorNehrutsa and others added 3 commits June 5, 2024 14:41
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.

None yet

3 participants