Hallo,
ich habe ein Arduino Uno, an dem 4 Motoren angeschlossen sind.
Dabei werden immer zwei über einen Motortreiber DRV8837 angesteuert.
1 | Motor1 und Motor2 sind immer identisch
|
2 | Motor3 und Motor4 sind immer identisch
|
1 | PD3 -> Ein-/Ausschalten Motor3 und Motor4
|
2 | PD4 -> Ein-/Ausschalten Motor1 und Motor2
|
3 | PD5 -> PWM Motor3 und Motor4
|
4 | PD6 -> PWM Motor1 und Motor2
|
1 | DDRD |= ((1 << PIND3) | (1 << PIND4)); // set PD3, PD4 to output
|
2 | DDRD |= ((1 << PIND5) | (1 << PIND6)); // set OC0A(PD5), OC0B(PD6) to output
|
3 |
|
4 | PORTD &= ~((1 << PIND3) | (1 << PIND4)); // set PD3, PD4 to low
|
5 |
|
6 | /*
|
7 | * WGM01; WGM00: FastPWM -> TOP:0xFF; Update of OCRx at: BOTTOM; TOV Flag Set on: MAX
|
8 | * COM0A1: Clear OC0A on compare match
|
9 | * COM0B1: Coear OC0B on compare match, set OC0B at BOTTOM (non inverting mode)
|
10 | */
|
11 | TCCR0A |= ((1 << COM0A1) | (1 << COM0B1) | (1 << WGM01) | (1 << WGM00));
|
12 |
|
13 | TCCR0B |= (1 << CS01); // clk i/o / 8 (from prescaler)
|
14 |
|
15 | OCR0A = 128-1; // initialize compare value
|
16 | OCR0B = 128-1; // initialize compare value
|
17 |
|
18 | PORTD |= ((1 << PIND3) | (1 << PIND4)); // set PD3, PD4 to high -> Start
|
eigentlich sollten jetzt alle Motoren drehen, doch alles bleibt still.
Habe ich was mit dem PWM falsch gemacht?