Compare commits

..

No commits in common. '1aa6b1706519b3f54de9bd2d7954109e8c650d8a' and 'b2721c0123ddc24c009afe3c445ce7bb52d48f58' have entirely different histories.

@ -4,9 +4,9 @@ FILES = $(SRCS:%.c=%) #main uart avrIOhelper/io-helper #uart#hier alle c-Datei
MCU = atmega2560
PROGC = m2560
CC = avr-gcc
TOOL = atmelice_isp
#TOOL = atmelice_isp
#TOOL = avrispmkii
#TOOL = usbasp-clone
TOOL = usbasp-clone
BUILDDIR = Builds

@ -25,8 +25,8 @@ typedef struct {
} PID_vars;
#define PID_VARS_INIT(x) PID_vars x = {.Kp=1.3,.Ki=0.00,.Kd=0.0,.output_max=20000.0, \
.output_min=-20000.0,._integral_sum=0.0,._prev_err=0.0,._dt=1.0}
#define PID_VARS_INIT(x) PID_vars x = {.Kp=1.0,.Ki=0.00,.Kd=0.1,.output_max=15000.0, \
.output_min=-15000.0,._integral_sum=0.0,._prev_err=0.0,._dt=1.0}
/* Function Prototypes */
double pid(PID_vars *vars, double current_err);

@ -33,6 +33,7 @@ void timer5_init()
OCR5C = 500;
DDRL |= 1 << 5;
}
void do_spule(){
@ -57,10 +58,6 @@ void do_spule(){
else{
/* speed regulation - keep taenzer at 10% */
int32_t tmp = (100 - (int32_t)taenzer_state.pos/1000)*10;
if(tmp < -75000/abzug_speed/2)
tmp = -75000/abzug_speed/2;
ICR5=75000/abzug_speed + tmp;
OCR5C = ICR5/2;
@ -78,8 +75,6 @@ void do_spule(){
if (read_Input(BTN_INIT, RISING)) {
spule_trans_homed = 0;
taenzer_state.homed = 0;
taenzer_state.active = 0;
}
}
}
@ -87,52 +82,23 @@ void do_spule(){
ISR(TIMER1_OVF_vect) {
if(ioHelperReadBit(outStates, MOTOR_TRANS_DIR)){
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){
ICR1 = ICR5/0.7;
OCR1A = ICR1/2;
//TCCR1B &= ~(_BV(CS11));
//TIMSK5 |= 1<<TOIE5;
printf("front stop\n");
set_Output(MOTOR_TRANS_DIR, 0); // direction: back
}
}
else{
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){
ICR1 = ICR5/0.7;
OCR1A = ICR1/2;
//TCCR1B &= ~(_BV(CS11));
//TIMSK5 |= 1<<TOIE5;
printf("end stop\n");
set_Output(MOTOR_TRANS_DIR, 1); // direction: front
}
}
}
ISR(TIMER5_OVF_vect) {
static int16_t cnt = 0;
cnt++;
if(cnt >= 2*4000){
cnt = 0;
TCCR1B |= _BV(CS11); //TURN ON
TIMSK5 &= ~(1<<TOIE5);
}
}

@ -21,7 +21,6 @@ taenzer_state_t taenzer_state = {
.homed = 0,
.pos = 0,
.force_setpoint = TAENZER_KRAFT_SETPOINT,
.active = 0
};
double pid(PID_vars *vars, double current_err) {
@ -56,8 +55,6 @@ void do_taenzer(){
taenzer_state.pos = 0;
}
if(!taenzer_state.homed && notaus_state == POWER_ON){
ICR4 = 30;
OCR4A = 15;
set_Output(MOTOR_TAENZER_DIR, 1); // direction: up
TCCR4B |= _BV(CS41); //TURN ON
}
@ -74,12 +71,9 @@ void do_taenzer(){
send_info();
#endif
}
if (read_Input(BTN_TAENZER_START, RISING)) {
taenzer_state.active = 1;
}
/* Force regualtion */
if(kraftsensor_valid && taenzer_state.active && taenzer_state.homed && taenzer_state.pos >= 0 && taenzer_state.pos < 500000){
if(kraftsensor_valid && taenzer_state.homed && taenzer_state.pos >= 0 && taenzer_state.pos < 500000){
int16_t err = (kraftsensor_value - taenzer_state.force_setpoint);
double pid_out = pid(&regler, err);

@ -7,7 +7,6 @@ typedef volatile struct {
uint8_t homed;
uint32_t pos;
int16_t force_setpoint;
uint8_t active;
} taenzer_state_t;
extern taenzer_state_t taenzer_state;