add translatoric axis

master
Eggert Jung 4 years ago
parent 678d40709d
commit 76bca5f039

@ -93,6 +93,7 @@ void ioHelperEdgeDetector(void);
// Schrittmotoren richtung
#define MOTOR_TAENZER_DIR BitPH4
#define MOTOR_TRANS_DIR BitPB6
#define LED_INIT BitPE3
#define LED_ABZUG BitPL6
@ -147,6 +148,8 @@ void ioHelperEdgeDetector(void);
#define BTN_SPULENWECHSEL BitPinK0
#define BTN_INIT BitPinF4
#define IN_TAENZER_HOME BitPinF0
#define IN_SPULE_HOME BitPinF1
#endif

@ -109,6 +109,7 @@ int main()
set_Output(LED_FEHLER, ON);
timer1_init(); //translation
timer3_init(); //abzug
timer4_init(); //taenzer
timer5_init(); //spule

@ -1,6 +1,25 @@
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdio.h>
#include "avrIOhelper/io-helper.h"
int32_t spule_trans_pos = 0;
uint8_t spule_trans_homed = 0;
void timer1_init()
{
TCCR1A |= (1<<COM1A1);
TCCR1B |= _BV(WGM13);
ICR1 = 100;
OCR1A = 50;
DDRB |= 1 << 5;
TIMSK1 |= 1<<TOIE1;
}
void timer5_init()
{
TCCR5A |= (1<<COM5C1);
@ -13,18 +32,56 @@ void timer5_init()
}
void do_spule(){
if (read_Input(BTN_WICKELN_EIN, RISING)) {
TCCR5B |= _BV(CS51); //TURN ON
}
if (read_Input(BTN_WICKELN_AUS, RISING)) {
TCCR5B &= ~(_BV(CS51));
if(read_Input(IN_SPULE_HOME, LEVEL) && spule_trans_homed == 0){
spule_trans_homed = 1;
spule_trans_pos = 0;
TCCR1B &= ~(_BV(CS11));
set_Output(MOTOR_TRANS_DIR, 0); // direction: back
ICR1 = ICR5/0.7;
OCR1A = ICR1/2;
}
if (read_Input(BTN_TAENZER_START, RISING)) {
ICR5-=15;
OCR5C = ICR5/2;
if(!spule_trans_homed){
set_Output(MOTOR_TRANS_DIR, 1); // direction: front
TCCR1B |= _BV(CS11); //TURN ON
}
if (read_Input(BTN_SPULENWECHSEL, RISING)) {
ICR5+=15;
OCR5C = ICR5/2;
else{
if (read_Input(BTN_WICKELN_EIN, RISING)) {
TCCR5B |= _BV(CS51); //TURN ON
TCCR1B |= _BV(CS11); //TURN ON
}
if (read_Input(BTN_WICKELN_AUS, RISING)) {
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;
ICR1 = 100;
OCR1A = 50;
}
}
}
ISR(TIMER1_OVF_vect) {
}
ISR(TIMER5_OVF_vect) {
}

@ -1,6 +1,7 @@
#ifndef _SPULE_H_
#define _SPULE_H_
void timer1_init(void);
void timer5_init(void);
void do_spule(void);