From a12432df36fda4daf4ca0be590ef3f9bd57df22e Mon Sep 17 00:00:00 2001 From: Nicolas Trimborn Date: Sun, 8 Aug 2021 12:04:57 +0200 Subject: [PATCH] fixed commutation pattern --- .../Motor_Master/Motor_Master/bldc.c | 8 +-- .../Motor_Master/motorparameters.h | 59 ++++++++++++------- 2 files changed, 42 insertions(+), 25 deletions(-) diff --git a/2_Motor_Master/Motor_Master/Motor_Master/bldc.c b/2_Motor_Master/Motor_Master/Motor_Master/bldc.c index d77d15b..b029f46 100644 --- a/2_Motor_Master/Motor_Master/Motor_Master/bldc.c +++ b/2_Motor_Master/Motor_Master/Motor_Master/bldc.c @@ -335,9 +335,9 @@ uint8_t readHallSensorM1(void) volatile uint8_t b = gpio_get_pin_level(M1_HALL_B_PIN); volatile uint8_t c = gpio_get_pin_level(M1_HALL_C_PIN); - return ((c << 2) | + return ((a << 2) | (b << 1) | - (a << 0)); + (c << 0)); } @@ -347,7 +347,7 @@ uint8_t readHallSensorM2(void) volatile uint8_t b = gpio_get_pin_level(M2_HALL_B_PIN); volatile uint8_t c = gpio_get_pin_level(M2_HALL_C_PIN); - return ((c << 2) | + return ((a << 2) | (b << 1) | - (a << 0)); + (c << 0)); } \ No newline at end of file diff --git a/2_Motor_Master/Motor_Master/Motor_Master/motorparameters.h b/2_Motor_Master/Motor_Master/Motor_Master/motorparameters.h index c2bbc8f..369d212 100644 --- a/2_Motor_Master/Motor_Master/Motor_Master/motorparameters.h +++ b/2_Motor_Master/Motor_Master/Motor_Master/motorparameters.h @@ -72,24 +72,24 @@ */ /* CCW from Back - works best in forward diraction*/ -static const uint16_t COMMUTATION_PATTERN[] = { - 0x003F, // (0) invalid state - 0x053D, // (1) - 0x1437, // (2) - 0x113D, // (3) - 0x111F, // (4) - 0x141F, // (5) - 0x0537, // (6) - 0x003F, // (7) invalid state - 0x003F, // (8) invalid state - 0x0537, // (9) - 0x141F, // (10) - 0x111F, // (11) - 0x113D, // (12) - 0x1437, // (13) - 0x053D, // (14) - 0x003F // (15) invalid state -}; +//static const uint16_t COMMUTATION_PATTERN[] = { + //0x003F, // (0) invalid state + //0x053D, // (1) + //0x1437, // (2) + //0x113D, // (3) + //0x111F, // (4) + //0x141F, // (5) + //0x0537, // (6) + //0x003F, // (7) invalid state + //0x003F, // (8) invalid state + //0x0537, // (9) + //0x141F, // (10) + //0x111F, // (11) + //0x113D, // (12) + //0x1437, // (13) + //0x053D, // (14) + //0x003F // (15) invalid state +//}; ////* CW From Back */ //static const uint16_t COMMUTATION_PATTERN[16] = { @@ -131,6 +131,26 @@ static const uint16_t COMMUTATION_PATTERN[] = { //0x003F // (15) invalid state //}; +////* A&C phase swapped */ +static const uint16_t COMMUTATION_PATTERN[16] = { + 0x003F, // (0) invalid state + 0x1437, // (1) + 0x053D, // (2) + 0x113D, // (3) + 0x111F, // (4) + 0x0537, // (5) + 0x141F, // (6) + 0x003F, // (7) invalid state + 0x003F, // (8) invalid state + 0x141F, // (9) + 0x0537, // (10) + 0x111F, // (11) + 0x113D, // (12) + 0x053D, // (13) + 0x1437, // (14) + 0x003F // (15) invalid state +}; + typedef struct { @@ -156,7 +176,6 @@ typedef struct const float32_t motor_MeasureRange_RPM; // give 20% headroom const float32_t motor_Max_Spd_ELEC; const float32_t motor_Max_Current_IDC_A; - const Hall_pins_t hallPins; } BLDCMotor_param_t; //static BLDCMotor_param_t FH_22mm24BXTR; @@ -176,8 +195,6 @@ const static BLDCMotor_param_t FH_22mm24BXTR = { .motor_MeasureRange_RPM = 3000 * 1.2, //(1.2f * MOTOR_MAX_SPD_RPM)f // give 20% headroom .motor_Max_Spd_ELEC = (3000/60)*7.0, //(MOTOR_MAX_SPD_RPM/60)*MOTOR_POLEPAIRS .motor_Max_Current_IDC_A = 0.368, - .hallPins = {M1_HALL_A_PIN, M1_HALL_B_PIN, M1_HALL_C_PIN} - }; /* Big Motor - 3216W024BXTR */