diff --git a/.gitignore b/.gitignore index 78050df..50f84c6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ _site Gemfile.lock node_modules -.jekyll-cache \ No newline at end of file +.jekyll-cache +bin/just-the-docs +assets/images/.DS_Store diff --git a/.jekyll-metadata b/.jekyll-metadata deleted file mode 100644 index ebacc0b..0000000 Binary files a/.jekyll-metadata and /dev/null differ diff --git a/README.md b/README.md index 323796e..cbca440 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # simplefoc.github.io Documentation website for SimpleFOCproject - + - [Documentation](https://docs.simplefoc.com) - [Community forum](https://community.simplefoc.com) - [Shop](https://simplefoc.com/shop) @@ -26,7 +26,7 @@ bundle install ``` And you're ready to go! -Just make sure that whenever you open your terminal to generate the webiste to activate the conda anvironment: +Just make sure that whenever you open your terminal to generate the website to activate the conda environment: ``` conda activate simpledocs ``` @@ -41,4 +41,13 @@ bundle exec jekyll serve Since the site is quiet large sometimes the `--incremental` flag helps with faster execution ``` bundle exec jekyll serve --incremental -``` \ No newline at end of file +``` + +## Olddocs generating + +1) Add the library version to the index.md +2) modify the `_config.yaml` + - `url: "http://olddocs.simplefoc.com" ` + - `baseurl: "v2.2.3"` +3) run `bundle exec jekyll build` +4) in `_site` you have the generated html \ No newline at end of file diff --git a/_includes/js/custom.js b/_includes/js/custom.js index 30eae2d..cc6befd 100644 --- a/_includes/js/custom.js +++ b/_includes/js/custom.js @@ -16,7 +16,9 @@ var libraires =[ "LowsideCurrentSense.h", "InlineCurrentSense.h", "MySensor.h", - "Sensor.h" + "Sensor.h", + "SimpleFOCDrivers.h", + "MagneticSensorAS5048A.h" ] var defines =[ diff --git a/_includes/nav.html b/_includes/nav.html index 02844ea..2025db8 100644 --- a/_includes/nav.html +++ b/_includes/nav.html @@ -77,6 +77,9 @@ {%- endif -%} {%- endunless -%} {%- endfor -%} + diff --git a/docs/boards/index.md b/docs/boards/index.md index a05c358..be1ab98 100644 --- a/docs/boards/index.md +++ b/docs/boards/index.md @@ -13,9 +13,9 @@ has_toc: false One of the goals of the SimpleFOCproject is to develop low-cost easy to use BLDC driver boards compatible with the SimpleFOClibraryand completely open source! For now there have been three official BLDC drivers developed by the SimpleFOCproject: -- SimpleFOCShield +- SimpleFOCShield - [Find out more](arduino_simplefoc_shield_showcase) +- SimpleFOCMini πŸ“’**NEW** - [Find out more](simplefocmini) - SimpleFOC PowerShield -- SimpleFOCMini πŸ“’**NEW** ## Arduino SimpleFOCShield v2.0.4 - [Find out more](arduino_simplefoc_shield_showcase) @@ -43,6 +43,32 @@ The SimpleFOCShield, in com - **Open Source**: Fully available fabrication files - [how to make it yourself](https://docs.simplefoc.com/arduino_simplefoc_shield_fabrication) +## πŸ“’**NEW**: SimpleFOCMini v1.0 - [Find out more](simplefocmini) + +Small package, low-cost BLDC driver board fully compatible with the SimpleFOClibrary + + + + + + + +## Features +- **Plug & play**: In combination with Arduino SimpleFOClibrary +- **DRV8313 based** - [datasheet](https://www.ti.com/lit/ds/symlink/drv8313.pdf?ts=1650461862269&ref_url=https%253A%252F%252Fwww.google.com%252F) + - Power supply: 8-24V + - Max current: 2.5A per phase + - Onboard 3.3V LDO +- **Small size**: 26x20 mm +- **Fully open-source**: + - [EasyEDA](https://easyeda.com/the.skuric/simplefocmini) + - [GitHub](https://github.com/simplefoc/SimpleFOCMini) +- **Low-cost**: + - JLCPCB production cost ~3-5€ + - Will be available in the [shop](https://www.simplefoc.com/shop) soon: 7-10€ + + Read more about this board at [link](https://github.com/simplefoc/SimpleFOCMini) + ## Arduino SimpleFOC PowerShield v0.2 ⚠️( under developement) A powerful arduino shield for running BLDC motors using the FOC algorithm. This board is based on the [BTN8982](https://www.infineon.com/dgdl/Infineon-BTN8982TA-DS-v01_00-EN.pdf?fileId=db3a30433fa9412f013fbe32289b7c17) half bridges and can support currents up to 30 Amps continuos and 50Amps peak. Making it a board that can run virtually any BLDC motor. @@ -78,29 +104,3 @@ This does not mean that the board itself is not functional or that it will not w - schematics Read more about this board at [link](https://github.com/simplefoc/Arduino-SimpleFOC-PowerShield) - -## πŸ“’**NEW**: SimpleFOCMini v1.0 - -Small package, low-cost BLDC driver board fully compatible with the SimpleFOClibrary - - - - - - - -## Features -- **Plug & play**: In combination with Arduino SimpleFOClibrary -- **DRV8313 based** - [datasheet](https://www.ti.com/lit/ds/symlink/drv8313.pdf?ts=1650461862269&ref_url=https%253A%252F%252Fwww.google.com%252F) - - Power supply: 8-24V - - Max current: 2.5A per phase - - Onboard 3.3V LDO -- **Small size**: 26x20 mm -- **Fully open-source**: - - [EasyEDA](https://easyeda.com/the.skuric/simplefocmini) - - [GitHub](https://github.com/simplefoc/SimpleFOCMini) -- **Low-cost**: - - JLCPCB production cost ~3-5€ - - Will be available in the [shop](https://www.simplefoc.com/shop) soon: 7-10€ - - Read more about this board at [link](https://github.com/simplefoc/SimpleFOCMini) \ No newline at end of file diff --git a/docs/boards/simplefoc_mini/getting_started/code.md b/docs/boards/simplefoc_mini/getting_started/code.md new file mode 100644 index 0000000..717310a --- /dev/null +++ b/docs/boards/simplefoc_mini/getting_started/code.md @@ -0,0 +1,102 @@ +--- +layout: default +title: Writing the code +parent: Starting with Mini +description: "Writing the Arduino program for your SimpleFOCMini." +nav_order: 2 +permalink: /mini_code +grand_parent: SimpleFOCMini +grand_grand_parent: SimpleFOC Boards +--- + +# Writing the code +Once you have all the [hardware connected](mini_connect_hardware): +- Microcontroller +- BLDC motor +- Position sensor +- Power supply + +we can start the most exciting part, coding! + +SimpleFOCMini is fully supported by Arduino SimpleFOClibrary, therefore please make sure you have the newest version of the SimpleFOClibrary installed. If you still did not get your owm version of the library please follow the [installation instructions](installation). + +Suggested approach when starting coding for the Arduino SimpleFOCMini is: + +- [Test the sensor](#step-1-testing-the-sensor) +- [Test the motor](#step-2-testing-the-motor) +- [Voltage motion control](#step-3-voltage-motion-control) +- [More complex control strategies](#step-4-more-complex-control-strategies) - position and velocity + +You can also follow our [Getting started](example_from_scratch) guide! + +## Step 1. Testing the sensor +First make sure your sensor works properly. Run one of the library examples specific to your sensors. You can find the library examples in +```sh +utils > + sensor_test > + encoder > + - encoder_example + - encoder_software_interrupts_example + magnetic_sensors > + - magnetic_sensor_i2c_example + - magnetic_sensor_spi_example + - magnetic_sensor_analog_example + hall_sensors > + - hall_sensor_example + - hall_sensor_software_interrupts_example +``` +Once you have your sensor reading the good values you can continue the testing the combination of the motor and the sensor. + +

Update the example pinout

+When testing the sensor make sure to update the pinout.
+ +## Step 2. Testing the motor +To test the BLDC motor before running FOC algorithm we suggest to run the open loop examples! +```sh +motion_control > + open_loop_motor_control > + - open_loop_position_example + - open_loop_velocity_example +``` +

Update the example pinout

+When testing the motor make sure to update the pinout that you have chosen in the hardware configuration.
+ +If you are not sure what is the number of pole pairs your motor has, please check the example code: +```sh +utils > + find_pole_pair_number > + - encoder + - magnetic_sensor +``` +This code will estimate the pole pairs number that your motor has. Please run this code several times to get a good estimation. The code will, generally show a good reading 7/10 times. + + +## Step 3. Voltage motion control +Once you have your sensor working, and you have the right number of pole pairs of your motor you can start using FOC algorithm. The best practice is to start with an example of the Voltage control: +```sh +motion_control > + torque_voltage_control > + - encoder + - magnetic_sensor + - hall_sensors +``` + +## Step 4. More complex control strategies +Now when you have your torque control using voltage ready you can continue to the position and velocity control algorithms. They will take a bit more time to tune but they will give you a chance to have great results. You can find the library examples for motion control loops in by navigating the examples: + +```sh +motion_control > + position_motion_control > + - encoder + - magnetic_sensor + - hall_sensors + torque_voltage_control > + - encoder + - magnetic_sensor + - hall_sensors + velocity_motion_control > + - encoder + - magnetic_sensor + - hall_sensors +``` +For more information about the possible SimpleFOCMini projects visit [example projects](examples) diff --git a/docs/boards/simplefoc_mini/getting_started/connections.md b/docs/boards/simplefoc_mini/getting_started/connections.md new file mode 100644 index 0000000..48446d7 --- /dev/null +++ b/docs/boards/simplefoc_mini/getting_started/connections.md @@ -0,0 +1,136 @@ +--- +layout: default +title: Connecting the hardware +parent: Starting with Mini +description: "Connecting SimpleFOCMini with your hardware." +nav_order: 1 +permalink: /mini_connect_hardware +grand_parent: SimpleFOCMini +grand_grand_parent: SimpleFOC Boards +--- + +# Connecting the hardware + +

+ +

+ +Connecting the SimpleFOCMini to the microcontroller, BLDC motor and power-supply is very straight forward. + +

+ +

+ +## Microcontroller +- SimpleFOCMini is designed as a standalone BLDC driver, which will basically work with any microcontroller. +- This board has 10 pins exposed for the connection to the microcontroller + +

+ +

+ +There are 5 pins that are required to be connected + +Pin Name | Description +--- | --- +GND | Ground (common ground) +IN1 | PWM input phase 1 +IN2 | PWM input phase 2 +IN3 | PWM input phase 3 +EN | Driver Enable + +These pins need to ba connected whenever using the SimpleFOCMini. The 3 pwm pins and the enable pin are used to control the DRV8313 driver and in terms of the SimpleFOClibrary they correspond to the entries of the `BLDCDriver3PWM` class. The common ground pin is very important as well in order to make sure that all the PWM and Enable pins are read properly by the driver chip. Once you decide which pins you will be using for `INx` and `EN` pins you will be able to porvide them to the `BLDCDriver3PWM` class in your Arduino sketch. + +```cpp +BLDCDriver3PWM driver = BLDCDriver3PWM(IN1, IN2, IN3, EN); +``` + +In addition to these pins there are 5 pins that are optional. + +Pin Name | Description +--- | --- +3.3V | 3.3V output - **NOT INPUT** +GND | Ground +nRT | Reset (active LOW) +nSP | Sleep (active LOW) +nFT | Fault output (active LOW) + +SimpleFOCMini is based on the DRV8313 driver which has integrated 3.3V regulator which might be useful in some applications to power a sensor or similar. The 3.3v pin of the SimpleFOCMini can therefore be used as a 3.3v source pin with the maximum current output of 10mA. Both GND pins exposed in the SimpleFOCMini's header are connected to the same ground, so you can choose the one which is more convenient to your application. +

BEWARE: 3.3V LDO Power limitations

+DRV8313 comes with the 3.3V voltage regulator and it is connected to the SimpleFOCMini's 3.3V pin. However it has a limitation of 10mA, which is in general not enough to power a microcontroller. But it might be enough to power a LED light or some position sensors. +
+ +Pin `nFT` (fault) is an active LOW output of the SimpleFOCMini which can be read to verify if the DRV8313 driver is working properly. If this pin is in LOW it means the DRV8313 is its fault state and it cannot drive the motor. Then the pin `nRT` (reset), which is also active LOW, can be used to reset the DRV8313 driver to reinitialise its internal state and exit the fault state, this cannot be done by simply toggling the enable pin. Finally the pin `nSP` (sleep) is an active LOW pin that puts the DRV8313 in the low-power sleep mode, consuming the current of under 1uA. + + + + + +## BLDC motor +- Motor phases `a`, `b` and `c` are connected directly the motor terminal connector `M1`,`M2` and `M3` + +

BEWARE: Power limitations

+SimpleFOCMini is designed for gimbal motors with internal resistance higher than R>10Ohm. The absolute maximal current of this board is 5A. Please make sure when using this board in your projects that the BLDC motor used does comply with these limits.
+If you still want to use this driver with the BLDC motors with very low resistance R < 1Ohm make sure to limit the voltage set to the board.
+For a bit more information about the choice of motors visit BLDC motor docs +
+ +## Power supply +- Power supply cables are connected directly to the terminal pins `+` and `-` +- Required power supply voltage is from 8V to 24V. + + +## Examples of connection schematics + +SimpleFOCMini can be connected to any microcontroller (MCU) pin combination that can ensure that the mini's `GND` pin is connected to the MCU's `GND` pin, MCU's 3 pwm capable pins are connected to the `IN1`,`IN2` and `IN3` pins, and one MCU's digital pin is connected to the `EN` pin. + + +An example connection of the SimpleFOCMini and Nucleo board is shown on the image below. + + + +SimpleFOCMini can be directly plugged into the Arduino headers of teh Nucleo board from the pin `10` to the `GND` pin and in that way reduce the amount of wires necessary. For more information on this example connection see [this library example](mini_example_nucleo). + +--- | --- | --- | ---| --- | --- +Mini Pin | EN | IN3 | IN2 | IN1 | GND +Nucleo Pin | 10 | 11 | 12 | 13 | GND + +```cpp +BLDCDriver3PWM driver = BLDCDriver3PWM(13, 12, 11, 10); +``` + +An example connection of the SimpleFOCMini and Arduino UNO is shown on the image below. + + +SimpleFOCMini can be directly plugged into the Arduino headers of the UNO board from the pin `8` to the `12` pin (pin 12 can act as a GND pin) and in that way reduce the amount of wires necessary. For more information on this example connection see [this library example](mini_example). + +--- | --- | --- | ---| --- | --- +Mini Pin | EN | IN3 | IN2 | IN1 | GND +UNO Pin | 8 | 9 | 10 | 11 | 12 + +```cpp +BLDCDriver3PWM driver = BLDCDriver3PWM(11, 10, 9, 8); +``` + +Another example of connecting the Arduino UNO with SimpleFOCMini is shown below + + +--- | --- | --- | ---| --- | --- +Mini Pin | EN | IN3 | IN2 | IN1 | GND +UNO Pin | 4 | 5 | 6 | 9 | GND + +```cpp +BLDCDriver3PWM driver = BLDCDriver3PWM(9, 6, 5, 4); +``` + +An example connection of the SimpleFOCMini and stm32 Bluepill is shown on the image below. + + + +--- | --- | --- | ---| --- | --- +Mini Pin | EN | IN3 | IN2 | IN1 | GND +Bluepill Pin | PB15 | PA8 | PA9 | PA10 | GND + +```cpp +BLDCDriver3PWM driver = BLDCDriver3PWM(PA10, PA9, PA8, PB15); +``` \ No newline at end of file diff --git a/docs/boards/simplefoc_mini/getting_started/index.md b/docs/boards/simplefoc_mini/getting_started/index.md new file mode 100644 index 0000000..6a3ee18 --- /dev/null +++ b/docs/boards/simplefoc_mini/getting_started/index.md @@ -0,0 +1,28 @@ +--- +layout: default +title: Starting with Mini +description: "Getting started with Arduino SimpleFOCMini" +parent: SimpleFOCMini +grand_parent: SimpleFOC Boards +nav_order: 1 +permalink: /mini_getting_started +has_children: true +has_toc: false +--- +# Getting Started with SimpleFOCMini + + + +## Step 1: [Connecting the hardware](mini_connect_hardware) + + + +Connecting the SimpleFOCMini to the microcontroller, BLDC motor and power-supply is straight forward. + +[Read more](mini_connect_hardware) + +## Step 2: [Writing the code](mini_code) + +Once you have all the hardware [ready to be connected](mini_connect_hardware), we can start the most exciting part, coding! + +[Read more](mini_code) \ No newline at end of file diff --git a/docs/boards/simplefoc_mini/index.md b/docs/boards/simplefoc_mini/index.md new file mode 100644 index 0000000..9cf81c5 --- /dev/null +++ b/docs/boards/simplefoc_mini/index.md @@ -0,0 +1,98 @@ +--- +layout: default +title: SimpleFOCMini +parent: SimpleFOC Boards +description: "Arduino SimpleFOCShield board showcase." +nav_order: 2 +permalink: /simplefocmini +has_children: true +has_toc: false +--- + + +# SimpleFOCMini v1.0 + +SimpleFOCMini is a small-package, low-cost, modular and user-friendly driver for running gimbal BLDC motors with FOC algorithm. As for the SimpleFOCShields, the main motivation of this board is to make using low-power BLDC motors in hobby applications more accessible. +The main goals of this board however are: + +- Produce a small package BLDC driver that still has all the features of the SimpleFOCShield v1 +- Make it in away to be a minimal working example for users that are interested to build their own boards based on the DRV8313 chip. +- Make it as cheap as possible. +- Use only long-term (as of mid 2022) available components. +- Finally, the goal of this board is to provide a modular and simple setup for controlling gimbal motors (up to 3Amps) using FOC control and enable fast prototyping and full exploitation of their capabilities. + +This board in combination with the SimpleFOClibrary will give you a simple and intuitive way to control the BLDC motors' current, torque, velocity and position. And this board can be used as a drop in replacement for the SimpleFOCShield v1. + + + + + +## Features +- **Plug & play**: In combination with Arduino SimpleFOClibrary +- **DRV8313 based** - [datasheet](https://www.ti.com/lit/ds/symlink/drv8313.pdf?ts=1650461862269&ref_url=https%253A%252F%252Fwww.google.com%252F) + - Power supply: 8-24V + - Max current: 2.5A per phase + - Onboard 3.3V LDO +- **Small size**: 26x20 mm +- **Fully open-source**: + - [EasyEDA](https://easyeda.com/the.skuric/simplefocmini) + - [GitHub](https://github.com/simplefoc/SimpleFOCMini) +- **Low-cost**: + - JLCPCB production cost ~3-5€ + - Will be available in the [shop](https://www.simplefoc.com/shop) soon: 7-10€ + + + +
+

BEWARE

+This BLDC driver board is primarily designed for gimbal motors with the internal resistance of R >10 Ξ©. Please make sure that your motor fits in this category before deciding to use the SimpleFOCMini. +
+ + + +### Connection schematic +An electrical connection example of a BLDC motor with an encoder as position sensor. +

+For more information about how to connect you hardware to your shield, check the full [connection example](mini_example). + +## Project example : Reaction wheel inverted pendulum + +This is a project of designing and controlling the reaction wheel inverted pendulum based entirely on Arduino SimpleFOClibrary and SimpleFOCShield + +This is a very fun project in many ways, and it is intended: +- Students in search for a good testing platform for their advanced algorithms +- Everyone with a bit of free time and a motivation to create something cool :D + +For full documentation of necessary components, design choices and the code please visit the [project docs](simplefoc_pendulum). + +

πŸ“’ +This project can be entirely done by using the SimpleFOCMini board.

+
+ +## Project example : Steer by wire - bidirectional haptic control examples + + +This video demonstrates SimpleFOCShield support for stacking with Arudino UNO and STM32 Nucleo-64 board. As well as support for different sensors magnetic and encoders with relatively large precision span. + +The control algorithms implemented in this project are : +- **Steer by wire** (force feedback): two motors with virtually coupled positions +- **Interactive gauge** (haptic velocity control): two motors with virtually coupled position and velocity + + +For full documentation of the projects setup and the code please visit the [project docs](haptics_examples). + +

πŸ“’ +This project can be entirely done by using the SimpleFOCMini board.

+
+ +## Getting started + +You already have your own SimpleFOCMini?
+[Here is a simple guide how to start preparing your setup](mini_getting_started) + + + +## How to get hold of the SimpleFOCMini +- **Fabricate the board yourself**: Please visit the [board fabrication](mini_fabrication) to find out how to manufacture the board yourself!
+- **Order the finished and tested board**: Check out our [shop](https://simplefoc.com/shop). + diff --git a/docs/boards/simplefoc_mini/mini_fabrication.md b/docs/boards/simplefoc_mini/mini_fabrication.md new file mode 100644 index 0000000..41bc877 --- /dev/null +++ b/docs/boards/simplefoc_mini/mini_fabrication.md @@ -0,0 +1,41 @@ +--- +layout: default +title: Fabrication +description: "Arduino SimpleFOCMini board fabrication" +parent: SimpleFOCMini +grand_parent: SimpleFOC Boards +nav_order: 2 +permalink: /mini_fabrication +has_children: true +has_toc: false +--- + + +# Fabrication guide for SimpleFOCMini +Here is a quick guide how to fabricate the SimpleFOCMini board. The board has been designed using the EasyEDA software that makes it very easy to fabricate using the JLCPCB website. + + +## Step by step guide +First step is to go to the [EasyEDA's project library](https://oshwlab.com/the.skuric/simplefocmini) and open the SimpleFOCMini project in the EasyEDA editor. +

+ +Then you need to open the SimpleFOCMini PCB file by clicking on it and then go to the top bar dropdown ***Fabrication*** and select ***One-click order PCB/SMT*** +

+ +The pop-up will show up asking if you want the Design Rule check, which is not necessary so you can click on ***No, continue and Order***. +

+Once the files are generated you the new pop-up will show up and there you just click ***OK***. +

+You will be redirected to the [JLCPCB site](https://cart.jlcpcb.com/quote?orderType=1&stencilLayer=2&stencilWidth=100&stencilLength=100&stencilCounts=5) with all the filled in entries. You just need to select he color and teh quantity that you would like to manufacture and go to the bottom where you can click on ***Confirm*** +

+The BOM and CPL files should be loaded automatically so then you should be able to click ***Next***. You need to provide the description of your purchase, ***DIY*** will do. +

+In the next window you will see all the components that are shown in the BOM (Bill of materials), here I'd suggest you do uncheck the two through hole female header components H1 and P1. And everything else should be fine, you can click ***Next***. +

+And that is it, the last window will show your purchase summary and show you the visualisation of the board. The only thing left to do is to save it to teh cart and go through the payment and shipping information. +

+ + +## Fabrication price + +Price of a 5 board batch at JLCPCB website is around 32$, making it 7.5$ per board. The shipping cost will depend on how urgently you need your boards, the slowest option is the cheapest for 16 business days delivery time the shipping price is 3$ and for 2-5 day delivery you will pay from 20-50$. \ No newline at end of file diff --git a/docs/boards/simplefoc_shield/fabrication/index.md b/docs/boards/simplefoc_shield/fabrication/index.md index e5b0c0e..42ac3fb 100644 --- a/docs/boards/simplefoc_shield/fabrication/index.md +++ b/docs/boards/simplefoc_shield/fabrication/index.md @@ -2,7 +2,7 @@ layout: default title: Board Fabrication description: "Arduino SimpleFOCShield board fabrication" -parent: Arduino SimpleFOCShield +parent: SimpleFOCShield grand_parent: SimpleFOC Boards nav_order: 2 permalink: /arduino_simplefoc_shield_fabrication diff --git a/docs/boards/simplefoc_shield/fabrication/shield_fabrication_v1.md b/docs/boards/simplefoc_shield/fabrication/shield_fabrication_v1.md index b1f6bb7..de311ac 100644 --- a/docs/boards/simplefoc_shield/fabrication/shield_fabrication_v1.md +++ b/docs/boards/simplefoc_shield/fabrication/shield_fabrication_v1.md @@ -3,7 +3,7 @@ layout: default title: v1.3.3 description: "Arduino SimpleFOCShield board fabrication" parent: Board Fabrication -grand_parent: Arduino SimpleFOCShield +grand_parent: SimpleFOCShield grand_grand_parent: SimpleFOC Boards nav_order: 1 permalink: /arduino_simplefoc_shield_fabrication_v1 diff --git a/docs/boards/simplefoc_shield/fabrication/shield_fabrication_v2.md b/docs/boards/simplefoc_shield/fabrication/shield_fabrication_v2.md index 04f881e..83a58f2 100644 --- a/docs/boards/simplefoc_shield/fabrication/shield_fabrication_v2.md +++ b/docs/boards/simplefoc_shield/fabrication/shield_fabrication_v2.md @@ -3,7 +3,7 @@ layout: default title: v2.0.4 description: "Arduino SimpleFOCShield board fabrication" parent: Board Fabrication -grand_parent: Arduino SimpleFOCShield +grand_parent: SimpleFOCShield grand_grand_parent: SimpleFOC Boards nav_order: 2 permalink: /arduino_simplefoc_shield_fabrication_v2 diff --git a/docs/boards/simplefoc_shield/getting_started/code.md b/docs/boards/simplefoc_shield/getting_started/code.md index 4055f31..8a850a2 100644 --- a/docs/boards/simplefoc_shield/getting_started/code.md +++ b/docs/boards/simplefoc_shield/getting_started/code.md @@ -5,7 +5,7 @@ parent: Getting Started description: "Writing the Arduino program for your SimpleFOCShield." nav_order: 3 permalink: /foc_shield_code -grand_parent: Arduino SimpleFOCShield +grand_parent: SimpleFOCShield grand_grand_parent: SimpleFOC Boards --- @@ -27,6 +27,8 @@ Suggested approach when starting coding for the Arduino Sim - [Voltage motion control](#step-3-voltage-motion-control) - [More complex control strategies](#step-4-more-complex-control-strategies) - position and velocity +You can also follow our [Getting started](example_from_scratch) guide! + ## Step 1. Testing the sensor First make sure your sensor works properly. Run one of the library examples specific to your sensors. You can find the library examples in ```sh diff --git a/docs/boards/simplefoc_shield/getting_started/connections.md b/docs/boards/simplefoc_shield/getting_started/connections.md index 559e217..b7a682e 100644 --- a/docs/boards/simplefoc_shield/getting_started/connections.md +++ b/docs/boards/simplefoc_shield/getting_started/connections.md @@ -5,7 +5,7 @@ parent: Getting Started description: "Connecting SimpleFOCShield with your hardware." nav_order: 2 permalink: /foc_shield_connect_hardware -grand_parent: Arduino SimpleFOCShield +grand_parent: SimpleFOCShield grand_grand_parent: SimpleFOC Boards --- diff --git a/docs/boards/simplefoc_shield/getting_started/index.md b/docs/boards/simplefoc_shield/getting_started/index.md index 882b87f..6ce9494 100644 --- a/docs/boards/simplefoc_shield/getting_started/index.md +++ b/docs/boards/simplefoc_shield/getting_started/index.md @@ -2,7 +2,7 @@ layout: default title: Getting Started description: "Getting started with Arduino SimpleFOCShield" -parent: Arduino SimpleFOCShield +parent: SimpleFOCShield grand_parent: SimpleFOC Boards nav_order: 1 permalink: /arduino_simplefoc_shield_installation diff --git a/docs/boards/simplefoc_shield/getting_started/soldering_pads/index.md b/docs/boards/simplefoc_shield/getting_started/soldering_pads/index.md index 0014408..3a2a7be 100644 --- a/docs/boards/simplefoc_shield/getting_started/soldering_pads/index.md +++ b/docs/boards/simplefoc_shield/getting_started/soldering_pads/index.md @@ -5,7 +5,7 @@ parent: Getting Started description: "Configuring your SimpleFOCShield by soldering the pads." nav_order: 1 permalink: /pads_soldering -grand_parent: Arduino SimpleFOCShield +grand_parent: SimpleFOCShield grand_grand_parent: SimpleFOC Boards has_children: true has_toc: false diff --git a/docs/boards/simplefoc_shield/getting_started/soldering_pads/pads_v1.md b/docs/boards/simplefoc_shield/getting_started/soldering_pads/pads_v1.md index 2f345e4..c2c02b5 100644 --- a/docs/boards/simplefoc_shield/getting_started/soldering_pads/pads_v1.md +++ b/docs/boards/simplefoc_shield/getting_started/soldering_pads/pads_v1.md @@ -6,7 +6,7 @@ grand_parent: Getting Started description: "Configuring your SimpleFOCShield by soldering the pads." nav_order: 1 permalink: /pads_soldering_v1 -grand_grand_parent: Arduino SimpleFOCShield +grand_grand_parent: SimpleFOCShield grand_grand_grand_parent: SimpleFOC Boards --- # Hardware configuration using soldering pads
SimpleFOCShield v1 diff --git a/docs/boards/simplefoc_shield/getting_started/soldering_pads/pads_v2.md b/docs/boards/simplefoc_shield/getting_started/soldering_pads/pads_v2.md index ccb7207..af5390d 100644 --- a/docs/boards/simplefoc_shield/getting_started/soldering_pads/pads_v2.md +++ b/docs/boards/simplefoc_shield/getting_started/soldering_pads/pads_v2.md @@ -6,7 +6,7 @@ grand_parent: Getting Started description: "Configuring your SimpleFOCShield by soldering the pads." nav_order: 2 permalink: /pads_soldering_v2 -grand_grand_parent: Arduino SimpleFOCShield +grand_grand_parent: SimpleFOCShield grand_grand_grand_parent: SimpleFOC Boards --- # Hardware configuration using soldering pads
SimpleFOCShield v2 diff --git a/docs/boards/simplefoc_shield/index.md b/docs/boards/simplefoc_shield/index.md index d856d74..be89dd4 100644 --- a/docs/boards/simplefoc_shield/index.md +++ b/docs/boards/simplefoc_shield/index.md @@ -1,6 +1,6 @@ --- layout: default -title: Arduino SimpleFOCShield +title: SimpleFOCShield parent: SimpleFOC Boards description: "Arduino SimpleFOCShield board showcase." nav_order: 1 diff --git a/docs/contact.md b/docs/contact.md index eae1680..5550eaa 100644 --- a/docs/contact.md +++ b/docs/contact.md @@ -1,6 +1,6 @@ --- layout: default -title: Contact +title: Contact and Contributing nav_order: 9 description: "Arduino Simple Field Oriented Control (FOC) library ." permalink: /contact @@ -30,4 +30,4 @@ Pull requests are welcome, but let's first discuss them in [community forum](htt ## Direct Contact For very serious questions πŸ˜„: -[simplefoc.com](https://simplefoc.com/contact) \ No newline at end of file +[simplefoc.com](https://simplefoc.com/contact) diff --git a/docs/simplefoc_library/cheatsheet/build_flags.md b/docs/simplefoc_library/cheatsheet/build_flags.md index 8cd421f..d387c9d 100644 --- a/docs/simplefoc_library/cheatsheet/build_flags.md +++ b/docs/simplefoc_library/cheatsheet/build_flags.md @@ -21,6 +21,9 @@ Build flags control the way the compiler generates the code for SimpleFOClibrary +nav_order: 9 +permalink: /citing +--- + +# Citing SimpleFOC + +We are very happy that *Simple**FOC**library* has been used as a component of several research project and has made its way to several scientific papers. We are hoping that this trend is going to continue as the project matures and becomes more robust! +A short resume paper about *Simple**FOC*** has been published in the Journal of Open Source Software: +

+ SimpleFOC: A Field Oriented Control (FOC) Library for Controlling Brushless Direct Current (BLDC) and Stepper Motors.
+ A. Skuric, HS. Bank, R. Unger, O. Williams, D. GonzΓ‘lez-Reyes
+Journal of Open Source Software, 7(74), 4232, https://doi.org/10.21105/joss.04232 +

+ +If you are interested in citing *Simple**FOC**library* or some other component of *Simple**FOC**project* in your research, we suggest you to cite our paper: + + + +
+ +
+@article{simplefoc2022,
+  doi = {10.21105/joss.04232},
+  url = {https://doi.org/10.21105/joss.04232},
+  year = {2022},
+  publisher = {The Open Journal},
+  volume = {7},
+  number = {74},
+  pages = {4232},
+  author = {Antun Skuric and Hasan Sinan Bank and Richard Unger and Owen Williams and David GonzΓ‘lez-Reyes},
+  title = {SimpleFOC: A Field Oriented Control (FOC) Library for Controlling Brushless Direct Current (BLDC) and Stepper Motors},
+  journal = {Journal of Open Source Software}
+}
+
+
+
+ + +## SimpleFOC: A Field Oriented Control (FOC) Library for Controlling Brushless Direct Current (BLDC) and Stepper Motors. + diff --git a/docs/simplefoc_library/code/current_sense/high_side.md b/docs/simplefoc_library/code/current_sense/high_side.md index e249020..31ee037 100644 --- a/docs/simplefoc_library/code/current_sense/high_side.md +++ b/docs/simplefoc_library/code/current_sense/high_side.md @@ -9,8 +9,11 @@ grand_grand_parent: Arduino SimpleFOC \ No newline at end of file diff --git a/docs/simplefoc_library/code/current_sense/index.md b/docs/simplefoc_library/code/current_sense/index.md index 28c6b24..9ef9df6 100644 --- a/docs/simplefoc_library/code/current_sense/index.md +++ b/docs/simplefoc_library/code/current_sense/index.md @@ -42,23 +42,25 @@ The current sense code will be written in a way to support as many different dri Also make sure to follow our [community forum](https://community.simplefoc.com), a lot of discussions is being held about current sensing and its applications! ## Current sensing support per MCU architecture - + MCU | In-line | Low-side | High-side --- | --- |--- |--- Arduino (8-bit) | βœ”οΈ | ❌ | ❌ Arduino DUE | βœ”οΈ | ❌ | ❌ -STM32 (in general) | βœ”οΈ | ❌ | ❌ -STM32F1 family | βœ”οΈ | βœ”οΈ (one motor) | ❌ -STM32F4 family | βœ”οΈ | βœ”οΈ (one motor) | ❌ -STM32G4 family | βœ”οΈ | βœ”οΈ (one motor) | ❌ -STM32 B-G431B-ESC1 | βœ”οΈ | βœ”οΈ | ❌ -ESP32 | βœ”οΈ | βœ”οΈ | ❌ -ESP8266 | ❌ | ❌ | ❌ -SAMD21 | βœ”οΈ | βœ”οΈ (one motor) | ❌ -SAMD51 | βœ”οΈ | ❌ | ❌ -Teensy | βœ”οΈ | ❌ | ❌ +stm32 (in general) | βœ”οΈ | ❌ | ❌ +stm32f1 family | βœ”οΈ | βœ”οΈ (one motor) | ❌ +stm32f4 family | βœ”οΈ | βœ”οΈ (one motor) | ❌ +stm32g4 family | βœ”οΈ | βœ”οΈ (one motor) | ❌ +stm32 B_G431B_ESC1 | ❌ | βœ”οΈ (one motor) | ❌ +esp32/esp32s3 | βœ”οΈ | βœ”οΈ | ❌ +esp32s2/esp32c3 | βœ”οΈ | ❌ | ❌ +esp8266 | ❌ | ❌ | ❌ +samd21 | βœ”οΈ | βœ”οΈ (one motor) | ❌ +samd51 | βœ”οΈ | ❌ | ❌ +teensy | βœ”οΈ | ❌ | ❌ Raspberry Pi Pico | βœ”οΈ | ❌ | ❌ Portenta H7 | βœ”οΈ | ❌ | ❌ +nRF52 | βœ”οΈ | ❌ | ❌ ## Digging deeper diff --git a/docs/simplefoc_library/code/current_sense/low_side.md b/docs/simplefoc_library/code/current_sense/low_side.md index e1313ac..e1f0129 100644 --- a/docs/simplefoc_library/code/current_sense/low_side.md +++ b/docs/simplefoc_library/code/current_sense/low_side.md @@ -187,7 +187,7 @@ It is very important that the the current sensing `init` function is called afte So the suggested code structure would be: ```cpp -void loop(){ +void setup(){ .... // driver init driver.init(); diff --git a/docs/simplefoc_library/code/drivers/bldc_driver/bldc_driver_3pwm.md b/docs/simplefoc_library/code/drivers/bldc_driver/bldc_driver_3pwm.md index 5296731..08338f8 100644 --- a/docs/simplefoc_library/code/drivers/bldc_driver/bldc_driver_3pwm.md +++ b/docs/simplefoc_library/code/drivers/bldc_driver/bldc_driver_3pwm.md @@ -119,6 +119,22 @@ Once when all the necessary configuration parameters are set the driver function driver.init(); ``` +This function is responsible for: +- determining and configuring the hardware timer for PWM generation +- verifying that all provided pins can be used to generate PWM +- configuring the PWM channels + +If for some reason the driver configuration fails this function will return `0` if everything went well the function will return `1`. So we suggest you to check if the init function was executed successfully before continuing +```cpp +Serial.print("Driver init "); +// init driver +if (driver.init()) Serial.println("success!"); +else{ + Serial.println("failed!"); + return; +} +``` + ## Step 3. Using `BLDCDriver3PWM` in real-time BLDC driver class was developed to be used with the SimpleFOClibrary and to provide the abstraction layer for FOC algorithm implemented in the `BLDCMotor` class. But the `BLDCDriver3PWM` class can used as a standalone class as well and once can choose to implement any other type of control algorithm using the bldc driver. diff --git a/docs/simplefoc_library/code/drivers/bldc_driver/bldc_driver_6pwm.md b/docs/simplefoc_library/code/drivers/bldc_driver/bldc_driver_6pwm.md index e7af5a4..01e732c 100644 --- a/docs/simplefoc_library/code/drivers/bldc_driver/bldc_driver_6pwm.md +++ b/docs/simplefoc_library/code/drivers/bldc_driver/bldc_driver_6pwm.md @@ -186,6 +186,22 @@ Once when all the necessary configuration parameters are set the driver function driver.init(); ``` +This function is responsible for: +- determining and configuring the hardware timer for PWM generation +- verifying that all provided pins can be used to generate PWM +- configuring the PWM channels + +If for some reason the driver configuration fails this function will return `0` if everything went well the function will return `1`. So we suggest you to check if the init function was executed successfully before continuing +```cpp +Serial.print("Driver init "); +// init driver +if (driver.init()) Serial.println("success!"); +else{ + Serial.println("failed!"); + return; +} +``` + ## Step 3. Using `BLDCDriver6PWM` in real-time BLDC driver class was developed to be used with the SimpleFOClibrary and to provide the abstraction layer for FOC algorithm implemented in the `BLDCMotor` class. But the `BLDCDriver3PWM` class can used as a standalone class as well and once can choose to implement any other type of control algorithm using the BLDC driver. diff --git a/docs/simplefoc_library/code/drivers/stepper_driver/stepper_driver_2pwm.md b/docs/simplefoc_library/code/drivers/stepper_driver/stepper_driver_2pwm.md index 089e108..84698f8 100644 --- a/docs/simplefoc_library/code/drivers/stepper_driver/stepper_driver_2pwm.md +++ b/docs/simplefoc_library/code/drivers/stepper_driver/stepper_driver_2pwm.md @@ -101,6 +101,22 @@ Once when all the necessary configuration parameters are set the driver function driver.init(); ``` +This function is responsible for: +- determining and configuring the hardware timer for PWM generation +- verifying that all provided pins can be used to generate PWM +- configuring the PWM channels + +If for some reason the driver configuration fails this function will return `0` if everything went well the function will return `1`. So we suggest you to check if the init function was executed successfully before continuing +```cpp +Serial.print("Driver init "); +// init driver +if (driver.init()) Serial.println("success!"); +else{ + Serial.println("failed!"); + return; +} +``` + ## Step 3. Using encoder in real-time BLDC driver class was developed to be used with the SimpleFOClibrary and to provide the abstraction layer for FOC algorithm implemented in the `StepperMotor` class. But the `StepperDriver4PWM` class can used as a standalone class as well and once can choose to implement any other type of control algorithm using the BLDC driver. diff --git a/docs/simplefoc_library/code/drivers/stepper_driver/stepper_driver_4pwm.md b/docs/simplefoc_library/code/drivers/stepper_driver/stepper_driver_4pwm.md index 40bc5cd..a20ecea 100644 --- a/docs/simplefoc_library/code/drivers/stepper_driver/stepper_driver_4pwm.md +++ b/docs/simplefoc_library/code/drivers/stepper_driver/stepper_driver_4pwm.md @@ -77,6 +77,22 @@ Once when all the necessary configuration parameters are set the driver function driver.init(); ``` +This function is responsible for: +- determining and configuring the hardware timer for PWM generation +- verifying that all provided pins can be used to generate PWM +- configuring the PWM channels + +If for some reason the driver configuration fails this function will return `0` if everything went well the function will return `1`. So we suggest you to check if the init function was executed successfully before continuing +```cpp +Serial.print("Driver init "); +// init driver +if (driver.init()) Serial.println("success!"); +else{ + Serial.println("failed!"); + return; +} +``` + ## Step 3. Using encoder in real-time BLDC driver class was developed to be used with the SimpleFOClibrary and to provide the abstraction layer for FOC algorithm implemented in the `StepperMotor` class. But the `StepperDriver4PWM` class can used as a standalone class as well and once can choose to implement any other type of control algorithm using the BLDC driver. diff --git a/docs/simplefoc_library/code/drivers_library.md b/docs/simplefoc_library/code/drivers_library.md index e09ed25..3d04d1c 100644 --- a/docs/simplefoc_library/code/drivers_library.md +++ b/docs/simplefoc_library/code/drivers_library.md @@ -49,7 +49,7 @@ It is steadily growing, but at the moment we have: ## How can I use it? -```c++ +```cpp #include "SimpleFOCDrivers.h" ``` @@ -57,7 +57,7 @@ It is in the arduino library manager, called "Simple FOC Drivers". Install as no To use some code from the library, include the specific driver module you want. For example: -```c++ +```cpp #include "encoders/as5048a/MagneticSensorAS5048A.h" ``` diff --git a/docs/simplefoc_library/code/motors/bldc_motors.md b/docs/simplefoc_library/code/motors/bldc_motors.md index 8baac31..c55bbec 100644 --- a/docs/simplefoc_library/code/motors/bldc_motors.md +++ b/docs/simplefoc_library/code/motors/bldc_motors.md @@ -237,12 +237,22 @@ motor.initFOC();

Can be skipped for openloop control!

If no sensor is attached this function will not really do anything, but you can still call it if necessary or more convenient.
This function does several things: +- Checks if driver (and current sense if available) are well initialised - Checks/modifies position sensor direction in respect to the motor's direction - Searches for encoder index if necessary - Finds the motor electrical offset in respect to the position sensor - Checks/modifies current sense pinout and gains signs if one available to make sure it aligned with the driver -This function is a final check function and it will disable your motor and display you a message what is wrong. (when using the [monitoring](monitoring) ). If everything is well configured, after the call of this function FOC is ready and our setup is done! +If for some reason the `initFOC` fails this function will return `0` and it will disable your motor and display you a message what is wrong (when using the [monitoring](monitoring) ). If everything is well configured, the call of this function will return `1` and the our setup is done, FOC is ready to be used! So we suggest you to check if the init function was executed successfully before continuing: + +```cpp +// init current sense +if (motor.initFOC()) Serial.println("FOC init success!"); +else{ + Serial.println("FOC init failed!"); + return; +} +``` The alignment procedure will have to move your motor several times and might not be desirable behavior, therefore for most of the position sensors (except encodes) and current senses, this alignment procedure can be skipped by following the steps 6.1 an 6.2. diff --git a/docs/simplefoc_library/code/motors/stepper_motors.md b/docs/simplefoc_library/code/motors/stepper_motors.md index 6daf86a..8222726 100644 --- a/docs/simplefoc_library/code/motors/stepper_motors.md +++ b/docs/simplefoc_library/code/motors/stepper_motors.md @@ -203,12 +203,22 @@ motor.initFOC();

Can be skipped for openloop control!

If no sensor is attached this function will not really do anything, but you can still call it if necessary or more convenient.
This function does several things: +- Checks if driver (and current sense if available) are well initialised - Checks/modifies position sensor direction in respect to the motor's direction - Searches for encoder index if necessary - Finds the motor electrical offset in respect to the position sensor +- Checks/modifies current sense pinout and gains signs if one available to make sure it aligned with the driver -This function is a final check function and it will disable your motor and display you a message what is wrong. (when using the [monitoring](monitoring) ). If everything is well configured, after the call of this function FOC is ready and our setup is done! +If for some reason the `initFOC` fails this function will return `0` and it will disable your motor and display you a message what is wrong (when using the [monitoring](monitoring) ). If everything is well configured, the call of this function will return `1` and the our setup is done, FOC is ready to be used! So we suggest you to check if the init function was executed successfully before continuing: +```cpp +// init current sense +if (motor.initFOC()) Serial.println("FOC init success!"); +else{ + Serial.println("FOC init failed!"); + return; +} +``` The alignment procedure will have to move your motor several times and might not be desirable behavior, therefore for most of the position sensors (except encodes) and current senses, this alignment procedure can be skipped by following the steps 5.1. ### Step 5.1 Skip alignment - position sensor diff --git a/docs/simplefoc_library/code/sensors/encoder.md b/docs/simplefoc_library/code/sensors/encoder.md index 1ea956d..f14b2df 100644 --- a/docs/simplefoc_library/code/sensors/encoder.md +++ b/docs/simplefoc_library/code/sensors/encoder.md @@ -254,6 +254,16 @@ class Encoder{ } ``` +
+

Calling `getVelocity` multiple times

+When calling `getVelocity` it will only calculate the velocity if the elapsed time from the previous call is longer than the time specified in teh variable `min_elapsed_time` (default 100us). If the elapsed time from the last call is shorter than `min_elapsed_time` the function will return previously calculated value. Variable `min_elapsed_time` can be changed easily if necessary: + +```cpp +encoder.min_elapsed_time = 0.0001; // 100us by default +``` +
+ + Here is a quick example: ```cpp #include diff --git a/docs/simplefoc_library/code/sensors/generic.md b/docs/simplefoc_library/code/sensors/generic.md index ae6838e..80ab89c 100644 --- a/docs/simplefoc_library/code/sensors/generic.md +++ b/docs/simplefoc_library/code/sensors/generic.md @@ -59,6 +59,15 @@ class GenericSensor{ } ``` +
+

Calling `getVelocity` multiple times

+When calling `getVelocity` it will only calculate the velocity if the elapsed time from the previous call is longer than the time specified in teh variable `min_elapsed_time` (default 100us). If the elapsed time from the last call is shorter than `min_elapsed_time` the function will return previously calculated value. Variable `min_elapsed_time` can be changed easily if necessary: + +```cpp +sensor.min_elapsed_time = 0.0001; // 100us by default +``` +
+ Here is a quick example: ```cpp #include diff --git a/docs/simplefoc_library/code/sensors/hall_sensor.md b/docs/simplefoc_library/code/sensors/hall_sensor.md index 81b35e9..79ab397 100644 --- a/docs/simplefoc_library/code/sensors/hall_sensor.md +++ b/docs/simplefoc_library/code/sensors/hall_sensor.md @@ -34,6 +34,14 @@ sensor.pullup = Pullup::USE_INTERN; ```

Arduino Pullup 20kΞ©

Be careful when using internal pullups, Arduino has relatively high valued pullups around 20kΞ©, which means that you might have some problems for higher velocities (for shorted impulse durations). Recommended pull-up values are in between 1kΞ© and 5kΞ©.
+### Step 2.1 Velocity outlier removal + +From the release v2.2.3 `HallSensor` class implements the outlier removal for its velocity calculations. It is based on a simple principle where all the calculated velocities higher than a certain maximal expected velocity are considered to be an outlier. To modify the maximal expected motor velocity, you can modify the variable `velocity_max`. This variable is set to 1000rad/s by default which is a good starting point for most applications. Except if you are using very high performance motors, then 1000 rad/s (~10,000 rpm) could still be reachable by the motor in which case please increase this value to a number outside the motor's reach. + +```cpp +// maximal expected velocity +sensor.velocity_max = 1000; // 1000rad/s by default ~10,000 rpm +``` ## Step 3. Interrupt setup There are two ways you can run hall sensors with Simple FOC library. - Using [hardware external interrupt](#hardware-external-interrupt) @@ -181,6 +189,15 @@ class HallSensor{ } ``` +
+

Calling `getVelocity` multiple times

+When calling `getVelocity` it will only calculate the velocity if the elapsed time from the previous call is longer than the time specified in teh variable `min_elapsed_time` (default 100us). If the elapsed time from the last call is shorter than `min_elapsed_time` the function will return previously calculated value. Variable `min_elapsed_time` can be changed easily if necessary: + +```cpp +sensor.min_elapsed_time = 0.0001; // 100us by default +``` +
+ Here is a quick example using only hardware interrupts: ```cpp #include diff --git a/docs/simplefoc_library/code/sensors/magnetic/magnetic_sensor_analog.md b/docs/simplefoc_library/code/sensors/magnetic/magnetic_sensor_analog.md index 0282e97..6990779 100644 --- a/docs/simplefoc_library/code/sensors/magnetic/magnetic_sensor_analog.md +++ b/docs/simplefoc_library/code/sensors/magnetic/magnetic_sensor_analog.md @@ -83,6 +83,16 @@ class MagneticSensorAnalog{ } ``` +
+

Calling `getVelocity` multiple times

+When calling `getVelocity` it will only calculate the velocity if the elapsed time from the previous call is longer than the time specified in teh variable `min_elapsed_time` (default 100us). If the elapsed time from the last call is shorter than `min_elapsed_time` the function will return previously calculated value. Variable `min_elapsed_time` can be changed easily if necessary: + +```cpp +sensor.min_elapsed_time = 0.0001; // 100us by default +``` +
+ + Here is a quick example for AS5600 magnetic sensor using it's analog output: ```cpp #include diff --git a/docs/simplefoc_library/code/sensors/magnetic/magnetic_sensor_i2c.md b/docs/simplefoc_library/code/sensors/magnetic/magnetic_sensor_i2c.md index 378d877..8db4b65 100644 --- a/docs/simplefoc_library/code/sensors/magnetic/magnetic_sensor_i2c.md +++ b/docs/simplefoc_library/code/sensors/magnetic/magnetic_sensor_i2c.md @@ -151,6 +151,17 @@ class MagneticSensorI2C{ } ``` +
+

Calling `getVelocity` multiple times

+When calling `getVelocity` it will only calculate the velocity if the elapsed time from the previous call is longer than the time specified in teh variable `min_elapsed_time` (default 100us). If the elapsed time from the last call is shorter than `min_elapsed_time` the function will return previously calculated value. Variable `min_elapsed_time` can be changed easily if necessary: + +```cpp +sensor.min_elapsed_time = 0.0001; // 100us by default +``` +
+ + + Here is a quick example for AS5600 magnetic sensor with I2C communication: ```cpp #include diff --git a/docs/simplefoc_library/code/sensors/magnetic/magnetic_sensor_pwm.md b/docs/simplefoc_library/code/sensors/magnetic/magnetic_sensor_pwm.md index a2fc66c..c5fd420 100644 --- a/docs/simplefoc_library/code/sensors/magnetic/magnetic_sensor_pwm.md +++ b/docs/simplefoc_library/code/sensors/magnetic/magnetic_sensor_pwm.md @@ -144,6 +144,39 @@ class MagneticSensorPWM{ } ``` +
+

Calling `getVelocity` multiple times

+When calling `getVelocity` it will only calculate the velocity if the elapsed time from the previous call is longer than the time specified in teh variable `min_elapsed_time` (default 100us). If the elapsed time from the last call is shorter than `min_elapsed_time` the function will return previously calculated value. Variable `min_elapsed_time` can be changed easily if necessary: + +```cpp +sensor.min_elapsed_time = 0.0001; // 100us by default +``` +
+ + + +
+

Calling `getVelocity` multiple times

+When calling `getVelocity` it will only calculate the velocity if the elapsed time from the previous call is longer than the time specified in teh variable `min_elapsed_time` (default 100us). If the elapsed time from the last call is shorter than `min_elapsed_time` the function will return previously calculated value. Variable `min_elapsed_time` can be changed easily if necessary: + +```cpp +sensor.min_elapsed_time = 0.0001; // 100us by default +``` +
+ + + +
+

Calling `getVelocity` multiple times

+When calling `getVelocity` it will only calculate the velocity if the elapsed time from the previous call is longer than the time specified in teh variable `min_elapsed_time` (default 100us). If the elapsed time from the last call is shorter than `min_elapsed_time` the function will return previously calculated value. Variable `min_elapsed_time` can be changed easily if necessary: + +```cpp +sensor.min_elapsed_time = 0.0001; // 100us by default +``` +
+ + + Here is a quick example for AS5048A magnetic sensor using its PWM output: ```cpp #include diff --git a/docs/simplefoc_library/code/sensors/magnetic/magnetic_sensor_spi.md b/docs/simplefoc_library/code/sensors/magnetic/magnetic_sensor_spi.md index d0dec05..3753d70 100644 --- a/docs/simplefoc_library/code/sensors/magnetic/magnetic_sensor_spi.md +++ b/docs/simplefoc_library/code/sensors/magnetic/magnetic_sensor_spi.md @@ -142,6 +142,17 @@ class MagneticSensorSPI{ } ``` +
+

Calling `getVelocity` multiple times

+When calling `getVelocity` it will only calculate the velocity if the elapsed time from the previous call is longer than the time specified in teh variable `min_elapsed_time` (default 100us). If the elapsed time from the last call is shorter than `min_elapsed_time` the function will return previously calculated value. Variable `min_elapsed_time` can be changed easily if necessary: + +```cpp +sensor.min_elapsed_time = 0.0001; // 100us by default +``` +
+ + + Here is a quick example for the AS5047U magnetic sensor with SPI communication: ```cpp #include diff --git a/docs/simplefoc_library/examples/haptics.md b/docs/simplefoc_library/examples/haptics.md index b68cb1c..dd8a92d 100644 --- a/docs/simplefoc_library/examples/haptics.md +++ b/docs/simplefoc_library/examples/haptics.md @@ -16,6 +16,8 @@ grand_parent: Arduino SimpleFOClib | | | | +Download the STL file as well as STEP and solidworks project of the 3d printed stand for the IPower GM4108H-120T motor with the mount for the CUI amt103 encoder, used in the images and the Youtube video, [here](extras/gm4108_encoder_mount.zip). + ## Connecting everything together Here is a picture of the setup used in this project. Check the Arduino code to see the pin numbers that are used. diff --git a/docs/simplefoc_library/examples/index.md b/docs/simplefoc_library/examples/index.md index ffd931b..e660f3e 100644 --- a/docs/simplefoc_library/examples/index.md +++ b/docs/simplefoc_library/examples/index.md @@ -57,4 +57,16 @@ parent: Arduino SimpleFOClibrary + + + \ No newline at end of file diff --git a/docs/simplefoc_library/examples/position_control_example.md b/docs/simplefoc_library/examples/position_control_example.md index 8d366c8..f6c39c1 100644 --- a/docs/simplefoc_library/examples/position_control_example.md +++ b/docs/simplefoc_library/examples/position_control_example.md @@ -12,7 +12,7 @@ grand_parent: Arduino SimpleFOClib # Position control example
using SimpleFOCShield For this BLDC motor position control example we are going to be using this hardware: -[Arduino UNO](https://store.arduino.cc/arduino-uno-rev3) | [Arduino SimpleFOCShield](arduino_simplefoc_shield_showcase) | [AMT 103 encoder](https://www.mouser.fr/ProductDetail/CUI-Devices/AMT103-V?qs=%2Fha2pyFaduiAsBlScvLoAWHUnKz39jAIpNPVt58AQ0PVb84dpbt53g%3D%3D) | [IPower GBM4198H-120T](https://www.ebay.com/itm/iPower-Gimbal-Brushless-Motor-GBM4108H-120T-for-5N-7N-GH2-ILDC-Aerial-photo-FPV/254541115855?hash=item3b43d531cf:g:q94AAOSwPcVVo571) +[Arduino UNO](https://store.arduino.cc/arduino-uno-rev3) | [Arduino SimpleFOCShield](arduino_simplefoc_shield_showcase) | [AMT 103 encoder](https://www.mouser.fr/ProductDetail/CUI-Devices/AMT103-V?qs=%2Fha2pyFaduiAsBlScvLoAWHUnKz39jAIpNPVt58AQ0PVb84dpbt53g%3D%3D) | [IPower GBM4108H-120T](https://www.ebay.com/itm/iPower-Gimbal-Brushless-Motor-GBM4108H-120T-for-5N-7N-GH2-ILDC-Aerial-photo-FPV/254541115855?hash=item3b43d531cf:g:q94AAOSwPcVVo571) --- | --- | --- | --- | | | @@ -241,5 +241,7 @@ void loop() { // function calculating the outer position loop and setting the target position motor.move(target_angle); + // user communication + command.run(); } ``` diff --git a/docs/simplefoc_library/examples/position_control_example_mini.md b/docs/simplefoc_library/examples/position_control_example_mini.md new file mode 100644 index 0000000..2e2695f --- /dev/null +++ b/docs/simplefoc_library/examples/position_control_example_mini.md @@ -0,0 +1,261 @@ +--- +layout: default +title: SimpleFOCMini & UNO +parent: Example projects +description: "Arduino Simple Field Oriented Control (FOC) library ." +nav_order: 9 +permalink: /mini_example +grand_parent: Arduino SimpleFOClibrary +--- + + +# Position control example
using SimpleFOCMini +For this BLDC motor position control example we are going to be using this hardware: + +[Arduino UNO](https://store.arduino.cc/arduino-uno-rev3) | [Arduino SimpleFOCMini](simplefocmini) | [AMT 103 encoder](https://www.mouser.fr/ProductDetail/CUI-Devices/AMT103-V?qs=%2Fha2pyFaduiAsBlScvLoAWHUnKz39jAIpNPVt58AQ0PVb84dpbt53g%3D%3D) | [IPower GBM4108H-120T](https://www.ebay.com/itm/iPower-Gimbal-Brushless-Motor-GBM4108H-120T-for-5N-7N-GH2-ILDC-Aerial-photo-FPV/254541115855?hash=item3b43d531cf:g:q94AAOSwPcVVo571) +--- | --- | --- | --- + | | | + + +# Connecting everything together +

+ +For more information about the SimpleFOCMini check the [docs](simplefocmini). + +

+ +## Encoder +- Channels `A` and `B` are connected to the Arduino UNO pins `2` and `3`. + +## Motor +- Motor phases `a`, `b` and `c` are connected directly the motor terminal connector connectors `M1`, `M2` and `M3` of the SimpleFOCMini board + +## SimpleFOCMini +- The most convenient way of plugging the SimpleFOCMini board to the Arduino UNO is to stack it on its pins `12-8`. + - `GND` - `12` + - `IN1` - `11` + - `IN2` - `10` + - `IN3` - `9` + - `EN` - `8` + +
+Pin `12` is not a real ground pin. As no power is transferred through the mini's `GND` pin then we can use pin `12` to approximate the `GND` pin by declaring it as digital output and setting it to `LOW`. This technique might not always work though. If you start seeing that your motor vibrates, even in the open loop control mode, then you should ditch this approach and connect the mini's `GND` pin to the Arduino UNO's `GND` pin. The vibrations should then stop completely. +
+ + +### Small motivation :D +

+ + +# Arduino code +Let's go through the full code for this example and write it together. +First thing you need to do is include the `SimpleFOC` library: + +```cpp +#include +``` +Make sure you have the library installed. If you still don't have it please check the [get started page](installation) + + +## Encoder code +First we define the `Encoder` class with the A and B channel pins and number of impulses per revolution. +```cpp +// define Encoder +Encoder encoder = Encoder(2, 3, 2048); +``` +Then we define the buffering callback functions. +```cpp +// channel A and B callbacks +void doA(){encoder.handleA();} +void doB(){encoder.handleB();} +``` +In the `setup()` function we initialize the encoder and enable interrupts: +```cpp +// initialize encoder hardware +encoder.init(); +// hardware interrupt enable +encoder.enableInterrupts(doA, doB); +``` +And that is it, let's setup the motor. + +
For more configuration parameters of the encoders please check the Encoder class docs.
+ + +## Motor code +First we need to define the `BLDCMotor` class with the number od pole pairs (`11`) +```cpp +// define BLDC motor +BLDCMotor motor = BLDCMotor(11); +``` +
If you are not sure what your pole pairs number is please check the find_pole_pairs.ino example.
+ + +Next we need to define the `BLDCDriver3PWM` class with the PWM pin numbers of the motor and the driver enable pin +```cpp +// define BLDC driver +BLDCDriver3PWM driver = BLDCDriver3PWM(11, 10, 9, 8); +``` + +Then in the `setup()` we configure first the voltage of the power supply if it is not `12` Volts and init the driver. +```cpp +// power supply voltage +// default 12V +driver.voltage_power_supply = 12; +driver.init(); +``` +Additionally we add the code to declare the pin `12` ad digital output set to `LOW` to be used as a common ground signal. In the `setup` we add +```cpp +pinMode(12,OUTPUT); // declares pin 12 as output and sets it to LOW +``` + +Then we tell the motor which control loop to run by specifying the `motor.controller` variable. +```cpp +// set control loop type to be used +// MotionControlType::torque +// MotionControlType::velocity +// MotionControlType::angle +motor.controller = MotionControlType::angle; +``` +Now we configure the velocity PI controller parameters +```cpp +// velocity PI controller parameters +// default P=0.5 I = 10 +motor.PID_velocity.P = 0.2; +motor.PID_velocity.I = 20; + +//default voltage_power_supply +motor.voltage_limit = 6; +``` +Additionally we can configure the Low pass filter time constant `Tf` +```cpp +// velocity low pass filtering +// default 5ms - try different values to see what is the best. +// the lower the less filtered +motor.LPF_velocity.Tf = 0.02; +``` +Finally we configure position P controller gain and the velocity limit variable. +```cpp +// angle P controller +// default P=20 +motor.P_angle.P = 20; +// maximal velocity of the position control +// default 20 +motor.velocity_limit = 4; +``` +
For more information about the angle control loop parameters please check the doc.
+ +Next we connect the encoder and the driver to the motor, do the hardware init and init of the Field Oriented Control. +```cpp +// link the motor to the sensor +motor.linkSensor(&encoder); +// link the motor to the driver +motor.linkDriver(&driver); + +// initialize motor +motor.init(); +// align encoder and start FOC +motor.initFOC(); +``` +The last peace of code important for the motor is of course the FOC routine in the `loop` function. +```cpp +void loop() { +// iterative FOC function +motor.loopFOC(); + +// iterative function setting and calculating the angle/position loop +// this function can be run at much lower frequency than loopFOC function +motor.move(); +} +``` +That is it, let's see the full code now! +
For more configuration parameters and control loops please check the BLDCMotor class doc.
+ +## Full Arduino code +To the full code I have added a small serial [commander interface](commander_interface), to be able to change position/angle target value in real time. + +```cpp +#include + +// init BLDC motor +BLDCMotor motor = BLDCMotor( 11 ); +// init driver +BLDCDriver3PWM driver = BLDCDriver3PWM(11, 10, 9, 8); +// init encoder +Encoder encoder = Encoder(2, 3, 2048); +// channel A and B callbacks +void doA(){encoder.handleA();} +void doB(){encoder.handleB();} + +// commander interface +Commander command = Commander(Serial); +void onTarget(char* cmd){ command.motion(&motor, cmd); } + +void setup() { + + pinMode(12,OUTPUT); // declares pin 12 as output and sets it to LOW + + // initialize encoder hardware + encoder.init(); + // hardware interrupt enable + encoder.enableInterrupts(doA, doB); + // link the motor to the sensor + motor.linkSensor(&encoder); + + // power supply voltage + // default 12V + driver.voltage_power_supply = 12; + driver.init(); + // link the motor to the driver + motor.linkDriver(&driver); + + // set control loop to be used + motor.controller = MotionControlType::angle; + + // controller configuration based on the control type + // velocity PI controller parameters + // default P=0.5 I = 10 + motor.PID_velocity.P = 0.2; + motor.PID_velocity.I = 20; + + //default voltage_power_supply + motor.voltage_limit = 6; + + // velocity low pass filtering + // default 5ms - try different values to see what is the best. + // the lower the less filtered + motor.LPF_velocity.Tf = 0.02; + + // angle P controller + // default P=20 + motor.P_angle.P = 20; + // maximal velocity of the position control + // default 20 + motor.velocity_limit = 4; + + // initialize motor + motor.init(); + // align encoder and start FOC + motor.initFOC(); + + // add target command T + command.add('T', doTarget, "motion control"); + + // monitoring port + Serial.begin(115200); + Serial.println("Motor ready."); + Serial.println("Set the target angle using serial terminal:"); + _delay(1000); +} + +void loop() { + // iterative FOC function + motor.loopFOC(); + + // function calculating the outer position loop and setting the target position + motor.move(); + + // commander interface with the user + commander.run(); + +} +``` diff --git a/docs/simplefoc_library/examples/position_control_example_mini_nucleo.md b/docs/simplefoc_library/examples/position_control_example_mini_nucleo.md new file mode 100644 index 0000000..8478628 --- /dev/null +++ b/docs/simplefoc_library/examples/position_control_example_mini_nucleo.md @@ -0,0 +1,246 @@ +--- +layout: default +title: SimpleFOCMini & Nucleo +parent: Example projects +description: "Arduino Simple Field Oriented Control (FOC) library ." +nav_order: 10 +permalink: /mini_example_nucleo +grand_parent: Arduino SimpleFOClibrary +--- + + +# Position control example
using SimpleFOCMini +For this BLDC motor position control example we are going to be using this hardware: + +[Stm32 Nucleo-64](https://www.mouser.fr/ProductDetail/STMicroelectronics/NUCLEO-F446RE?qs=%2Fha2pyFaduj0LE%252BzmDN2WNd7nDNNMR7%2Fr%2FThuKnpWrd0IvwHkOHrpg%3D%3D) | [Arduino SimpleFOCMini](simplefocmini) | [AMT 103 encoder](https://www.mouser.fr/ProductDetail/CUI-Devices/AMT103-V?qs=%2Fha2pyFaduiAsBlScvLoAWHUnKz39jAIpNPVt58AQ0PVb84dpbt53g%3D%3D) | [IPower GBM4108H-120T](https://www.ebay.com/itm/iPower-Gimbal-Brushless-Motor-GBM4108H-120T-for-5N-7N-GH2-ILDC-Aerial-photo-FPV/254541115855?hash=item3b43d531cf:g:q94AAOSwPcVVo571) +--- | --- | --- | --- + | | | + + +# Connecting everything together +

+ +For more information about the SimpleFOCMini check the [docs](simplefocmini). + +

+ +## Encoder +- Channels `A` and `B` are connected to the Arduino UNO pins `2` and `3`. + +## Motor +- Motor phases `a`, `b` and `c` are connected directly the motor terminal connector connectors `M1`, `M2` and `M3` of the SimpleFOCMini board + +## SimpleFOCMini +- The most convenient way of plugging the SimpleFOCMini board to the Nucleo board is to stack it on its pins `12-8`. + - `GND` - `GND` + - `IN1` - `13` + - `IN2` - `12` + - `IN3` - `11` + - `EN` - `10` + +# Arduino code +Let's go through the full code for this example and write it together. +First thing you need to do is include the `SimpleFOC` library: + +```cpp +#include +``` +Make sure you have the library installed. If you still don't have it please check the [get started page](installation) + + +## Encoder code +First we define the `Encoder` class with the A and B channel pins and number of impulses per revolution. +```cpp +// define Encoder +Encoder encoder = Encoder(2, 3, 2048); +``` +Then we define the buffering callback functions. +```cpp +// channel A and B callbacks +void doA(){encoder.handleA();} +void doB(){encoder.handleB();} +``` +In the `setup()` function we initialize the encoder and enable interrupts: +```cpp +// initialize encoder hardware +encoder.init(); +// hardware interrupt enable +encoder.enableInterrupts(doA, doB); +``` +And that is it, let's setup the motor. + +
For more configuration parameters of the encoders please check the Encoder class docs.
+ + +## Motor code +First we need to define the `BLDCMotor` class with the number od pole pairs (`11`) +```cpp +// define BLDC motor +BLDCMotor motor = BLDCMotor(11); +``` +
If you are not sure what your pole pairs number is please check the find_pole_pairs.ino example.
+ + +Next we need to define the `BLDCDriver3PWM` class with the PWM pin numbers of the motor and the driver enable pin +```cpp +// define BLDC driver +BLDCDriver3PWM driver = BLDCDriver3PWM(13, 12, 11, 10); +``` + +Then in the `setup()` we configure first the voltage of the power supply if it is not `12` Volts and init the driver. +```cpp +// power supply voltage +// default 12V +driver.voltage_power_supply = 12; +driver.init(); +``` + +Then we tell the motor which control loop to run by specifying the `motor.controller` variable. +```cpp +// set control loop type to be used +// MotionControlType::torque +// MotionControlType::velocity +// MotionControlType::angle +motor.controller = MotionControlType::angle; +``` +Now we configure the velocity PI controller parameters +```cpp +// velocity PI controller parameters +// default P=0.5 I = 10 +motor.PID_velocity.P = 0.2; +motor.PID_velocity.I = 20; + +//default voltage_power_supply +motor.voltage_limit = 6; +``` +Additionally we can configure the Low pass filter time constant `Tf` +```cpp +// velocity low pass filtering +// default 5ms - try different values to see what is the best. +// the lower the less filtered +motor.LPF_velocity.Tf = 0.02; +``` +Finally we configure position P controller gain and the velocity limit variable. +```cpp +// angle P controller +// default P=20 +motor.P_angle.P = 20; +// maximal velocity of the position control +// default 20 +motor.velocity_limit = 4; +``` +
For more information about the angle control loop parameters please check the doc.
+ +Next we connect the encoder and the driver to the motor, do the hardware init and init of the Field Oriented Control. +```cpp +// link the motor to the sensor +motor.linkSensor(&encoder); +// link the motor to the driver +motor.linkDriver(&driver); + +// initialize motor +motor.init(); +// align encoder and start FOC +motor.initFOC(); +``` +The last peace of code important for the motor is of course the FOC routine in the `loop` function. +```cpp +void loop() { +// iterative FOC function +motor.loopFOC(); + +// iterative function setting and calculating the angle/position loop +// this function can be run at much lower frequency than loopFOC function +motor.move(); +} +``` +That is it, let's see the full code now! +
For more configuration parameters and control loops please check the BLDCMotor class doc.
+ +## Full Arduino code +To the full code I have added a small serial [commander interface](commander_interface), to be able to change position/angle target value in real time. + +```cpp +#include + +// init BLDC motor +BLDCMotor motor = BLDCMotor( 11 ); +// init driver +BLDCDriver3PWM driver = BLDCDriver3PWM(13, 12, 11, 10); +// init encoder +Encoder encoder = Encoder(2, 3, 2048); +// channel A and B callbacks +void doA(){encoder.handleA();} +void doB(){encoder.handleB();} + +// commander interface +Commander command = Commander(Serial); +void onTarget(char* cmd){ command.motion(&motor, cmd); } + +void setup() { + + // initialize encoder hardware + encoder.init(); + // hardware interrupt enable + encoder.enableInterrupts(doA, doB); + // link the motor to the sensor + motor.linkSensor(&encoder); + + // power supply voltage + // default 12V + driver.voltage_power_supply = 12; + driver.init(); + // link the motor to the driver + motor.linkDriver(&driver); + + // set control loop to be used + motor.controller = MotionControlType::angle; + + // controller configuration based on the control type + // velocity PI controller parameters + // default P=0.5 I = 10 + motor.PID_velocity.P = 0.2; + motor.PID_velocity.I = 20; + + //default voltage_power_supply + motor.voltage_limit = 6; + + // velocity low pass filtering + // default 5ms - try different values to see what is the best. + // the lower the less filtered + motor.LPF_velocity.Tf = 0.02; + + // angle P controller + // default P=20 + motor.P_angle.P = 20; + // maximal velocity of the position control + // default 20 + motor.velocity_limit = 4; + + // initialize motor + motor.init(); + // align encoder and start FOC + motor.initFOC(); + + // add target command T + command.add('T', doTarget, "motion control"); + + // monitoring port + Serial.begin(115200); + Serial.println("Motor ready."); + Serial.println("Set the target angle using serial terminal:"); + _delay(1000); +} + +void loop() { + // iterative FOC function + motor.loopFOC(); + + // function calculating the outer position loop and setting the target position + motor.move(); + + // commander interface with the user + commander.run(); + +} +``` diff --git a/docs/simplefoc_library/examples/stepper_control_nucleo.md b/docs/simplefoc_library/examples/stepper_control_nucleo.md index 422e531..d6659cc 100644 --- a/docs/simplefoc_library/examples/stepper_control_nucleo.md +++ b/docs/simplefoc_library/examples/stepper_control_nucleo.md @@ -1,6 +1,6 @@ --- layout: default -title: Stepper Motor Control Nucleo-64 +title: Stepper Motor Control Nucleo parent: Example projects description: "Arduino Simple Field Oriented Control (FOC) library ." nav_order: 8 diff --git a/docs/simplefoc_library/hardware/mcus/index.md b/docs/simplefoc_library/hardware/mcus/index.md index 45b8446..c1ba65a 100644 --- a/docs/simplefoc_library/hardware/mcus/index.md +++ b/docs/simplefoc_library/hardware/mcus/index.md @@ -79,8 +79,9 @@ stm32 (in general) | βœ”οΈ | ❌ | ❌ stm32f1 family | βœ”οΈ | βœ”οΈ (one motor) | ❌ stm32f4 family | βœ”οΈ | βœ”οΈ (one motor) | ❌ stm32g4 family | βœ”οΈ | βœ”οΈ (one motor) | ❌ -stm32 B_G431B_ESC1 | βœ”οΈ | βœ”οΈ | ❌ -esp32 | βœ”οΈ | βœ”οΈ | ❌ +stm32 B_G431B_ESC1 | ❌ | βœ”οΈ (one motor) | ❌ +esp32/esp32s3 | βœ”οΈ | βœ”οΈ | ❌ +esp32s2/esp32c3 | βœ”οΈ | ❌ | ❌ esp8266 | ❌ | ❌ | ❌ samd21 | βœ”οΈ | βœ”οΈ (one motor) | ❌ samd51 | βœ”οΈ | ❌ | ❌ diff --git a/docs/simplefoc_library/index.md b/docs/simplefoc_library/index.md index 7048559..b856a24 100644 --- a/docs/simplefoc_library/index.md +++ b/docs/simplefoc_library/index.md @@ -14,6 +14,12 @@ has_toc: False ![Library Compile](https://github.com/simplefoc/Arduino-FOC/workflows/Library%20Compile/badge.svg) ![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg) ![arduino-library-badge](https://www.ardu-badge.com/badge/Simple%20FOC.svg?) +[![status](https://joss.theoj.org/papers/4382445f249e064e9f0a7f6c1bb06b1d/status.svg)](https://joss.theoj.org/papers/4382445f249e064e9f0a7f6c1bb06b1d) + +![GitHub release (latest by date)](https://img.shields.io/github/v/release/simplefoc/arduino-foc) +![GitHub Release Date](https://img.shields.io/github/release-date/simplefoc/arduino-foc?color=blue) +![GitHub commits since tagged version](https://img.shields.io/github/commits-since/simplefoc/arduino-foc/latest/dev) +![GitHub commit activity (branch)](https://img.shields.io/github/commit-activity/m/simplefoc/arduino-foc/dev) This Arduino library implements Field Oriented Control (FOC) algorithm for BLDC and Stepper motors. FOC algorithm produces incomparably smooth operation and high degree of torque, velocity and position control. The library is intended both for: diff --git a/extras/Images/connection_mini.jpg b/extras/Images/connection_mini.jpg new file mode 100644 index 0000000..e8ca7b0 Binary files /dev/null and b/extras/Images/connection_mini.jpg differ diff --git a/extras/Images/connection_mini_nucleo.jpg b/extras/Images/connection_mini_nucleo.jpg new file mode 100644 index 0000000..cfbe1e1 Binary files /dev/null and b/extras/Images/connection_mini_nucleo.jpg differ diff --git a/extras/Images/mini_connection_bluepill.png b/extras/Images/mini_connection_bluepill.png new file mode 100644 index 0000000..57e5fff Binary files /dev/null and b/extras/Images/mini_connection_bluepill.png differ diff --git a/extras/Images/mini_connection_mucleo.png b/extras/Images/mini_connection_mucleo.png new file mode 100644 index 0000000..7c236f8 Binary files /dev/null and b/extras/Images/mini_connection_mucleo.png differ diff --git a/extras/Images/mini_connection_uno.png b/extras/Images/mini_connection_uno.png new file mode 100644 index 0000000..cce11eb Binary files /dev/null and b/extras/Images/mini_connection_uno.png differ diff --git a/extras/Images/mini_connection_uno1.png b/extras/Images/mini_connection_uno1.png new file mode 100644 index 0000000..cd41e38 Binary files /dev/null and b/extras/Images/mini_connection_uno1.png differ diff --git a/extras/Images/mini_connection_uno2.png b/extras/Images/mini_connection_uno2.png new file mode 100644 index 0000000..478b858 Binary files /dev/null and b/extras/Images/mini_connection_uno2.png differ diff --git a/extras/Images/mini_fab (1).png b/extras/Images/mini_fab (1).png new file mode 100644 index 0000000..52407a5 Binary files /dev/null and b/extras/Images/mini_fab (1).png differ diff --git a/extras/Images/mini_fab (2).png b/extras/Images/mini_fab (2).png new file mode 100644 index 0000000..98b7076 Binary files /dev/null and b/extras/Images/mini_fab (2).png differ diff --git a/extras/Images/mini_fab (3).png b/extras/Images/mini_fab (3).png new file mode 100644 index 0000000..6a405cf Binary files /dev/null and b/extras/Images/mini_fab (3).png differ diff --git a/extras/Images/mini_fab (4).png b/extras/Images/mini_fab (4).png new file mode 100644 index 0000000..b1cec0a Binary files /dev/null and b/extras/Images/mini_fab (4).png differ diff --git a/extras/Images/mini_fab (5).png b/extras/Images/mini_fab (5).png new file mode 100644 index 0000000..bfb639c Binary files /dev/null and b/extras/Images/mini_fab (5).png differ diff --git a/extras/Images/mini_fab (6).png b/extras/Images/mini_fab (6).png new file mode 100644 index 0000000..efc0a6e Binary files /dev/null and b/extras/Images/mini_fab (6).png differ diff --git a/extras/Images/mini_fab (7).png b/extras/Images/mini_fab (7).png new file mode 100644 index 0000000..0204770 Binary files /dev/null and b/extras/Images/mini_fab (7).png differ diff --git a/extras/Images/mini_fab (8).png b/extras/Images/mini_fab (8).png new file mode 100644 index 0000000..e31074a Binary files /dev/null and b/extras/Images/mini_fab (8).png differ diff --git a/extras/Images/mini_fab (9).png b/extras/Images/mini_fab (9).png new file mode 100644 index 0000000..8787e38 Binary files /dev/null and b/extras/Images/mini_fab (9).png differ diff --git a/extras/Images/mini_gif1.gif b/extras/Images/mini_gif1.gif new file mode 100644 index 0000000..0b42691 Binary files /dev/null and b/extras/Images/mini_gif1.gif differ diff --git a/extras/Images/mini_req_opt.png b/extras/Images/mini_req_opt.png new file mode 100644 index 0000000..9027572 Binary files /dev/null and b/extras/Images/mini_req_opt.png differ diff --git a/extras/Images/mini_where.png b/extras/Images/mini_where.png new file mode 100644 index 0000000..d69d6c3 Binary files /dev/null and b/extras/Images/mini_where.png differ diff --git a/extras/gm4108_encoder_mount.zip b/extras/gm4108_encoder_mount.zip new file mode 100644 index 0000000..8977b5f Binary files /dev/null and b/extras/gm4108_encoder_mount.zip differ diff --git a/index.md b/index.md index af29885..3c732f7 100644 --- a/index.md +++ b/index.md @@ -12,6 +12,11 @@ permalink: / ![arduino-library-badge](https://www.ardu-badge.com/badge/Simple%20FOC.svg?) [![status](https://joss.theoj.org/papers/4382445f249e064e9f0a7f6c1bb06b1d/status.svg)](https://joss.theoj.org/papers/4382445f249e064e9f0a7f6c1bb06b1d) +![GitHub release (latest by date)](https://img.shields.io/github/v/release/simplefoc/arduino-foc) +![GitHub Release Date](https://img.shields.io/github/release-date/simplefoc/arduino-foc?color=blue) +![GitHub commits since tagged version](https://img.shields.io/github/commits-since/simplefoc/arduino-foc/latest/dev) +![GitHub commit activity (branch)](https://img.shields.io/github/commit-activity/m/simplefoc/arduino-foc/dev) + We live in very exciting times πŸ˜ƒ! BLDC motors are entering the hobby community more and more and many great projects have already emerged leveraging their far superior dynamics and power capabilities. BLDC motors have numerous advantages over regular DC motors but they have one big disadvantage, the complexity of control. Even though it has become relatively easy to design and manufacture PCBs and create our own hardware solutions for driving BLDC motors the proper low-cost solutions are yet to come. One of the reasons for this is the apparent complexity of writing the BLDC driving algorithms, Field oriented control (FOC) being an example of one of the most efficient ones. The solutions that can be found on-line are almost exclusively very specific for certain hardware configuration and the microcontroller architecture used. Additionally, most of the efforts at this moment are still channeled towards the high-power applications of the BLDC motors and proper low-cost and low-power FOC supporting boards are very hard to find today and even may not exist.
@@ -19,52 +24,51 @@ Therefore this is an attempt to: - 🎯 Demystify FOC algorithm and make a robust but simple Arduino library: [Arduino SimpleFOClibrary ](#arduino-simplefoclibrary-v160) - Support as many motor + sensor + current sense + driver + mcu combinations out there - 🎯 Develop a modular FOC supporting BLDC driver boards: - - ***NEW*** πŸ“’: *Minimalistic* BLDC driver (<3Amps) : [SimpleFOCMini ](https://github.com/simplefoc/SimpleFOCMini). + - ***NEW*** πŸ“’: *Minimalistic* BLDC driver (<3Amps) : [SimpleFOCMini ](simplefocmini). - *Low-power* gimbal driver (<5Amps) : [Arduino SimpleFOCShield ](arduino_simplefoc_shield_showcase). - *Medium-power* BLDC driver (<30Amps): [Arduino SimpleFOCPowerShield ](https://github.com/simplefoc/Arduino-SimpleFOC-PowerShield). - See also [@byDagor](https://github.com/byDagor)'s *fully-integrated* ESP32 based board: [Dagor Brushless Controller](https://github.com/byDagor/Dagor-Brushless-Controller) -
-

NEW RELEASE πŸ“’: SimpleFOClibrary v2.2.2 see release

-
    -
  • GenericCurrentSense bugfix and testing
  • -
  • bugfix leonardo #170
  • -
  • bugfix - no index search after specifying natural direction
  • -
  • Low level API restructuring -
      -
    • Driver API
    • -
    • Current sense API
    • -
    -
  • -
  • New debugging interface - see in docs -
      -
    • Static class SimpleFOCDebug
    • -
    -
  • -
  • CurrentSense API change - added method linkDriver() - see in docs
  • -
  • Low-side current sensing - see in docs -
      -
    • ESP32 generic support for multiple motors
    • -
    • Added low-side current sensing support for stm32 - only one motor -
        -
      • f1 family
      • -
      • f4 family
      • -
      • g4 family
      • -
      -
    • -
    -
  • -
  • New appraoch for current estimation for torque control using voltage - see in docs -
      -
    • Support for motor KV rating - back emf estimation
    • -
    • Using motor phase resistance
    • -
    -
  • -
  • KV rating and phase resistance used for open-loop current limiting as well - see in docs
  • -
+ +
+

NEWS πŸ“’: SimpleFOClibrary has been published in the Journal of Open Source Software read more

+ +SimpleFOC: A Field Oriented Control (FOC) Library for Controlling Brushless Direct Current (BLDC) and Stepper Motors.
+A. Skuric, HS. Bank, R. Unger, O. Williams, D. GonzΓ‘lez-Reyes
+Journal of Open Source Software, 7(74), 4232
+
+ +
+

NEW RELEASE πŸ“’: SimpleFOClibrary v2.2.3 see release

+- stm32 low-side current sensing + - g4 supported + - thoroughly tested f1/f4/g4 - [#187](https://github.com/simplefoc/Arduino-FOC/issues/187) + - bg431b: added support for VBAT and TEMPERATURE readings [#222](https://github.com/simplefoc/Arduino-FOC/pull/222) +- bugfixing + - leonardo + - mega2560 [#190](https://github.com/simplefoc/Arduino-FOC/issues/190) + - inline current sense without driver [#188](https://github.com/simplefoc/Arduino-FOC/issues/188) + - bg431b support current sense fix [#210](https://github.com/simplefoc/Arduino-FOC/pull/210) + - `StepperDriver4PWM` wrong init [#182](https://github.com/simplefoc/Arduino-FOC/issues/182) + - open loop back-emf voltage issue [#219](https://github.com/simplefoc/Arduino-FOC/issues/219) + - SAMD51 compile issue [#217](https://github.com/simplefoc/Arduino-FOC/issues/217) + - ESP32-S3 compile issue [#198](https://github.com/simplefoc/Arduino-FOC/issues/198) + - ESP32 compile issue [#208](https://github.com/simplefoc/Arduino-FOC/issues/208), [#207](https://github.com/simplefoc/Arduino-FOC/issues/207) + - magnetic sensor direction finding more robust [#173](https://github.com/simplefoc/Arduino-FOC/issues/173), [#164](https://github.com/simplefoc/Arduino-FOC/pull/164) + - `StepDirListener` improved timing [#169](https://github.com/simplefoc/Arduino-FOC/issues/169), [#209](https://github.com/simplefoc/Arduino-FOC/pull/209) + - `HallSensor` velocity calculation fix [#192](https://github.com/simplefoc/Arduino-FOC/issues/192) +- API changes + - `setPhaseVoltage` is now public function + - `getVelocity` can now be called as many times as necessary - [see in docs](encoder#standalone-sensor) + - it recalculates the velocity if the time between calls is longer then `min_elapsed_time` - default 0.1ms + - `HallSensor` velocity calculation outlier removal using max expected velocity `velocity_max` - [see in docs](hall_sensors#step-21-velocity-outlier-removal) + - BG431 board can be used only with `LowsideCurrentSense` class! - [see in docs](current_sense#current-sensing-support-per-mcu-architecture) + - `initFOC` fails if current sense not initialised - [see in docs](bldcdriver3pwm#step-23-initialisation) + - driver and current sense have to be well initialised for `initFOC` to start - [see in docs](bldcmotor#step-6-align-motor-and-all-the-sensors---field-oriented-control-init) + - `cs.init()` and `driver.init()` return `1` if well initialised and `0` if failed
-## Arduino SimpleFOClibrary v2.2.2 +## Arduino SimpleFOClibrary v2.2.3 This video demonstrates the Simple FOC library basic usage, electronic connections and shows its capabilities.