Skip to content

Commit

Permalink
WIP - Motor optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
mspider65 committed Feb 7, 2021
1 parent 9b8447f commit 013591d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
29 changes: 17 additions & 12 deletions main/tsdz_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ struct_tsdz_cfg tsdz_cfg = {
.ui8_walk_assist_level = {20,30,40,48},
.ui8_torque_offset_fix = 0,
.ui16_torque_offset_value = 0,
.ui8_hall_ref_angles = {223, 10, 53, 95, 138, 181},
.ui8_hall_counter_offset_up = 28,
.ui8_hall_counter_offset_down = 8
.ui8_hall_ref_angles = {217, 4, 47, 89, 132, 175},
.ui8_hall_offset_up = 43,
.ui8_hall_offset_down = 23
};

uint8_t stm8_fw_version = -1;
Expand Down Expand Up @@ -600,11 +600,8 @@ void getControllerMessage(uint8_t lcd_os_message[]) {
break;

case 1:
// Phase angle adjust
if (lcd_os_message[2] == MOTOR_CALIBRATION_MODE)
lcd_os_message[5] = ui8_app_rotor_angle_adj;
else
lcd_os_message[5] = tsdz_cfg.ui8_phase_angle_adj;
// Free for future use
lcd_os_message[5] = 0;

// wheel perimeter
lcd_os_message[6] = (uint8_t) (tsdz_cfg.ui16_wheel_perimeter & 0xff);
Expand Down Expand Up @@ -664,14 +661,22 @@ void getControllerMessage(uint8_t lcd_os_message[]) {
}
break;
case 4:
if (tsdz_cfg.ui8_hall_counter_offset_up || tsdz_cfg.ui8_hall_counter_offset_down) {
lcd_os_message[5] = tsdz_cfg.ui8_hall_counter_offset_up;
lcd_os_message[6] = tsdz_cfg.ui8_hall_counter_offset_down;
// Hall counter offset (Up & Down transition)
if (tsdz_cfg.ui8_hall_offset_up || tsdz_cfg.ui8_hall_offset_down) {
lcd_os_message[5] = tsdz_cfg.ui8_hall_offset_up;
lcd_os_message[6] = tsdz_cfg.ui8_hall_offset_down;
} else {
lcd_os_message[5] = 0;
lcd_os_message[6] = 0;
}
lcd_os_message[7] = 0;

// Phase angle adjust
if (lcd_os_message[2] == MOTOR_CALIBRATION_MODE)
lcd_os_message[7] = ui8_app_rotor_angle_adj;
else
lcd_os_message[7] = tsdz_cfg.ui8_phase_angle_adj;

// Free for future use
lcd_os_message[8] = 0;
lcd_os_message[9] = 0;
lcd_os_message[10] = 0;
Expand Down
4 changes: 2 additions & 2 deletions main/tsdz_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ typedef struct _tsdz_cfg {
volatile uint8_t ui8_torque_offset_fix;
volatile uint16_t ui16_torque_offset_value;
volatile uint8_t ui8_hall_ref_angles[6];
volatile uint8_t ui8_hall_counter_offset_up;
volatile uint8_t ui8_hall_counter_offset_down;
volatile uint8_t ui8_hall_offset_up;
volatile uint8_t ui8_hall_offset_down;
} struct_tsdz_cfg;

#pragma pack(1)
Expand Down

0 comments on commit 013591d

Please sign in to comment.