From e2fd3f0ffacf0881dc2511f883de2c4d804b4f89 Mon Sep 17 00:00:00 2001 From: Jiri Kubias Date: Sat, 25 Apr 2009 03:29:14 +0200 Subject: [PATCH] eb_lift opravene zajizdeni na nulovou pozici. Asci by t ochtelo nejak v budoucnu opravit. --- src/eb_lift_09/def.h | 1 + src/eb_lift_09/lift.c | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/eb_lift_09/def.h b/src/eb_lift_09/def.h index 2984dd38..e33d48aa 100644 --- a/src/eb_lift_09/def.h +++ b/src/eb_lift_09/def.h @@ -77,6 +77,7 @@ uint8_t init_flag; // init status flag uint32_t p; ///< PI controller constants * 1000 uint32_t last_move_time; ///< Last timer_msec when act_pos changed + bool enable_reg; ///< enable regulator }; extern volatile uint32_t timer_msec; diff --git a/src/eb_lift_09/lift.c b/src/eb_lift_09/lift.c index 30b343ae..b0d533bc 100644 --- a/src/eb_lift_09/lift.c +++ b/src/eb_lift_09/lift.c @@ -402,6 +402,7 @@ void fsm_move(struct fsm *fsm, events my_event){ } fsm->last_move_time = timer_msec; + fsm->enable_reg = 1; // enable re break; case EVENT_DO: @@ -417,7 +418,8 @@ void fsm_move(struct fsm *fsm, events my_event){ fsm->current_state = &fsm_wait; // move to fsm_homing_bw fsm->ans_can = fsm->req_pos; can_send_status(); - PRINT_STR_VAL(fsm->type, "fsm_move: reached endswitch", fsm->req_pos); + PRINT_STR_VAL(fsm->type, "fsm_move: reached endswitch", fsm->req_pos); + // TODO FIXME TODO FIXME TODO FIXME nastavit act_pos =0????? break; } @@ -432,13 +434,14 @@ void fsm_move(struct fsm *fsm, events my_event){ { if(e <= 0 || timer_msec - fsm->last_move_time > 200) { - fsm->set_engine(fsm->motor_dir, 30 /*fsm->speed_normal*/); + fsm->set_engine(fsm->motor_dir, 35 /*fsm->speed_normal*/); + fsm->enable_reg = 0; return; } } - if (e > 0) { + if (e > 0 && fsm->enable_reg ) { /* Go there (P controller)*/ u = e*fsm->p/1000; if (u>100) u = 100; -- 2.39.2