|
|
|
|
@ -10,8 +10,6 @@
|
|
|
|
|
volatile uint16_t windings = 0;
|
|
|
|
|
volatile uint16_t windings_wakeup = 0;
|
|
|
|
|
|
|
|
|
|
volatile uint8_t trans_state = 0;
|
|
|
|
|
|
|
|
|
|
int32_t spule_trans_pos = 0;
|
|
|
|
|
uint8_t spule_trans_homed = 0;
|
|
|
|
|
|
|
|
|
|
@ -82,7 +80,7 @@ void do_spule(){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// manual forwarding if button is held
|
|
|
|
|
else if(!get_abzug_state() || (get_abzug_state() && read_Input(IN_BREMSE_STATE, LEVEL)) ){
|
|
|
|
|
else if(!get_abzug_state()){
|
|
|
|
|
if(read_Input(BTN_WICKELN_EIN, LEVEL)){
|
|
|
|
|
set_spooling_speed(300);
|
|
|
|
|
spule_onoff(1);
|
|
|
|
|
@ -120,13 +118,11 @@ void do_spule(){
|
|
|
|
|
ICR5 = ctrl_speed;
|
|
|
|
|
OCR5C = ICR5/2;
|
|
|
|
|
|
|
|
|
|
if(trans_state != 4)
|
|
|
|
|
ICR1 = ICR5/TRANS_ROT_FACTOR;
|
|
|
|
|
else
|
|
|
|
|
ICR1 = 0.5*(ICR5/TRANS_ROT_FACTOR);
|
|
|
|
|
|
|
|
|
|
ICR1 = ICR5/TRANS_ROT_FACTOR;
|
|
|
|
|
OCR1A = ICR1/2;
|
|
|
|
|
|
|
|
|
|
if (read_Input(BTN_WICKELN_EIN, RISING) && !read_Input(IN_BREMSE_STATE, LEVEL)) {
|
|
|
|
|
if (read_Input(BTN_WICKELN_EIN, RISING)) {
|
|
|
|
|
spule_onoff(1);
|
|
|
|
|
}
|
|
|
|
|
if (read_Input(BTN_WICKELN_AUS, RISING)) {
|
|
|
|
|
@ -140,17 +136,6 @@ void do_spule(){
|
|
|
|
|
windings = 0;
|
|
|
|
|
windings_wakeup = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (read_Input(IN_BREMSE_STATE, FALLING)) {
|
|
|
|
|
printf("draußen\n");
|
|
|
|
|
spule_onoff(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (read_Input(IN_BREMSE_STATE, RISING)) {
|
|
|
|
|
printf("drinne\n");
|
|
|
|
|
spule_onoff(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//PORTH |= (1<<5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -175,8 +160,7 @@ ISR(TIMER5_OVF_vect) {
|
|
|
|
|
windings++;
|
|
|
|
|
steps=0;
|
|
|
|
|
printf("windungen: %d\t", windings);
|
|
|
|
|
printf("trans pos: %ld\n", spule_trans_pos);
|
|
|
|
|
printf("speed %d\n", ICR1);
|
|
|
|
|
printf("trans pos: %ld\n", taenzer_state.pos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(windings == windings_wakeup){
|
|
|
|
|
@ -186,30 +170,23 @@ ISR(TIMER5_OVF_vect) {
|
|
|
|
|
uint8_t windings_on_layer = windings % 25;
|
|
|
|
|
|
|
|
|
|
if(windings_on_layer == 0 && steps == 0){
|
|
|
|
|
trans_state = 1;
|
|
|
|
|
ICR1 = ICR5/TRANS_ROT_FACTOR;
|
|
|
|
|
OCR1A = ICR1/2;
|
|
|
|
|
set_Output(MOTOR_TRANS_DIR, TOGGLE);
|
|
|
|
|
printf("toggle at pos: %ld\n", spule_trans_pos);
|
|
|
|
|
printf("speed %d\n", ICR1);
|
|
|
|
|
}
|
|
|
|
|
if(windings_on_layer == 1 && steps == 0){
|
|
|
|
|
trans_state = 2;
|
|
|
|
|
printf("nachlauf aufbauen\n");
|
|
|
|
|
TCCR1B &= ~(_BV(CS11));
|
|
|
|
|
}
|
|
|
|
|
if(windings_on_layer == 3 && steps == 0){
|
|
|
|
|
trans_state = 3;
|
|
|
|
|
TCCR1B |= _BV(CS11);
|
|
|
|
|
printf("done\n");
|
|
|
|
|
printf("speed %d\n", ICR1);
|
|
|
|
|
}
|
|
|
|
|
if(windings_on_layer == 21 && steps == 0){
|
|
|
|
|
trans_state = 4;
|
|
|
|
|
ICR1 = 0.5*(ICR5/TRANS_ROT_FACTOR);
|
|
|
|
|
OCR1A = ICR1/2;
|
|
|
|
|
printf("nachlauf abbauen\n");
|
|
|
|
|
printf("speed %d\n", ICR1);
|
|
|
|
|
}
|
|
|
|
|
//;PORTH |= (1<<5);
|
|
|
|
|
}
|
|
|
|
|
|