You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the context of the <spanclass="simple">Simple<spanclass="foc">FOC</span>project</span> many different open-source community projects have been developed.
14
19
20
+
## Helper tools
21
+
22
+
-### Stm32 Pinout documentation
23
+
24
+
This is repo that aims providing a documentation on available PWM and ADC pins of most of the families of stm32 microcontrollers. This is an information that is usually hard to find and therefore we have decided to put it all in one place. The website is autogenerated parsing the latest release of the [stm32duino core](https://github.com/stm32duino/Arduino_Core_STM32).
<blockquoteclass="info"> 📢 Here is a quick guide to choosing appropriate PWM pins for different MCU architectures <ahref="choosing_pwm_pins">see in docs</a>.</blockquote>
Copy file name to clipboardExpand all lines: docs/simplefoc_library/cheatsheet/build_flags.md
+3
Original file line number
Diff line number
Diff line change
@@ -32,3 +32,6 @@ Flag | Architecture | Description
32
32
`SIMPLEFOC_DEBUG_RP2040` | RP2040 | set to enable extra debug output on Raspberry Pico.
33
33
`SIMPLEFOC_ESP32_USELEDC` | ESP32 | force use of the LEDC PWM driver even on ESP32s that support MCPWM. Mainly useful for testing purposes, normally you would prefer MCPWM if it is available.
34
34
`SIMPLEFOC_ESP32_HW_DEADTIME` | ESP32 | Select between MCPWM hardware deadtime and a software implementation allowing phase_state configuration. Defaults to hardware for being tested more.
35
+
`SIMPLEFOC_TEENSY_DEBUG` | Teensy 3.x / 4.x | Set to enable extra debug output for Teensy 3.x / 4.x MCUs.
36
+
`SIMPLEFOC_TEENSY4_ADC_INTERRUPT_DEBUG` | Teensy 4 | Enables a simple debugging for low-side current sense interrupts which sets the pin `30` to high each time the ADC1 fires an interrupt.
37
+
`SIMPLEFOC_TEENSY4_FORCE_CENTER_ALIGNED_3PWM` | Teensy 4 | Force center aligned 3PWM mode on Teensy 4. Normally 3PWM mode is not center aligned and the timers are not synchronized.
<blockquoteclass="info"> 📢 Here is a quick guide to choosing appropriate PWM pins for different MCU architectures <ahref="choosing_pwm_pins">see in docs</a>.</blockquote>
45
46
46
47
### Low-side current sensing considerations
47
48
@@ -59,13 +60,10 @@ You can also always ask the community for help - <a href="https://community.simp
59
60
## Step 2.1 PWM Configuration
60
61
```cpp
61
62
// pwm frequency to be used [Hz]
62
-
// for atmega328 fixed to 32kHz
63
+
// for atmega328 either 4k or 32kHz
63
64
// esp32/stm32/teensy configurable
64
65
driver.pwm_frequency = 20000;
65
66
```
66
-
<blockquoteclass="warning">
67
-
⚠️ Arduino devices based on ATMega328 chips have fixed pwm frequency of 32kHz.
68
-
</blockquote>
69
67
70
68
Here is a list of different microcontrollers and their PWM frequency and resolution used with the Arduino <spanclass="simple">Simple<spanclass="foc">FOC</span>library</span>.
All of these settings are defined in the `drivers/hardware_specific/x_mcu.cpp/h` of the library source.
80
78
81
-
82
79
### Low-side current sensing considerations
83
80
84
81
As the ADC conversion takes some time to finish and as this conversion has to happen only during the specific time window ( when all the phases are grounded - low-side mosfets are ON ) it is important to use an appropriate PWM frequency. PWM frequency will determine how long each period of the PWM is and in term how much time the low-side switches are ON. Higher PWM frequency will leave less time for the ADC to read the current values.
⚠️ 6 PWM configuration is very hardware specific and please make sure to respect certain guidelines in order for it to work properly!
39
39
</blockquote>
40
40
41
+
<blockquoteclass="info"> 📢 Here is a quick guide to choosing appropriate PWM pins for different MCU architectures <ahref="choosing_pwm_pins">see in docs</a>.</blockquote>
42
+
41
43
### Arduino UNO support
42
44
Arduino UNO and all the atmega328 based boards have only 6 PWM pins and in order to use the `BLDCDrievr6PWM` we need to use all of them. Those are `3`,`5`,`6`,`9`,`10` and `11`.
43
45
Furthermore in order for the algorithm to work well we need to use the PWM pins that belong to the same timer for each high/low side pair of each phase.
@@ -106,20 +108,17 @@ As ADC conversion has to be synchronised with the PWM generated on ALL the phase
106
108
In order to maximise your chances for the low-side current sensing to work well we suggest to make sure that the PWM pins chosen for your driver all belong to the same timer.
107
109
108
110
Finding out which pins belong to different timers might require some time to be spent in the MCU datasheet 😄
111
+
To try to save you some time, we have created a quick guide to choosing appropriate PWM pins for different MCU architectures <ahref="choosing_pwm_pins">see in docs</a>.
109
112
You can also always ask the community for help - <ahref="https://community.simplefoc.com/">community link</a>!
110
113
</blockquote>
111
114
112
115
## Step 2.1 PWM Configuration
113
116
```cpp
114
117
// pwm frequency to be used [Hz]
115
-
// for atmega328 fixed to 32kHz
118
+
// for atmega328 either 4k or 32kHz
116
119
// esp32/stm32/teensy configurable
117
120
driver.pwm_frequency = 20000;
118
121
```
119
-
<blockquoteclass="warning">
120
-
⚠️ Arduino devices based on ATMega328 chips have fixed PWM frequency of 32kHz.
121
-
</blockquote>
122
-
123
122
Here is a list of different microcontrollers and their PWM frequency and resolution used with the Arduino <spanclass="simple">Simple<spanclass="foc">FOC</span>library</span>.
124
123
125
124
MCU | default frequency | MAX frequency | PWM resolution | Center-aligned | Configurable freq
<sup>*</sup> For ESP32, the support for 6 PWM depends on the model of ESP32. The models that have a MCPWM peripheral support 6 PWM, the ones that do not only support the other PWM modes.
48
+
<blockquoteclass="info"> 📢 Here is a quick guide to choosing appropriate PWM pins for different MCU architectures <ahref="choosing_pwm_pins">see in docs</a>.</blockquote>
<blockquoteclass="info"> 📢 Here is a quick guide to choosing appropriate PWM pins for different MCU architectures <ahref="choosing_pwm_pins">see in docs</a>.</blockquote>
59
+
58
60
## Step 2.1 PWM Configuration
59
61
```cpp
60
62
// pwm frequency to be used [Hz]
61
-
// for atmega328 fixed to 32kHz
63
+
// for atmega328 either 4k or 32kHz
62
64
// esp32/stm32/teensy configurable
63
65
driver.pwm_frequency = 20000;
64
66
```
65
-
<blockquoteclass="warning">
66
-
⚠️ Arduino devices based on ATMega328 chips have fixed PWM frequency of 32kHz.
67
-
</blockquote>
68
67
69
68
Here is a list of different microcontrollers and their PWM frequency and resolution used with the Arduino <spanclass="simple">Simple<spanclass="foc">FOC</span>library</span>.
<blockquoteclass="info"> 📢 Here is a quick guide to choosing appropriate PWM pins for different MCU architectures <ahref="choosing_pwm_pins">see in docs</a>.</blockquote>
35
+
34
36
## Step 2.1 PWM Configuration
35
37
```cpp
36
38
// pwm frequency to be used [Hz]
37
-
// for atmega328 fixed to 32kHz
39
+
// for atmega328 either 4k or 32kHz
38
40
// esp32/stm32/teensy configurable
39
41
driver.pwm_frequency = 20000;
40
42
```
41
-
<blockquoteclass="warning">
42
-
⚠️ Arduino devices based on ATMega328 chips have fixed pwm frequency of 32kHz.
43
-
</blockquote>
44
43
45
-
Here is a list of different microcontrollers and their PWM frequency and resolution used with the Arduino <spanclass="simple">Simple<spanclass="foc">FOC</span>library</span>.
44
+
Here is a list of different microcontrollers and their PWM frequency and resolution used with the Arduino <spanclass="simple">Simple<spanclass="foc">FOC</span>library</span>.
46
45
47
46
MCU | default frequency | MAX frequency | PWM resolution | Center-aligned | Configurable freq
Copy file name to clipboardExpand all lines: docs/simplefoc_library/digging_deeper/index.md
+7
Original file line number
Diff line number
Diff line change
@@ -27,5 +27,12 @@ To better understand what is going on under the hood of this algorithm and to ge
27
27
</a>
28
28
<p> A discussion about the theory of different parts of the FOC algorithm and <span class="simple">Simple<span class="foc">FOC</span>library</span> </p>
0 commit comments