-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'driver_merge_tmp/mcpwm' into 'master'
feature: Motor Control PWM(mcpwm) driver and examples See merge request !698
- Loading branch information
Showing
22 changed files
with
6,008 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
MCPWM | ||
===== | ||
|
||
Overview | ||
-------- | ||
|
||
ESP32 has two MCPWM units which can be used to control different motors. | ||
|
||
Block Diagram | ||
------------- | ||
|
||
The block diagram of MCPWM unit is as shown. | ||
|
||
:: | ||
|
||
__________________________________________________________________________ | ||
| SYNCSIG FAULT SIG CAPTURE SIG | | ||
| 0 1 2 0 1 2 0 1 2 | | ||
|___________________________________________________________________ G | | ||
INTERRUPTS<-----+ | | | | | | | | | | P | | ||
| | | | | | | | | | | I | | ||
________|_|___|___|_____________|___|___|_________|___|___|_________ | O | | ||
| | | | | | | | | | | | | | ||
| | | | | | | | | | | | M | | ||
| | | | __v___v___v__ __v___v___v__ | | A | | ||
| | | | | | | | | | T | | ||
| | | | | FAULT | | CAPTURE | | | R | | ||
| | | | | HANDLER | | | | | I | | ||
| | | | | | |___________| | | X | | ||
| | | | |___________| | | | | ||
| | | | | | | | ||
| ____v___v___v____ ____________________ | | | | ||
| | +---------+ | | +------------+ |--------->|PWM0A| | ||
| | | Timer 0 | | | | Operator 0 | | | | | | ||
| | +---------+ | | +------------+ |--------->|PWM0B| | ||
| | | | | | | | | ||
| | +---------+ | | +------------+ |--------->|PWM1A| | ||
| | | Timer 1 | |------------------->| | Operator 1 | | | | | | ||
| | +---------+ | | +------------+ |--------->|PWM1B| | ||
| | | | | | | | | ||
| | +---------+ | | +------------+ |--------->|PWM2A| | ||
| | | Timer 2 | | | | Operator 2 | | | | | | ||
| | +---------+ | | +------------+ |--------->|PWM2B| | ||
| |_______________| |__________________| | |_____| | ||
| | | ||
| MCPWM-UNIT 0/1 | | ||
|___________________________________________________________________| | ||
|
||
Application Example | ||
------------------- | ||
|
||
MCPWM different motor example: :example:`peripherals/mcpwm`. | ||
|
||
API Reference | ||
------------- | ||
|
||
Header Files | ||
^^^^^^^^^^^^ | ||
|
||
* :component_file:`driver/include/driver/mcpwm.h` | ||
|
||
Type Definitions | ||
^^^^^^^^^^^^^^^^ | ||
|
||
|
||
Enumerations | ||
^^^^^^^^^^^^ | ||
|
||
.. doxygenenum:: mcpwm_io_signals_t | ||
.. doxygenenum:: mcpwm_unit_t | ||
.. doxygenenum:: mcpwm_timer_t | ||
.. doxygenenum:: mcpwm_operator_t | ||
.. doxygenenum:: mcpwm_counter_type_t | ||
.. doxygenenum:: mcpwm_duty_type_t | ||
.. doxygenenum:: mcpwm_carrier_os_t | ||
.. doxygenenum:: mcpwm_carrier_out_ivt_t | ||
.. doxygenenum:: mcpwm_sync_signal_t | ||
.. doxygenenum:: mcpwm_fault_signal_t | ||
.. doxygenenum:: mcpwm_fault_input_level_t | ||
.. doxygenenum:: mcpwm_action_on_pwmxa_t | ||
.. doxygenenum:: mcpwm_action_on_pwmxb_t | ||
.. doxygenenum:: mcpwm_capture_signal_t | ||
.. doxygenenum:: mcpwm_capture_on_edge_t | ||
.. doxygenenum:: mcpwm_deadtime_type_t | ||
|
||
Structures | ||
^^^^^^^^^^ | ||
|
||
.. doxygenstruct:: mcpwm_config_t | ||
:members: | ||
|
||
.. doxygenstruct:: mcpwm_carrier_config_t | ||
:members: | ||
|
||
|
||
Functions | ||
^^^^^^^^^ | ||
|
||
.. doxygenfunction:: mcpwm_gpio_init | ||
.. doxygenfunction:: mcpwm_init | ||
.. doxygenfunction:: mcpwm_set_frequency | ||
.. doxygenfunction:: mcpwm_set_duty | ||
.. doxygenfunction:: mcpwm_set_duty_in_us | ||
.. doxygenfunction:: mcpwm_set_duty_type | ||
.. doxygenfunction:: mcpwm_get_frequency | ||
.. doxygenfunction:: mcpwm_get_duty | ||
.. doxygenfunction:: mcpwm_set_signal_high | ||
.. doxygenfunction:: mcpwm_set_signal_low | ||
.. doxygenfunction:: mcpwm_start | ||
.. doxygenfunction:: mcpwm_stop | ||
.. doxygenfunction:: mcpwm_carrier_init | ||
.. doxygenfunction:: mcpwm_carrier_enable | ||
.. doxygenfunction:: mcpwm_carrier_disable | ||
.. doxygenfunction:: mcpwm_carrier_set_period | ||
.. doxygenfunction:: mcpwm_carrier_set_duty_cycle | ||
.. doxygenfunction:: mcpwm_carrier_oneshot_mode_enable | ||
.. doxygenfunction:: mcpwm_carrier_oneshot_mode_disable | ||
.. doxygenfunction:: mcpwm_carrier_output_invert | ||
.. doxygenfunction:: mcpwm_deadtime_enable | ||
.. doxygenfunction:: mcpwm_deadtime_disable | ||
.. doxygenfunction:: mcpwm_fault_init | ||
.. doxygenfunction:: mcpwm_fault_set_oneshot_mode | ||
.. doxygenfunction:: mcpwm_fault_set_cyc_mode | ||
.. doxygenfunction:: mcpwm_fault_deinit | ||
.. doxygenfunction:: mcpwm_capture_enable | ||
.. doxygenfunction:: mcpwm_capture_disable | ||
.. doxygenfunction:: mcpwm_capture_signal_get_value | ||
.. doxygenfunction:: mcpwm_capture_signal_get_edge | ||
.. doxygenfunction:: mcpwm_sync_enable | ||
.. doxygenfunction:: mcpwm_sync_disable | ||
.. doxygenfunction:: mcpwm_isr_register | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# | ||
# This is a project Makefile. It is assumed the directory this Makefile resides in is a | ||
# project subdirectory. | ||
# | ||
|
||
PROJECT_NAME := mcpwm_basic_config | ||
|
||
include $(IDF_PATH)/make/project.mk | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# MCPWM basic config Example | ||
|
||
This example will show you how to use each submodule of MCPWM unit | ||
|
||
The example can't be used without modifying the code first | ||
|
||
Edit the macros at the top of mcpwm_example_basic_config.c to enable/disable the submodules which are used in the example | ||
|
||
|
||
## Step 1: Pin assignment | ||
* The gpio init function initializes: | ||
* six MCPWM output pins | ||
* three MCPWM fault input pins | ||
* three MCPWM sync input pins | ||
* three MCPWM capture input pins | ||
|
||
|
||
## Step 2: Connection | ||
* Six MCPWM output pins to motor driver input signals | ||
* Fault, sync, capture signals can be connected to respective signals | ||
|
||
|
||
## Step 3: Initialize MCPWM | ||
* You need to set the frequency and duty cycle of each three MCPWM timer along with other parameters mentioned | ||
* You need to set the MCPWM channel you want to use, with these timers | ||
|
||
|
||
## Step 4: Testing | ||
* The deadtime module, set deadtime type and with value as time*100ns | ||
* The sync module, synchonizes all the timer pulses | ||
* The fault module when enabled takes action on MCPWM signals when fault occurs | ||
* The capture module captures input signal(digital i.e. hall sensor value, etc), timing between two rising/falling edge |
3 changes: 3 additions & 0 deletions
3
examples/peripherals/mcpwm/mcpwm_basic_config/main/component.mk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# | ||
# Main Makefile. This is basically the same as a component makefile. | ||
# |
Oops, something went wrong.