diff --git a/Inc/targets.h b/Inc/targets.h index 5ee42f93..d1178716 100644 --- a/Inc/targets.h +++ b/Inc/targets.h @@ -1317,6 +1317,8 @@ #define NFAULT_PORT GPIOB #define NFAULT_PIN LL_GPIO_PIN_5 #define TARGET_MIN_BEMF_COUNTS 3 +#define RAMP_SPEED_LOW_RPM 1 +#define RAMP_SPEED_HIGH_RPM 8 #endif #ifdef RHINO80A_F051 diff --git a/Src/main.c b/Src/main.c index 94508ed0..24866ecd 100644 --- a/Src/main.c +++ b/Src/main.c @@ -379,13 +379,10 @@ float consumed_current = 0; int32_t smoothed_raw_current = 0; int16_t actual_current = 0; -char lowkv = 0; - uint16_t min_startup_duty = 120; uint16_t sin_mode_min_s_d = 120; char bemf_timeout = 10; -char startup_boost = 50; char reversing_dead_band = 1; uint16_t low_pin_count = 0; @@ -629,9 +626,15 @@ void loadEEpromSettings() } if (eepromBuffer.startup_power < 151 && eepromBuffer.startup_power > 49) { - min_startup_duty = (eepromBuffer.startup_power); - minimum_duty_cycle = (eepromBuffer.startup_power / 3); - stall_protect_minimum_duty = minimum_duty_cycle + 10; + if (!eepromBuffer.comp_pwm) { // higher startup power for non-complementary pwm + min_startup_duty = (eepromBuffer.startup_power) *2 ; + minimum_duty_cycle = (eepromBuffer.startup_power / 2); + stall_protect_minimum_duty = minimum_duty_cycle + 10; + } else { + min_startup_duty = (eepromBuffer.startup_power); + minimum_duty_cycle = (eepromBuffer.startup_power / 3); + stall_protect_minimum_duty = minimum_duty_cycle + 10; + } } else { min_startup_duty = 150; minimum_duty_cycle = (min_startup_duty / 2) + 10; @@ -748,10 +751,6 @@ void loadEEpromSettings() high_rpm_level = motor_kv / 12 / (32 / eepromBuffer.motor_poles); } reverse_speed_threshold = map(motor_kv, 300, 3000, 1000, 500); - // reverse_speed_threshold = 200; -// if (!eepromBuffer.comp_pwm) { -// eepromBuffer.bi_direction = 0; -// } } void saveEEpromSettings() @@ -896,18 +895,6 @@ void interruptRoutine() maskPhaseInterrupts(); thiszctime = INTERVAL_TIMER_COUNT; SET_INTERVAL_TIMER_COUNT(0); -// if(thiszctime < (commutation_interval - (commutation_interval>>2))){ -// send_LED_RGB(0, 0, 255); -// // waitTime = waitTime + commutation_interval - thiszctime; -// waitTime = waitTime + (commutation_interval>>2); -// // thiszctime = commutation_interval + (commutation_interval>>2); -// }else if(thiszctime > (commutation_interval + (commutation_interval>>2))){ -// send_LED_RGB(255, 0, 0); -// // waitTime = waitTime - thiszctime - commutation_interval; -// waitTime = waitTime - (commutation_interval>>2); -// // thiszctime = commutation_interval - (commutation_interval>>2); -// } - // waitTime = waitTime >> fast_accel; SET_AND_ENABLE_COM_INT(waitTime+1); // enable COM_TIMER interrupt __enable_irq(); }