|
|
@@ -28,7 +28,7 @@ extern float target_d;
|
|
|
extern float target_q;
|
|
|
#endif
|
|
|
|
|
|
-static bool mc_is_hwbrake(void);
|
|
|
+static bool mc_detect_hwbrake(void);
|
|
|
static bool mc_is_gpio_mlock(void);
|
|
|
static void _pwm_brake_prot_timer_handler(shark_timer_t *);
|
|
|
static shark_timer_t _brake_prot_timer = TIMER_INIT(_brake_prot_timer, _pwm_brake_prot_timer_handler);
|
|
|
@@ -305,7 +305,7 @@ bool mc_start(u8 mode) {
|
|
|
mc_stop();
|
|
|
return false;
|
|
|
}
|
|
|
- if (mc_is_hwbrake()) {
|
|
|
+ if (mc_detect_hwbrake()) {
|
|
|
PMSM_FOC_Brake(true);
|
|
|
}
|
|
|
gpio_beep(200);
|
|
|
@@ -598,7 +598,7 @@ void mc_force_run_open(s16 vd, s16 vq) {
|
|
|
pwm_enable_channel();
|
|
|
phase_current_calibrate_wait();
|
|
|
PMSM_FOC_Set_Angle(0);
|
|
|
- PMSM_FOC_SetOpenVdq(vd, 0);
|
|
|
+ PMSM_FOC_SetOpenVdq((float)vd * 0.7f, 0);
|
|
|
_force_wait = 2000;
|
|
|
motor.b_force_run = true;
|
|
|
}
|
|
|
@@ -827,11 +827,11 @@ static bool mc_is_gpio_mlock(void) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
-static bool mc_is_hwbrake(void) {
|
|
|
+static bool _mc_is_hwbrake(void) {
|
|
|
int count = 50;
|
|
|
int settimes = 0;
|
|
|
while(count-- > 0) {
|
|
|
- bool b1 = mc_get_gpio_brake() && mc_get_gpio_brake1();
|
|
|
+ bool b1 = mc_get_gpio_brake() || mc_get_gpio_brake1();
|
|
|
if (b1) {
|
|
|
settimes ++;
|
|
|
}
|
|
|
@@ -855,6 +855,11 @@ static bool mc_is_hwbrake(void) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+static bool mc_detect_hwbrake(void) {
|
|
|
+ motor.b_break = _mc_is_hwbrake();
|
|
|
+ return motor.b_break;
|
|
|
+}
|
|
|
+
|
|
|
static void _fan_det_timer_handler(shark_timer_t *t) {
|
|
|
if (t == &_fan_det_timer1) {
|
|
|
motor.fan[0].rpm = 0;
|
|
|
@@ -881,12 +886,7 @@ void Fan_IRQHandler(int idx) {
|
|
|
}
|
|
|
|
|
|
void MC_Brake_IRQHandler(void) {
|
|
|
-
|
|
|
- if (mc_is_hwbrake()) {
|
|
|
- motor.b_break = true;
|
|
|
- }else {
|
|
|
- motor.b_break = false;
|
|
|
- }
|
|
|
+ mc_detect_hwbrake();
|
|
|
|
|
|
if (!motor.b_start) {
|
|
|
return;
|
|
|
@@ -1048,7 +1048,7 @@ static bool mc_process_force_running(void) {
|
|
|
if (_force_wait > 0) {
|
|
|
--_force_wait;
|
|
|
}else {
|
|
|
- _force_angle += 1.0f;
|
|
|
+ _force_angle += 1.5f;
|
|
|
rand_angle(_force_angle);
|
|
|
PMSM_FOC_Set_Angle(_force_angle);
|
|
|
}
|