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.
- Both of them cost more than 100$.
- Both of them are oriented to high current operations.
- Low cost applications <50$
- Low current operation < 5A
- Simple usage and scalability (Arduino) and demistify FOC control in a simple way.
- Brushless motor - 3 pahse (IPower GBM4198H-120T Ebay)
- Encoder - ( Incremental 2400cpr Ebay)
- HMBGC V2.2 Ebay
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
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
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()
.
There are three cascade control loops implemented in the library:
Using the fucntion
motor.setPhaseVoltage(float Uq)
you can run BLDC motor as it is DC motor using Park transformation.
Using the fucntion
motor.setVelocity(float v)
you can run BLDC motor in closed loop with desired velocity.
Using the fucntion
motor.setPosition(float pos)
you can run BLDC motor in closed loop with desired position.