|
|
@@ -1030,7 +1030,13 @@ void TIMER_UP_IRQHandler(void){
|
|
|
measure_time_t g_meas_foc = {.exec_max_time = 25, .intval_max_time = 62, .intval_low_err = 0, .intval_hi_err = 0, .first = true,};
|
|
|
#define TIME_MEATURE_START() time_measure_start(&g_meas_foc)
|
|
|
#define TIME_MEATURE_END() time_measure_end(&g_meas_foc)
|
|
|
-
|
|
|
+#if (CONFIG_ENABLE_IAB_REC==1)
|
|
|
+#define CONFIG_IAB_REC_COUNT 8000
|
|
|
+static s16 ia[CONFIG_IAB_REC_COUNT], ib[CONFIG_IAB_REC_COUNT];
|
|
|
+static int iab_w_count = 0, iab_r_count = 0;
|
|
|
+static bool b_iab_rec = false;
|
|
|
+extern void can_plot2(s16 v1, s16 v2);
|
|
|
+#endif
|
|
|
/*ADC 电流采集中断,调用FOC的核心处理函数*/
|
|
|
void ADC_IRQHandler(void) {
|
|
|
if (phase_current_offset()) {//check if is adc offset checked
|
|
|
@@ -1043,6 +1049,15 @@ void ADC_IRQHandler(void) {
|
|
|
}
|
|
|
TIME_MEATURE_START();
|
|
|
|
|
|
+#if (CONFIG_ENABLE_IAB_REC==1)
|
|
|
+ if (b_iab_rec && (iab_w_count < CONFIG_IAB_REC_COUNT)) {
|
|
|
+ float iabc[3];
|
|
|
+ phase_current_get(iabc);
|
|
|
+ ia[iab_w_count] = (s16)iabc[0];
|
|
|
+ ib[iab_w_count] = (s16)iabc[1];
|
|
|
+ iab_w_count ++;
|
|
|
+ }
|
|
|
+#endif
|
|
|
motor_vbus_crit_low((s16)sample_vbus_raw()); //need fast detect vbus very low, to stop the motor
|
|
|
|
|
|
if (!PMSM_FOC_Schedule()) {/* FOC 角度错误,立即停机 */
|
|
|
@@ -1069,7 +1084,33 @@ void ADC_IRQHandler(void) {
|
|
|
TIME_MEATURE_END();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+#if (CONFIG_ENABLE_IAB_REC==1)
|
|
|
+static void _iab_plot_timer_handler(shark_timer_t *t) {
|
|
|
+ if (!b_iab_rec) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (iab_r_count < iab_w_count) {
|
|
|
+ can_plot2(ia[iab_r_count], ib[iab_r_count]);
|
|
|
+ iab_r_count ++;
|
|
|
+ shark_timer_post(t, 10);
|
|
|
+ }
|
|
|
+}
|
|
|
+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;
|
|
|
+ }
|
|
|
+ if (!rec) {
|
|
|
+ b_iab_rec = false;
|
|
|
+ shark_timer_cancel(&_iab_plot_timer);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ iab_w_count = 0;
|
|
|
+ iab_r_count = 0;
|
|
|
+ b_iab_rec = true;
|
|
|
+ shark_timer_post(&_iab_plot_timer, 100);
|
|
|
+}
|
|
|
+#endif
|
|
|
static bool mc_run_stall_process(u8 run_mode) {
|
|
|
if ((run_mode == CTRL_MODE_TRQ || run_mode == CTRL_MODE_SPD) && !PMSM_FOC_AutoHoldding()) {
|
|
|
//堵转判断
|