Kann mir bitte wiedermal jemand weiterhelfen?
Ich benutze den BLDC-Code von Ulrich Radig, was soweit super läuft.
Allerdings würde ich gerne die Drehrichtung ändern können.
Eigentlich müsste es doch reichen, die Zuordnungen in der Switch-Case
Anwendung zu tauschen. Also case(0) wird zu case(5), case(1) zu case(4)
usw., dachte ich jedenfalls. Der Motor ruckelt zwar in die andere
Richtung los, aber mehr auch nicht. Und die Treiber werden verdammt
heiß.
Wo ist mein Denkfehler?
Hier mal der orginale Ausschnitt ohne meine Änderung:
1 | void next_commutate_state (unsigned char startup)
|
2 |
|
3 | {
|
4 |
|
5 | switch (rotor_state)
|
6 | {
|
7 | case (0):
|
8 | if(!SENSE_H || startup)
|
9 | {
|
10 | WH_OFF;
|
11 | UH_ON;
|
12 | SENSE_W;
|
13 | rotor_state = 1;
|
14 | TCNT1 = 1;
|
15 | }
|
16 | break;
|
17 |
|
18 | case (1):
|
19 | if(SENSE_H || startup)
|
20 | {
|
21 | VL_OFF;
|
22 | WL_ON;
|
23 | SENSE_V;
|
24 | rotor_state = 2;
|
25 | TCNT1 = 1;
|
26 | }
|
27 | break;
|
28 |
|
29 | case (2):
|
30 | if(!SENSE_H || startup)
|
31 | {
|
32 | UH_OFF;
|
33 | VH_ON;
|
34 | SENSE_U;
|
35 | rotor_state = 3;
|
36 | TCNT1 = 1;
|
37 | }
|
38 | break;
|
39 |
|
40 | case (3):
|
41 | if(SENSE_H || startup)
|
42 | {
|
43 | WL_OFF;
|
44 | UL_ON;
|
45 | SENSE_W;
|
46 | rotor_state = 4;
|
47 | TCNT1 = 1;
|
48 | }
|
49 | break;
|
50 |
|
51 | case (4):
|
52 | if(!SENSE_H || startup)
|
53 | {
|
54 | VH_OFF;
|
55 | WH_ON;
|
56 | SENSE_V;
|
57 | rotor_state = 5;
|
58 | TCNT1 = 1;
|
59 | }
|
60 | break;
|
61 |
|
62 | case (5):
|
63 | if(SENSE_H || startup)
|
64 | {
|
65 | UL_OFF;
|
66 | VL_ON;
|
67 | SENSE_U;
|
68 | rotor_state = 0;
|
69 | TCNT1 = 1;
|
70 | }
|
71 | break;
|
72 | }
|
73 |
|
74 | }
|