Skip to content

Arduino Based Field Oriented Control Algorithm and Example

Notifications You must be signed in to change notification settings

whstudio123/Arduino-FOC

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Arduino based Field Oriented Control (FOC) for gimbal motors

This project is based on widely used in Hobby world brushless gimbal controller HMBGC V2.2.

Proper low cost FOC supporting board is very hard to find these days even may not exist. The reason may be that the hobby community has not yet dug into it properly.

The closest you can get to FOC support and low cost (I was able to find) is:

There are two main probelms with these kinds of borads:

  • Both of them cost more than 100$.
  • Both of them are oriented to high current operations.

This porject aims to close the gap in the areas:

  • Low cost applications <50$
  • Low current operation < 5A
  • Simple usage and scalability (Arduino) and demistify FOC control in a simple way.

All you need for this project is (an exaple in brackets):

  • Brushless motor - 3 pahse (IPower GBM4198H-120T Ebay)
  • Encoder - ( Incremental 2400cpr Ebay)
  • HMBGC V2.2 Ebay

Using the library

Conneciton of encoder and motor

To use HMBGC controller for vector control (FOC) you need to connect motor to one of the motor terminals and connect the Encoder. The shema of connection is shown on the figures above, I also took a (very bad) picture of my setup.

The code

The code is organised in two libraries, BLDCmotor.h and endcoder.h. BLDCmotor.h contains all the necessary FOC funciton implemented and encoder.h deals with the encoder. I will make this better in future. :D

Initialization

The heart of the init is the constructor call:

BLDCMotor motor = BLDCMotor(9,10,11,&counter[ENCODER_1],A0,A1,11,2400);
//BLDCMotorint(phA, phB, phC, long* counter, int encA, int encB , int pp, int cpr)

The first three arguments are pin numbers of them motor phases, either 9,10,11 or 6,5,3 Fourth argument is a pointer to the encoder counter Fith and sixt argument are encoder pins channel A and channel B Seventh argument is number of Pole pairs of the motor And Eight argument is the cpr of the encoder

Usage in loop

I have not made an implementation using timer intrupts just yet, but it is one of the future steps. At the motment the function control loop function has to be iteratively called in the loop().

Control loops

There are three cascade control loops implemented in the library:

Open loop voltage Uq

Using the fucntion

motor.setPhaseVoltage(float Uq)

you can run BLDC motor as it is DC motor using Park transformation.

Closed loop velocity control

Using the fucntion

motor.setVelocity(float v)

you can run BLDC motor in closed loop with desired velocity.

Closed loop position control

Using the fucntion

motor.setPosition(float pos)

you can run BLDC motor in closed loop with desired position.

About

Arduino Based Field Oriented Control Algorithm and Example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 97.8%
  • C 2.2%