diff --git a/spule.c b/spule.c index 92f119f..0e40ad0 100644 --- a/spule.c +++ b/spule.c @@ -7,6 +7,8 @@ #include "taenzer.h" #include "abzug.h" +volatile uint16_t windings = 0; +volatile uint16_t windings_wakeup = 0; int32_t spule_trans_pos = 0; uint8_t spule_trans_homed = 0; @@ -33,6 +35,7 @@ void timer5_init() OCR5C = 500; DDRL |= 1 << 5; + TIMSK5 |= 1<= 85000){ - ICR1 = ICR5/0.7; - OCR1A = ICR1/2; - printf("end stop\n"); - set_Output(MOTOR_TRANS_DIR, 1); // direction: front - } } - + //TODO keep track if position stays in bounds } ISR(TIMER5_OVF_vect) { - static int16_t cnt = 0; - cnt++; + static uint16_t steps = 0; + steps++; + if(steps == 5000){ + windings++; + steps=0; + printf("windungen: %d\n", windings); + } - if(cnt >= 2*4000){ - cnt = 0; - TCCR1B |= _BV(CS11); //TURN ON - TIMSK5 &= ~(1<