Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions docs/boards/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ There two main formats of the official drivers boards developed by the <span cla

- <span class="simple">Shield</span> form factor: These boards are designed to be compatible with the Arduino ecosystem and are intended to be used with the <span class="simple">Simple<span class="foc">FOC</span>library</span> and the Arduino IDE. They are designed to be easy to use and are intended for low to mid power applications.
- <span class="simple">Simple<span class="foc">FOC</span>Shield</span> - <small>[Find out more](arduino_simplefoc_shield_showcase)</small>
- <span class="simple">Simple<span class="foc">FOC</span> <b>Power</b>Shield</span> - <small>⚠️<i>( development abandoned )</i></small> - <small>[Find out more](#arduino-simplefoc-powershield-v02-️-development-abandoned-)</small>
- <span class="simple">Simple<span class="foc">FOC</span> <b>Power</b>Shield</span> - <small>⚠️<i>( development abandoned )</i></small> - <small>[Find out more](#simplefoc-powershield-v02-️-development-abandoned-)</small>
- 📢**NEW**: <span class="simple">Simple<span class="foc">FOC</span><b>Drive</b></span> - <small>[Find out more](boards#simplefoc-drive-v10---find-out-more)</small>

- <span class="simple">Mini</span> form factor: These boards are designed to be small, low-cost, and easy to use. They are intended for low power applications and are designed to be compatible with the <span class="simple">Simple<span class="foc">FOC</span>library</span>.
- <span class="simple">Simple<span class="foc">FOC</span>Mini</span> - <small>[Find out more](simplefocmini)</small>
- <span class="simple">Simple<span class="foc">FOC</span> <b>Step</b>Mini</span> (📢**NEW**) - <small> [Find out more](#simplefoc-stepmini-v10---see-on-github)
- <span class="simple">Simple<span class="foc">FOC</span> <b>Step</b>Mini</span> - <small> [Find out more](#simplefoc-stepmini-v10---see-on-github)


In addition to the official boards, there are many other boards compatible with <span class="simple">Simple<span class="foc">FOC</span>library</span> that you can explore, see the [docs](supported_hardware). Additionally, some other cool hardware designs have been proposed by the community. Check out our [community forum](https://community.simplefoc.com/) for more info.
Expand Down Expand Up @@ -111,6 +112,39 @@ This does not mean that the board itself is not functional or that it will not w

Read more about this board at [link](https://github.com/simplefoc/Arduino-SimpleFOC-PowerShield)

### <span class="simple">Simple<span class="foc">FOC</span> <b>Drive</b></span> <small>v1.0</small> - <small>[Find out more](https://github.com/simplefoc/SimpleFOC-DriveShield)</small>

![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?color=blue)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/simplefoc/SimpleFOC-DriveShield)
![GitHub Release Date](https://img.shields.io/github/release-date/simplefoc/SimpleFOC-DriveShield?color=blue)

<div class="width40">
<img src="https://raw.githubusercontent.com/simplefoc/SimpleFOC-DriveShield/refs/heads/main/images/top.jpg" />
</div>

This is an open-source low-cost BLDC driver boards in the form of a Arduino shield. It is a part of the SimpleFOC project. The board is the big brother of the SimpleFOCShield and is designed to drive motors with higher current requirements, up to 30Amps. The board is created with the same philosophy as the SimpleFOCShield - to be simple to use, low-cost, and open-source and fully compatible with the SimpleFOClibrary.

Additionally the aim of the board is to serve as a template project for the community to build their own motor drivers.

- The board is relatively simple and can be easily modified to fit different requirements.
- The board is designed in EasyEDA and all the fabrication files are available for download

### Features
{: .no_toc }

- **Boards absolute max ratings**
- Max current: 20A continuous (peak 30A - measured)
- Max input voltage: 30V
- **Stackable**: running 2 motors in the same time
- **Encoder/Hall sensors interface**: Integrated 3.3kΩ pullups (configurable)
- **I2C interface**: Integrated 4.7kΩ pullups (configurable)
- **Configurable pinout**: Hardware configuration - soldering connections
- **Arduino headers**: Arduino UNO, Arduino MEGA, STM32 Nucleo boards...
- **Open Source**:
- Fully designed in EasyEDA: [EasyEDA project](https://oshwlab.com/the.skuric/SimpleFOC-Drive)
- Fully available on github: [GitHub project](https://github.com/simplefoc/SimpleFOC-DriveShield)
- **Low-cost**: Estimated price of 25-40€ - Will be available in the SimpleFOC shop


## Boards in the <span class="simple">Mini</span> form factor

Expand Down
3 changes: 2 additions & 1 deletion docs/simplefoc_library/code/current_sense/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ stm32f1 family | ✔️ | ✔️ (one motor) | ❌
stm32f4 family | ✔️ | ✔️ (one motor) | ❌
stm32g4 family | ✔️ | ✔️ (one motor) | ❌
stm32l4 family | ✔️ | ✔️ (one motor) | ❌
stm32f7 family | ✔️ | ✔️ (initial) | ❌
stm32f7 family | ✔️ | ✔️ (one motor) | ❌
stm32h7 family | ✔️ | ✔️ (one motor) | ❌
stm32 B_G431B_ESC1 | ❌ | ✔️ (one motor) | ❌
esp32/esp32s3 | ✔️ | ✔️ | ❌
esp32s2/esp32c3 | ✔️ | ❌ | ❌
Expand Down
11 changes: 10 additions & 1 deletion docs/simplefoc_library/code/current_sense/low_side.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ Low side current sensing for all the architectures is on our road-map and we are
<a href ="javascript:show('stepper','type');" id="btn-stepper" class="btn btn-type btn-stepper"> Stepper motors</a>

<p class="type type-bldc" ><img src="extras/Images/low-side.png" class="width50"></p>
<p class="type type-stepper hide" ><img src="extras/Images/lowside_stepper.png" class="width60"></p>
<div class="type type-stepper hide" >

<img src="extras/Images/lowside_stepper.png" class="width60">

<blockquote class="info">
<p class="heading">Other topologies for low-side current sensing for Steppers</p>
See the link <a href="https://community.simplefoc.com/t/low-side-current-sensing-for-stepper-motors/7235">Low-side current sensing for stepper motors</a> in the community forum for more information about other topologies for low-side current sensing for stepper motors.
</blockquote>
</div>


<blockquote class="info" markdown="1">
Expand All @@ -44,6 +52,7 @@ STM32f4 family | ✔️ (one motor) | DMA| ~25kHz| all
STM32g4 family | ✔️ (one motor) | DMA| ~25kHz| all
STM32l4 family | ✔️ (one motor) | DMA| ~25kHz| all
STM32f7 family | ✔️ (one motor) | DMA| ~25kHz | all
STM32h7 family | ✔️ (one motor) | DMA| ~25kHz | all
STM32 B_G431B_ESC1 | ✔️ | DMA| ~25kHz| all
ESP32 with MCPWM |✔️ | Interrupts| ~20kHz| all
ESP32 with LEDC | ❌ | -| -| -
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,26 @@ Examples:
- X-NUCLEO-IHM07M1
- etc.

<a href="javascript:show('bldc','motor');" class="btn btn-bldc btn-motor btn-primary">BLDCMotor</a>
<a href="javascript:show('stepper','motor');" class="btn btn-stepper btn-motor">HybridStepperMotor</a>



<div class="motor motor-bldc" markdown="1">
<img src="extras/Images/3pwm_driver.png" class="width40">
</div>

<div class="motor motor-stepper hide" markdown="1">
<img src="extras/Images/hybrid_3pwm.jpg" class="width40">

<blockquote class="warning" markdown="1">
⚠️ **Note:** When using the 3PWM BLDC driver with a stepper motor, ensure that the common phase `Uo` is connected to the driver's C phase pin.
</blockquote>

</div>





## Step 1. Hardware setup
Expand All @@ -46,6 +64,39 @@ BLDCDriver3PWM driver = BLDCDriver3PWM(9, 10, 11, 8, 7, 6);

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

<blockquote class="warning" markdown="1">
<p class="heading">⚠️ <b>Note:</b> When using the 3PWM BLDC driver with a stepper motor, ensure that the common phase `Uo` is connected to the driver's C phase pin.</p>

Even if the common phase `Uo` is physically connected to some other driver output (`A` or `B`), please provide it as the `C` phase pin in the driver constructor. This is important for the correct operation of the stepper motor.

Consider an example of the driver connected to the MCU pins as follows:

```cpp
#define PIN_A 9
#define PIN_B 10
#define PIN_C 11
#define ENABLE 8
```

If the common phase `Uo` is connected to the driver pin `A`, you should still provide it as the `C` phase pin in the driver constructor:
```cpp
// common phase `Uo` connected to driver pin `A` so it is provided as the `C` phase pin
BLDCDriver3PWM driver = BLDCDriver3PWM(PIN_C, PIN_B, PIN_A, ENABLE);
```

If the common phase `Uo` is connected to the driver pin `B`, you should provide it as the `C` phase pin in the driver constructor:
```cpp
// common phase `Uo` connected to driver pin `B` so it is provided as the `C` phase pin
BLDCDriver3PWM driver = BLDCDriver3PWM(PIN_A, PIN_C, PIN_B, ENABLE);
```

Or if the common phase `Uo` is connected to the driver pin `C`, you should provide it as the `C` phase pin in the driver constructor:
```cpp
// common phase `Uo` connected to driver pin `C` so it is provided as the `C` phase pin
BLDCDriver3PWM driver = BLDCDriver3PWM(PIN_A, PIN_B, PIN_C, ENABLE);
```
</blockquote>

### Low-side current sensing considerations

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.
Expand Down Expand Up @@ -105,7 +156,16 @@ driver.voltage_power_supply = 12;
driver.voltage_limit = 12;
```

<a href="javascript:show('bldc','motor');" class="btn btn-bldc btn-motor btn-primary">BLDCMotor</a>
<a href="javascript:show('stepper','motor');" class="btn btn-stepper btn-motor">HybridStepperMotor</a>

<div class="motor motor-bldc" markdown="1">

<img src="extras/Images/limits.png" class="width60">
</div>
<div class="motor motor-stepper hide" markdown="1">
<img src="extras/Images/hybrid_limits.jpg" class="width60">
</div>

This parameter is used by the `BLDCMotor` class as well. As shown on the figure above the once the voltage limit `driver.voltage_limit` is set, it will be communicated to the FOC algorithm in `BLDCMotor` class and the phase voltages will be centered around the `driver.voltage_limit/2`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,22 @@ Examples:
- ODrive 3.6
- etc.

<a href="javascript:show('bldc','motor');" class="btn btn-bldc btn-motor btn-primary">BLDCMotor</a>
<a href="javascript:show('stepper','motor');" class="btn btn-stepper btn-motor">HybridStepperMotor</a>

<div class="motor motor-bldc" markdown="1">
<img src="extras/Images/6pwm_driver.png" class="width40">
</div>

<div class="motor motor-stepper hide" markdown="1">
<img src="extras/Images/hybrid_6pwm.jpg" class="width40">


<blockquote class="warning" markdown="1">
⚠️ **Note:** When using the 3PWM BLDC driver with a stepper motor, ensure that the common phase `Uo` is connected to the driver's C phase pin.
</blockquote>

</div>

6 PWM control mode gives much more freedom for BLDC motor control than 3PWM control since each of the 6 half-bride mosfets can be controlled separately.

Expand All @@ -42,6 +56,43 @@ BLDCDriver6PWM driver = BLDCDriver6PWM(5,6, 9,10, 3,11, 8);

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


<blockquote class="warning" markdown="1">
<p class="heading">⚠️ <b>Note:</b> When using the 6PWM BLDC driver with a stepper motor, ensure that the common phase `Uo` is connected to the driver's C phase pin.</p>

Even if the common phase `Uo` is physically connected to some other driver output (`A` or `B`), please provide it as the `C` phase pin in the driver constructor. This is important for the correct operation of the stepper motor.

Consider an example of the driver connected to the MCU pins as follows:

```cpp
#define PIN_A_H 9
#define PIN_A_L 10
#define PIN_B_H 11
#define PIN_B_L 12
#define PIN_C_H 13
#define PIN_C_L 14
#define ENABLE 8
```

If the common phase `Uo` is connected to the driver pin `A`, you should still provide it as the `C` phase pin in the driver constructor:
```cpp
// common phase `Uo` connected to driver pin `A` so it is provided as the `C` phase pin
BLDCDriver6PWM driver = BLDCDriver6PWM(PIN_C_H, PIN_C_L, PIN_B_H, PIN_B_L, PIN_A_H, PIN_A_L, ENABLE);
```

If the common phase `Uo` is connected to the driver pin `B`, you should provide it as the `C` phase pin in the driver constructor:
```cpp
// common phase `Uo` connected to driver pin `B` so it is provided as the `C` phase pin
BLDCDriver6PWM driver = BLDCDriver6PWM(PIN_A_H, PIN_A_L, PIN_C_H, PIN_C_L, PIN_B_H, PIN_B_L, ENABLE);
```

Or if the common phase `Uo` is connected to the driver pin `C`, you should provide it as the `C` phase pin in the driver constructor:
```cpp
// common phase `Uo` connected to driver pin `C` so it is provided as the `C` phase pin
BLDCDriver6PWM driver = BLDCDriver6PWM(PIN_A_H, PIN_A_L, PIN_B_H, PIN_B_L, PIN_C_H, PIN_C_L, ENABLE);
```
</blockquote>

### Arduino UNO support
Arduino UNO and all the atmega328 based boards have only 6 PWM pins and in order to use the `BLDCDrievr6PWM` we need to use all of them. Those are `3`,`5`,`6`,`9`,`10` and `11`.
Furthermore in order for the algorithm to work well we need to use the PWM pins that belong to the same timer for each high/low side pair of each phase.
Expand Down Expand Up @@ -174,7 +225,16 @@ driver.voltage_power_supply = 12;
driver.voltage_limit = 12;
```

<a href="javascript:show('bldc','motor');" class="btn btn-bldc btn-motor btn-primary">BLDCMotor</a>
<a href="javascript:show('stepper','motor');" class="btn btn-stepper btn-motor">HybridStepperMotor</a>

<div class="motor motor-bldc" markdown="1">

<img src="extras/Images/limits.png" class="width60">
</div>
<div class="motor motor-stepper hide" markdown="1">
<img src="extras/Images/hybrid_limits.jpg" class="width60">
</div>

This parameter is used by the `BLDCMotor` class as well. As shown on the figure above the once the voltage limit `driver.voltage_limit` is set, it will be communicated to the FOC algorithm in `BLDCMotor` class and the phase voltages will be centered around the `driver.voltage_limit/2`.

Expand Down
4 changes: 2 additions & 2 deletions docs/simplefoc_library/code/drivers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ has_toc: False

Arduino <span class="simple">Simple<span class="foc">FOC</span>library</span> supports BLDC and stepper motor drivers:

- [BLDC driver <i class="fa fa-external-link"></i>](bldcdriver)
- [BLDC driver <i class="fa fa-external-link"></i>](bldcdriver) (BLDC or Hybrid stepper motors)
- **3 PWM signals** ( 3 phase ) - `BLDCDriver3PWM`
- **6 PWM signals** ( 3 phase ) - `BLDCDriver6PWM`
- [Stepper drivers <i class="fa fa-external-link"></i>](stepperdriver)
- [Stepper drivers <i class="fa fa-external-link"></i>](stepperdriver) (Stepper motors)
- **4 PWM signals** ( 2 phase ) - `StepperDriver4PWM`
- **2 PWM signals** ( 2 phase ) - `StepperDriver2PWM`

Expand Down
51 changes: 50 additions & 1 deletion docs/simplefoc_library/code/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,12 @@ For full documentation of the setup and all configuration parameters please visi


## Step 4. <a href="motors_config" class="remove_dec"> Motor setup </a>
After the position sensor and the driver we proceed to initializing and configuring the motor. The library supports BLDC motors handled by the `BLDCMotor` class as well as stepper motors handled by the `StepperMotor` class. Both classes are instantiated by providing just the `pole_pairs` number of the motor and optionally the motors´ phase resistance and the KV rating.
After the position sensor and the driver we proceed to initializing and configuring the motor. The library supports BLDC motors handled by the `BLDCMotor` class as well as stepper motors handled by the `StepperMotor` and `HybridStepperMotor` classes. Both classes are instantiated by providing just the `pole_pairs` number of the motor and optionally the motors' phase resistance and the KV rating.


<a href="javascript:show('0m','motor');" id="btn-0m" class="btn-motor btn btn-primary">BLDC motor</a>
<a href ="javascript:show('1m','motor');" id="btn-1m" class="btn-motor btn">Stepper motor</a>
<a href ="javascript:show('2m','motor');" id="btn-2m" class="btn-motor btn">HybridStepper motor</a>


<div class="motor motor-0m" markdown="1" style="display:block">
Expand Down Expand Up @@ -386,12 +387,60 @@ void setup() {
// init driver
// link the motor to the driver
motor.linkDriver(&driver);
// link driver and the current sense

// link the motor to current sense
motor.linkCurrentSense(&current_sese);

// set control loop type to be used
motor.controller = MotionControlType::velocity;
// initialize motor
motor.init();

// init current sense

}

void loop() {

}
```
</div>


<div class="motor motor-2m" markdown="1" style="display:none">

In this example we will use HybridStepper motor (Stepper motor coupled with a BLDC driver):
```cpp
#include <SimpleFOC.h>

// HybridStepperMotor( int pole_pairs , (phase_resistance, KV_rating optional))
HybridStepperMotor motor = HybridStepperMotor(50);

// instantiate driver
// instantiate sensor
// instantiate current sensor

void setup() {
// init sensor
// link the motor to the sensor
motor.linkSensor(&sensor);

// init driver
// link the motor to the driver
motor.linkDriver(&driver);
// link driver and the current sense

// link the motor to current sense
motor.linkCurrentSense(&current_sese);

// set control loop type to be used
motor.controller = MotionControlType::velocity;
// initialize motor
motor.init();

// init current sense

}

void loop() {
Expand Down
Loading