fix spooling bug
This commit is contained in:
12
spule.c
12
spule.c
@@ -10,6 +10,8 @@
|
|||||||
volatile uint16_t windings = 0;
|
volatile uint16_t windings = 0;
|
||||||
volatile uint16_t windings_wakeup = 0;
|
volatile uint16_t windings_wakeup = 0;
|
||||||
|
|
||||||
|
volatile uint8_t trans_state = 0;
|
||||||
|
|
||||||
int32_t spule_trans_pos = 0;
|
int32_t spule_trans_pos = 0;
|
||||||
uint8_t spule_trans_homed = 0;
|
uint8_t spule_trans_homed = 0;
|
||||||
|
|
||||||
@@ -118,8 +120,10 @@ void do_spule(){
|
|||||||
ICR5 = ctrl_speed;
|
ICR5 = ctrl_speed;
|
||||||
OCR5C = ICR5/2;
|
OCR5C = ICR5/2;
|
||||||
|
|
||||||
|
if(trans_state != 4)
|
||||||
ICR1 = ICR5/TRANS_ROT_FACTOR;
|
ICR1 = ICR5/TRANS_ROT_FACTOR;
|
||||||
|
else
|
||||||
|
ICR1 = 0.5*(ICR5/TRANS_ROT_FACTOR);
|
||||||
OCR1A = ICR1/2;
|
OCR1A = ICR1/2;
|
||||||
|
|
||||||
if (read_Input(BTN_WICKELN_EIN, RISING) && !read_Input(IN_BREMSE_STATE, LEVEL)) {
|
if (read_Input(BTN_WICKELN_EIN, RISING) && !read_Input(IN_BREMSE_STATE, LEVEL)) {
|
||||||
@@ -181,20 +185,24 @@ ISR(TIMER5_OVF_vect) {
|
|||||||
uint8_t windings_on_layer = windings % 25;
|
uint8_t windings_on_layer = windings % 25;
|
||||||
|
|
||||||
if(windings_on_layer == 0 && steps == 0){
|
if(windings_on_layer == 0 && steps == 0){
|
||||||
|
trans_state = 1;
|
||||||
ICR1 = ICR5/TRANS_ROT_FACTOR;
|
ICR1 = ICR5/TRANS_ROT_FACTOR;
|
||||||
OCR1A = ICR1/2;
|
OCR1A = ICR1/2;
|
||||||
set_Output(MOTOR_TRANS_DIR, TOGGLE);
|
set_Output(MOTOR_TRANS_DIR, TOGGLE);
|
||||||
printf("toggle at pos: %ld\n", spule_trans_pos);
|
printf("toggle at pos: %ld\n", spule_trans_pos);
|
||||||
}
|
}
|
||||||
if(windings_on_layer == 1 && steps == 0){
|
if(windings_on_layer == 1 && steps == 0){
|
||||||
|
trans_state = 2;
|
||||||
printf("nachlauf aufbauen\n");
|
printf("nachlauf aufbauen\n");
|
||||||
TCCR1B &= ~(_BV(CS11));
|
TCCR1B &= ~(_BV(CS11));
|
||||||
}
|
}
|
||||||
if(windings_on_layer == 3 && steps == 0){
|
if(windings_on_layer == 3 && steps == 0){
|
||||||
|
trans_state = 3;
|
||||||
TCCR1B |= _BV(CS11);
|
TCCR1B |= _BV(CS11);
|
||||||
printf("done\n");
|
printf("done\n");
|
||||||
}
|
}
|
||||||
if(windings_on_layer == 21 && steps == 0){
|
if(windings_on_layer == 21 && steps == 0){
|
||||||
|
trans_state = 4;
|
||||||
ICR1 = 0.5*(ICR5/TRANS_ROT_FACTOR);
|
ICR1 = 0.5*(ICR5/TRANS_ROT_FACTOR);
|
||||||
OCR1A = ICR1/2;
|
OCR1A = ICR1/2;
|
||||||
printf("nachlauf abbauen\n");
|
printf("nachlauf abbauen\n");
|
||||||
|
|||||||
5
spule.h
5
spule.h
@@ -1,8 +1,13 @@
|
|||||||
#ifndef _SPULE_H_
|
#ifndef _SPULE_H_
|
||||||
#define _SPULE_H_
|
#define _SPULE_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
void timer1_init(void);
|
void timer1_init(void);
|
||||||
void timer5_init(void);
|
void timer5_init(void);
|
||||||
void do_spule(void);
|
void do_spule(void);
|
||||||
|
|
||||||
|
extern volatile uint16_t windings;
|
||||||
|
extern int32_t spule_trans_pos;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user