|
|
@@ -47,6 +47,7 @@ static motor_t motor = {
|
|
|
.b_is96Mode = false,
|
|
|
.mode = CTRL_MODE_OPEN,
|
|
|
};
|
|
|
+static motor_err_t mc_error;
|
|
|
|
|
|
static void MC_Check_MosVbusThrottle(void) {
|
|
|
int count = 1000;
|
|
|
@@ -916,7 +917,6 @@ static void _pwm_brake_prot_timer_handler(shark_timer_t *t){
|
|
|
pwm_brake_enable(true);
|
|
|
sys_debug("MC protect error\n");
|
|
|
}
|
|
|
-static float err_vbus, err_id,err_iq, ctl_mode;
|
|
|
|
|
|
void MC_Protect_IRQHandler(void){
|
|
|
pwm_brake_enable(false);
|
|
|
@@ -924,10 +924,21 @@ void MC_Protect_IRQHandler(void){
|
|
|
if (!motor.b_start) {
|
|
|
return;
|
|
|
}
|
|
|
- err_vbus = get_vbus_float();
|
|
|
- err_id = PMSM_FOC_Get()->idq_ctl[0].s_Cp;
|
|
|
- err_iq = PMSM_FOC_Get()->idq_ctl[1].s_Cp;
|
|
|
- ctl_mode = PMSM_FOC_Get()->out.n_RunMode;
|
|
|
+ mc_error.vbus = (s16)get_vbus_float();
|
|
|
+ mc_error.ibus = (s16)get_vbus_current();
|
|
|
+ mc_error.id_ref = (s16)PMSM_FOC_Get()->idq_ctl[0].s_Cp;
|
|
|
+ mc_error.iq_ref = (s16)PMSM_FOC_Get()->idq_ctl[1].s_Cp;
|
|
|
+ mc_error.run_mode = PMSM_FOC_Get()->out.n_RunMode;
|
|
|
+ mc_error.id = (s16)PMSM_FOC_Get()->out.s_RealIdq.d;
|
|
|
+ mc_error.iq = (s16)PMSM_FOC_Get()->out.s_RealIdq.q;
|
|
|
+ mc_error.vd = (s16)PMSM_FOC_Get()->out.s_OutVdq.d;
|
|
|
+ mc_error.vq = (s16)PMSM_FOC_Get()->out.s_OutVdq.q;
|
|
|
+ mc_error.rpm = (s16)motor_encoder_get_speed();
|
|
|
+ mc_error.torque_ref = (s16)PMSM_FOC_Get()->in.s_targetTorque;
|
|
|
+ mc_error.b_smo_running = !foc_observer_is_encoder();
|
|
|
+ mc_error.mos_temp = get_mos_temp();
|
|
|
+ mc_error.mot_temp = get_motor_temp();
|
|
|
+
|
|
|
mc_set_critical_error(FOC_CRIT_Phase_Err);
|
|
|
_mc_internal_init(CTRL_MODE_OPEN, false);
|
|
|
adc_stop_convert();
|
|
|
@@ -937,7 +948,7 @@ void MC_Protect_IRQHandler(void){
|
|
|
}
|
|
|
|
|
|
void motor_debug(void) {
|
|
|
- sys_debug("err: %f, %f, %f, %d\n", err_vbus, err_id, err_iq, ctl_mode);
|
|
|
+ sys_debug("err: %f, %f, %f, %d\n", mc_error.vbus, mc_error.id_ref, mc_error.iq_ref, mc_error.run_mode);
|
|
|
}
|
|
|
|
|
|
void TIMER_UP_IRQHandler(void){
|