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/current_sense/inline.md
+1
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,7 @@ SAMD51 | ✔️
32
32
Teensy | ✔️
33
33
Raspberry Pi Pico | ✔️
34
34
Portenta H7 | ✔️
35
+
Renesas (UNO R4) | ❌ (TBD)
35
36
36
37
## Hardware configuration
37
38
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`.
### Where to place the `current_sense` configuration in your FOC code?
184
185
185
-
It is very important that the the current sensing `init` function is called after the `BLDCMotor` and `BLDCDriver` init functions are called. Which will make sure that the driver is enabled when current sense calibration is taking place. Also, it is important that the current sense `init` function is called before starting the foc algorithm with the `initFOC` function.
186
+
It is very important that the the current sensing `init` function is called after the `BLDCDriver` init function is called. This will make sure that the driver is enabled when current sense calibration is taking place. Also, it is important that the current sense `init` function is called before initializing the motor and starting the foc algorithm with the `initFOC` function.
186
187
187
188
So the suggested code structure would be:
188
189
@@ -207,6 +208,7 @@ void setup(){
207
208
}
208
209
```
209
210
Function `initFOC()` will make sure that the `BLDCDriver` and `LowsideCurrentSense` classes are both well aligned, it is very important that the phase `A` of the current sense is exactly the phase `A` of the driver, phase `B` of the current sense exactly pahse `B` of the driver and the same for the phase `C`. To verify this, the `initFOC` will be calling the current sense's function `current_sense.driverAlign(...)`.
211
+
210
212
### Alignment with the motor phases `driverAlign(...)`
211
213
212
214
The current sense and the driver alignment inside `initFOC` is done by calling the function:
⚠️ 6 PWM configuration is very hardware specific and please make sure to respect certain guidelines in order for it to work properly!
@@ -65,15 +65,15 @@ In hardware 6 PWM mode the user uses only one timer, usually Timer 1 for all the
65
65
Where `T1Cx` are the Timer 1 channels and `T1CxN` are their complementary channels (inverted channels). Each pair of `T1Cx` and `T1CxN` is used for one pair of the high/low PWM pins. The library will configure the necessary timers and registers if you provide these pins to the constrictor of the `BLDCDriver6PWM` class. For example:
66
66
```cpp
67
67
// BLDCDriver6PWM( int phA_h, int phA_l, int phB_h, int phB_l, int phC_h, int phC_l, int en)
68
-
BLDCDriver6PWM motor = BLDCDriver6PWM(PA8, PB13, PA9, PB14, PA10, PB15);
If it is not possible to use the hardware 6 PWM mode with your board <spanclass="simple">Simple<spanclass="foc">FOC</span>library</span> enables you to use any two channels of any of the timers as your high/low side PWM pair. Basically, the library will automatically configure the complementary channels on the provided low side pins. The only requirement for this code to work properly is exatcly the same as for the Arudino UNO, each phase high/low PWM pair needs to belong to the same timer.
73
73
For example, if we take STM32 Nucleo F401RE board we can take for example:
74
74
```cpp
75
75
// BLDCDriver6PWM( int phA_h, int phA_l, int phB_h, int phB_l, int phC_h, int phC_l, int en)
76
-
BLDCDriver6PWM motor = BLDCDriver6PWM(7, 2, 6, 3, 5, 4);
<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.
Copy file name to clipboardExpand all lines: docs/simplefoc_library/code/motors/bldc_motors.md
+7-9
Original file line number
Diff line number
Diff line change
@@ -258,22 +258,20 @@ The alignment procedure will have to move your motor several times and might not
258
258
259
259
### Step 6.1 Skip alignment - position sensor
260
260
261
-
If you are using absolute sensors such as magnetic sensors or hall sensors, once you have done the alignment procedure and once you have the motor's zero electrical offset sensor direction you no longer need the full calibration sequence. Therefore, to the `motor.initFOC()` you can provide the sensor offset `zero_electric_offset` and sensor direction `sensor_direction` to avoid alignment procedure:
The same can be done by using the motor parameters:
261
+
If you are using absolute sensors such as magnetic sensors or hall sensors, once you have done the alignment procedure and once you have the motor's zero electrical offset sensor direction you no longer need the full calibration sequence.
262
+
263
+
In this case you can set the sensor offset `zero_electric_offset` and sensor direction `sensor_direction` in the motor parameters to avoid the alignment procedure:
268
264
```cpp
269
-
//align sensor and start FOC
265
+
//set calibration values
270
266
motor.zero_electric_offset = 2.15; // rad
271
267
motor.sensor_direction = Direction::CW; // CW or CCW
268
+
// then call initFOC()
272
269
motor.initFOC();
273
270
```
274
271
You can find these values by running the `find_sensor_offset_and_direction.ino` example.
275
272
276
-
More generally, if you know any of these two values make sure to provide and the `iniFOC` will skip that part of the calibration. For example, for encoder sensors the zero electrical offset changes all the time but the sensor direction will stay the same so you can provide it and skip a large part of the calibration sequence.
273
+
If you set either of these two values the `initFOC` will skip that part of the calibration. For example, for encoder sensors the zero electrical offset changes all the time but the sensor direction will stay the same so you can provide it and skip a large part of the calibration sequence.
274
+
277
275
### Step 6.2 Skip alignment - current sense
278
276
279
277
For the current sensors it is as well possible to avoid the calibration procedure an that is done by specifying the curren sense flag called `skip_align`:
- Arduino boards - frequency change support either 32kHz or 4kHz
35
-
- Arduino Uno - synched timers in 3pwm and 6pwm mode [#71](https://github.com/simplefoc/Arduino-FOC/issues/71)
36
-
- Teensy 3.x initial support for 6pwm
37
-
- Teensy 4.x initial support for 6pwm
38
-
- Example for v3.1 SimpleFOCShield
39
-
- RP2040 compatibility for earlehillpower core [#234](https://github.com/simplefoc/Arduino-FOC/pull/234)[#236](https://github.com/simplefoc/Arduino-FOC/pull/236)
40
-
- More flexible monitoring API
41
-
- start, end and separator characters
42
-
- decimal places (settable through commander)
43
-
- Added machine readable verbose mode in `Commander`[#233](https://github.com/simplefoc/Arduino-FOC/pull/233)
44
-
-*Simple**FOC**WebController* - Web based user interface for SimpleFOC by [@geekuillaume](https://github.com/geekuillaume) - [webcontroller.simplefoc.com](https://webcontroller.simplefoc.com)
- bugfix - current sense align - added offset exchange when exchanging pins
47
-
- bugfix - trapezoid 150 fixed
48
-
- bugfix - 4pwm on ESP8266 [#224](https://github.com/simplefoc/Arduino-FOC/pull/224)
49
-
- Additional `InlineCurrentSense` and `LowsideCurrentSense` constructor using milliVolts per Amp [#253](https://github.com/simplefoc/Arduino-FOC/pull/253)
50
-
- STM32L4xx current sense support by [@Triple6](https://github.com/Triple6) (discord) [#257](https://github.com/simplefoc/Arduino-FOC/pull/257)
51
-
- phase disable in 6pwm mode
52
-
- stm32 - software and hardware 6pwm
53
-
- atmega328
54
-
- atmega2560
55
-
- Lag compensation using motor inductance [#246](https://github.com/simplefoc/Arduino-FOC/issues/246)
56
-
- current control through voltage torque mode enhancement
57
-
- extended `BLDCMotor` and `StepperMotor` constructors to receive the inductance paramerer
58
-
- can also be set using `motor.phase_inductance` or through `Commander`
- And more bugfixes - see the [complete list of 2.3.1 fixes here](https://github.com/simplefoc/Arduino-FOC/issues?q=is%3Aissue+milestone%3A2.3.1_Release)
41
+
- Change: simplify initFOC() API ([d57d32d](https://github.com/simplefoc/Arduino-FOC/commit/d57d32dd8715dbed4e476469bc3de0c052f1d531). [5231e5e](https://github.com/simplefoc/Arduino-FOC/commit/5231e5e1d044b0cc33ede67664b6ef2f9d0a8cdf), [10c5b87](https://github.com/simplefoc/Arduino-FOC/commit/10c5b872672cab72df16ddd738bbf09bcce95d28))
42
+
- Change: check for linked driver in currentsense and exit gracefully ([5ef4d9d](https://github.com/simplefoc/Arduino-FOC/commit/5ef4d9d5a92e03da0dd5af7f624243ab30f1b688))
43
+
- Compatibility with newest versions of Arduino framework for STM32, Renesas, ESP32, Atmel SAM, Atmel AVR, nRF52 and RP2040
0 commit comments