• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

main/11-Mar-2024-263216

CMakeLists.txtD11-Mar-2024247 75

MakefileD11-Mar-2024194 92

README.mdD11-Mar-20245.3 KiB8261

README.md

1| Supported Targets | ESP32 | ESP32-S3 |
2| ----------------- | ----- | -------- |
3
4# MCPWM BLDC Hall motor control Example
5
6(See the README.md file in the upper level 'examples' directory for more information about examples.)
7
8This example will illustrate how to use MCPWM driver to control BLDC motor with hall sensor feedback. In the example, a timer is running at the background to update the motor speed periodically.
9
10With the hardware fault detection feature of MCPWM, the example will shut down the MOSFETs when over current happens.
11
12## How to Use Example
13
14### Hardware Required
15
161. The BLDC motor used in this example has a hall sensor capture sequence of `6-->4-->5-->1-->3-->2-->6-->4-->` and so on.
172. A three-phase gate driver, this example uses [IR2136](https://www.infineon.com/cms/en/product/power/gate-driver-ics/ir2136s/).
183. Six N-MOSFETs, this example uses [IRF540NS](https://www.infineon.com/cms/en/product/power/mosfet/12v-300v-n-channel-power-mosfet/irf540ns/).
194. A development board with any Espressif SoC which features MCPWM peripheral (e.g., ESP32-DevKitC, ESP-WROVER-KIT, etc.)
205. A USB cable for Power supply and programming.
21
22Connection :
23
24```
25          ┌─────────────────────────────────────────────┐
26          │                                             │
27          │         ┌───────────────────────────┐       │
28          │         │                           │       │
29┌─────────┴─────────┴───────────┐      ┌────────┴───────┴──────────┐
30│      GPIO19      GPIO18       │      │        EN    FAULT        │
31│                         GPIO21├──────┤PWM_UH                     │        ┌────────────┐
32│                         GPIO22├──────┤PWM_UL                    U├────────┤            │
33│                               │      │                           │        │            │
34│                         GPIO23├──────┤PWM_VH                    V├────────┤    BLDC    │
35│         ESP Board       GPIO25├──────┤PWM_VL   3-Phase Bridge    │        │            │
36│                               │      │               +          W├────────┤            │
37│                         GPIO26├──────┤PWM_WH      MOSFET         │        └─┬───┬───┬──┘
38│                         GPIO27├──────┤PWM_WL                     │          │   │   │
39│    GPIO5  GPIO4  GPIO2        │      │                           │          │   │   │
40└─────┬──────┬──────┬───────────┘      └───────────────────────────┘          │   │   │
41      │      │      │   Hall U                                                │   │   │
42      │      │      └─────────────────────────────────────────────────────────┘   │   │
43      │      │          Hall V                                                    │   │
44      │      └────────────────────────────────────────────────────────────────────┘   │
45      │                 Hall W                                                        │
46      └───────────────────────────────────────────────────────────────────────────────┘
47```
48
49### Build and Flash
50
51Run `idf.py -p PORT flash monitor` to build, flash and monitor the project.
52
53(To exit the serial monitor, type ``Ctrl-]``.)
54
55See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html) for full steps to configure and use ESP-IDF to build projects.
56
57
58## Example Output
59
60Run the example, you will see the following output log:
61
62```
63...
64I (0) cpu_start: Starting scheduler on APP CPU.
65I (327) example: Disable gate driver
66I (327) gpio: GPIO[18]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
67I (337) example: Setup PWM and Hall GPIO (pull up internally)
68I (347) example: Initialize PWM (default to turn off all MOSFET)
69I (357) example: Initialize over current fault action
70I (357) example: Initialize Hall sensor capture
71I (367) example: Please turn on the motor power
72I (5367) example: Enable gate driver
73I (5367) example: Changing speed at background
74...
75```
76
77## Dive into the example
78
791. How to change the rotation direction?
80
81      The rotation direction is controlled by how the hall sensor value is parsed. If you pass `false` to `bldc_get_hall_sensor_value`, the BLDC should rotate in clock wise. Likewise, passing `true` to that function will make tha BLDC rotate in counter clock wise.
82