|
@@ -30,7 +30,6 @@ static hall_t g_hall;
|
|
|
#define us_2_s(tick) ((float)tick / 1000000.0f) //s32q14
|
|
#define us_2_s(tick) ((float)tick / 1000000.0f) //s32q14
|
|
|
#define HALL_MAX_TIME 1000000UL
|
|
#define HALL_MAX_TIME 1000000UL
|
|
|
|
|
|
|
|
-static u32 stop_cnt = 0;
|
|
|
|
|
static u32 g_delta_cnt = 0;
|
|
static u32 g_delta_cnt = 0;
|
|
|
static u32 g_trns_cnt = 0;
|
|
static u32 g_trns_cnt = 0;
|
|
|
static u32 g_min_delta;
|
|
static u32 g_min_delta;
|
|
@@ -112,7 +111,7 @@ static float __INLINE hall_elec_angle_vel(void){
|
|
|
|
|
|
|
|
void hall_debug_log(void) {
|
|
void hall_debug_log(void) {
|
|
|
sys_debug("angle dir %d, stat %d, lowres %f, err %d,%d\n", g_hall.dir, g_hall.state, g_hall.low_res_pos, g_hall.sig_errors, g_hall.noise_errors);
|
|
sys_debug("angle dir %d, stat %d, lowres %f, err %d,%d\n", g_hall.dir, g_hall.state, g_hall.low_res_pos, g_hall.sig_errors, g_hall.noise_errors);
|
|
|
- sys_debug("D: %d,%d,%d,%d\n", stop_cnt, g_delta_cnt, g_trns_cnt, g_min_delta);
|
|
|
|
|
|
|
+ sys_debug("D: %d,%d,%d\n", g_delta_cnt, g_trns_cnt, g_min_delta);
|
|
|
sys_debug("RPM: %f\n", hall_get_velocity());
|
|
sys_debug("RPM: %f\n", hall_get_velocity());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -139,7 +138,6 @@ void hall_init(void) {
|
|
|
gpio_hall_init();
|
|
gpio_hall_init();
|
|
|
}
|
|
}
|
|
|
hall_init_low_pos();
|
|
hall_init_low_pos();
|
|
|
- stop_cnt = 0;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void hall_set_direction(s8 dir) {
|
|
void hall_set_direction(s8 dir) {
|
|
@@ -243,7 +241,6 @@ float hall_update_elec_angle(void) {
|
|
|
g_hall.elec_angle = elec_smooth_angle;
|
|
g_hall.elec_angle = elec_smooth_angle;
|
|
|
g_hall.position += g_hall.elec_angle_vel * FOC_CTRL_US / g_hall.mot_poles;
|
|
g_hall.position += g_hall.elec_angle_vel * FOC_CTRL_US / g_hall.mot_poles;
|
|
|
if ((g_hall.samples.filled > 1) && (delta_ticks / g_hall.last_delta_ticks >= 1.4f)) {
|
|
if ((g_hall.samples.filled > 1) && (delta_ticks / g_hall.last_delta_ticks >= 1.4f)) {
|
|
|
- stop_cnt ++;
|
|
|
|
|
g_hall.elec_angle_vel = g_hall.elec_angle_vel * 0.95f;
|
|
g_hall.elec_angle_vel = g_hall.elec_angle_vel * 0.95f;
|
|
|
if (g_hall.elec_angle_vel < 30) {
|
|
if (g_hall.elec_angle_vel < 30) {
|
|
|
g_hall.elec_angle_vel = 0;
|
|
g_hall.elec_angle_vel = 0;
|
|
@@ -254,6 +251,10 @@ float hall_update_elec_angle(void) {
|
|
|
return hall_get_elec_angle();
|
|
return hall_get_elec_angle();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+float hall_get_vel_counts(void) {
|
|
|
|
|
+ return g_hall.elec_angle_vel/PHASE_60_DEGREE * g_hall.dir;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
float hall_get_velocity(void) {
|
|
float hall_get_velocity(void) {
|
|
|
return g_hall.velocity_filted;
|
|
return g_hall.velocity_filted;
|
|
|
}
|
|
}
|
|
@@ -280,12 +281,12 @@ static __INLINE void hall_calc_mot_velocity(u32 delta_cnt) {
|
|
|
float hall_offset_detect(float *off) {
|
|
float hall_offset_detect(float *off) {
|
|
|
return 0.0f;
|
|
return 0.0f;
|
|
|
}
|
|
}
|
|
|
-extern float foc_observer_sensorless_angle(void);
|
|
|
|
|
|
|
+
|
|
|
void HALL_IRQHandler(void) {
|
|
void HALL_IRQHandler(void) {
|
|
|
g_delta_cnt++;
|
|
g_delta_cnt++;
|
|
|
u32 mask = cpu_enter_critical();
|
|
u32 mask = cpu_enter_critical();
|
|
|
u32 delta_cnt = hall_delta_us(g_hall.edge_ticks);
|
|
u32 delta_cnt = hall_delta_us(g_hall.edge_ticks);
|
|
|
- if (delta_cnt < 300) {
|
|
|
|
|
|
|
+ if (delta_cnt < 200) {
|
|
|
g_hall.noise_errors++;
|
|
g_hall.noise_errors++;
|
|
|
goto hall_end;
|
|
goto hall_end;
|
|
|
}
|
|
}
|