summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Tittelbach <xro@realraum.at>2013-10-17 00:22:11 +0000
committerBernhard Tittelbach <xro@realraum.at>2013-10-17 00:22:11 +0000
commitd0ebfde5e1fa3b3680541f133127c840e72e6bc0 (patch)
tree1654d15b2e19572da0c2a0f1c7f64db3d8a7c8b7
parentvarious bugfixes and improvements + documentation (diff)
run over limit to avoid wrong manual movement detection
git-svn-id: https://svn.spreadspace.org/avr/trunk@246 aa12f405-d877-488e-9caf-2d797e2a1cc7
-rw-r--r--tuer-rfid/stepper.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/tuer-rfid/stepper.c b/tuer-rfid/stepper.c
index 5ee5943..aceca66 100644
--- a/tuer-rfid/stepper.c
+++ b/tuer-rfid/stepper.c
@@ -57,7 +57,7 @@ uint8_t step_table [] =
volatile uint16_t step_cnt = 0;
#define STEP_CNT_STOP (LENGTH_STEP_TABLE*172)
-#define STEP_CNT_OFF (STEP_CNT_STOP + 100)
+#define STEP_CNT_STOP_PLUS_EXTRA (STEP_CNT_STOP + (LENGTH_STEP_TABLE*20))
stepper_direction_t step_direction = dir_open;
inline void stepper_stop(void)
@@ -79,6 +79,8 @@ static inline uint8_t stepper_handle(void)
uint8_t stepper_output = step_table[step_idx];
stepper_output <<= STEPPER_FIRST_BIT;
STEPPER_PORT = (STEPPER_PORT & STEPPER_OUTPUT_BITMASK ) | stepper_output;
+ step_idx += (step_direction == dir_open) ? 1 : -1;
+ step_idx %= LENGTH_STEP_TABLE;
if(step_cnt < STEP_CNT_STOP) {
limits_t l = limits_get();
@@ -86,18 +88,16 @@ static inline uint8_t stepper_handle(void)
(step_direction == dir_close && l == close) || l == both)
step_cnt = STEP_CNT_STOP + 1;
- step_idx += (step_direction == dir_open) ? 1 : -1;
- step_idx %= LENGTH_STEP_TABLE;
} else if(step_cnt == STEP_CNT_STOP) {
eventqueue_push(move_timeout);
- return 0;
+ return 0; //stop
}
step_cnt++;
- if(step_cnt >= STEP_CNT_OFF)
- return 0;
+ if(step_cnt >= STEP_CNT_STOP_PLUS_EXTRA)
+ return 0; //stop
- return 1;
+ return 1; // continue running
}
void stepper_init(void)