Code-Work :)
This commit is contained in:
parent
c6ec20e5e7
commit
7393d1d12c
8 changed files with 1247 additions and 1179 deletions
|
@ -31,13 +31,13 @@ Board::Board() {
|
|||
DDRG = (1 << PG0) | (1 << PG1) | (1 << PG2) | (1 << PG3) | (1 << PG4);
|
||||
PORTG = (1 << PG0) | (1 << PG1);
|
||||
|
||||
// aktiviere Kanal A+C auf PWM1 mit 8Bit
|
||||
//TCCR1A = (1<< COM1A1) | (1<< COM1C1) | (1<< WGM10);
|
||||
//TCCR1B = (1<<ICNC1) | (1<<CS12) | (1<<CS10); // set clock/prescaler 1/1024 -> enable counter
|
||||
// aktiviere Kanal A+B auf PWM1 mit 8Bit
|
||||
TCCR1A = (1<< COM1A1) | (1<< COM1B1) | (1<< WGM10);
|
||||
TCCR1B = (1<<ICNC1) | (1<<CS12) | (1<<CS10); // set clock/prescaler 1/1024 -> enable counter
|
||||
|
||||
// aktiviere Kanal A+B auf PWM3 mit 8Bit
|
||||
//TCCR3A = (1<< COM3A1) | (1<< COM3B1) | (1<< WGM10);
|
||||
//TCCR3B = (1<<ICNC3) | (1<<CS32) | (1<<CS30); // set clock/prescaler 1/1024 -> enable counter
|
||||
TCCR3A = (1<< COM3A1) | (1<< COM3B1) | (1<< WGM10);
|
||||
TCCR3B = (1<<ICNC3) | (1<<CS32) | (1<<CS30); // set clock/prescaler 1/1024 -> enable counter
|
||||
|
||||
// Schalte Motoren auf 0
|
||||
motor(0,0);
|
||||
|
@ -45,6 +45,10 @@ Board::Board() {
|
|||
motor(2,0);
|
||||
motor(3,0);
|
||||
|
||||
// Kicker-richtung einstellen
|
||||
PORTE &= ~(1 << PE6); // Pin2 low
|
||||
PORTA |= (1 << PA2); // Pin1 high
|
||||
|
||||
// Uart-Interface einschalten
|
||||
uart1_init( 10); // 9600 BAUD bei 16MHz Atmel
|
||||
|
||||
|
@ -198,27 +202,35 @@ void Board::motor(int i, int speed)
|
|||
MOTOR2_PORT |= MOTOR2_A;//In 1 ein
|
||||
}
|
||||
}
|
||||
else if(i == 3)
|
||||
else if(i == 3) // Dribbler... hier haben wir kein PWM
|
||||
{
|
||||
DRIBBLER_PWM = pwm;
|
||||
if(speed > 0)
|
||||
{
|
||||
DRIBBLER_PORT |= DRIBBLER_A;//In 1 ein
|
||||
DRIBBLER_PORT &= ~DRIBBLER_B;//In 2 aus
|
||||
DRIBBLER_PWMPORT |= DRIBBLER_PWM;
|
||||
}
|
||||
else if(speed < 0)
|
||||
{
|
||||
DRIBBLER_PORT |= DRIBBLER_B;//In 2 ein
|
||||
DRIBBLER_PORT &= ~DRIBBLER_A;//In 1 aus
|
||||
DRIBBLER_PWMPORT |= DRIBBLER_PWM;
|
||||
}
|
||||
else
|
||||
{
|
||||
DRIBBLER_PORT |= DRIBBLER_B;//In 2 ein
|
||||
DRIBBLER_PORT |= DRIBBLER_A;//In 1 ein
|
||||
DRIBBLER_PWMPORT &= ~DRIBBLER_PWM;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Board::kicker() {
|
||||
KICKER_AN
|
||||
usleep(KICKER_USLEEP);
|
||||
KICKER_AUS
|
||||
}
|
||||
|
||||
//PWM routine für den Beeper
|
||||
ISR (TIMER0_OVF_vect)
|
||||
{
|
||||
|
|
|
@ -11,26 +11,33 @@
|
|||
|
||||
#define BEEPER_PIN PG2
|
||||
|
||||
// Definiere Konstanten für die Motoren/Dribbler
|
||||
#define MOTOR0_PORT PORTD
|
||||
#define MOTOR0_PWM OCR3A
|
||||
#define MOTOR0_A (1 << 5)
|
||||
#define MOTOR0_B (1 << 4)
|
||||
// Definiere Konstanten für die Motoren/Dribbler
|
||||
#define MOTOR0_PORT PORTB
|
||||
#define MOTOR0_PWM OCR1A
|
||||
#define MOTOR0_A (1 << 0)
|
||||
#define MOTOR0_B (1 << 1)
|
||||
|
||||
#define MOTOR1_PORT PORTD
|
||||
#define MOTOR1_PWM OCR3B
|
||||
#define MOTOR1_A (1 << 6)
|
||||
#define MOTOR1_B (1 << 7)
|
||||
#define MOTOR1_PORT PORTB
|
||||
#define MOTOR1_PWM OCR1B
|
||||
#define MOTOR1_A (1 << 2)
|
||||
#define MOTOR1_B (1 << 3)
|
||||
|
||||
#define MOTOR2_PORT PORTB
|
||||
#define MOTOR2_PWM OCR1A
|
||||
#define MOTOR2_A (1 << 0)
|
||||
#define MOTOR2_B (1 << 1)
|
||||
#define MOTOR2_PORT PORTD
|
||||
#define MOTOR2_PWM OCR3A
|
||||
#define MOTOR2_A (1 << 5)
|
||||
#define MOTOR2_B (1 << 4)
|
||||
|
||||
#define DRIBBLER_PORT PORTB
|
||||
#define DRIBBLER_PWM OCR1C
|
||||
#define DRIBBLER_A (1 << 2)
|
||||
#define DRIBBLER_B (1 << 3)
|
||||
#define DRIBBLER_PORT PORTD
|
||||
#define DRIBBLER_PWMPORT PORTA
|
||||
#define DRIBBLER_PWM (1 << 5)
|
||||
#define DRIBBLER_A (1 << 6)
|
||||
#define DRIBBLER_B (1 << 7)
|
||||
|
||||
// Kicker
|
||||
#define KICKER_AN PORTG |= (1 << PG3);
|
||||
#define KICKER_AUS PORTG &= ~(1 << PG3);
|
||||
#define KICKER_USLEEP 10
|
||||
|
||||
|
||||
// Definiere Konstanten für Abstandsensoren
|
||||
#define ABSTAND_PORT PORTC
|
||||
|
@ -54,6 +61,7 @@ public:
|
|||
void ledOff();
|
||||
void led(bool status);
|
||||
void motor(int i, int speed);
|
||||
void kicker();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Reference in a new issue