PCA fade for stairs light

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Sminter4
Normal user
Posts: 18
Joined: 04 Aug 2021, 23:25

PCA fade for stairs light

#1 Post by Sminter4 » 05 Mar 2022, 08:14

I would like to build a staircase light in which each step dims one after the other.
Is it possible to give the PCA9685 a fade function like the ESP GPIO (

Code: Select all

PWM,<GPIO>,<duty>,<duration>
)?
E.g.

Code: Select all

PCAPWM,1,4095,500

User avatar
Ath
Normal user
Posts: 3481
Joined: 10 Jun 2018, 12:06
Location: NL

Re: PCA fade for stairs light

#2 Post by Ath » 05 Mar 2022, 10:45

What build are you using for your ESP? (.bin filename please), I'll try to provide a build here for testing.
/Ton (PayPal.me)

Sminter4
Normal user
Posts: 18
Joined: 04 Aug 2021, 23:25

Re: PCA fade for stairs light

#3 Post by Sminter4 » 05 Mar 2022, 14:06

I am currently using the Build: ESP_Easy_mega_20211224_test_A_beta_ESP8266_4M1M Dec 24 2021
I would like to test the PCA PWM fade function. She is very important to me.

Of course, the top class would be a function that could turn on or off several GPIOs in parallel (not serially).
E.g. parallel switching on for warm and cold white LEDs...

User avatar
Ath
Normal user
Posts: 3481
Joined: 10 Jun 2018, 12:06
Location: NL

Re: PCA fade for stairs light

#4 Post by Ath » 05 Mar 2022, 14:17

I have provided the regular TEST_A build for ESP8266 4M1M, as the beta in the name is a) about the Arduino framework version, and current builds from the mega branch are on a newer Arduino version than the beta that was used for the December build, and b) current beta build has a feature that is really beta, so you should only use that if you know why you are using that.
ESP_Easy_mega_20220305_test_A_ESP8266_4M1M.zip
(651.59 KiB) Downloaded 199 times
/Ton (PayPal.me)

Sminter4
Normal user
Posts: 18
Joined: 04 Aug 2021, 23:25

Re: PCA fade for stairs light

#5 Post by Sminter4 » 05 Mar 2022, 17:05

Wow, that was fast! Respect!
My previous tests were successful!

Two more questions:
- Is on or off dimming also possible in parallel? For example, in which the PCA takes over the task instead of the ESP. Or that a timer is used as a thread instead of the delay.
- Will the PCA fade function also be transferred to the next espeasy releases?

User avatar
Ath
Normal user
Posts: 3481
Joined: 10 Jun 2018, 12:06
Location: NL

Re: PCA fade for stairs light

#6 Post by Ath » 05 Mar 2022, 17:42

Great, thank you :D
Sminter4 wrote: 05 Mar 2022, 17:05 Two more questions:
- Is on or off dimming also possible in parallel? For example, in which the PCA takes over the task instead of the ESP. Or that a timer is used as a thread instead of the delay.
The fading is done in a loop, exactly how the fading is done for the regular PWM command, using a loop-step of ca. 1 msec. Not something that can be off-loaded to the PCA, unfortunately.
Because of the 'speed' of the ESP's CPU it isn't quite feasible to switch to a timer approach at this time, as the minimal loop-time is ~20 msec, so the fading would probably 'stutter'. And that's also the reason no multiple outputs can be faded in parallel.
Sminter4 wrote: 05 Mar 2022, 17:05 - Will the PCA fade function also be transferred to the next espeasy releases?
Once PR #3970, that I opened today, is merged and a new release published, everyone can enjoy this feature ;)
/Ton (PayPal.me)

Sminter4
Normal user
Posts: 18
Joined: 04 Aug 2021, 23:25

Re: PCA fade for stairs light

#7 Post by Sminter4 » 06 Mar 2022, 20:43

Thank you for the info. :)
If the ESP8266 is too slow, could an ESP32 theoretically run the fade function in parallel?

User avatar
Ath
Normal user
Posts: 3481
Joined: 10 Jun 2018, 12:06
Location: NL

Re: PCA fade for stairs light

#8 Post by Ath » 06 Mar 2022, 21:24

Sminter4 wrote: 06 Mar 2022, 20:43 Thank you for the info. :)
If the ESP8266 is too slow, could an ESP32 theoretically run the fade function in parallel?
The issue here is that it needs a redesign of a) the way the fading is done, and b) the way the GPIO's are controlled. That should be in some time-critical loop, where it now is just a call-out to this output routine.

I'll put it on the back-burner, meaning, I'll think about it, but no promises or time-line :arrow:
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8736
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: PCA fade for stairs light

#9 Post by TD-er » 08 Mar 2022, 20:44

ESP32 does have fade instructions in hardware, so that should be possible.
I don't use them yet as I ran into some issues.
ESP32 does have 3 (???) HW timers which can be used via a crossbar switch to toggle pin(s)
However there are also 2 different ones regarding the used clock, meaning higher frequencies must use the 80 MHz clock and lower frequencies can use the lower frequency one.

But... some libraries may also allocate one or more of these timers causing issues on an already configured pulse signal on some pin.
And there are other limitations which may affect operations.

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests