Skip to content

Commit 97b921d

Browse files
committed
changed navigation structure + voltag control explained
1 parent 03cdb2d commit 97b921d

File tree

16 files changed

+171
-27
lines changed

16 files changed

+171
-27
lines changed
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
---
22
layout: default
3-
title: Citing SimpleFOC
4-
parent: Arduino <span class="simple">Simple<span class="foc">FOC</span>library</span>
5-
nav_order: 9
3+
title: Citing <span class="simple">Simple<span class="foc">FOC</span></span>
4+
nav_order: 8
65
permalink: /citing
76
---
87

docs/simplefoc_library/code/drivers_library.md renamed to docs/simplefoc_libraries/drivers_library.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
---
22
layout: default
3-
title: SimpleFOC Drivers Library
4-
nav_order: 10
3+
title: <span class="simple">Simple<span class="foc">FOC</span>Drivers</span>
4+
nav_order: 1
55
permalink: /drivers_library
6-
parent: Writing the Code
7-
grand_parent: Arduino <span class="simple">Simple<span class="foc">FOC</span>library</span>
6+
parent: <span class="simple">Simple<span class="foc">FOC</span>utils</span>
87
has_children: False
98
has_toc: False
109
---
1110

1211

13-
# SimpleFOC drivers library
12+
# <span class="simple">Simple<span class="foc">FOC</span>Drivers</span> library
1413

1514
![Library Compile](https://github.com/simplefoc/Arduino-FOC-Drivers/workflows/Library%20Compile/badge.svg)
1615
![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)
17-
![arduino-library-badge](https://www.ardu-badge.com/badge/Simple%20FOC%20Drivers.svg?)
16+
![arduino-library-badge](https://www.ardu-badge.com/badge/SimpleFOCDrivers.svg?)
1817

1918

2019
The <span class="simple">Simple<span class="foc">FOC</span>library</span>'s main objective is to provide an efficient low level motion motor control for BLDC and stepper motors.

docs/simplefoc_libraries/index.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
layout: default
3+
title: <span class="simple">Simple<span class="foc">FOC</span>utils</span>
4+
description: "Arduino Simple Field Oriented Control (FOC) library ."
5+
nav_order: 5
6+
permalink: /arduino_simplefoc_libraries
7+
has_children: True
8+
has_toc: False
9+
---
10+
11+
12+
# <span class="simple">Simple<span class="foc">FOC</span>utils</span>
13+
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.
14+
15+
16+
## Arduino libraries
17+
18+
- ### <span class="simple">Simple<span class="foc">FOC</span>Drivers</span>
19+
20+
This library contains an assortment of drivers and supporting code for <span class="simple">Simple<span class="foc">FOC</span>library</span>.
21+
22+
23+
The intent is to keep the core of <span class="simple">Simple<span class="foc">FOC</span>library</span> clean, and thus easy to maintain, understand and port to different platforms. In addition to this core, there are various drivers and supporting code which has grown around <span class="simple">Simple<span class="foc">FOC</span>library</span>, and which we would like to make available to the community. [Read more ...](drivers_library)
24+
25+
<a href ="https://github.com/simplefoc/Arduino-FOC-drivers" class="btn"><i class="fa fa-github"></i> Github repo</a>
26+
27+
- ### <span class="simple">Simple<span class="foc">DC</span>Motor</span> - <i>coming soon!</i>
28+
29+
<span class="simple">Simple<span class="foc">FOC</span>library</span> is really intended for field oriented control of PMSM/BLDC motors, it's in the name ;-). But for different reasons, sometimes DC motors are preferred, and while we're not focused on this use-case, we do have a fair amount of code that can be leveraged to help with DC-Motor control applications.
30+
31+
32+
So this represents a less-supported effort to provide some useful building blocks for DC-Motors.
33+
34+
<a href ="https://github.com/simplefoc/Arduino-FOC-dcmotor" class="btn"><i class="fa fa-github"></i> Github repo</a>
35+
36+
37+
## User interface applications
38+
39+
- ### <span class="simple">Simple<span class="foc">FOC</span>Studio</span> by [@jorgemaker](https://github.com/JorgeMaker)
40+
41+
Graphical user interface for the <span class="simple">Simple<span class="foc">FOC</span>library</span> based on python3 and PyQt5. This application allows to tune and configure any BLDC/Stepper <span class="simple">Simple<span class="foc">FOC</span>library</span> controlled device, using serial port communications and the [Commander](commander_interface) interface. [Read more ... ](studio)
42+
43+
<a href ="https://github.com/simplefoc/Arduino-FOC-dcmotor" class="btn"><i class="fa fa-github"></i> Github repo</a>
44+
45+
- ### <span class="simple">Simple<span class="foc">FOC</span>Generator</span> by [@stijnsprojects](https://github.com/stijnsprojects)
46+
47+
A web application which helps you generate <span class="simple">Simple<span class="foc">FOC</span>library</span> arduino sketches based on the hardware that you are using.
48+
49+
<a href ="https://github.com/stijnsprojects/simplefocgenerator" class="btn btn"><i class="fa fa-github"></i> Github repo</a> <a href ="https://stijnsprojects.github.io/simplefocgenerator/" class="btn btn-primary"><i class="fa fa-github"></i> Open <span class="simple">Simple<span class="foc">FOC</span>Generator</span></a>
50+
51+
- ### <span class="simple">Simple<span class="foc">FOC</span>webcontroller</span> by [@geekuillaume](https://github.com/geekuillaume)
52+
53+
This is a controller interface for the <span class="simple">Simple<span class="foc">FOC</span>library</span>. It uses WebSerial to communicate with a suitable micro-controller using serial port communications and the [Commander](commander_interface) interface.
54+
55+
<a href ="https://github.com/geekuillaume/simplefoc-webcontroller" class="btn btn"><i class="fa fa-github"></i> Github repo</a> <a href ="https://docs.simplefoc.com/simplefoc-webcontroller/" class="btn btn-primary"><i class="fa fa-github"></i> Open <span class="simple">Simple<span class="foc">FOC</span>webcontroller</span></a>
56+

docs/simplefoc_library/simplefocstudio.md renamed to docs/simplefoc_libraries/simplefocstudio.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
layout: default
33
title: Simple<b>FOC</b>Studio
4-
nav_order: 4
4+
nav_order: 2
55
permalink: /studio
6-
parent: Arduino <span class="simple">Simple<span class="foc">FOC</span>library</span>
6+
parent: <span class="simple">Simple<span class="foc">FOC</span>utils</span>
77
---
88

99
# *Simple**FOC**Studio* <small>by [@JorgeMaker](https://github.com/JorgeMaker) </small>

docs/simplefoc_library/code/motion_control/closed_loop_control/torque_control/voltage.md

Lines changed: 80 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ motor.torque_controller = TorqueControlType::voltage;
2020

2121
There are three different ways to control the torque of your motor using voltage requiring different knowledge about your motor mechanical parameters:
2222
- [Pure voltage control](#pure-voltage-control) - no motor parameters needed
23-
- [Estimated current control](#voltage-control-with-current-estimation) - phase resistance required
24-
- [Estimated current control with Back-EMF compensation](#voltage-control-with-current-estimation-and-back-emf-compensation) - required phase resistance and KV rating of the motor
23+
- [Estimated current control](#voltage-control-with-current-estimation) - phase resistance $$R$$ required
24+
- [Estimated current control with Back-EMF compensation](#voltage-control-with-current-estimation-and-back-emf-compensation) - required phase resistance $$R$$ and $$KV$$ rating of the motor
25+
- [Estimated current control with Back-EMF and lag compensation](#voltage-control-with-current-estimation-and-back-emf-compensation) - required phase resistance $$R$$, inductance $$L$$ and $$KV$$ rating of the motor
2526

2627
Block diagrams of the three torque control techniques based on voltage control can be represented as:
2728
<script type="text/javascript">
@@ -36,16 +37,18 @@ Block diagrams of the three torque control techniques based on voltage control c
3637
</script>
3738

3839
<a href ="javascript:show(0);" id="btn-0" class="btn btn-primary">Voltage control</a>
39-
<a href ="javascript:show(1);" id="btn-1" class="btn">Voltage control + Phase resistance</a>
40-
<a href ="javascript:show(2);" id="btn-2" class="btn">Voltage control + Phase resistance + KV rating</a>
40+
<a href ="javascript:show(1);" id="btn-1" class="btn"> + Phase resistance</a>
41+
<a href ="javascript:show(2);" id="btn-2" class="btn"> + KV rating</a>
42+
<a href ="javascript:show(3);" id="btn-3" class="btn"> + Phase inductance</a>
4143

42-
<img style="display:block" id="0" class="gallery_img" src="extras/Images/voltage_loop_0000.jpg"/>
43-
<img style="display:none" id="1" class="gallery_img" src="extras/Images/voltage_loop_0001.jpg"/>
44-
<img style="display:none" id="2" class="gallery_img" src="extras/Images/voltage_loop_0002.jpg"/>
44+
<img style="display:block" id="0" class="gallery_img width80" src="extras/Images/vm0.jpg"/>
45+
<img style="display:none" id="1" class="gallery_img width80" src="extras/Images/vm1.jpg"/>
46+
<img style="display:none" id="2" class="gallery_img width80" src="extras/Images/vm2.jpg"/>
47+
<img style="display:none" id="3" class="gallery_img width80" src="extras/Images/vm3.jpg"/>
4548

4649
## Pure voltage control
4750

48-
<a name="foc_image"></a><img src="extras/Images/voltage_loop_0000.jpg">
51+
<a name="foc_image"></a><img class="width80" src="extras/Images/vm0.jpg">
4952

5053
The voltage control algorithm reads the angle $$a$$ from the position sensor and the gets target $$U_q$$ voltage value from the user and using the FOC algorithm sets the appropriate $$u_a$$, $$u_b$$ and $$u_c$$ voltages to the motor. FOC algorithm ensures that these voltages generate the magnetic force in the motor rotor exactly with <i>90 degree</i> offset from its permanent magnetic field, which guarantees maximal torque, this is called commutation.
5154

@@ -72,7 +75,7 @@ If you set a certain desired voltage $$U_g$$ your motor should start moving and
7275

7376
Block diagram of this torque control strategy is as follows
7477

75-
<a name="foc_image"></a><img src="extras/Images/voltage_loop_0001.jpg">
78+
<a name="foc_image"></a><img class="width80" src="extras/Images/vm1.jpg">
7679

7780
If the user provides the phase resistance $$R$$ value of the motor, the user can set the desired current $$I_d$$ (that generates the desired torque $$I_d = k\tau_d$$) and the library will automatically calculate the appropriate voltage $$U_q$$.
7881

@@ -114,7 +117,7 @@ If your desired current is set to some value that is not 0, but your motor does
114117

115118
Block diagram of this torque control strategy is as follows
116119

117-
<a name="foc_image"></a><img src="extras/Images/voltage_loop_0002.jpg" >
120+
<a name="foc_image"></a><img class="width80" src="extras/Images/vm2.jpg" >
118121

119122
If the user provides the phase resistance $$R$$ value and the motor's $$KV$$ rating of the motor, the user can set the desired current $$I_d$$ (that generates the desired torque $$I_d = k\tau_d$$) directly. The library will automatically calculate the appropriate voltage $$U_q$$ while compensating for the generated Back EMF voltage by keeping track of the motor velocity $$v$$.
120123

@@ -165,6 +168,73 @@ If your desired current is set to some value that is not 0, but your motor does
165168

166169

167170

171+
## Voltage control using current estimation with Back-EMF and lag compensation
172+
173+
Block diagram of this torque control strategy is as follows
174+
175+
<a name="foc_image"></a><img class="width80" src="extras/Images/vm3.jpg" >
176+
177+
If the user provides the phase resistance $$R$$ value and the motor's $$KV$$ rating of the motor, the user can set the desired current $$I_d$$ (that generates the desired torque $$I_d = k\tau_d$$) directly. The library will automatically calculate the appropriate voltage $$U_q$$ while compensating for the generated Back EMF voltage by keeping track of the motor velocity $$v$$.
178+
179+
$$
180+
U_q = I_d R + U_{bemf}= (k\tau_d) R + \frac{v}{KV}
181+
$$
182+
183+
Additionally if the user sets the phase inductance value $$L$$, the library will be able to compensate for the lag of the torque vector by calculating an appropriate d-axis voltage $$U_d$$
184+
185+
$$
186+
U_d = -I_d L v n_{pp} = -(k\tau_d)L v n_{pp}
187+
$$
188+
189+
where $$n_{pp}$$ is the number of motor's pole pairs. By compensating the lag of the torque vector due to the motor rotation velocity $$v$$, the motor will be able to spin with higher max velocity. Therefore the lag compensation will have the most effect if application requires going to the maximal motor velocity.
190+
191+
User can specify the phase resistance and the KV rating of the motor either through the constructor for example
192+
```cpp
193+
// BLDCMotor(pole pair number, phase resistance [Ohms], KV rating [rpm/V], phase inductance [H])
194+
BLDCMotor motor = BLDCMotor( 11, 2.5, 120, 0.01 );
195+
```
196+
197+
198+
<blockquote class="info">
199+
<p class="heading"> RULE OF THUMB: KV value</p>
200+
KV rating of the motor is defined as speed of the motor in rpm with the set voltage \(U_q\) of 1 Volt. If you do not know your motor's KV rating you can easily measure it using the library. Run your motor int the voltage mode and set the target voltage to one 1V and read the motor velocity. <span class="simple">Simple<span class="foc">FOC</span>library</span> shows that velocity in the rad/s so in order to convert it to the rpm you just need to multiply it by \(30/\pi \approx 10\).<br><br>
201+
202+
As explained above as the Back-EMF constant of the motor is always a bit smaller than the inverse of the KV rating ( \(k_{bemf}<1/KV\) ), the rule of thumb is to set the KV rating 10-20% higher than the one given in the datasheet, or the one determined experimentally.
203+
</blockquote>
204+
205+
206+
207+
With the $$R$$ and $$KV$$ information the <span class="simple">Simple<span class="foc">FOC</span>library</span> is able to estimate current set to the motor and the user will be able to control the motor torque, provided the motor parameters are correct (enough 😄).
208+
209+
210+
<blockquote class="warning">
211+
<p class="heading">⚠️ Practical limitations</p>
212+
Back-EMF voltage is defined as \(U_{bemf} = k_{bemf}v\) and calculating it based on the motor \(KV\) rating of the motor is just an approximation because the motor BEMF constant \(k_{bemf}\) is not exacly \(k_{bemf}=1/KV\).
213+
It can be shown that the back-emf constant is always somewhat smaller than the inverse of the KV rating:
214+
\[k_{bemf}<\frac{1}{KV}\]
215+
</blockquote>
216+
217+
### Expected motor behavior
218+
If the user sets the desired current of 0 Amps, the motor should have very low resistance, much lower than in the two torque control strategies above. The motor should feel like it is almost disconnected.
219+
220+
<blockquote class="info">
221+
<p class="heading"> For current 0 motor moves</p>
222+
If your desired current is set to 0, but when you move your motor with your hand it continues moving on its own and does not come back to a complete stop, your \(KV\) value is too high. Try reducing it.
223+
</blockquote>
224+
225+
If you set a certain desired current $$I_d$$ your motor should accelerate to its maximum velocity. The acceleration value is proportional to the motor torque and will be proportional to the current $$I_d$$. So for larger currents your motor will accelerate faster and for the lower currents it will accelerate slower. But for the motor without load, regardless of set target current $$I_d$$ the motor should reach its max velocity.
226+
227+
<blockquote class="info">
228+
<p class="heading"> For current \(I_d > 0\) motor does not move</p>
229+
If your desired current is set to some value that is not 0, but your motor does not move, your phase resistance value \(R\) is probably too low. Try increasing it.
230+
</blockquote>
231+
232+
For different values of the motor phase inductance $$L$$ motor will be able to reach different maximal velocities. The higher the inductance value the higher the maximal velocity. However, after certain inductance value the motor maximal velocity will stop being affected as it will reach its absolute max velocity.
233+
234+
<blockquote class="info">
235+
<p class="heading"> How to find the phase inductance \(L\) value</p>
236+
Start with low value, such as 0.1mH and set your target current \(I_d\) to certain value to allow the motor to accelerate to it's max velocity. Then use the Commander interface to change the inductance and see see how the motor's velocity evolves. By raising the \(L\) value, the velocity should increase. After certain \(L\) value the velocity will stop increasing and if you continue it might even decrease. So use the minimal \(L\) value that reaches the max velocity.
237+
</blockquote>
168238

169239

170240

docs/simplefoc_library/hardware/mcus/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ esp32/esp32s3 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️
4141
esp32s2/esp32c3 | ✔️ | ✔️ | ✔️ | ❌ | ✔️
4242
esp8266 | ✔️ | ✔️ | ✔️ | ❌ | ✔️
4343
samd21/51 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️
44-
teensy | ✔️ | ✔️ | ✔️ | | ✔️
44+
teensy | ✔️ | ✔️ | ✔️ | ✔️ | ✔️
4545
Raspberry Pi Pico | ✔️ | ✔️ | ✔️ | ✔️ | ✔️
4646
Portenta H7 | ✔️ | ✔️ | ✔️ | ❌ | ✔️
4747
nRF52 |✔️ | ✔️ | ✔️ | ✔️ | ✔️

docs/simplefoc_library/hardware/mcus/teensy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ grand_grand_parent: Arduino <span class="simple">Simple<span class="foc">FOC</sp
1313

1414
MCU | 2 PWM mode | 4PWM mode | 3 PWM mode | 6 PWM mode | pwm frequency config
1515
--- | --- |--- |--- |--- |---
16-
teensy | ✔️ | ✔️ | ✔️ | | ✔️
16+
teensy | ✔️ | ✔️ | ✔️ | ✔️ | ✔️
1717

1818
Arduino <span class="simple">Simple<span class="foc">FOC</span>library</span> has recently started to support Teensy boards as well. The most commonly tested boards are Teensy 4.1 and Teensy 3.2, but most of the boards in 4.x and 3.x series should work out of the box with the library.
1919

docs/simplefoc_library/work_roadmap.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,32 @@ nav_order: 8
66
permalink: /roadmap
77
---
88

9-
# Roadmap
9+
# Feature Roadmap
1010

11-
For more info about the features of library releases visit the [github releases <i class="fa fa-tag"></i>](https://github.com/simplefoc/Arduino-FOC/releases). This page is not really rigorously maintained and can be outdated from time to time.
11+
This page is not really rigorously maintained and can be a bit outdated.
12+
13+
<div class="image_icon" >
14+
<a href="https://simplefoc.notion.site/Developement-4149a181ea5b4383964cc8cc250e7d11" >
15+
<img src="extras/Images/roadmap.png" >
16+
<i class="fa fa-external-link-square fa-2x"></i>
17+
<p >Roadmap with Notion</p>
18+
</a>
19+
</div>
20+
<div class="image_icon" >
21+
<a href="https://github.com/simplefoc/Arduino-FOC/releases" >
22+
<img src="extras/Images/releases.png" >
23+
<i class="fa fa-external-link-square fa-2x"></i>
24+
<p >Github changelog</p>
25+
</a>
26+
</div>
27+
28+
For more info about the features of library releases visit the [github releases <i class="fa fa-tag"></i>](https://github.com/simplefoc/Arduino-FOC/releases).
29+
30+
# Old roadmap
31+
<details markdown=1>
1232

1333
## Motion Control and FOC algorithm
14-
- [ ] **Motor control: Low-side current sensing** - No.1
34+
- [x] **Motor control: Low-side current sensing** - No.1
1535
- [ ] **Motor control: Inline current sensing with DMA** - No.2
1636
- [ ] Motor control: High-side current sensing
1737
- [x] **Bugfix: Floating point angle overflow**
@@ -78,6 +98,6 @@ For more info about the features of library releases visit the [github releases
7898
- [x] VIDEO: Two motors running on HMBGC example
7999
- [x] VIDEO: Initial video with simple demonstration
80100

81-
101+
</details>
82102

83103

extras/Images/driverslib.png

30.9 KB
Loading

extras/Images/generator.png

51.3 KB
Loading

0 commit comments

Comments
 (0)