Skip to content

Commit 99060ef

Browse files
committed
bugfix for not stopping motor
1 parent 08593e9 commit 99060ef

File tree

4 files changed

+26
-24
lines changed

4 files changed

+26
-24
lines changed

ACAsetPoint.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,11 @@ uint16_t aca_setpoint(uint16_t ui16_time_ticks_between_pas_interrupt, uint16_t s
247247
if ((ui16_aca_flags & SPEED_INFLUENCES_TORQUESENSOR) == SPEED_INFLUENCES_TORQUESENSOR) {
248248
float_temp *= (1.0 + ((float) ui16_virtual_erps_speed) / ((float) (ui16_speed_kph_to_erps_ratio * ((float) ui8_speedlimit_kph)) / 100.0)); // influence of current speed based on base speed limit
249249
}
250-
250+
if(PAS_is_active)
251251
uint32_current_target = (uint32_t) (float_temp * (float) (ui16_battery_current_max_value) / 255.0 + (float) ui16_current_cal_b);
252+
else uint32_current_target =(uint32_t) ui16_current_cal_b;
253+
254+
252255
controll_state_temp += 4;
253256

254257
}

config.h

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,43 @@
1010

1111
#define NUMBER_OF_PAS_MAGS 12
1212
#define limit 28
13-
#define timeout 3125
13+
#define timeout 16000
1414
#define wheel_circumference 2230L
1515
#define limit_without_pas 6
1616
#define ADC_THROTTLE_MIN_VALUE 43
1717
#define ADC_THROTTLE_MAX_VALUE 182
1818
#define BATTERY_VOLTAGE_MIN_VALUE 148
19-
#define BATTERY_CURRENT_MAX_VALUE 64L
19+
#define BATTERY_CURRENT_MAX_VALUE 66L
2020
#define PHASE_CURRENT_MAX_VALUE 350L
2121
#define REGEN_CURRENT_MAX_VALUE 50L
22-
#define MOTOR_ROTOR_DELTA_PHASE_ANGLE_RIGHT 246
22+
#define MOTOR_ROTOR_DELTA_PHASE_ANGLE_RIGHT 238
2323
#define current_cal_a 46
24-
#define LEVEL_1 26
25-
#define LEVEL_2 38
26-
#define LEVEL_3 55
27-
#define LEVEL_4 80
24+
#define LEVEL_1 22
25+
#define LEVEL_2 33
26+
#define LEVEL_3 50
27+
#define LEVEL_4 75
2828
#define LEVEL_5 100
2929
#define MORSE_TIME_1 50
3030
#define MORSE_TIME_2 50
3131
#define MORSE_TIME_3 50
32-
#define RAMP_END 1500
32+
#define RAMP_END 0
3333
#define P_FACTOR 0.5
3434
#define I_FACTOR 0.2
35-
#define GEAR_RATIO 69L
35+
#define GEAR_RATIO 51L
3636
#define PAS_THRESHOLD 1.9
37-
#define RAMP_START 64000
37+
#define RAMP_START 0
3838
#define limit_with_throttle_override 35
3939
#define CORRECTION_AT_ANGLE 127
4040
#define ANGLE_4_0 1
41-
#define ANGLE_6_60 41
42-
#define ANGLE_2_120 84
43-
#define ANGLE_3_180 129
41+
#define ANGLE_6_60 43
42+
#define ANGLE_2_120 86
43+
#define ANGLE_3_180 128
4444
#define BLUOSEC
45-
#define ANGLE_1_240 167
46-
#define ANGLE_5_300 212
47-
#define TQS_CALIB 0.0
48-
#define ACA 4764
49-
#define EEPROM_NOINIT // eeprom will not be cleared
50-
#define EEPROM_INIT_MAGIC_BYTE 93 // makes sure (chance of fail 1/255) eeprom is invalidated after flashing new config
45+
#define ANGLE_1_240 171
46+
#define ANGLE_5_300 213
47+
#define TQS_CALIB 10000.0
48+
#define ACA 6812
49+
#define EEPROM_INIT_MAGIC_BYTE 25 // makes sure (chance of fail 1/255) eeprom is invalidated after flashing new config
5150
#define ADC_BATTERY_VOLTAGE_K 67
5251
#define ACA_EXPERIMENTAL 128
5352
#define BATTERY_VOLTAGE_MAX_VALUE 208

main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ int main(void) {
154154
// scheduled update of setpoint and duty cycle (slow loop, 50 Hz)
155155
if (ui8_slowloop_flag) {
156156
//printf("MainSlowLoop\n");
157-
157+
debug_pin_set();
158158
ui8_slowloop_flag = 0; //reset flag for slow loop
159159
ui8_veryslowloop_counter++; // increase counter for very slow loop
160160

@@ -212,7 +212,7 @@ int main(void) {
212212
#endif
213213
}//end of very slow loop
214214

215-
215+
debug_pin_reset();
216216
}// end of slow loop
217217
}// end of while(1) loop
218218
}

motor.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void hall_sensors_read_and_action(void) {
8484
case 3://rotor position 180 degree
8585
// full electric revolution recognized, update counters
8686
uint8_t_hall_case[3] = ui8_adc_read_phase_B_current();
87-
debug_pin_set();
87+
8888

8989
if (ui8_half_rotation_flag) {
9090
ui8_half_rotation_flag = 0;
@@ -126,7 +126,7 @@ void hall_sensors_read_and_action(void) {
126126
ui8_foc_enable_flag = 1;
127127

128128
uint8_t_hall_case[0] = ui8_adc_read_phase_B_current();
129-
debug_pin_reset();
129+
//debug_pin_reset();
130130
ui8_motor_rotor_hall_position = ui8_s_hall_angle4_0;
131131
break;
132132

0 commit comments

Comments
 (0)