All Projects → simplefoc → Arduino Foc

simplefoc / Arduino Foc

Licence: mit
Arduino FOC for BLDC and Stepper motors - Arduino Based Field Oriented Control Algorithm Library

Projects that are alternatives of or similar to Arduino Foc

Irremoteesp8266
Infrared remote library for ESP8266/ESP32: send and receive infrared signals with multiple protocols. Based on: https://github.com/shirriff/Arduino-IRremote/
Stars: ✭ 1,964 (+407.49%)
Mutual labels:  arduino, arduino-library, encoder
KY-040-Encoder-Library---Arduino
Arduino library for the KY-040 Encoder
Stars: ✭ 37 (-90.44%)
Mutual labels:  encoder, arduino-library
Espui
A simple web user interface library for ESP32 and ESP8266
Stars: ✭ 330 (-14.73%)
Mutual labels:  arduino, arduino-library
Jc button
Arduino library to debounce button switches, detect presses, releases, and long presses
Stars: ✭ 289 (-25.32%)
Mutual labels:  arduino, arduino-library
Linkedlist
🔗 A fully implemented LinkedList made to work with general Microcontrollers and Arduino projects
Stars: ✭ 241 (-37.73%)
Mutual labels:  arduino, arduino-library
RotaryEncoder
This is small and fast Arduino library for Rotary Encoder with interrupts.
Stars: ✭ 60 (-84.5%)
Mutual labels:  encoder, arduino-library
Rf24network
OSI Layer 3 Networking for nRF24L01(+) Radios on Arduino and Raspberry Pi
Stars: ✭ 278 (-28.17%)
Mutual labels:  arduino, arduino-library
Lpd8806
Arduino library for LED strips and pixels using LPD8806 (and probably LPD8803/LPD8809)
Stars: ✭ 207 (-46.51%)
Mutual labels:  arduino, arduino-library
Adafruit Pwm Servo Driver Library
Adafruit PWM Servo Driver Library
Stars: ✭ 300 (-22.48%)
Mutual labels:  arduino, arduino-library
Qrcode
QR code generation library in C, optimized for low-power devices, such as Arduino.
Stars: ✭ 351 (-9.3%)
Mutual labels:  arduino, arduino-library
Ssd1306
Driver for SSD1306, SSD1331, SSD1351, IL9163, ILI9341, ST7735, PCD8544, Nokia 5110 displays running on Arduino/ESP32/Linux (Rasperry) platforms
Stars: ✭ 303 (-21.71%)
Mutual labels:  arduino, arduino-library
Helios
The free embedded operating system.
Stars: ✭ 223 (-42.38%)
Mutual labels:  arduino, arduino-library
Arduino Tvout
Arduino-TVout
Stars: ✭ 216 (-44.19%)
Mutual labels:  arduino, arduino-library
Rf24mesh
OSI Layer 7 Mesh Networking for RF24Network & nrf24L01+ devices
Stars: ✭ 329 (-14.99%)
Mutual labels:  arduino, arduino-library
Arduinowebsockets
A library for writing modern websockets applications with Arduino (ESP8266 and ESP32)
Stars: ✭ 213 (-44.96%)
Mutual labels:  arduino, arduino-library
Md parola
Library for modular scrolling LED matrix text displays
Stars: ✭ 282 (-27.13%)
Mutual labels:  arduino, arduino-library
Heatpump
Arduino library to control Mitsubishi Heat Pumps via connector cn105
Stars: ✭ 327 (-15.5%)
Mutual labels:  arduino, arduino-library
Dsckeybusinterface
An Arduino/esp8266/esp32 library to directly interface with DSC security systems.
Stars: ✭ 202 (-47.8%)
Mutual labels:  arduino, arduino-library
Timezone
Arduino library to facilitate time zone conversions and automatic daylight saving (summer) time adjustments.
Stars: ✭ 205 (-47.03%)
Mutual labels:  arduino, arduino-library
Xbee Arduino
Arduino library for communicating with XBee radios in API mode
Stars: ✭ 294 (-24.03%)
Mutual labels:  arduino, arduino-library

Arduino Simple Field Oriented Control (FOC) library

Library Compile License: MIT arduino-library-badge

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.
Therefore this is an attempt to:

NEW RELEASE 📢: SimpleFOClibrary v2.1
  • Initial current sensing support🎉
    • Inline current sensors
    • adaptive zero finding and shunt direction
  • Implemented real torque control
    • using voltage
    • using current magnitude (one current)
    • using FOC currents ( d-q currents ) - real foc control
  • SVPWM full implementation d+q axis
  • Simplified sensor implementation📢
    • For new sensor implementation only one function necessary getAngle()
  • Upgrade of the HallSensor implementation by @owennewo
  • Support for Arduino DUE - everything except the 6PWM mode
  • Support for ATMega328pb
  • bugfix for the Teensy boards ( setting 3pwm )
  • extended support for 2PWM stepper drivers - by @zjor
  • included F macro for shrinking string memory usage - moved to programming memory
  • disable phase support for 3pwm driver
    • not yet for 6pwm
  • rewritten initFOC()
    • can be skipped and outputs much more info
    • align sensor: direction + zero offset + pole pair check
    • align current sense
  • sensor offset supported (motor.sensor_offset)
  • refactored motor commands interface
    • much more flexible and easy to extend
    • very easy to add new commands and function callbacks
    • implemented motor+pid+lpf commands of-the-shelf
  • Added step/dir interface
    • integrated as an optional communication channel

BEWARE 📢 slight API changes included

  • ControlType renamed into MotionControlType
  • ControlType::voltage does not exist any more now - MotionControlType::torque

Arduino SimpleFOCShield v2.0.3

Features

  • Plug & play: In combination with Arduino SimpleFOClibrary - github
  • Low-cost: Price of €15 - Check the pricing
  • In-line current sensing: Up to 3Amps/5Amps bidirectional
    • configurable: 3.3Amps - 3.3V adc, 5Amps - 5V adc
  • Integrated 8V regulator:
    • Enable/disable by soldering pads
  • Max power 120W - max current 5A, power-supply 12-24V
    • Designed for Gimbal motors with the internal resistance >10 Ωs.
  • 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 available fabrication files - how to make it yourself

Arduino SimpleFOClibrary v2.1

This video demonstrates the SimpleFOClibrary basic usage, electronic connections and shows its capabilities.

Features

  • Arduino compatible:
    • Arduino library code
    • Arduino Library Manager integration
  • Open-Source: Full code and documentation available on github
  • Easy to setup and configure:
  • Modular:
  • Plug & play: Arduino SimpleFOCShield

Getting Started

Depending on if you want to use this library as the plug and play Arduino library or you want to get insight in the algorithm and make changes there are two ways to install this code.

  • Full library installation Docs
  • Minimal project builder Docs

Arduino SimpleFOClibrary installation to Arduino IDE

Arduino Library Manager

The simplest way to get hold of the library is directly by using Arduino IDE and its integrated Library Manager.

  • Open Arduino IDE and start Arduino Library Manager by clicking: Tools > Manage Libraries....
  • Search for Simple FOC library and install the latest version.
  • Reopen Arduino IDE and you should have the library examples in File > Examples > Simple FOC.

Using Github website

  • Go to the github repository
  • Click first on Clone or Download > Download ZIP.
  • Unzip it and place it in Arduino Libraries folder. Windows: Documents > Arduino > libraries.
  • Reopen Arduino IDE and you should have the library examples in File > Examples > Simple FOC.

Using terminal

  • Open terminal and run
cd #Arduino libraries folder
git clone https://github.com/simplefoc/Arduino-FOC.git
  • Reopen Arduino IDE and you should have the library examples in File > Examples > Simple FOC.

SimpleFOClibrary minimal project builder

For those willing to experiment and to modify the code I suggest using the minimal project builder minimal branch.

This code is completely independent and you can run it as any other Arduino Sketch without the need for any libraries.

All you need to do is:

  • Go to minimal branch
  • Follow the tutorial in the README file and choose only the library files that are necessary for your application.

Arduino code example

This is a simple Arduino code example implementing the velocity control program of a BLDC motor with encoder.

NOTE: This program uses all the default control parameters.

#include <SimpleFOC.h>

//  BLDCMotor( pole_pairs )
BLDCMotor motor = BLDCMotor(11);
//  BLDCDriver( pin_pwmA, pin_pwmB, pin_pwmC, enable (optional) )
BLDCDriver3PWM driver = BLDCDriver3PWM(9, 10, 11, 8);
//  Encoder(pin_A, pin_B, CPR)
Encoder encoder = Encoder(2, 3, 2048);
// channel A and B callbacks
void doA(){encoder.handleA();}
void doB(){encoder.handleB();}


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 [V]
  driver.voltage_power_supply = 12;
  // initialise driver hardware
  driver.init();
  // link driver
  motor.linkDriver(&driver);

  // set control loop type to be used
  motor.controller = MotionControlType::velocity;
  // initialize motor
  motor.init();
  
  // align encoder and start FOC
  motor.initFOC();
}

void loop() {
  // FOC algorithm function
  motor.loopFOC();

  // velocity control loop function
  // setting the target velocity or 2rad/s
  motor.move(2);
}

You can find more details in the SimpleFOC documentation.

Example projects

Here are some of the SimpleFOClibrary and SimpleFOCShield application examples.

Documentation

Find out more information about the Arduino SimpleFOC project in docs website

Arduino FOC repo structure

Branch Description Status
master Stable and tested library version Library Compile
dev Development library version Library Dev Compile
minimal Minimal Arduino example with integrated library MinimalBuild
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].