|
|
@@ -19,7 +19,7 @@ static u32 _hall_detect_task(void *args);
|
|
|
static void _hall_init_el_angle(void);
|
|
|
|
|
|
|
|
|
-#define HALL_PLACE_OFFSET (220 << 19) //(345) //315
|
|
|
+#define HALL_PLACE_OFFSET (230 << 19) //(345) //315
|
|
|
/*
|
|
|
4,5,1,3,2,6,4
|
|
|
*/
|
|
|
@@ -92,13 +92,11 @@ static void hall_sensor_default(void) {
|
|
|
}
|
|
|
_sensor_hander.manual_angle = 0x3FF;
|
|
|
_hall_init_el_angle();
|
|
|
- hall_debug_log();
|
|
|
}
|
|
|
|
|
|
void hall_sensor_init(void) {
|
|
|
- mc_hall_init();
|
|
|
hall_sensor_default();
|
|
|
-
|
|
|
+ mc_hall_init();
|
|
|
shark_task_create(_hall_detect_task, NULL);
|
|
|
}
|
|
|
|
|
|
@@ -106,13 +104,13 @@ void hall_sensor_clear(void) {
|
|
|
hall_sensor_default();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
static u32 _hall_detect_task(void *args) {
|
|
|
if (_sensor_hander.el_speed != 0) {
|
|
|
u32 ticks_now = timer_count32_get();
|
|
|
- u32 delta_us = timer_count32_delta(ticks_now, _sensor_hander.hall_ticks);
|
|
|
- if (delta_us >= (1200*1000)) {
|
|
|
- hall_sensor_clear();
|
|
|
+ if (ticks_now > _sensor_hander.hall_ticks) {
|
|
|
+ if (timer_count32_delta(ticks_now, _sensor_hander.hall_ticks) > 2000*1000) {
|
|
|
+ hall_sensor_clear();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return 0;
|
|
|
@@ -429,13 +427,14 @@ void HALL_IRQHandler(void) {
|
|
|
_sensor_hander.comp_count = 0;//(s32)(delta_us/FOC_CTRL_US)/2;
|
|
|
_sensor_hander.angle_comp_ts = 0;//estimate_delta_angle/_sensor_hander.comp_count;
|
|
|
_sensor_hander.estimate_el_angle = theta_now;
|
|
|
+ delta_us = _hall_get_angle_ticks();
|
|
|
}else {
|
|
|
_sensor_hander.comp_count = 0;
|
|
|
_sensor_hander.angle_comp_ts = 0;
|
|
|
_sensor_hander.estimate_el_angle = theta_now;
|
|
|
}
|
|
|
_sensor_hander.estimate_delta_angle = 0;
|
|
|
- _sensor_hander.delta_angle_ts = next_delta_angle/(delta_us/FOC_CTRL_US);
|
|
|
+ _sensor_hander.delta_angle_ts = (next_delta_angle/((delta_us<<6)/FOC_CTRL_US))<<6;
|
|
|
_sensor_hander.next_delta_angle = next_delta_angle;
|
|
|
_sensor_hander.measured_el_angle = theta_now;
|
|
|
|