Skip to content

Commit 17316b9

Browse files
committed
work in ptogress
1 parent fda3246 commit 17316b9

65 files changed

Lines changed: 1657 additions & 161 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/simplefoc_library/code/current_sense/index.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ MCU | In-line | Low-side | High-side
4848
Arduino (8-bit) | ✔️ | ❌ | ❌
4949
Arduino DUE | ✔️ | ❌ | ❌
5050
stm32 (in general) | ✔️ | ❌ | ❌
51-
stm32f1 family | ✔️ | ✔️ (one motor) | ❌
52-
stm32f4 family | ✔️ | ✔️ (one motor) | ❌
53-
stm32g4 family | ✔️ | ✔️ (one motor) | ❌
54-
stm32l4 family | ✔️ | ✔️ (one motor) | ❌
55-
stm32f7 family | ✔️ | ✔️ (one motor) | ❌
56-
stm32h7 family | ✔️ | ✔️ (one motor) | ❌
51+
stm32f1 family | ✔️ | ✔️ | ❌
52+
stm32f4 family | ✔️ | ✔️ | ❌
53+
stm32g4 family | ✔️ | ✔️ | ❌
54+
stm32l4 family | ✔️ | ✔️ | ❌
55+
stm32f7 family | ✔️ | ✔️ | ❌
56+
stm32h7 family | ✔️ | ✔️ | ❌
5757
stm32 B_G431B_ESC1 | ❌ | ✔️ (one motor) | ❌
5858
esp32/esp32s3 | ✔️ | ✔️ | ❌
5959
esp32s2/esp32c3 | ✔️ | ❌ | ❌
@@ -66,6 +66,7 @@ Raspberry Pi Pico | ✔️ | ❌ | ❌
6666
Portenta H7 | ✔️ | ❌ | ❌
6767
nRF52 | ✔️ | ❌ | ❌
6868
Renesas (UNO R4) | ❌ | ❌ | ❌
69+
Arduino Nano Matter(📢NEW) | ✔️ | ✔️ (one motor) | ✔️ (not tested)
6970

7071
Note: current sensing on Renesas MCUs will be added in a future release.
7172

docs/simplefoc_library/code/current_sense/inline.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Teensy | ✔️
4141
Raspberry Pi Pico | ✔️
4242
Portenta H7 | ✔️
4343
Renesas (UNO R4) | ❌ (TBD)
44+
Arduino Nano Matter(📢NEW) | ✔️
4445

4546

4647

@@ -59,7 +60,7 @@ To instantiate the inline current sensor using the <span class="simple">Simple<s
5960
// - phA - A phase adc pin
6061
// - phB - B phase adc pin
6162
// - phC - C phase adc pin (optional)
62-
InlineCurrentSense current_sense = InlineCurrentSense(0.01, 20, A0, A1, A2);
63+
InlineCurrentSense current_sense = InlineCurrentSense(0.01f, 20.0f, A0, A1, A2);
6364
```
6465

6566
This class takes as a parameter either shunt resistance value `shunt_resistor`, amplification gain `gain` and two or three ADC channel pins depending on the available measuring hardware that you might have. It is important to specify right adc channels for right driver/motor phase. So if your pin `A0` measures the phase current `A` and pin `A1` measures the phase current `B` make sure to provide them to the constructor in that order.
@@ -75,7 +76,7 @@ Alternatively `InlineCurrentSense` can be created by specifying the mV per Amp r
7576
// - phA - A phase adc pin
7677
// - phB - B phase adc pin
7778
// - phC - C phase adc pin (optional)
78-
InlineCurrentSense current_sense = InlineCurrentSense(66.0, A0, A1, A2);
79+
InlineCurrentSense current_sense = InlineCurrentSense(66.0f, A0, A1, A2);
7980
```
8081

8182
### Measuring 2 out of 3 currents

docs/simplefoc_library/code/current_sense/low_side.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,24 @@ MCU | Low-side Current sensing | ADC conversion type | Max PWM freqeuncy | supp
4747
Arduino (8-bit) | ❌ | - | -| -
4848
Arduino DUE | ❌ | - | -| -
4949
STM32 (in general) |❌ | - | -| -
50-
STM32f1 family | ✔️ (one motor) | DMA | ~20kHz| all
51-
STM32f4 family | ✔️ (one motor) | DMA| ~25kHz| all
52-
STM32g4 family | ✔️ (one motor) | DMA| ~25kHz| all
53-
STM32l4 family | ✔️ (one motor) | DMA| ~25kHz| all
54-
STM32f7 family | ✔️ (one motor) | DMA| ~25kHz | all
55-
STM32h7 family | ✔️ (one motor) | DMA| ~25kHz | all
50+
STM32f1 family | ✔️ | Interrupt | ~20kHz| all
51+
STM32f4 family | ✔️ | Interrupt| ~25kHz| all
52+
STM32g4 family | ✔️ | Interrupt| ~25kHz| all
53+
STM32l4 family | ✔️ | Interrupt| ~25kHz| all
54+
STM32f7 family | ✔️ | Interrupt| ~25kHz | all
55+
STM32h7 family | ✔️ | Interrupt| ~25kHz | all
5656
STM32 B_G431B_ESC1 | ✔️ | DMA| ~25kHz| all
5757
ESP32 with MCPWM |✔️ | Interrupts| ~20kHz| all
5858
ESP32 with LEDC | ❌ | -| -| -
5959
ESP8266 | ❌ | -| -| -
60-
SAMD21 | ✔️/❌ (one motor, poorly tested) | Interrupts | ?| ?
60+
SAMD21 | ✔️ (one motor) | Interrupts | ~20kHz| one ADC
6161
SAMD51 | ❌ | -| -| -
6262
Teensy3 | ❌| -| -| -
6363
Teensy4 | ✔️ (inital)| Interrupts| ~20kHz| ADC1
6464
Raspberry Pi Pico | ❌ | -| -
6565
Portenta H7 | ❌ | -| -| -
6666
Renesas (UNO R4) | ❌ (TBD) | -| -| -
67+
Arduino Nano Matter(📢NEW) | ✔️(one motor) | DMA | N/A | ADC0
6768

6869
### Important hardware considerations
6970

@@ -126,7 +127,7 @@ In order to maximise your chances for the low-side current sensing to work well
126127
// - phA - A phase adc pin
127128
// - phB - B phase adc pin
128129
// - phC - C phase adc pin (optional)
129-
LowsideCurrentSense current_sense = LowsideCurrentSense(0.01, 20, A0, A1, A2);
130+
LowsideCurrentSense current_sense = LowsideCurrentSense(0.01f, 20.0f, A0, A1, A2);
130131
```
131132
</div>
132133
<div class="type type-stepper hide" markdown="1">
@@ -137,7 +138,7 @@ LowsideCurrentSense current_sense = LowsideCurrentSense(0.01, 20, A0, A1, A2);
137138
// - gain - current-sense op-amp gain
138139
// - phA - A phase adc pin
139140
// - phB - B phase adc pin
140-
LowsideCurrentSense current_sense = LowsideCurrentSense(0.01, 20, A0, A1);
141+
LowsideCurrentSense current_sense = LowsideCurrentSense(0.01f, 20.0f, A0, A1);
141142
```
142143
</div>
143144

@@ -153,7 +154,7 @@ Alternatively `LowsideCurrentSense` can be created by specifying the mV per Amp
153154
// - mVpA - mV per Amp ratio
154155
// - phA - A phase adc pin
155156
// - phB - B phase adc pin
156-
LowsideCurrentSense current_sense = LowsideCurrentSense(66.0, A0, A1);
157+
LowsideCurrentSense current_sense = LowsideCurrentSense(66.0f, A0, A1);
157158
```
158159
</div>
159160
<div class="type type-bldc" markdown="1">
@@ -164,7 +165,7 @@ LowsideCurrentSense current_sense = LowsideCurrentSense(66.0, A0, A1);
164165
// - phA - A phase adc pin
165166
// - phB - B phase adc pin
166167
// - phC - C phase adc pin (optional)
167-
LowsideCurrentSense current_sense = LowsideCurrentSense(66.0, A0, A1, A2);
168+
LowsideCurrentSense current_sense = LowsideCurrentSense(66.0f, A0, A1, A2);
168169
```
169170

170171
### Measuring 2 out of 3 currents

docs/simplefoc_library/code/drivers/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,6 @@ Raspberry Pi Pico | ✔️ | ✔️ | ✔️ | ✔️ | ✔️
4646
Portenta H7 | ✔️ | ✔️ | ✔️ | ❌ | ✔️
4747
Renesas (UNO R4 Minima) | ✔️ | ✔️ | ✔️ | ✔️ | ✔️
4848
nRF52 |✔️ | ✔️ | ✔️ | ✔️ | ✔️
49+
Arduino Nano Matter (📢NEW) | ✔️ | ✔️ | ✔️ | ✔️ | ✔️
4950

5051
<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>

docs/simplefoc_library/code/motion_control/closed_loop_control/angle.md renamed to docs/simplefoc_library/code/motion_control/closed_loop_control/angle/angle.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
---
22
layout: default
3-
title: Position Control
3+
title: Cascade Position Control
44
description: "Arduino Simple Field Oriented Control (FOC) library ."
5-
nav_order: 3
6-
permalink: /angle_loop
7-
parent: Closed-Loop control
8-
grand_parent: Motion Control
9-
grand_grand_parent: Writing the Code
10-
grand_grand_grand_parent: Arduino <span class="simple">Simple<span class="foc">FOC</span>library</span>
5+
nav_order: 1
6+
permalink: /angle_cascade_control
7+
parent: Position Control
8+
grand_parent: Closed-Loop control
9+
grand_grand_parent: Motion Control
10+
grand_grand_grand_parent: Writing the Code
11+
grand_grand_grand_grand_parent: Arduino <span class="simple">Simple<span class="foc">FOC</span>library</span>
1112
toc: true
1213
---
1314

1415

15-
# Position control loop
16+
# Cascade position control loop
1617
This control loop allows you to move your motor to the desired angle in real-time. This mode is enabled by:
1718
```cpp
1819
// set angle/position motion control loop
@@ -28,19 +29,19 @@ You can test this algorithm by running the examples in `motion_control/position_
2829
The angle/position control closes the control loop around the velocity control loop. And the velocity control closes the control loop around the torque control, regardless which one it is. If it is the voltage mode without phase resistance set, the velocity motion control will set the the torque command using the voltage <i>U<sub>q</sub></i>:
2930

3031
<div class="type type-b">
31-
<img class="width60" src="extras/Images/angle_loop_v.png">
32+
<img class="width60" src="extras/Images/a_b_v.drawio.png">
3233
</div>
3334
<div class="type type-s hide">
34-
<img class="width60" src="extras/Images/angle_loop_stepper_volt.png">
35+
<img class="width60" src="extras/Images/a_s_v.drawio.png">
3536
</div>
3637

3738

3839
And if it is any of the current torque control modes (FOC or DC current) or voltage mode with provided phase resistance, the angle motion control will be setting the target current <i>i<sub>q</sub></i> to the torque controller:
3940
<div class="type type-b">
40-
<img class="width60" src="extras/Images/angle_loop_i.png">
41+
<img class="width60" src="extras/Images/a_b_i.drawio.png">
4142
</div>
4243
<div class="type type-s hide">
43-
<img class="width60" src="extras/Images/angle_loop_stepper_curr.png">
44+
<img class="width60" src="extras/Images/a_s_i.drawio.png">
4445
</div>
4546

4647
The angle control loop is therefore created by adding one more control loop in cascade on the [velocity control loop](velocity_loop) like showed on the figure above. The loop is closed by using additional PID controller and an optional low pass filter. The controller reads the angle <i>a</i> from the motor (filters is optionally) and determines which velocity <i>v<sub>d</sub></i> the motor should move to reach the desired angle <i>a<sub>d</sub></i> set by the user. And then the velocity controller reads the current filtered velocity from the motor <i>v<sub>f</sub></i> and sets the torque target (<i>u<sub>q</sub></i> voltage or <i>i<sub>q</sub></i> current) to the torque control loop, needed to reach the velocity <i>v<sub>d</sub></i>, set by the angle loop.

0 commit comments

Comments
 (0)