add nachlaufwinkel
This commit is contained in:
37
spule.c
37
spule.c
@@ -87,23 +87,52 @@ void do_spule(){
|
|||||||
ISR(TIMER1_OVF_vect) {
|
ISR(TIMER1_OVF_vect) {
|
||||||
if(ioHelperReadBit(outStates, MOTOR_TRANS_DIR)){
|
if(ioHelperReadBit(outStates, MOTOR_TRANS_DIR)){
|
||||||
spule_trans_pos -= 1;
|
spule_trans_pos -= 1;
|
||||||
|
if(spule_trans_homed && spule_trans_pos == 84999){
|
||||||
|
TCCR1B &= ~(_BV(CS11));
|
||||||
|
TIMSK5 |= 1<<TOIE5;
|
||||||
|
printf("nachlauf aufbauen");
|
||||||
|
}
|
||||||
|
if(spule_trans_homed && spule_trans_pos == 4*3540){
|
||||||
|
ICR1 = 0.5*(ICR5/0.7);
|
||||||
|
OCR1A = ICR1/2;
|
||||||
|
printf("nachlauf abbauen");
|
||||||
|
}
|
||||||
if(spule_trans_homed && spule_trans_pos <= 0){
|
if(spule_trans_homed && spule_trans_pos <= 0){
|
||||||
//TCCR1B &= ~(_BV(CS11));
|
ICR1 = ICR5/0.7;
|
||||||
//TIMSK5 |= 1<<TOIE5;
|
OCR1A = ICR1/2;
|
||||||
printf("front stop\n");
|
printf("front stop\n");
|
||||||
set_Output(MOTOR_TRANS_DIR, 0); // direction: back
|
set_Output(MOTOR_TRANS_DIR, 0); // direction: back
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
spule_trans_pos += 1;
|
spule_trans_pos += 1;
|
||||||
|
if(spule_trans_homed && spule_trans_pos == 3540){
|
||||||
|
TCCR1B &= ~(_BV(CS11));
|
||||||
|
TIMSK5 |= 1<<TOIE5;
|
||||||
|
printf("nachlauf aufbauen");
|
||||||
|
}
|
||||||
|
if(spule_trans_homed && spule_trans_pos == (85000 - (4*3540)) ){
|
||||||
|
ICR1 = 0.5*(ICR5/0.7);
|
||||||
|
OCR1A = ICR1/2;
|
||||||
|
printf("nachlauf abbauen");
|
||||||
|
}
|
||||||
if(spule_trans_pos >= 85000){
|
if(spule_trans_pos >= 85000){
|
||||||
//TCCR1B &= ~(_BV(CS11));
|
ICR1 = ICR5/0.7;
|
||||||
//TIMSK5 |= 1<<TOIE5;
|
OCR1A = ICR1/2;
|
||||||
printf("end stop\n");
|
printf("end stop\n");
|
||||||
set_Output(MOTOR_TRANS_DIR, 1); // direction: front
|
set_Output(MOTOR_TRANS_DIR, 1); // direction: front
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ISR(TIMER5_OVF_vect) {
|
ISR(TIMER5_OVF_vect) {
|
||||||
|
static int16_t cnt = 0;
|
||||||
|
cnt++;
|
||||||
|
|
||||||
|
if(cnt >= 2*4000){
|
||||||
|
cnt = 0;
|
||||||
|
TCCR1B |= _BV(CS11); //TURN ON
|
||||||
|
TIMSK5 &= ~(1<<TOIE5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user