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
Copy file name to clipboardExpand all lines: README.md
+40-12Lines changed: 40 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,7 +61,7 @@ The code is simple enough to be ran on Arudino Uno board.
61
61
#### Encoder
62
62
- Encoder channels `A` and `B` are connected to the Arduino's external intrrupt pins `2` and `3`.
63
63
- Optionally if your encoder has `index` signal you can connect it to any available pin, figure shows pin `4`.
64
-
- The librtary doesnt support the Index pin for now (version v1.1.0)
64
+
- The library doesnt support the Index pin for now (version v1.1.0)
65
65
#### L6234 breakout board
66
66
- Connected to the arduino pins `9`,`10` and `11`.
67
67
- Additionally you can connect the `enable` pin to the any digital pin of the arduino the picture shows pin `8` but this is optional. You can connect the driver enable directly to 5v.
@@ -85,8 +85,8 @@ To use HMBGC controller for vector control (FOC) you need to connect motor to on
85
85
Since HMBGC doesn't have acces to the arduinos external interrupt pins `2` and `3` and additionally we only have acces to the analog pins, we need to read the encoder using the software interrupt. To show the functionallity we provide one example of the HMBGC code (`HMBGC_example.ino`) using the [PciManager library](https://github.com/prampec/arduino-pcimanager).
86
86
87
87
- Encoder channels `A` and `B` are connected to the pins `A0` and `A1`.
88
-
- Optionally if your encoder has `index` signal you can connect it to any available pin, figure shows pin `A3`.
89
-
- The librtary doesnt support the Index pin for now (version v1.1.0)
88
+
- Optionally if your encoder has `index` signal you can connect it to any available pin, figure shows pin `A2`.
89
+
- The library doesnt support the Index pin for now (version v1.1.0)
90
90
#### Motor
91
91
- Motor phases `a`,`b` and `c` are connected directly to the driver outputs
92
92
@@ -96,19 +96,47 @@ Motor phases `a`,`b`,`c` and encoder channels `A` and `B` have to be oriented ri
96
96
97
97
98
98
## The code
99
-
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
99
+
The code is organised into a librarie. The library contains two classes `BLDCmotor` and `Endcoder`. `BLDCmotor` contains all the necessary FOC algorithm funcitons as well as PI controllers for the velocity and angle control. `Encoder`deals with the encoder interupt funcitons, calcualtes motor angle and velocity( using the [Mixed Time Frequency Method](https://github.com/askuric/Arduino-Mixed-Time-Frequency-Method)).
100
100
101
101
### Initialization
102
-
The heart of the init is the constructor call:
102
+
#### Motor initialisaiton:
103
+
To intialise the motor you need to input the `pwm` pins, number of `pole pairs` and optionally driver `enable` pin.
103
104
```cpp
104
-
BLDCMotor motor = BLDCMotor(9,10,11,&counter[ENCODER_1],A0,A1,11,2400);
105
-
//BLDCMotorint(phA, phB, phC, long* counter, int encA, int encB , int pp, int cpr)
105
+
// BLDCMotor( int phA, int phB, int phC, int pp, int en)
106
+
// - phA, phB, phC - motor A,B,C phase pwm pins
107
+
// - pp - pole pair number
108
+
// - enable pin - (optional input)
109
+
BLDCMotor motor = BLDCMotor(9, 10, 11, 11, 8);
110
+
```
111
+
#### Encoder intiialisation
112
+
To initialise the encoder you need to provide the encoder `A` and `B` channel pins, encoder `CPR` and optionally `index` pin.
113
+
114
+
```cpp
115
+
// Encoder(int encA, int encB , int cpr, int index)
0 commit comments