Skip to content

Commit 67839d2

Browse files
committed
refactoring
1 parent 1f478a6 commit 67839d2

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

MotorFOCExample/BLDCmotor.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
#include "Arduino.h"
66

7-
#define _2_SQRT3 1.15470053838
8-
#define _1_SQRT3 0.57735026919
9-
#define _120_D2R 2.09439510239
107

118
// Power supply woltage
129
#define U_MAX 12
@@ -28,6 +25,10 @@
2825

2926
// sign funciton
3027
#define sign(a) ( ( (a) < 0 ) ? -1 : ( (a) > 0 ) )
28+
// utility defines
29+
#define _2_SQRT3 1.15470053838
30+
#define _1_SQRT3 0.57735026919
31+
#define _120_D2R 2.09439510239
3132

3233

3334
// encoder measurement structure

MotorFOCExample/MotorFOCExample.ino

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#include "BLDCMotor.h"
2-
1+
#include "BLDCmotor.h"
32

43
// Encoder variables
54
#define CPR 600 // counts per revolution
@@ -9,7 +8,6 @@
98
#define encoderPinA 2 // Arduino UNO interrupt 0
109
#define encoderPinB 3 // Arduino UNO interrupt 1
1110

12-
1311
/*
1412
BLDCMotorEncoder( int phA, int phB, int phC, int pp, int encA, int encB , int cpr, int en)
1513
- phA, phB, phC - motor A,B,C phase pwm pins
@@ -20,6 +18,11 @@ BLDCMotorEncoder( int phA, int phB, int phC, int pp, int encA, int encB , int cp
2018
*/
2119
BLDCMotorEncoder motor = BLDCMotorEncoder(9, 10, 11, 11, encoderPinA,encoderPinB, PPR, 8);
2220

21+
// Encoder interrupt callback functions
22+
void doEncoderA() {motor.handleEncoderA();}
23+
// B channel
24+
void doEncoderB() {motor.handleEncoderB();}
25+
2326
void setup() {
2427
// debugging port
2528
Serial.begin(115200);
@@ -75,12 +78,4 @@ void setPwmFrequency(int pin) {
7578
}
7679

7780

78-
// Encoder interrupt callback functions
79-
void doEncoderA() {
80-
motor.handleEncoderA();
81-
}
82-
// B channel
83-
void doEncoderB() {
84-
motor.handleEncoderB();
85-
}
8681

0 commit comments

Comments
 (0)