Skip to content

Commit

Permalink
prepatations for v2.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
askuric committed Apr 22, 2024
1 parent 668160f commit d8f1aee
Show file tree
Hide file tree
Showing 36 changed files with 685 additions and 88 deletions.
14 changes: 14 additions & 0 deletions docs/simplefoc_libraries/helper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
layout: default
title: <i class="fa fa-sm fa-book"></i> stm32 pinouts
#title: <a href="http://docs.simplefoc.com/stm32pinouts" style="padding:0px;color:inherit;background:none">stm32 pinout helper</a>
parent: <span class="simple">Simple<span class="foc">FOC</span>utils</span>
description: "Arduino Simple Field Oriented Control (FOC) library ."
nav_order: 1
permalink: stm32pinouts
has_children: False
---

Redirecting to the stm32 pinout helper page...

<meta http-equiv="refresh" content="0;url=https://docs.simplefoc.com/stm32pinouts/">
14 changes: 14 additions & 0 deletions docs/simplefoc_libraries/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,26 @@ nav_order: 5
permalink: /arduino_simplefoc_utils
has_children: True
has_toc: False
navbar:
items:
- title: External Link
url: https://example.com
external: true
---


# <span class="simple">Simple<span class="foc">FOC</span>utils</span>
In the context of the <span class="simple">Simple<span class="foc">FOC</span>project</span> many different open-source community projects have been developed.

## Helper tools

- ### Stm32 Pinout documentation

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).

<a href ="https://github.com/simplefoc/stm32pinouts" class="btn"><i class="fa fa-github"></i> Github repo</a> <a href ="https://docs.simplefoc.com/stm32pinouts/" class="btn btn-primary"><i class="fa fa-github"></i> Open stm32 pinout helper</a>

<blockquote class="info"> 📢 Here is a quick guide to choosing appropriate PWM pins for different MCU architectures <a href="choosing_pwm_pins">see in docs</a>.</blockquote>

## Arduino libraries

Expand Down
2 changes: 1 addition & 1 deletion docs/simplefoc_libraries/libraries/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ layout: default
title: libraries
parent: <span class="simple">Simple<span class="foc">FOC</span>utils</span>
description: "Arduino Simple Field Oriented Control (FOC) library ."
nav_order: 1
nav_order: 2
permalink: /additional_libraries
has_children: True
has_toc: False
Expand Down
2 changes: 1 addition & 1 deletion docs/simplefoc_libraries/tools/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ layout: default
title: tools
parent: <span class="simple">Simple<span class="foc">FOC</span>utils</span>
description: "Arduino Simple Field Oriented Control (FOC) library ."
nav_order: 2
nav_order: 3
permalink: /additional_tools
has_children: True
has_toc: False
Expand Down
3 changes: 3 additions & 0 deletions docs/simplefoc_library/cheatsheet/build_flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ Flag | Architecture | Description
`SIMPLEFOC_DEBUG_RP2040` | RP2040 | set to enable extra debug output on Raspberry Pico.
`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.
`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.
`SIMPLEFOC_TEENSY_DEBUG` | Teensy 3.x / 4.x | Set to enable extra debug output for Teensy 3.x / 4.x MCUs.
`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.
`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.
6 changes: 4 additions & 2 deletions docs/simplefoc_library/code/current_sense/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ stm32 (in general) | ✔️ | ❌ | ❌
stm32f1 family | ✔️ | ✔️ (one motor) | ❌
stm32f4 family | ✔️ | ✔️ (one motor) | ❌
stm32g4 family | ✔️ | ✔️ (one motor) | ❌
stm32l4 family | ✔️ | ✔️ (initial) | ❌
stm32l4 family | ✔️ | ✔️ (one motor) | ❌
stm32f7 family | ✔️ | ✔️ (initial) | ❌
stm32 B_G431B_ESC1 | ❌ | ✔️ (one motor) | ❌
esp32/esp32s3 | ✔️ | ✔️ | ❌
esp32s2/esp32c3 | ✔️ | ❌ | ❌
esp8266 | ❌ | ❌ | ❌
samd21 | ✔️ | ✔️ (one motor) | ❌
samd51 | ✔️ | ❌ | ❌
teensy | ✔️ | ❌ | ❌
teensy3 | ✔️ | ❌ | ❌
teensy4 | ✔️ | ✔️(one motor) | ❌
Raspberry Pi Pico | ✔️ | ❌ | ❌
Portenta H7 | ✔️ | ❌ | ❌
nRF52 | ✔️ | ❌ | ❌
Expand Down
5 changes: 4 additions & 1 deletion docs/simplefoc_library/code/current_sense/low_side.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ STM32 (in general) |❌
STM32f1 family | ✔️ (one motor)
STM32f4 family | ✔️ (one motor)
STM32g4 family | ✔️ (one motor)
STM32l4 family | ✔️ (one motor)
STM32f7 family | ✔️ (one motor)
STM32 B_G431B_ESC1 | ✔️
ESP32 |✔️
ESP8266 | ❌
SAMD21 | ✔️/❌ (one motor, poorly tested)
SAMD51 | ❌
Teensy | ❌
Teensy3 | ❌
Teensy4 | ✔️ (inital)
Raspberry Pi Pico | ❌
Portenta H7 | ❌
Renesas (UNO R4) | ❌ (TBD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Additionally this bldc driver class enables the user to provide enable signal fo
BLDCDriver3PWM driver = BLDCDriver3PWM(9, 10, 11, 8, 7, 6);
```

<blockquote class="info"> 📢 Here is a quick guide to choosing appropriate PWM pins for different MCU architectures <a href="choosing_pwm_pins">see in docs</a>.</blockquote>

### Low-side current sensing considerations

Expand All @@ -59,13 +60,10 @@ You can also always ask the community for help - <a href="https://community.simp
## Step 2.1 PWM Configuration
```cpp
// pwm frequency to be used [Hz]
// for atmega328 fixed to 32kHz
// for atmega328 either 4k or 32kHz
// esp32/stm32/teensy configurable
driver.pwm_frequency = 20000;
```
<blockquote class="warning">
⚠️ Arduino devices based on ATMega328 chips have fixed pwm frequency of 32kHz.
</blockquote>

Here is a list of different microcontrollers and their PWM frequency and resolution used with the Arduino <span class="simple">Simple<span class="foc">FOC</span>library</span>.

Expand All @@ -78,7 +76,6 @@ Teensy | 25kHz | 50kHz | 8bit | yes | yes

All of these settings are defined in the `drivers/hardware_specific/x_mcu.cpp/h` of the library source.


### Low-side current sensing considerations

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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ BLDCDriver6PWM driver = BLDCDriver6PWM(5,6, 9,10, 3,11, 8);
⚠️ 6 PWM configuration is very hardware specific and please make sure to respect certain guidelines in order for it to work properly!
</blockquote>

<blockquote class="info"> 📢 Here is a quick guide to choosing appropriate PWM pins for different MCU architectures <a href="choosing_pwm_pins">see in docs</a>.</blockquote>

### Arduino UNO support
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`.
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.
Expand Down Expand Up @@ -106,20 +108,17 @@ As ADC conversion has to be synchronised with the PWM generated on ALL the phase
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.

Finding out which pins belong to different timers might require some time to be spent in the MCU datasheet 😄
To try to save you some time, we have created a quick guide to choosing appropriate PWM pins for different MCU architectures <a href="choosing_pwm_pins">see in docs</a>.
You can also always ask the community for help - <a href="https://community.simplefoc.com/">community link</a>!
</blockquote>

## Step 2.1 PWM Configuration
```cpp
// pwm frequency to be used [Hz]
// for atmega328 fixed to 32kHz
// for atmega328 either 4k or 32kHz
// esp32/stm32/teensy configurable
driver.pwm_frequency = 20000;
```
<blockquote class="warning">
⚠️ Arduino devices based on ATMega328 chips have fixed PWM frequency of 32kHz.
</blockquote>

Here is a list of different microcontrollers and their PWM frequency and resolution used with the Arduino <span class="simple">Simple<span class="foc">FOC</span>library</span>.

MCU | default frequency | MAX frequency | PWM resolution | Center-aligned | Configurable freq
Expand Down
7 changes: 4 additions & 3 deletions docs/simplefoc_library/code/drivers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ These classes can be used as stand-alone classes and they can be used to set cer

MCU | 2 PWM mode | 4 PWM mode | 3 PWM mode | 6 PWM mode | pwm frequency config
--- | --- |--- |--- |--- |---
Arduino (8-bit) | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ (either 4kHz or 32kHz)
Arduino AVR (8-bit) | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ (either 4kHz or 32kHz)
Arduino DUE | ✔️ | ✔️ | ✔️ | ❌ | ✔️
stm32 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️
esp32 | ✔️ | ✔️ | ✔️ | ✔️ / ❌<sup>*</sup> | ✔️
esp32 `MCPWM` | ✔️ | ✔️ | ✔️ | ✔️ | ✔️
esp32 `LEDC`| ✔️ | ✔️ | ✔️ | ❌ | ✔️
esp8266 | ✔️ | ✔️ | ✔️ | ❌ | ✔️
samd21/51 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️
teensy | ✔️ | ✔️ | ✔️ | ✔️ | ✔️
Raspberry Pi Pico | ✔️ | ✔️ | ✔️ | ✔️ | ✔️
Portenta H7 | ✔️ | ✔️ | ✔️ | ❌ | ✔️
Renesas (UNO R4 Minima) | ✔️ | ✔️ | ✔️ | ✔️ | ✔️

<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.
<blockquote class="info"> 📢 Here is a quick guide to choosing appropriate PWM pins for different MCU architectures <a href="choosing_pwm_pins">see in docs</a>.</blockquote>
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ To create the interface to the stepper driver you need to specify the 2 `PWM` pi

For two direction pins per phase use the constructor:
```cpp
// pwm1 PWM1 phase pwm pin
// in1 IN1A phase dir pins
// pwm2 PWM2 phase pwm pin
// in2 IN2A phase dir pins
// en1 enable pin phase 1 (optional input)
// en2 enable pin phase 2 (optional input)
// StepperDriver2PWM(int pwm1, int* in1, int pwm2, int* in2, int en1 = NOT_SET, int en2 = NOT_SET);
// pwm1 PWM1 phase pwm pin
// in1 IN1A phase dir pins
// pwm2 PWM2 phase pwm pin
// in2 IN2A phase dir pins
// en1 enable pin phase 1 (optional input)
// en2 enable pin phase 2 (optional input)
// StepperDriver2PWM(int pwm1, int* in1, int pwm2, int* in2, int en1 = NOT_SET, int en2 = NOT_SET);
StepperDriver2PWM driver = StepperDriver2PWM(3, {4,5}, 10, {9,8}, 11, 12);
```
Expand All @@ -55,16 +55,15 @@ For only one direction pin per phase use the constructor:
StepperDriver2PWM driver = StepperDriver2PWM(3, 4, 5, 6, 11, 12);
```

<blockquote class="info"> 📢 Here is a quick guide to choosing appropriate PWM pins for different MCU architectures <a href="choosing_pwm_pins">see in docs</a>.</blockquote>

## Step 2.1 PWM Configuration
```cpp
// pwm frequency to be used [Hz]
// for atmega328 fixed to 32kHz
// for atmega328 either 4k or 32kHz
// esp32/stm32/teensy configurable
driver.pwm_frequency = 20000;
```
<blockquote class="warning">
⚠️ Arduino devices based on ATMega328 chips have fixed PWM frequency of 32kHz.
</blockquote>

Here is a list of different microcontrollers and their PWM frequency and resolution used with the Arduino <span class="simple">Simple<span class="foc">FOC</span>library</span>.

Expand All @@ -75,7 +74,7 @@ STM32 | 50kHz | 100kHz | 14bit | yes | yes
ESP32 | 40kHz | 100kHz | 10bit | yes | yes
Teensy | 50kHz | 100kHz | 8bit | yes | yes

All of these settings are defined in the `drivers/hardware_specific/x_mcu.cpp/h` of the library source.
All of these settings are defined in the `drivers/hardware_specific/x/x_mcu.cpp/h` of the library source.


## Step 2.2 Voltages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,17 @@ To create the interface to the stepper driver you need to specify the 4 `pwm` pi
StepperDriver4PWM driver = StepperDriver4PWM(5, 6, 9, 10, 7, 8);
```

<blockquote class="info"> 📢 Here is a quick guide to choosing appropriate PWM pins for different MCU architectures <a href="choosing_pwm_pins">see in docs</a>.</blockquote>

## Step 2.1 PWM Configuration
```cpp
// pwm frequency to be used [Hz]
// for atmega328 fixed to 32kHz
// for atmega328 either 4k or 32kHz
// esp32/stm32/teensy configurable
driver.pwm_frequency = 20000;
```
<blockquote class="warning">
⚠️ Arduino devices based on ATMega328 chips have fixed pwm frequency of 32kHz.
</blockquote>

Here is a list of different microcontrollers and their PWM frequency and resolution used with the Arduino <span class="simple">Simple<span class="foc">FOC</span>library</span>.
Here is a list of different microcontrollers and their PWM frequency and resolution used with the Arduino <span class="simple">Simple<span class="foc">FOC</span>library</span>.

MCU | default frequency | MAX frequency | PWM resolution | Center-aligned | Configurable freq
--- | --- | --- | --- | ---
Expand Down
7 changes: 7 additions & 0 deletions docs/simplefoc_library/digging_deeper/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,12 @@ To better understand what is going on under the hood of this algorithm and to ge
</a>
<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>
</div>
<div style="width:50%;text-align:center;" class="">
<a href="practical_guides">
<i class="fa fa-4x fa-cubes"></i>
<h4 style="color:inherit">Practical guides</h4>
</a>
<p> A collection of practical guides and explanations of different procedures when it comes to interacting with BLDC motors </p>
</div>
</div>

Loading

0 comments on commit d8f1aee

Please sign in to comment.