|
@@ -25,54 +25,57 @@
|
|
|
extern float target_d;
|
|
extern float target_d;
|
|
|
extern float target_q;
|
|
extern float target_q;
|
|
|
#endif
|
|
#endif
|
|
|
-static u32 _app_low_task(void *args);
|
|
|
|
|
-static u32 _app_report_task(void *args);
|
|
|
|
|
-static u32 _app_plot_task(void *args);
|
|
|
|
|
|
|
+static u32 app_low_task(void *args);
|
|
|
|
|
+static u32 app_report_task(void *args);
|
|
|
|
|
+static u32 app_plot_task(void *args);
|
|
|
//static u32 _app_trq_test_task(void *args);
|
|
//static u32 _app_trq_test_task(void *args);
|
|
|
extern void PMSM_FOC_LogDebug(void);
|
|
extern void PMSM_FOC_LogDebug(void);
|
|
|
extern void mc_err_code_log(void);
|
|
extern void mc_err_code_log(void);
|
|
|
extern void encoder_log(void);
|
|
extern void encoder_log(void);
|
|
|
extern void sample_log(void);
|
|
extern void sample_log(void);
|
|
|
extern void thro_torque_log(void);
|
|
extern void thro_torque_log(void);
|
|
|
-extern void eCtrl_debug_log(void);
|
|
|
|
|
extern bool can_is_connect_pc(void);
|
|
extern bool can_is_connect_pc(void);
|
|
|
extern measure_time_t g_meas_hall;
|
|
extern measure_time_t g_meas_hall;
|
|
|
extern measure_time_t g_meas_foc;
|
|
extern measure_time_t g_meas_foc;
|
|
|
extern measure_time_t g_meas_MCTask;
|
|
extern measure_time_t g_meas_MCTask;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-#if 0
|
|
|
|
|
-static s16 test_rpm = 0000;
|
|
|
|
|
-static float test_trq = 0;
|
|
|
|
|
-static float test_id = 0;
|
|
|
|
|
-static float test_iq = 0;
|
|
|
|
|
-static u32 _app_trq_test_task(void *args) {
|
|
|
|
|
- DQ_t dq;
|
|
|
|
|
- motor_mpta_fw_lookup(test_rpm, test_trq, &dq);
|
|
|
|
|
- test_id = dq.d;
|
|
|
|
|
- test_iq = dq.q;
|
|
|
|
|
- sys_debug("lookup: %d, %f, %f, %f\n", test_rpm, test_trq, test_id, test_iq);
|
|
|
|
|
- test_rpm = 8000;
|
|
|
|
|
- test_trq += 5.0f;
|
|
|
|
|
- return 500;
|
|
|
|
|
-}
|
|
|
|
|
-#endif
|
|
|
|
|
void app_start(void){
|
|
void app_start(void){
|
|
|
can_debug(true);
|
|
can_debug(true);
|
|
|
can_message_init();
|
|
can_message_init();
|
|
|
nv_storage_init();
|
|
nv_storage_init();
|
|
|
mc_conf_init();
|
|
mc_conf_init();
|
|
|
- mc_err_block_init();
|
|
|
|
|
|
|
+ mc_err_block_init(FOC_Reset_Reson);
|
|
|
mc_init();
|
|
mc_init();
|
|
|
- shark_task_create(_app_low_task, NULL);
|
|
|
|
|
- shark_task_create(_app_report_task, NULL);
|
|
|
|
|
- shark_task_create(_app_plot_task, NULL);
|
|
|
|
|
- //shark_task_create(_app_trq_test_task, NULL);
|
|
|
|
|
|
|
+ shark_task_create(app_low_task, NULL);
|
|
|
|
|
+ shark_task_create(app_report_task, NULL);
|
|
|
|
|
+ shark_task_create(app_plot_task, NULL);
|
|
|
sys_debug("mc start\n");
|
|
sys_debug("mc start\n");
|
|
|
shark_task_run();
|
|
shark_task_run();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static u32 _app_report_task(void *p) {
|
|
|
|
|
|
|
+static void app_print_log(void) {
|
|
|
|
|
+ //sys_debug("Slow: %d - %d\n", g_meas_MCTask.intval_time, g_meas_MCTask.exec_time);
|
|
|
|
|
+ //sys_debug("Fast: %d - %d, err: %d-%d-%d\n", g_meas_foc.intval_time, g_meas_foc.exec_time, g_meas_foc.intval_hi_err, g_meas_foc.intval_low_err, g_meas_foc.exec_max_error_time);
|
|
|
|
|
+ //sys_debug("FOC time err %d %d\n", g_meas_foc.intval_time_h_error, g_meas_foc.intval_time_l_error);
|
|
|
|
|
+ //sys_debug("acc vol %d, bid %d\n", get_acc_vol(), gpio_board_id());
|
|
|
|
|
+ //sys_debug("throttle %f\n", get_throttle_float());
|
|
|
|
|
+ //sys_debug("ADC Vref %f, %f\n", get_adc_vref(), adc_5vref_compesion());
|
|
|
|
|
+ //sys_debug("dead time %d\n", get_deadtime());
|
|
|
|
|
+ //thro_torque_log();
|
|
|
|
|
+ //sys_debug("_>%f, %f, %f\n", ladrc_observer_get()->ld, ladrc_observer_get()->lq, ladrc_observer_get()->poles);
|
|
|
|
|
+ encoder_log();
|
|
|
|
|
+ //motor_debug();
|
|
|
|
|
+ sample_log();
|
|
|
|
|
+ //PMSM_FOC_LogDebug();
|
|
|
|
|
+ //F_debug();
|
|
|
|
|
+ //eCtrl_debug_log();
|
|
|
|
|
+ //sys_debug("enc err %d, %d\n", foc_observer_enc_errcount(), foc_observer_sensorless_stable());
|
|
|
|
|
+ //mc_err_code_log();
|
|
|
|
|
+ //sys_debug("=====\n");
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static u32 app_report_task(void *p) {
|
|
|
static u32 loop = 0;
|
|
static u32 loop = 0;
|
|
|
|
|
|
|
|
can_report_ext_status(0x43);
|
|
can_report_ext_status(0x43);
|
|
@@ -99,26 +102,8 @@ static u32 _app_report_task(void *p) {
|
|
|
can_report_mot_params_ested(mot_params_get_est_flux(), FLUX_TYPE);
|
|
can_report_mot_params_ested(mot_params_get_est_flux(), FLUX_TYPE);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (++loop % 5 == 0) {
|
|
|
|
|
- //sys_debug("rst 0x%x\n", get_mcu_reset_source());
|
|
|
|
|
- //sys_debug("Slow: %d - %d\n", g_meas_MCTask.intval_time, g_meas_MCTask.exec_time);
|
|
|
|
|
- //sys_debug("Fast: %d - %d, err: %d-%d-%d\n", g_meas_foc.intval_time, g_meas_foc.exec_time, g_meas_foc.intval_hi_err, g_meas_foc.intval_low_err, g_meas_foc.exec_max_error_time);
|
|
|
|
|
- //sys_debug("FOC time err %d %d\n", g_meas_foc.intval_time_h_error, g_meas_foc.intval_time_l_error);
|
|
|
|
|
- //sys_debug("acc vol %d, bid %d\n", get_acc_vol(), gpio_board_id());
|
|
|
|
|
- //sys_debug("throttle %f\n", get_throttle_float());
|
|
|
|
|
- //sys_debug("ADC Vref %f, %f\n", get_adc_vref(), adc_5vref_compesion());
|
|
|
|
|
- //sys_debug("dead time %d\n", get_deadtime());
|
|
|
|
|
- //thro_torque_log();
|
|
|
|
|
- //sys_debug("_>%f, %f, %f\n", ladrc_observer_get()->ld, ladrc_observer_get()->lq, ladrc_observer_get()->poles);
|
|
|
|
|
- encoder_log();
|
|
|
|
|
- //motor_debug();
|
|
|
|
|
- sample_log();
|
|
|
|
|
- //PMSM_FOC_LogDebug();
|
|
|
|
|
- //F_debug();
|
|
|
|
|
- //eCtrl_debug_log();
|
|
|
|
|
- //sys_debug("enc err %d, %d\n", foc_observer_enc_errcount(), foc_observer_sensorless_stable());
|
|
|
|
|
- //mc_err_code_log();
|
|
|
|
|
- //sys_debug("=====\n");
|
|
|
|
|
|
|
+ if (++loop % 10 == 0) {
|
|
|
|
|
+ app_print_log();
|
|
|
}
|
|
}
|
|
|
return 200;
|
|
return 200;
|
|
|
}
|
|
}
|
|
@@ -131,7 +116,7 @@ static void plot_smo_angle(void) {
|
|
|
delta = fast_atan2(s, c)/PI*180.0f;
|
|
delta = fast_atan2(s, c)/PI*180.0f;
|
|
|
can_plot3(foc()->in.mot_angle, smo_angle, delta);
|
|
can_plot3(foc()->in.mot_angle, smo_angle, delta);
|
|
|
}
|
|
}
|
|
|
-static u32 _app_plot_task(void * args) {
|
|
|
|
|
|
|
+static u32 app_plot_task(void * args) {
|
|
|
if (plot_type == 1) {
|
|
if (plot_type == 1) {
|
|
|
s16 plot_arg1 = (s16)foc_observer_sensorless_speed();
|
|
s16 plot_arg1 = (s16)foc_observer_sensorless_speed();
|
|
|
s16 plot_arg2 = (s16)mot_contrl_get_speed(&motor.controller);
|
|
s16 plot_arg2 = (s16)mot_contrl_get_speed(&motor.controller);
|
|
@@ -166,7 +151,7 @@ static u32 _app_plot_task(void * args) {
|
|
|
}
|
|
}
|
|
|
return 20;
|
|
return 20;
|
|
|
}
|
|
}
|
|
|
-static u32 _app_low_task(void *args) {
|
|
|
|
|
|
|
+static u32 app_low_task(void *args) {
|
|
|
wdog_reload();
|
|
wdog_reload();
|
|
|
if (!mot_contrl_is_start(&motor.controller)) {
|
|
if (!mot_contrl_is_start(&motor.controller)) {
|
|
|
mc_err_block_save();
|
|
mc_err_block_save();
|