Hi,
ich versuche mit einem NodeMCU ESP8266 einen DRV8316REVM anzusteuern und
nutze hierzu die Arduino-IDE. In meinem Code generiere ich sinussignale,
die ich als PWM-Signal ausgebe. Ich habe 3 LEDs angeschlossen, die auch
ihre helligkeit verändern, aber nach ein paar Zyklen bleibt die
helligkeit der drei LEDs konstant und ich glaube, dass das Programm neu
gestartet wird.
Hier ist mein bisheriger Code:
1 | #include <math.h>
| 2 | #include <Ticker.h>
| 3 |
| 4 | const int sinTableLength = 256;
| 5 | const float pi = 3.14159;
| 6 | const int pwmPin_U = D1;
| 7 | const int pwmPin_V = D2;
| 8 | const int pwmPin_W = D3;
| 9 | const int pwmFrequency = 1000; // PWM-Frequenz in Hertz
| 10 |
| 11 | int sinTable[sinTableLength];
| 12 | volatile int pwmIndex = 0; // Index der Sinustabelle
| 13 | Ticker ticker;
| 14 |
| 15 | void setup() {
| 16 |
| 17 | Serial.begin(115200);
| 18 |
| 19 | for (int i = 0; i < sinTableLength; i++) {
| 20 | float radian = (float)i / sinTableLength * 2 * pi;
| 21 | sinTable[i] = round(sin(radian) * 127.0 + 128); // Skalierung auf den Bereich von 0 bis 255
| 22 | }
| 23 |
| 24 | pinMode(pwmPin_U, OUTPUT);
| 25 | pinMode(pwmPin_V, OUTPUT);
| 26 | pinMode(pwmPin_W, OUTPUT);
| 27 | analogWriteFreq(pwmFrequency);
| 28 |
| 29 | // Ticker einrichten
| 30 | ticker.attach_ms(1000 / pwmFrequency, updatePWM); // Timer für die PWM-Aktualisierung einrichten
| 31 | }
| 32 |
| 33 | void loop() {
| 34 | }
| 35 |
| 36 | void updatePWM() {
| 37 | // LEDs entsprechend der Sinustabelle steuern
| 38 | analogWrite(pwmPin_U, sinTable[pwmIndex]);
| 39 | //Serial.println(pwmPin_U);
| 40 | analogWrite(pwmPin_V, sinTable[(pwmIndex + 85) % 256]);
| 41 | //Serial.println(pwmPin_V);
| 42 | analogWrite(pwmPin_W, sinTable[(pwmIndex + 170) % 256]);
| 43 | //Serial.println(pwmPin_W);
| 44 | pwmIndex = (pwmIndex + 1) % 256;
| 45 | // Serial.println("pwmIndex: ");
| 46 | }
|
Im Serial-Monitor wird dann folgendes ausgegeben: 1 | 18:04:58.830 -> 3ffffe50: feefeffe feefeffe feefeffe feefeffe
| 2 | 18:04:58.830 -> 3ffffe60: feefeffe feefeffe feefeffe feefeffe
| 3 | 18:04:58.830 -> 3ffffe70: feefeffe feefeffe feefeffe feefeffe
| 4 | 18:04:58.830 -> 3ffffe80: 00000000 00000000 0000001f 4010015c
| 5 | 18:04:58.830 -> 3ffffe90: feefeffe feefeffe 3fffc228 40105f45
| 6 | 18:04:58.862 -> 3ffffea0: 4000050c feefeffe feefeffe feefeffe
| 7 | 18:04:58.862 -> 3ffffeb0: 40201bfd 00000030 00000017 ffffffff
| 8 | 18:04:58.862 -> 3ffffec0: 40201bfd 00000050 3fffc704 00000000
| 9 | 18:04:58.862 -> 3ffffed0: 00000000 00000000 00000000 fffffffe
| 10 | 18:04:58.862 -> 3ffffee0: ffffffff 3fffc6fc 00000001 3fffdab0
| 11 | 18:04:58.862 -> 3ffffef0: 00000000 3fffdad0 3ffeeda8 00000030
| 12 | 18:04:58.862 -> 3fffff00: 40202cf1 00000001 00000020 40100a10
| 13 | 18:04:58.894 -> 3fffff10: 40203038 00000001 0000001c 40202f5e
| 14 | 18:04:58.894 -> 3fffff20: 3fffff70 40c846c0 00000004 bcc8c000
| 15 | 18:04:58.894 -> 3fffff30: 40105e05 00003e9f 2faecded af060000
| 16 | 18:04:58.894 -> 3fffff40: 40105eb2 3ffee458 00003e9f 00000000
| 17 | 18:04:58.894 -> 3fffff50: 40106089 00003e9f 3ffee908 00000000
| 18 | 18:04:58.894 -> 3fffff60: 3ffee480 3ffee908 000000ff 4020b0f0
| 19 | 18:04:58.894 -> 3fffff70: 00000001 00003d67 4020120f 3ffee8e8
| 20 | 18:04:58.928 -> 3fffff80: 00000000 3fffdad0 3ffeeda8 4020120f
| 21 | 18:04:58.928 -> 3fffff90: feefeffe feefeffe feefeffe 3ffeeda8
| 22 | 18:04:58.928 -> 3fffffa0: 3fffdad0 00000000 3ffeed94 3ffeeda8
| 23 | 18:04:58.928 -> <<<stack<<<
| 24 | 18:04:58.928 ->
| 25 | 18:04:58.928 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
| 26 | 18:04:58.928 ->
| 27 | 18:04:58.928 -> ets Jan 8 2013,rst cause:2, boot mode:(3,6)
| 28 | 18:04:58.977 ->
| 29 | 18:04:58.977 -> load 0x4010f000, len 3424, room 16
| 30 | 18:04:58.977 -> tail 0
| 31 | 18:04:58.977 -> chksum 0x2e
| 32 | 18:04:58.977 -> load 0x3fff20b8, len 40, room 8
| 33 | 18:04:58.977 -> tail 0
| 34 | 18:04:58.977 -> chksum 0x2b
| 35 | 18:04:58.977 -> csum 0x2b
| 36 | 18:04:58.977 -> v00044080
| 37 | 18:04:58.977 -> ~ld
| 38 | 18:04:59.010 -> ��n�r��n|�l�l`bbrl�nb�nl`�rl�l��
|
Hat jemand eine Idee, was falsch ist und bin ich hier auf dem richtigen
Weg ?
Danke...
Warum so kompliziert mit floats, wenn du dann doch wieder die PWM damit
beschreibst?
Hinterlege die Sinustabelle im Flash und lies sie direkt aus, um die PWM
damit zu beschreiben.
Eine 3-Phasen Tabelle kannst du aus meinem FU-Projekt plündern oder du
lässt dir eine Phase im Internet errechnen:
https://www.mikrocontroller.net/articles/3-Phasen_Frequenzumrichter_mit_AVR
https://www.daycounter.com/Calculators/Sine-Generator-Calculator.phtml
https://deepbluembedded.com/sine-lookup-table-generator-calculator/
Beachte dabei, das mein Projekt zwei verschiedene Kurven unterstützt.
Einmal puren Sinus und einmal die für BLDC besseren 'Popokurven'.
Die Sinus Generatoren im Netz machen immer puren Sinus.
Matthias S. schrieb:
> Warum so kompliziert mit floats, wenn du dann doch wieder die PWM damit
> beschreibst?
> Hinterlege die Sinustabelle im Flash und lies sie direkt aus, um die PWM
> damit zu beschreiben.
> Eine 3-Phasen Tabelle kannst du aus meinem FU-Projekt plündern oder du
> lässt dir eine Phase im Internet errechnen:
> https://www.mikrocontroller.net/articles/3-Phasen_Frequenzumrichter_mit_AVR
>
> https://www.daycounter.com/Calculators/Sine-Generator-Calculator.phtml
>
> https://deepbluembedded.com/sine-lookup-table-generator-calculator/
>
> Beachte dabei, das mein Projekt zwei verschiedene Kurven unterstützt.
> Einmal puren Sinus und einmal die für BLDC besseren 'Popokurven'.
> Die Sinus Generatoren im Netz machen immer puren Sinus.
Vielen Dank für die Hilfe. Ich habe den Code so angepasst, dass es für
U, V und W ein eigenes Array gibt (120° verschoben). Hier ist der neue
Code:
1 | #include <math.h>
| 2 | #include <Ticker.h>
| 3 | #include <string.h>
| 4 |
| 5 | const int pwmPin_U = D2;
| 6 | const int pwmPin_V = D3;
| 7 | const int pwmPin_W = D4;
| 8 | const int pwmFrequency = 100; // PWM-Frequenz in Hertz
| 9 |
| 10 | int u, v, w;
| 11 |
| 12 | const uint16_t sinTable_U[] = {
| 13 | 128, 131, 134, 137, 140, 143, 146, 149, 152, 156, 159, 162, 165, 168, 171, 174, 176, 179, 182, 185, 188, 191, 193, 196, 199, 201, 204, 206, 209, 211, 213, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 235, 237, 239, 240, 242, 243, 244, 246, 247, 248, 249, 250, 251, 251, 252, 253, 253, 254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 254, 254, 253, 253, 252, 252, 251, 250, 249, 248, 247, 246, 245, 244, 242, 241, 239, 238, 236, 235, 233, 231, 229, 227, 225, 223, 221, 219, 217, 215, 212, 210, 207, 205, 202, 200, 197, 195, 192, 189, 186, 184, 181, 178, 175, 172, 169, 166, 163, 160, 157, 154, 151, 148, 145, 142, 138, 135, 132, 129, 126, 123,
| 14 | 120, 117, 113, 110, 107, 104, 101, 98, 95, 92, 89, 86, 83, 80, 77, 74, 71, 69, 66, 63, 60, 58, 55, 53, 50, 48, 45, 43, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 19, 17, 16, 14, 13, 11, 10, 9, 8, 7, 6, 5, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 9, 11, 12, 13, 15, 16, 18, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 42, 44, 46, 49, 51, 54, 56, 59, 62, 64, 67, 70, 73, 76, 79, 81, 84, 87, 90, 93, 96, 99, 103, 106, 109, 112, 115, 118, 121, 124};
| 15 |
| 16 | const uint16_t sinTable_V[] = {
| 17 | 207, 210, 212, 214, 217, 219, 221, 223, 225, 227, 229, 231, 233, 235, 237, 238, 240, 241, 243, 244, 245, 247, 248, 249, 250, 251, 252, 252, 253, 254, 254, 255, 255, 255, 256, 256, 256, 256, 256, 256, 256, 255, 255, 254, 254, 253, 253, 252, 251, 250, 249, 248, 247, 246, 245, 243, 242, 240, 239, 237, 235, 234, 232, 230, 228, 226, 224, 222, 220, 218, 215, 213, 211, 208, 206, 203, 201, 198, 195, 193, 190, 187, 184, 181, 178, 176, 173, 170, 167, 164, 161, 158, 154, 151, 148, 145, 142, 139, 136, 133, 129, 126, 123, 120, 117, 114, 111, 107, 104, 101, 98, 95, 92, 89, 86, 83, 80, 77, 74, 71, 69, 66, 63, 60, 58, 55, 53, 50, 48, 45, 43, 40, 38, 36, 34, 32, 30, 28, 26, 24,
| 18 | 22, 20, 19, 17, 16, 14, 13, 11, 10, 9, 8, 7, 6, 5, 4, 3, 3, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 10, 11, 12, 13, 15, 16, 18, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37, 40, 42, 44, 47, 49, 52, 54, 57, 59, 62, 65, 68, 70, 73, 76, 79, 82, 85, 88, 91, 94, 97, 100, 103, 106, 109, 112, 116, 119, 122, 125, 128, 131, 134, 138, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, 189, 191, 194, 197, 200, 202, 205 };
| 19 |
| 20 |
| 21 | const uint16_t sinTable_W[] = {
| 22 | 252, 253, 254, 254, 255, 255, 255, 256, 256, 256, 256, 256, 256, 256, 255, 255, 254, 254, 253, 253, 252, 251, 250, 249, 248, 247, 246, 244, 243, 242, 240, 239, 237, 235, 234, 232, 230, 228, 226, 224, 222, 220, 217, 215, 213, 210, 208, 205, 203, 200, 198, 195, 192, 190, 187, 184, 181, 178, 175, 172, 169, 166, 163, 160, 157, 154, 151, 148, 145, 142, 139, 136, 132, 129, 126, 123, 120, 117, 113, 110, 107, 104, 101, 98, 95, 92, 89, 86, 83, 80, 77, 74, 71, 69, 66, 63, 60, 58, 55, 52, 50, 47, 45, 43, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 19, 17, 15, 14, 13, 11, 10, 9, 8, 7, 6, 5, 4, 3, 3, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 3,
| 23 | 4, 5, 5, 6, 7, 8, 10, 11, 12, 14, 15, 17, 18, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37, 40, 42, 44, 47, 49, 52, 54, 57, 60, 62, 65, 68, 71, 73, 76, 79, 82, 85, 88, 91, 94, 97, 100, 103, 106, 109, 113, 116, 119, 122, 125, 128, 132, 135, 138, 141, 144, 147, 150, 153, 156, 160, 163, 166, 169, 172, 175, 177, 180, 183, 186, 189, 192, 194, 197, 200, 202, 205, 207, 210, 212, 214, 217, 219, 221, 223, 225, 227, 229, 231, 233, 235, 237, 238, 240, 241, 243, 244, 245, 247, 248, 249, 250, 251, 252 };
| 24 |
| 25 |
| 26 | volatile int pwmIndex = 0; // Index der Sinustabelle (volatile verwenden, da von der ISR verwendet)
| 27 |
| 28 | Ticker ticker;
| 29 |
| 30 | void setup() {
| 31 |
| 32 | Serial.begin(115200);
| 33 |
| 34 | pinMode(pwmPin_U, OUTPUT);
| 35 | pinMode(pwmPin_V, OUTPUT);
| 36 | pinMode(pwmPin_W, OUTPUT);
| 37 | analogWriteFreq(pwmFrequency);
| 38 |
| 39 | /*
| 40 | Serial.println("Sinuswerte für PWM U:");
| 41 | printSinTable(sinTable_U);
| 42 | Serial.println("\nSinuswerte für PWM V:");
| 43 | printSinTable(sinTable_V);
| 44 | Serial.println("\nSinuswerte für PWM W:");
| 45 | printSinTable(sinTable_W);
| 46 | */
| 47 | // Ticker einrichten
| 48 | ticker.attach_ms(1000 / pwmFrequency, updatePWM); // Timer für die PWM-Aktualisierung einrichten
| 49 | }
| 50 |
| 51 | void loop() {
| 52 |
| 53 |
| 54 |
| 55 | delay(50000);
| 56 | }
| 57 |
| 58 | void updatePWM() {
| 59 |
| 60 |
| 61 | // LEDs entsprechend der Sinustabelle steuern
| 62 | analogWrite(pwmPin_U, sinTable_U[pwmIndex]);
| 63 |
| 64 | //analogWrite(pwmPin_V, sinTable_V[pwmIndex]); <- Fehler ?
| 65 |
| 66 | analogWrite(pwmPin_W, sinTable_W[pwmIndex]);
| 67 |
| 68 | pwmIndex = (pwmIndex + 1) % 255;
| 69 | }
|
Die 3 Leds werden auch für einen kurzen Moment heller und dunkler, aber
dann kommt wieder der oben beschriebene Fehler.
Wenn ich die Zeile 64 1 | analogWrite(pwmPin_V, sinTable_V[pwmIndex]);
|
auskommentiere, leuchten nur noch zwei LEDs, aber der Fehler tritt
nicht mehr auf. Vielleicht hat jemand eine Idee, warum ?
Sollte es mit der Ticker-Bibliothek prinzipiell so funktionieren ?
Alex schrieb:
> 18:04:58.928 -> --------------- CUT HERE FOR EXCEPTION DECODER
Was liefert dir denn der Exception Decoder für diesen Stack Trace?
LG, Sebastian
Alex schrieb:
> const uint16_t sinTable_V[]
Das sind gar keine uint16_t, sondern uint8_t - Jedenfalls ist es
vermutlich so gemeint. Allerdings sind da einige '256' drin, die den
Wertebereich sprengen. Ich denke, da liegt auch das Problem.
Danke. Ich habe die 256 auf 255 geändert.
Den Typ habe ich auf uint8_t geändert.
Es wird kein Fehler mehr im SerialMonitor angezeigt.
Die LEDs leuchten schön um 120° verschoben nacheinander auf.
Aber nach ein paar Durchgängen (3-4) frieren die LEDs für ca. 1 Sekunde
ein und das ganze Programm scheint neu abzulaufen. Also wieder ein paar
Durchläufe, bis die LEDs wieder einfrieren.
1 | #include <Ticker.h>
| 2 |
| 3 | const int pwmPin_U = D2;
| 4 | const int pwmPin_V = D3;
| 5 | const int pwmPin_W = D4;
| 6 | const int pwmFrequency = 600; // PWM-Frequenz in Hertz
| 7 |
| 8 | const uint8_t sinTable_U[] = {
| 9 | 128, 131, 134, 137, 140, 143, 146, 149, 152, 156, 159, 162, 165, 168, 171, 174, 176, 179, 182, 185, 188, 191, 193, 196, 199, 201, 204, 206, 209, 211, 213, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 235, 237, 239, 240, 242, 243, 244, 246, 247, 248, 249, 250, 251, 251, 252, 253, 253, 254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 254, 254, 253, 253, 252, 252, 251, 250, 249, 248, 247, 246, 245, 244, 242, 241, 239, 238, 236, 235, 233, 231, 229, 227, 225, 223, 221, 219, 217, 215, 212, 210, 207, 205, 202, 200, 197, 195, 192, 189, 186, 184, 181, 178, 175, 172, 169, 166, 163, 160, 157, 154, 151, 148, 145, 142, 138, 135, 132, 129, 126, 123,
| 10 | 120, 117, 113, 110, 107, 104, 101, 98, 95, 92, 89, 86, 83, 80, 77, 74, 71, 69, 66, 63, 60, 58, 55, 53, 50, 48, 45, 43, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 19, 17, 16, 14, 13, 11, 10, 9, 8, 7, 6, 5, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 9, 11, 12, 13, 15, 16, 18, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 42, 44, 46, 49, 51, 54, 56, 59, 62, 64, 67, 70, 73, 76, 79, 81, 84, 87, 90, 93, 96, 99, 103, 106, 109, 112, 115, 118, 121, 124};
| 11 |
| 12 | const uint8_t sinTable_V[] = {
| 13 | 207, 210, 212, 214, 217, 219, 221, 223, 225, 227, 229, 231, 233, 235, 237, 238, 240, 241, 243, 244, 245, 247, 248, 249, 250, 251, 252, 252, 253, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 254, 253, 253, 252, 251, 250, 249, 248, 247, 246, 245, 243, 242, 240, 239, 237, 235, 234, 232, 230, 228, 226, 224, 222, 220, 218, 215, 213, 211, 208, 206, 203, 201, 198, 195, 193, 190, 187, 184, 181, 178, 176, 173, 170, 167, 164, 161, 158, 154, 151, 148, 145, 142, 139, 136, 133, 129, 126, 123, 120, 117, 114, 111, 107, 104, 101, 98, 95, 92, 89, 86, 83, 80, 77, 74, 71, 69, 66, 63, 60, 58, 55, 53, 50, 48, 45, 43, 40, 38, 36, 34, 32, 30, 28, 26, 24,
| 14 | 22, 20, 19, 17, 16, 14, 13, 11, 10, 9, 8, 7, 6, 5, 4, 3, 3, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 10, 11, 12, 13, 15, 16, 18, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37, 40, 42, 44, 47, 49, 52, 54, 57, 59, 62, 65, 68, 70, 73, 76, 79, 82, 85, 88, 91, 94, 97, 100, 103, 106, 109, 112, 116, 119, 122, 125, 128, 131, 134, 138, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, 189, 191, 194, 197, 200, 202, 205 };
| 15 |
| 16 |
| 17 | const uint8_t sinTable_W[] = {
| 18 | 252, 253, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 254, 253, 253, 252, 251, 250, 249, 248, 247, 246, 244, 243, 242, 240, 239, 237, 235, 234, 232, 230, 228, 226, 224, 222, 220, 217, 215, 213, 210, 208, 205, 203, 200, 198, 195, 192, 190, 187, 184, 181, 178, 175, 172, 169, 166, 163, 160, 157, 154, 151, 148, 145, 142, 139, 136, 132, 129, 126, 123, 120, 117, 113, 110, 107, 104, 101, 98, 95, 92, 89, 86, 83, 80, 77, 74, 71, 69, 66, 63, 60, 58, 55, 52, 50, 47, 45, 43, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 19, 17, 15, 14, 13, 11, 10, 9, 8, 7, 6, 5, 4, 3, 3, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 3,
| 19 | 4, 5, 5, 6, 7, 8, 10, 11, 12, 14, 15, 17, 18, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37, 40, 42, 44, 47, 49, 52, 54, 57, 60, 62, 65, 68, 71, 73, 76, 79, 82, 85, 88, 91, 94, 97, 100, 103, 106, 109, 113, 116, 119, 122, 125, 128, 132, 135, 138, 141, 144, 147, 150, 153, 156, 160, 163, 166, 169, 172, 175, 177, 180, 183, 186, 189, 192, 194, 197, 200, 202, 205, 207, 210, 212, 214, 217, 219, 221, 223, 225, 227, 229, 231, 233, 235, 237, 238, 240, 241, 243, 244, 245, 247, 248, 249, 250, 251, 252 };
| 20 |
| 21 |
| 22 | volatile int pwmIndex = 0; // Index der Sinustabelle (volatile verwenden, da von der ISR verwendet)
| 23 |
| 24 | Ticker ticker;
| 25 |
| 26 | void setup() {
| 27 |
| 28 | //Serial.begin(115200);
| 29 |
| 30 | pinMode(pwmPin_U, OUTPUT);
| 31 | pinMode(pwmPin_V, OUTPUT);
| 32 | pinMode(pwmPin_W, OUTPUT);
| 33 | analogWriteFreq(pwmFrequency);
| 34 |
| 35 | // Ticker einrichten
| 36 | ticker.attach_ms(1000 / pwmFrequency, updatePWM); // Timer für die PWM-Aktualisierung einrichten
| 37 | }
| 38 |
| 39 | void loop() {
| 40 | delay(50000);
| 41 | }
| 42 |
| 43 | void updatePWM() {
| 44 |
| 45 |
| 46 | // LEDs entsprechend der Sinustabelle steuern
| 47 | analogWrite(pwmPin_U, sinTable_U[pwmIndex]);
| 48 |
| 49 | analogWrite(pwmPin_V, sinTable_V[pwmIndex]);
| 50 |
| 51 | analogWrite(pwmPin_W, sinTable_W[pwmIndex]);
| 52 |
| 53 | pwmIndex = (pwmIndex + 1) % 255;
| 54 | }
|
Warscheinlich habe ich keine Fehler-Ausgabe mehr bekommen, weil ich die
Zeile Serial.begin auskommentiert hatte.
Hier ist das Ergebnis vom Exception Decoder: 1 | Exception 4: Level1Interrupt: Level-1 interrupt as indicated by set level-1 bits in the INTERRUPT register
| 2 | PC: 0x40000f83
| 3 | EXCVADDR: 0x00000000
| 4 |
| 5 | Decoding stack results
| 6 | 0x4010015c: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\alex\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp line 238
| 7 | 0x40201cac: esp_yield() at C:\Users\alex\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp line 144
| 8 | 0x401012b1: _notifyPWM(PWMState*, bool) at C:\Users\alex\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_waveform_pwm.cpp line 168
| 9 | 0x40203954: _setPWMFreq_weak(uint32_t) at C:\Users\alex\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_waveform_pwm.cpp line 208
| 10 | 0x4010015c: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\alex\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp line 238
| 11 | 0x40201cac: esp_yield() at C:\Users\alex\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp line 144
| 12 | 0x401012b1: _notifyPWM(PWMState*, bool) at C:\Users\alex\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_waveform_pwm.cpp line 168
| 13 | 0x40203b8e: _setPWM_weak(int, uint32_t, uint32_t) at C:\Users\alex\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_waveform_pwm.cpp line 343
| 14 | 0x4010015c: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\alex\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp line 238
| 15 | 0x4020140c: std::__detail::__variant::__gen_vtable_impl >::operator=(std::__detail::__variant::_Move_assign_base >&&)::{lambda(auto:1&&, auto:2)#1}&&, std::variant >&)>, std::integer_sequence >::__visit_invoke(std::__detail::__variant::_Move_assign_base >::operator=(std::__detail::__variant::_Move_assign_base >&&)::{lambda(auto:1&&, auto:2)#1}, std::variant >) at c:\users\alex\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0/variant line 1060
| 16 | 0x4020fc50: lwip_cyclic_timer at core/timeouts.c line 241
| 17 | 0x402026a1: __analogWriteMode(uint8_t, int, bool) at C:\Users\alex\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_wiring_pwm.cpp line 79
| 18 | 0x402012c2: std::__detail::__variant::__gen_vtable_impl >::swap(std::variant >&)::{lambda(auto:1&&, auto:2)#1}&&, std::variant >&)>, std::integer_sequence >::__visit_invoke(std::variant >::swap(std::variant >&)::{lambda(auto:1&&, auto:2)#1}, std::variant >&) at c:\users\alex\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits/std_function.h line 357
| 19 | 0x4020fc50: lwip_cyclic_timer at core/timeouts.c line 241
| 20 | 0x40201047: updatePWM() at C:\Users\alex\Documents\Arduino\OhneFehler/OhneFehler.ino line 54
| 21 | 0x402014f4: Ticker::_static_callback() at C:\Users\alex\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\Ticker\src\Ticker.cpp line 135
| 22 | 0x40201028: updatePWM() at C:\Users\alex\Documents\Arduino\OhneFehler/OhneFehler.ino line 48
| 23 | 0x4020497c: std::_Function_handler ::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) at c:\users\alex\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits/std_function.h line 268
| 24 | 0x40204974: std::_Function_handler ::_M_invoke(std::_Any_data const&) at c:\users\alex\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits/std_function.h line 289
| 25 | 0x40201b26: loop_task(ETSEvent*) at C:\Users\alex\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp line 273
| 26 | 0x401000ab: app_entry_redefinable() at C:\Users\alex\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp line 386
| 27 | 0x4010015c: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\alex\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp line 238
| 28 | 0x40202c39: uart_flush(uart_t*) at C:\Users\alex\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\uart.cpp line 587
| 29 | 0x40100a10: malloc(size_t) at C:\Users\alex\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 912
| 30 | 0x40202f80: uart_init(int, int, int, int, int, size_t, bool) at C:\Users\alex\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\uart.cpp line 715
| 31 | 0x40202ea6: uart_init(int, int, int, int, int, size_t, bool) at C:\Users\alex\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\uart.cpp line 707
| 32 | 0x4020115b: setup() at c:\users\alex\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits/std_function.h line 303
| 33 | 0x4020115b: setup() at c:\users\alex\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits/std_function.h line 303
|
Also, ich spreche ja null Arduino, aber eine ISR wird normalerweise
anders deklariert, nämlich so ähnlich wie: 1 | ISR(TIM1_OVF_vect) {
| 2 | // code here
| 3 | }
|
Nach allem, was ich gestern abend so über Interrupts in Arduino gelesen
habe, macht ihr das genauso. Es kommt also wahrscheinlich zu einem
Überlauf, wenn deine Pseudo ISR zu oft gerufen wird.
Es kann sicher sein, das das bei einem ESP nochmal anders funktioniert,
aber der Fehler deutet zumindest auf die ISR hin, wenn ich das richtig
lese.
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
|