2020-04-09 08:40:57 +00:00
|
|
|
| Supported Targets | ESP32 |
|
|
|
|
| ----------------- | ----- |
|
|
|
|
|
2017-03-29 08:39:35 +00:00
|
|
|
# MCPWM brushed dc motor control Example
|
|
|
|
|
|
|
|
This example will show you how to use MCPWM module to control brushed dc motor, you need to make connection between ESP32 and motor driver
|
|
|
|
|
|
|
|
This code is tested with L298 motor driver, user needs to make changes according to the driver they use
|
|
|
|
|
|
|
|
Motor first moves forward, then backward and then stops for 2 Secs each countinuously
|
|
|
|
|
|
|
|
|
|
|
|
## Step 1: Pin assignment
|
2018-10-10 00:15:23 +00:00
|
|
|
* GPIO15 is assigned as the enable/input 1 for motor driver
|
2017-03-29 08:39:35 +00:00
|
|
|
* GPIO16 is assigned as the enable/input 2 for motor driver
|
|
|
|
|
|
|
|
|
|
|
|
## Step 2: Connection
|
|
|
|
* connect GPIO15 with input 1 of motor driver
|
|
|
|
* connect GPIO16 with input 2 of motor driver
|
|
|
|
|
|
|
|
|
|
|
|
## Step 3: Initialize MCPWM
|
|
|
|
* You need to set the frequency and duty cycle of MCPWM timer
|
2018-10-10 00:15:23 +00:00
|
|
|
* You need to set the MCPWM unit you want to use, and bind the unit with one of the timers
|