make spooling speed controled instead of manual

master
Eggert Jung 4 years ago
parent c4181a27e2
commit 721689c525

@ -1,8 +1,12 @@
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
#include <stdio.h>
#include "avrIOhelper/io-helper.h"
#include "taenzer.h"
#include "abzug.h"
int32_t spule_trans_pos = 0;
uint8_t spule_trans_homed = 0;
@ -50,6 +54,14 @@ void do_spule(){
TCCR1B |= _BV(CS11); //TURN ON
}
else{
/* speed regulation - keep taenzer at 10% */
int32_t tmp = (100 - (int32_t)taenzer_state.pos/1000)*10;
ICR5=75000/abzug_speed + tmp;
OCR5C = ICR5/2;
ICR1 = ICR5/0.7;
OCR1A = ICR1/2;
if (read_Input(BTN_WICKELN_EIN, RISING)) {
TCCR5B |= _BV(CS51); //TURN ON
TCCR1B |= _BV(CS11); //TURN ON
@ -58,20 +70,6 @@ void do_spule(){
TCCR5B &= ~(_BV(CS51));
TCCR1B &= ~(_BV(CS11));
}
if (read_Input(BTN_TAENZER_START, RISING)) {
ICR5-=15;
OCR5C = ICR5/2;
ICR1 = ICR5/0.7;
OCR1A = ICR1/2;
}
if (read_Input(BTN_SPULENWECHSEL, RISING)) {
ICR5+=15;
OCR5C = ICR5/2;
ICR1 = ICR5/0.7;
OCR1A = ICR1/2;
}
if (read_Input(BTN_INIT, RISING)) {
spule_trans_homed = 0;