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
Inline current sensing technique is the simplest one to use and the most precise one. The shunt resistors are placed in-line with motor phases and the current measured on these shunt resistors will be motor phase current regardless of the state of the PWM duty cycle. This implementation is therefore very suitable for Arduino devices due to the fact that adc can be sampled at any time to read the current and the adc acquisition duration is as important as for the other current sensing approaches. The downside of this approach is the hardware, this current sensing architecture requirers high-precision bidirectional amplifiers with much better PWM rejection than the regular low-side or high-side amplifiers.
13
+
Inline current sensing technique is the simplest one to use and the most precise one. The shunt resistors are placed in-line with motor phases and the current measured on these shunt resistors will be motor phase current regardless of the state of the PWM duty cycle. This implementation is therefore very suitable for Arduino devices due to the fact that adc can be sampled at any time to read the current and the adc acquisition duration is not as important as for the other current sensing approaches. The downside of this approach is the hardware, this current sensing architecture requires high-precision bidirectional amplifiers with much better PWM rejection than the regular low-side or high-side amplifiers.
In-line current sensing is currently supported for almost all MCU architectures supported by the <spanclass="simple">Simple<spanclass="foc">FOC</span>library</span>. Only not supported architecture is teh ESP8266 which does not have 2 ADC pins, making it unable to run FOC.
20
+
In-line current sensing is currently supported for almost all MCU architectures supported by the <spanclass="simple">Simple<spanclass="foc">FOC</span>library</span>. Only not supported architecture is the ESP8266 which does not have 2 ADC pins, making it unable to run FOC.
To instantiate the inline current sensor using the <spanclass="simple">Simple<spanclass="foc">FOC</span>library</span> just create an instance of the class `InlineCurrentSense`. This class takes as a parameter 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 put provide them to the constructor in that order.
47
+
To instantiate the inline current sensor using the <spanclass="simple">Simple<spanclass="foc">FOC</span>library</span> just create an instance of the class `InlineCurrentSense`. This class takes as a parameter 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.
48
48
49
49
### Measuring 2 out of 3 currents
50
50
Field Oriented Control algorithm can run with both 2 or 3 phase current measurements. If measuring 2 out of 3 currents, when defining your `InlineCurrentSense` class put the flag `_NC` (not connected) to the phase value you are not using.
Copy file name to clipboardExpand all lines: docs/simplefoc_library/code/current_sense/low_side.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,7 +67,7 @@ driver.pwm_frequency = 20000;
67
67
68
68
#### 2. PWM pin considerations
69
69
70
-
As ADC conversion has to be synchronised with the PWM generated on ALL the phases, it is important that all the PWM generated for all the phases have aligned PWM. Since the microcontrollers usually have more than one timer for PWM generation on its pins, different architectures of microcontrollers have different degrees of alinement in between the PWM generated from different timers.
70
+
As ADC conversion has to be synchronised with the PWM generated on ALL the phases, it is important that all the PWM generated for all the phases have aligned PWM. Since the microcontrollers usually have more than one timer for PWM generation on its pins, different architectures of microcontrollers have different degrees of alignment in between the PWM generated from different timers.
71
71
72
72
73
73
<blockquoteclass="info">
@@ -171,10 +171,10 @@ else{
171
171
}
172
172
```
173
173
174
-
Once when your current sense has been intialised and calibrated you can start measuring the currents!
174
+
When your current sense has been intialised and calibrated you can start measuring the currents!
175
175
176
176
## Using the current sense with FOC algorithm
177
-
To use the `LowsideCurrentSense` with the FOC algorithm all you need to do is to add it to link it with the `BLDCMotor` you wish to use it with:
177
+
To use the `LowsideCurrentSense` with the FOC algorithm all you need to do is link it with the `BLDCMotor` you wish to use it with:
178
178
```cpp
179
179
// link motor and current sense
180
180
motor.linkCurrentSense(¤t_sense);
@@ -272,7 +272,7 @@ See the full example for the Aliexpress DRB8302 based board in the library examp
272
272
## Standalone current sense
273
273
274
274
Since the low-side current sense has to be synchornised with PWM of a driver of interest it does not make sense to use it as a stand-alone sensor.
275
-
But once when you linked the current sense with the `BLDCMotor` you can use it to read your phase currents, overall current magnitude and DQ currents.
275
+
But once you have linked the current sense with the `BLDCMotor` you can use it to read your phase currents, overall current magnitude and DQ currents.
276
276
277
277
Reading the phase currents can be done by calling:
Copy file name to clipboardExpand all lines: docs/simplefoc_library/code/motion_control/closed_loop_control/torque_control/foc_current.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ The FOC current torque control algorithm reads the phase currents of the BLDC mo
27
27
The torque generated in the motor is proportional to the q-axis current <i>i<sub>q</sub></i>, making this torque control mode the *true torque control* of a BLDC motor.
28
28
29
29
## Configuration parameters
30
-
In order to make this loop run smoothly the user needs to configure the PID controller parameters of teh`PID_current_q` and Low pass filter `LPF_current_q` time constant.
30
+
In order to make this loop run smoothly the user needs to configure the PID controller parameters of the`PID_current_q` and Low pass filter `LPF_current_q` time constant.
Copy file name to clipboardExpand all lines: docs/simplefoc_library/code/motion_control/closed_loop_control/torque_control/index.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ has_toc: False
41
41
-[DC current mode](dc_current_torque_mode) - `dc_current`
42
42
-[FOC current mode](foc_current_torque_mode) - `foc_current`
43
43
44
-
In short **voltage control mode** is the simplest approximation of the motor torque control and it so basic that can be run on any motor+driver+mcu combination out there. **DC current mode** is teh next step of the motor's torque approximation which is much more exact than the voltage mode but requires current sensing and much stronger microcontroller. **FOC current mode** is controls motor's true torque and it is not an approximation, it also requires current sensor and even more processing power than the DC current mode. See in depth explanations in [torque mode docs](torque_control).
44
+
In short **voltage control mode** is the simplest approximation of the motor torque control and it so basic that can be run on any motor+driver+mcu combination out there. **DC current mode** is the next step of the motor's torque approximation which is much more exact than the voltage mode but requires current sensing and much stronger microcontroller. **FOC current mode** is controls motor's true torque and it is not an approximation, it also requires current sensor and even more processing power than the DC current mode. See in depth explanations in [torque mode docs](torque_control).
45
45
46
46
This motion control mode is enabled setting the `controller` parameter to:
47
47
```cpp
@@ -73,7 +73,7 @@ For more information about the source code implementation of the motion control
73
73
Torque control type | PROS | CONS
74
74
----- | ----- | ------
75
75
Voltage | ✔️ Very simple and fast <br>✔️ Good performance with any MCU <br> ✔️ Very smooth on low speeds<br> ✔️ No current sense needed | ❌ Not optimal on high speeds <br> ❌ Cannot control true current draw <br> ❌ Torque is approximated (low error on low speeds)
76
-
DC current | ✔️ Can control true current draw <br> ✔️ Suitable for low performance MUCs <br> ✔️ Current limiting | ❌ More complex to execute (slower) <br> ❌ Can achieve lower speeds than voltage mode <br>❌ Torque is approximated (low error on low speeds) <br> ❌ Needs current sensing
76
+
DC current | ✔️ Can control true current draw <br> ✔️ Suitable for low performance MCUs <br> ✔️ Current limiting | ❌ More complex to execute (slower) <br> ❌ Can achieve lower speeds than voltage mode <br>❌ Torque is approximated (low error on low speeds) <br> ❌ Needs current sensing
77
77
FOC current | ✔️ True torque control (any velocity) <br> ✔️ Can control true current draw <br> ✔️ Very efficient on higher velocities <br> ✔️ Current limiting | ❌ The most complex to execute (slowest) <br> ❌ Not suitable for low-performing MCUs (can become unstable) <br> ❌ Needs current sensing
Copy file name to clipboardExpand all lines: docs/simplefoc_library/code/motion_control/open_loop/angle_openloop.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,12 +71,12 @@ The angle open-loop control will (if not provided phase resistance) set the volt
71
71
```cpp
72
72
voltage = voltage_limit; // Volts
73
73
```
74
-
This is very ineficeint, as for different motors with different phase resistances the same voltage values can produce wildly different currents.
75
-
For gimbal motor, you can run it in the open loop with the voltage limits of 5-10 Volts and it will reach the currents of 0.5-2 amps as it has the pahse resistance from 5-15 Ohms. For drone motors, the voltage limits should stay very low, under 1 volt. Because they have pahse resisatnce of 0.05 to 0.2 Ohms.
74
+
This is very inefficient, as for different motors with different phase resistances the same voltage values can produce wildly different currents.
75
+
For gimbal motor, you can run it in the open loop with the voltage limits of 5-10 Volts and it will reach the currents of 0.5-2 amps as it has the phase resistance from 5-15 Ohms. For drone motors, the voltage limits should stay very low, under 1 volt. Because they have phase resisatnce of 0.05 to 0.2 Ohms.
76
76
77
77
### Current limiting approaches
78
78
79
-
We suggest you to provide the motor class with the `phase_resistance` value and set the `motor.current_limit` instead the voltage limit. This current might be surpassed but at least you will know an approximate current your motor is drawing. You can calculate the current the motor is going to be producing by checking the motor resistance `phase_resistance` and evaluating:
79
+
We suggest you to provide the motor class with the `phase_resistance` value and set the `motor.current_limit` instead of the voltage limit. This current might be surpassed but at least you will know an approximate current your motor is drawing. You can calculate the current the motor is going to be producing by checking the motor resistance `phase_resistance` and evaluating:
80
80
```cpp
81
81
voltage = current_limit * phase_resistance; // Amps
Copy file name to clipboardExpand all lines: docs/simplefoc_library/digging_deeper/theory/FOC_routine.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ Field oriented control algorithm's main task is to take user defined voltage <i>
15
15
16
16
<imgsrc="../extras/Images/voltage_loop.png">
17
17
18
-
FOC algorithm calculates the phase voltages which create the magnetic field in the motor's rotor which are exactly 90 degrees "behind" the magnetic field of the permanent magnets of the rotor, creating a pushing effect. Here is a very nice animation of what happens inside of the motor when running simplified version of the the FOC called six-step modulation.
18
+
FOC algorithm calculates the phase voltages which create the magnetic field in the motor's stator which are exactly 90 degrees "behind" the magnetic field of the permanent magnets of the rotor, creating a pushing effect. Here is a very nice animation of what happens inside of the motor when running simplified version of the the FOC called six-step modulation.
There are several key differences in between these two algorithms. But in terms of <spanclass="simple">Simple<spanclass="foc">FOC</span>library</span> all that you need to know is that Space Vector algorithm better uses the maximal voltage range of the power supply. In the tables above, you can see that for <i>U<sub>q</sub> = 0.5V</i> the magnitude of sine waves generated by the Sinusoidal modulation is exactly equal to 1, and Space vector modulation is not quiet there yet. The "double sine" wave produced by the space vector has lower magnitude by the factor of `2/sqrt(3) = 1.15` which means that it can deliver 15% more power to the motor using same power supply.
195
+
There are several key differences in between these two algorithms. But in terms of <spanclass="simple">Simple<spanclass="foc">FOC</span>library</span> all that you need to know is that Space Vector algorithm better uses the maximal voltage range of the power supply. In the tables above, you can see that for <i>U<sub>q</sub> = 0.5V</i> the magnitude of sine waves generated by the Sinusoidal modulation is exactly equal to 1, and Space vector modulation is not quite there yet. The "double sine" wave produced by the space vector has lower magnitude by the factor of `2/sqrt(3) = 1.15` which means that it can deliver 15% more power to the motor using same power supply.
196
196
197
197
This means, for your power-supply with the voltage <i>V<sub>power_supply</sub></i>, when using `SinePWM` you will be able to set maximal <i>U<sub>q</sub> = 0.5 V<sub>power_supply</sub> </i> and if using `SpaceVectorPWM` you will be able to set <i>U<sub>q</sub> = 0.58 V<sub>power_supply</sub> </i>
Copy file name to clipboardExpand all lines: docs/simplefoc_library/digging_deeper/theory/low_pass_filtering.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ This makes it a bit more clear what the time constant `Tf` of the Low pass filte
33
33
alpha = 0.01/(0.01 + 0.001) = 0.91
34
34
```
35
35
36
-
Which means that your actual velocity measurement <i>v</i> will influence the filtered value <i>v<sub>f</sub><i> with the coefficient `1-alpha = 0.09` which is going to smooth the velocity values considerably (maybe even too much, depends of the application).
36
+
Which means that your actual velocity measurement <i>v</i> will influence the filtered value <i>v<sub>f</sub><i> with the coefficient `1-alpha = 0.09` which is going to smooth the velocity values considerably (maybe even too much, depending on the application).
Copy file name to clipboardExpand all lines: docs/simplefoc_library/digging_deeper/theory/voltage_torque_control.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,13 +26,13 @@ Therefore as for the DC motor we know that the motor torque `T` is directly prop
26
26
T = I*K
27
27
```
28
28
Where `K` is the motor constant defined by its hardware.
29
-
And we also know that the curren is proportional to the set voltage `U`:
29
+
And we also know that the current is proportional to the set voltage `U`:
30
30
31
31
```cpp
32
32
I = (U - EMF)/R
33
33
```
34
34
35
-
Where `R` is the motor resistance and `EMF` is the generated back EMF voltage. Thi equation doesn't take in consideration any dynamics but in general it works good enough.
35
+
Where `R` is the motor resistance and `EMF` is the generated back EMF voltage. This equation doesn't take in consideration any dynamics but in general it works good enough.
36
36
37
37
So what we can conclude from all this is that (if we neglect the EMF):
0 commit comments