You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
38
+
39
+
## The code
40
+
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
41
+
42
+
### Initialization
43
+
The heart of the init is the constructor call:
44
+
```cpp
45
+
BLDCMotor motor = BLDCMotor(9,10,11,&counter[ENCODER_1],A0,A1,11,2400);
46
+
//BLDCMotorint(phA, phB, phC, long* counter, int encA, int encB , int pp, int cpr)
47
+
```
48
+
The first three arguments are pin numbers of them motor phases, either 9,10,11 or 6,5,3
49
+
Fourth argument is a pointer to the encoder counter
50
+
Fith and sixt argument are encoder pins channel A and channel B
51
+
Seventh argument is number of Pole pairs of the motor
52
+
And Eight argument is the cpr of the encoder
53
+
54
+
### Usage in loop
55
+
56
+
I have not made an implementation using timer intrupts just yet, but it is one of the future steps.
57
+
At the motment the function control loop function has to be iteratively called in the `loop()`.
58
+
59
+
## Control loops
60
+
There are three cascade control loops implemented in the library:
61
+
### Open loop voltage Uq
62
+
Using the fucntion
63
+
```cpp
64
+
motor.setPhaseVoltage(float Uq)
65
+
```
66
+
you can run BLDC motor as it is DC motor using Park transformation.
67
+
<imgsrc="./Images/voltage.png">
68
+
### Closed loop velocity control
69
+
Using the fucntion
70
+
```cpp
71
+
motor.setVelocity(float v)
72
+
```
73
+
you can run BLDC motor in closed loop with desired velocity.
74
+
<imgsrc="./Images/velocity.png" >
75
+
### Closed loop velocity control
76
+
Using the fucntion
77
+
```cpp
78
+
motor.setPosition(float pos)
79
+
```
80
+
you can run BLDC motor in closed loop with desired position.
0 commit comments