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
Copy file name to clipboardExpand all lines: docs/simplefoc_library/code/communication/commander/index.md
+1-2Lines changed: 1 addition & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ has_toc: false
12
12
13
13
# Commander interface
14
14
15
-
Commander is a simple and flexible interface monitoring, supervision, configuration and control using the G-code like communication protocol. The communication is based on `ASCII` character command ids which makes simple and efficient to parse on any mcu. After the command id has been received the function attached to this command is called and provided the remaining string of characters received which follows the command character.
15
+
Commander is a simple and flexible interface monitoring, supervision, configuration and control using the G-code like communication protocol. The communication is based on `ASCII` character command ids which makes simple and efficient to parse on any MCU. After the command id has been received the function attached to this command is called and provided the remaining string of characters received which follows the command character.
Or maybe you wish to tune the velocity PID and you and change the target value of the motor and you wish to remove unnecessary memory overhead due to the other functionalities you do nto necessarily need, then your code could look something like:
Copy file name to clipboardExpand all lines: docs/simplefoc_library/code/communication/commander/motion.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
@@ -25,7 +25,7 @@ Motion control interface in the `Commander` can be integrated in user's applicat
25
25
26
26
27
27
## Target setting in one line
28
-
Commander interface enables the user to set the target value for the motion control as well as the limits at once. However different motion control strategies have different numbers of limits (angle, velocity, torque) so depending of the motion control mode used the behavior of the command will change:
28
+
Commander interface enables the user to set the target value for the motion control as well as the limits at once. However different motion control strategies have different numbers of limits (angle, velocity, torque) so depending of the motion control mode used the behaviour of the command will change:
29
29
30
30
This feature is available to the user if any one of the three interfaces is added to the `Commander`.
The simplest forms of communication such as step/dir are designed to be handled in hardware and software, interrupt based, implementation of these communication interfaces is usually not the optimal solution. It will provide the user a good base for testing purposes, but it is hard guarantee long-term robustness.
66
+
The simplest forms of communication such as step/dir are designed to be handled in hardware and software, interrupt based, implementation of these communication interfaces is usually not the optimal solution. It will provide the user a good base for testing purposes, but it is hard to guarantee long-term robustness.
up to this moment ( [check the releases <iclass="fa fa-tag"></i>](https://github.com/simplefoc/Arduino-FOC/releases) ), Arduino <spanclass="simple">Simple<spanclass="foc">FOC</span>library</span> supports in-line current sensing for almost all platforms and low-side current sensing on ESP32 boards, stm32 (f1, f4 and g4 families - one motor), samd21 (one motor) and on the stm32 based B_G431B_ESC1 boards (one motor).
23
+
up to this moment ( [check the releases <iclass="fa fa-tag"></i>](https://github.com/simplefoc/Arduino-FOC/releases) ), Arduino <spanclass="simple">Simple<spanclass="foc">FOC</span>library</span> supports in-line current sensing for almost all platforms and low-side current sensing on ESP32 boards, stm32 (f1, f4 and g4 families - one motor), SAMD21 (one motor) and on the STM32 based B-G431B-ESC1 boards (one motor).
24
24
25
25
Each one of the current sensing classes will implement all the necessary functionalities for simple and robust implementation of FOC algorithm:
26
26
- Hardware config
@@ -31,7 +31,7 @@ Each one of the current sensing classes will implement all the necessary functio
31
31
- Adaptive alignment with driver phases
32
32
- Reading the phase currents
33
33
- Calculation of the current vector magnitude
34
-
- Calculation of the FOC d and q currents
34
+
- Calculation of the FOC D and Q currents
35
35
36
36
Each of the implemented classes can be used as stand-alone classes and they can be used to read current values on BLDC driver outputs out of scope of the Arduino <spanclass="simple">Simple<spanclass="foc">FOC</span>library</span>, see example codes in `utils > current_sense_test`.
37
37
In order for FOC algorithm to work the current sense classes are linked to a `BLDCMotor` class which uses the driver to read the FOC currents.
For more theoretical explanations and source code implementations of the current sensing and its integration into the FOC and motion check out the [digging deeper section](digging_deeper).
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>. The 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
+16-17Lines changed: 16 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,22 +21,22 @@ Low side current sensing for all the architectures is on our road-map and we are
21
21
22
22
## Current sensing support per MCU architecture
23
23
24
-
Low side current sensing is currently supported for several MCU architectures supported by the <spanclass="simple">Simple<spanclass="foc">FOC</span>library</span>. ESP32 architecture has the most generic support, supporting multiple motors per chip. Stm32 families f1, f4 and g4 are initially supported and support low-side sensing for only one motor. A special case of the stm32 board is the BG431_ESC1 development kit which has very specific low-side implementation for its hardware configuration, and it is fully supported by the library. Samd21 architecture is under development, it has an initial support for only one motor, but for now as it has not been extensively tested, we suggest not to rely on our implementation.
24
+
Low side current sensing is currently supported for several MCU architectures supported by the <spanclass="simple">Simple<spanclass="foc">FOC</span>library</span>. ESP32 architecture has the most generic support, supporting multiple motors per chip. Stm32 families f1, f4 and g4 are initially supported and support low-side sensing for only one motor. A special case of the STM32 board is the B-G431-ESC1 development kit which has very specific low-side implementation for its hardware configuration, and it is fully supported by the library. Samd21 architecture is under development, it has an initial support for only one motor, but for now as it has not been extensively tested, we suggest not to rely on our implementation.
25
25
26
26
MCU | Low-side Current sensing
27
27
--- | ---
28
28
Arduino (8-bit) | ❌
29
29
Arduino DUE | ❌
30
-
stm32 (in general) |❌
31
-
stm32f1 family | ✔️ (one motor)
32
-
stm32f4 family | ✔️ (one motor)
33
-
stm32g4 family | ✔️ (one motor)
34
-
stm32 B_G431B_ESC1 | ✔️
35
-
esp32 |✔️
36
-
esp8266 | ❌
37
-
samd21 | ✔️/❌ (one motor, poorly tested)
38
-
samd51 | ❌
39
-
teensy | ❌
30
+
STM32 (in general) |❌
31
+
STM32f1 family | ✔️ (one motor)
32
+
STM32f4 family | ✔️ (one motor)
33
+
STM32g4 family | ✔️ (one motor)
34
+
STM32 B_G431B_ESC1 | ✔️
35
+
ESP32 |✔️
36
+
ESP8266 | ❌
37
+
SAMD21 | ✔️/❌ (one motor, poorly tested)
38
+
SAMD51 | ❌
39
+
Teensy | ❌
40
40
Raspberry Pi Pico | ❌
41
41
Portenta H7 | ❌
42
42
@@ -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);
@@ -233,8 +233,7 @@ If you are sure in your configuration and if you wish to skip the alignment proc
233
233
current_sense.skip_align = true;
234
234
```
235
235
236
-
For example [AliExpress DRV8302 board](https://fr.aliexpress.com/wholesale?catId=0&initiative_id=SB_20211003032006&SearchText=bldc+drv8302) , you would have a code similar to this:
237
-
For example, Arduino <spanclass="simple">Simple<spanclass="foc">FOC</span>Shield</span> v2, you would have a code similar to this:
236
+
For example for the [AliExpress DRV8302 board](https://fr.aliexpress.com/wholesale?catId=0&initiative_id=SB_20211003032006&SearchText=bldc+drv8302), you would have code similar to this:
238
237
```cpp
239
238
// one possible combination of current sensing pins for SimpleFOCShield v2
240
239
// shunt - 5milliOhm
@@ -272,7 +271,7 @@ See the full example for the Aliexpress DRB8302 based board in the library examp
272
271
## Standalone current sense
273
272
274
273
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.
274
+
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
275
277
276
Reading the phase currents can be done by calling:
This is the class which provides an abstraction layer of most of the common 3PWM bldc drivers out there. Basically any BLDC driver board that can be run using 3PWM signals can be represented with this class.
An example code of the BLDC driver with three enable pins, one for each phase. This code will put one phase at the time to the high-impedance mode and pun 3 and 6 Volts on the remaining two.
167
+
An example code of the BLDC driver with three enable pins, one for each phase. This code will put one phase at the time to the high-impedance mode and put 3 and 6 Volts on the remaining two.
0 commit comments