Tasmota Max number of PWM Channels

965 views
Skip to first unread message

Paul Faure

unread,
Dec 8, 2021, 10:52:26 PM12/8/21
to TasmotaUsers
Hi All,

I am looking to output 6 PWM channels (MultiPWM, SetOption68 1) but it seems like the max number that I can pick is 5.
Is there a hardware or software limitation?

Thanks,
Paul

Philip Knowles

unread,
Dec 9, 2021, 12:09:51 AM12/9/21
to Paul Faure, TasmotaUsers
PWM can be allocated to any GPIO. Tasmota most likely has a limit of 5 due to that's the most a dimmer would need. Most limits like that can be overridden at compile time but you'll need to hunt for it in the config file. It may be worth searching in the Issues as you'll often find the solution there.
Regards

Phil K


From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Paul Faure <paul...@gmail.com>
Sent: Thursday, December 9, 2021 3:52:26 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Tasmota Max number of PWM Channels
 
--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/6d667a9d-276c-4c8c-8d8f-d0162e9360b0n%40googlegroups.com.

Paul Faure

unread,
Dec 10, 2021, 9:34:42 PM12/10/21
to TasmotaUsers
I have done some searching already and can't find reference to someone doing what I am going. I am using gate logic to multiplex multiple PWM signals together for an art project.

I have a feeling this is the code to change:
tasmota.h line 63:
  const uint8_t MAX_PWMS = 5;                 // Max number of PWM channels

I will give it a go and see what happens.

Paul

Paul Faure

unread,
Dec 10, 2021, 10:04:47 PM12/10/21
to TasmotaUsers
When I made this change:
tasmota.h
//const uint8_t MAX_PWMS = 5;                 // Max number of PWM channels
const uint8_t MAX_PWMS = 6;                 // Max number of PWM channels

It is erroring out here:
tasmota/settings.h:772:1: error: static assertion failed: TSettings Size is not correct

Why does TSettings need to be exactly 4k?

settings.h
typedef struct {
  uint16_t      cfg_holder;                // 000  v6 header
  uint16_t      cfg_size;                  // 002
...
  uint16_t      pwm_value[MAX_PWMS];       // 2EC
...
  uint32_t      cfg_timestamp;             // FF8
  uint32_t      cfg_crc32;                 // FFC
} TSettings;
static_assert(sizeof(TSettings) == 4096, "TSettings Size is not correct");

I tried to remove some to innocuous uint16_t to offset the increase in PWM, but it didn't work.

Thoughts?

Paul Faure

unread,
Jan 8, 2022, 7:54:31 PM1/8/22
to TasmotaUsers
Hi All,

Looking for some advice on how to increase the max number of PWM outputs to 6.

I tried the following:
tasmota.h

< const uint8_t MAX_PWMS = 5;                 // Max number of PWM channels
> const uint8_t MAX_PWMS = 6;                 // Max number of PWM channels
< const uint8_t MAX_DOMOTICZ_SNS_IDX = 11;    // Max number of Domoticz sensors indices
> const uint8_t MAX_DOMOTICZ_SNS_IDX = 10;    // Max number of Domoticz sensors indices

user_config_override.h
#undef USE_DOMOTICZ

And got it to compile, flash and boot. It successfully shows 6 options in the configuration, however, there are three issues:

It treats the 6th PWM as a "Color" instead of a basic PWM output (seems "SetOption68 1" has no effect on it)
"POWER1":"ON","Channel1":100,
"POWER2":"ON","Channel2":100,
"POWER3":"ON","Channel3":98,
"POWER4":"ON","Channel4":100,
"POWER5":"ON","Channel5":100,
"Color":"FFFFFAFFFF"

Second, none of the PWM output any voltage, even when they are on.

And third, the UI seems to limit to 5 PWD on the main page.

Any help would be appreciated.

Many Thanks,
Paul

Capture2.PNG
Capture.PNG

Paul Faure

unread,
Jan 9, 2022, 12:09:17 PM1/9/22
to TasmotaUsers
I managed to fix issue #1 and #2 by changing a bit more code. I thought perhaps Scripting-Language may be the solution... Found this online https://github.com/arendst/Tasmota/discussions/10144 , but the scripting-language for ESP8266 is still limited to 5 PWM.

So where would I look in the code to resolve the issue where no voltage is created on the GPIOs for my PWM? The link above mentioned "shift alignment"?

Paul Faure

unread,
Jan 9, 2022, 12:10:53 PM1/9/22
to TasmotaUsers
Correct, I fixed issue #1 and #3 (settings).
Issue #2 persists (no output voltage for any PWM).

Reply all
Reply to author
Forward
0 new messages