|
@@ -1253,6 +1253,7 @@ measure_time_t g_meas_foc = {.exec_max_time = 25, .intval_max_time = 62, .intva
|
|
|
static s16 ia[CONFIG_IAB_REC_COUNT], ib[CONFIG_IAB_REC_COUNT];
|
|
static s16 ia[CONFIG_IAB_REC_COUNT], ib[CONFIG_IAB_REC_COUNT];
|
|
|
static int iab_w_count = 0, iab_r_count = 0;
|
|
static int iab_w_count = 0, iab_r_count = 0;
|
|
|
static bool b_iab_rec = false;
|
|
static bool b_iab_rec = false;
|
|
|
|
|
+static bool b_vab_rec = false;
|
|
|
extern void can_plot2(s16 v1, s16 v2);
|
|
extern void can_plot2(s16 v1, s16 v2);
|
|
|
#endif
|
|
#endif
|
|
|
/*ADC 电流采集中断,调用FOC的核心处理函数*/
|
|
/*ADC 电流采集中断,调用FOC的核心处理函数*/
|
|
@@ -1272,14 +1273,20 @@ void ADC_IRQHandler(void) {
|
|
|
ia[iab_w_count] = (s16)motor.controller.foc.in.curr_abc[0];
|
|
ia[iab_w_count] = (s16)motor.controller.foc.in.curr_abc[0];
|
|
|
ib[iab_w_count] = (s16)motor.controller.foc.in.curr_abc[1];
|
|
ib[iab_w_count] = (s16)motor.controller.foc.in.curr_abc[1];
|
|
|
iab_w_count ++;
|
|
iab_w_count ++;
|
|
|
|
|
+ }else if (b_vab_rec && (iab_w_count < CONFIG_IAB_REC_COUNT)) {
|
|
|
|
|
+ ia[iab_w_count] = (s16)motor.controller.phase_v_ab.a;
|
|
|
|
|
+ ib[iab_w_count] = (s16)motor.controller.foc.out.vol_albeta.a*TWO_BY_THREE;
|
|
|
|
|
+ iab_w_count ++;
|
|
|
}
|
|
}
|
|
|
#endif
|
|
#endif
|
|
|
motor_vbus_crit_check((s16)sample_vbus_raw()); //need fast detect vbus very low, to stop the motor
|
|
motor_vbus_crit_check((s16)sample_vbus_raw()); //need fast detect vbus very low, to stop the motor
|
|
|
float vd, vq;
|
|
float vd, vq;
|
|
|
if (motor.b_ind_start) {
|
|
if (motor.b_ind_start) {
|
|
|
mot_params_high_freq_inject();
|
|
mot_params_high_freq_inject();
|
|
|
- vd = motor.controller.foc.out.vol_dq.d;
|
|
|
|
|
- vq = motor.controller.foc.out.vol_dq.q;
|
|
|
|
|
|
|
+#if CONFIG_MOT_IND_USE_PHASE_SAMPLE==0
|
|
|
|
|
+ vd = motor.controller.foc.out.vol_dq.d * TWO_BY_THREE;
|
|
|
|
|
+ vq = motor.controller.foc.out.vol_dq.q * TWO_BY_THREE;
|
|
|
|
|
+#endif
|
|
|
}
|
|
}
|
|
|
if (!mot_contrl_update(&motor.controller)) {/* FOC 角度错误,立即停机 */
|
|
if (!mot_contrl_update(&motor.controller)) {/* FOC 角度错误,立即停机 */
|
|
|
if (mot_contrl_is_start(&motor.controller)) {
|
|
if (mot_contrl_is_start(&motor.controller)) {
|
|
@@ -1309,6 +1316,10 @@ void ADC_IRQHandler(void) {
|
|
|
if (motor.b_ind_start) {
|
|
if (motor.b_ind_start) {
|
|
|
float id = motor.controller.foc.out.curr_dq.d;
|
|
float id = motor.controller.foc.out.curr_dq.d;
|
|
|
float iq = motor.controller.foc.out.curr_dq.q;
|
|
float iq = motor.controller.foc.out.curr_dq.q;
|
|
|
|
|
+#if CONFIG_MOT_IND_USE_PHASE_SAMPLE==1
|
|
|
|
|
+ vd = motor.controller.phase_v_dq.d;
|
|
|
|
|
+ vq = motor.controller.phase_v_dq.q;
|
|
|
|
|
+#endif
|
|
|
mot_params_hj_sample_vi(vd, vq, id, iq);
|
|
mot_params_hj_sample_vi(vd, vq, id, iq);
|
|
|
}
|
|
}
|
|
|
TIME_MEATURE_END();
|
|
TIME_MEATURE_END();
|
|
@@ -1316,7 +1327,7 @@ void ADC_IRQHandler(void) {
|
|
|
|
|
|
|
|
#if (CONFIG_ENABLE_IAB_REC==1)
|
|
#if (CONFIG_ENABLE_IAB_REC==1)
|
|
|
static void _iab_plot_timer_handler(shark_timer_t *t) {
|
|
static void _iab_plot_timer_handler(shark_timer_t *t) {
|
|
|
- if (!b_iab_rec) {
|
|
|
|
|
|
|
+ if (!b_iab_rec && !b_vab_rec) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if (iab_r_count < iab_w_count) {
|
|
if (iab_r_count < iab_w_count) {
|
|
@@ -1326,18 +1337,26 @@ static void _iab_plot_timer_handler(shark_timer_t *t) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
static shark_timer_t _iab_plot_timer = TIMER_INIT(_iab_plot_timer, _iab_plot_timer_handler);
|
|
static shark_timer_t _iab_plot_timer = TIMER_INIT(_iab_plot_timer, _iab_plot_timer_handler);
|
|
|
-void mc_start_current_rec(bool rec) {
|
|
|
|
|
- if (b_iab_rec == rec) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+void mc_start_current_rec(bool is_i, bool rec) {
|
|
|
|
|
+
|
|
|
if (!rec) {
|
|
if (!rec) {
|
|
|
b_iab_rec = false;
|
|
b_iab_rec = false;
|
|
|
|
|
+ b_vab_rec = false;
|
|
|
shark_timer_cancel(&_iab_plot_timer);
|
|
shark_timer_cancel(&_iab_plot_timer);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if (b_iab_rec == true || b_vab_rec == true) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
iab_w_count = 0;
|
|
iab_w_count = 0;
|
|
|
iab_r_count = 0;
|
|
iab_r_count = 0;
|
|
|
- b_iab_rec = true;
|
|
|
|
|
|
|
+ if (is_i) {
|
|
|
|
|
+ b_iab_rec = true;
|
|
|
|
|
+ }else {
|
|
|
|
|
+ b_vab_rec = true;
|
|
|
|
|
+ }
|
|
|
shark_timer_post(&_iab_plot_timer, 100);
|
|
shark_timer_post(&_iab_plot_timer, 100);
|
|
|
}
|
|
}
|
|
|
#endif
|
|
#endif
|