PWM Signal problems
Posted: Sun Apr 21, 2024 7:26 pm
On my ESP32 S2 (self created hardware design, schematic can be found here or embedded at the bottom:
https://preview.redd.it/esp32s2-wont-sh ... e38d7165c4
I have, however, tested the hardware thoroguhly with a multimeter. this part is fine.
I have defined:
according to my hardware schematic.
in my setup() i have
(now I am aware that IO18 is a special pin and shouldn't be used for PWM output, but that is not my problem here. )
now, so far all is fine, BUT:
i then created a class ledHandler {}
and moved the ledcAttach() parts in a setup() method which i called from the global setup()
with ledHandler.setup().
and then, when I use
green and blue work just fine. Red does not.
I mean, i fixed the bug by moving the ledcAttach() parts back to global setup() but does anyone have a n explanation for this?
https://preview.redd.it/esp32s2-wont-sh ... e38d7165c4
I have, however, tested the hardware thoroguhly with a multimeter. this part is fine.
I have defined:
Code: Select all
#define LEDC_TIMER_8_BIT 8
#define LEDC_BASE_FREQ 5000
const int ledPinBlue1 = 18;
const int ledPinRed1 = 38;
const int ledPinGreen1 = 8;
const int ledPinGreen2 = 3;
const int ledPinRed2 = 9;
const int ledPinBlue2 = 37;
in my setup() i have
Code: Select all
ledcAttach(ledPinRed1, LEDC_BASE_FREQ, LEDC_TIMER_8_BIT);
ledcAttach(ledPinGreen1, LEDC_BASE_FREQ, LEDC_TIMER_8_BIT);
ledcAttach(ledPinBlue1, LEDC_BASE_FREQ, LEDC_TIMER_8_BIT);
ledcAttach(ledPinRed2, LEDC_BASE_FREQ, LEDC_TIMER_8_BIT);
ledcAttach(ledPinGreen2, LEDC_BASE_FREQ, LEDC_TIMER_8_BIT);
ledcAttach(ledPinBlue2, LEDC_BASE_FREQ, LEDC_TIMER_8_BIT);
now, so far all is fine, BUT:
i then created a class ledHandler {}
and moved the ledcAttach() parts in a setup() method which i called from the global setup()
with ledHandler.setup().
and then, when I use
Code: Select all
ledcWrite(ledPinRed1, 128);
ledcWrite(ledPinGreen1, 128);
ledcWrite(ledPinBlue1, 128);
ledcWrite(ledPinRed2, 128);
ledcWrite(ledPinGreen2, 128);
ledcWrite(ledPinBlue2, 128);
I mean, i fixed the bug by moving the ledcAttach() parts back to global setup() but does anyone have a n explanation for this?