fabianoriccardi / dimmable-light

Arduino library to manage dimmers compatible with AVR, ESP8266, ESP32, SAMD, and RP2040 platforms.
GNU Lesser General Public License v2.1
97 stars 29 forks source link

`DimmableLight::getDetectedFrequency()` returns wrong value on Robodyn AC Dimmer 24A #46

Closed mathieucarbou closed 11 months ago

mathieucarbou commented 11 months ago

My code:

DimmableLight::setSyncPin(_pin); // ZC pin of Robodyn
DimmableLight::begin();

Calling after, each 5 sec: DimmableLight::getDetectedFrequency()

Returned value is 122.

I have another ZCD module (https://www.pcbway.com/project/shareproject/120_220VAC_Opto_Isolated_Zero_Cross_Detector_Module_for_DIN_Rail_Carrier_Mount_w_57a9f83e.html) and this one works perfectly.

Note: if I set FILTER_INT_PERIOD, getDetectedFrequency () return 0 for both Robodyn and this ZCD module.

mathieucarbou commented 11 months ago

Hello again,

I took some measurements this evening (Owon HDS2202S) and it turns out the Robodyn ZCD pulse is really short in duration: still 5V, but really short, like 0.5 ms, compared to the 1.5 ms duration of the pulse of the dedicated ZCD.

I am wondering if there are some issues detecting that in the code ?

Oscillo_ZCD_Robodyn

Oscillo_ZCD

fabianoriccardi commented 11 months ago

Hi Mathieu, which mcu are you using?

mathieucarbou commented 11 months ago

Hi Mathieu, which mcu are you using?

ESP32 NodeMCU devkit

This one: https://www.az-delivery.de/en/products/esp32-developmentboard

I've read the Wiki and learned about some ESP32 issues to detect short pulses, I am trying to activate filters now...

mathieucarbou commented 11 months ago

I added -D FILTER_INT_PERIOD and everything works fine with both the Robodyn and the other ZCD module.

Thanks a lot for this library by the way: far better written than most others, and goes deeper in the details 👍

fabianoriccardi commented 11 months ago

ESP32 NodeMCU devkit

I was supposing it, ESP32 gave quite few troubles, especially when combined with the RobotDyn dimmer. 😅 Glad that you quickly solved it!

Thanks a lot for this library by the way: far better written than most others, and goes deeper in the details 👍

Many thanks!

mathieucarbou commented 11 months ago

... And feel free to use the images above if you need, to illustrate your wiki page or put another ZCD module in ref ;-)

fabianoriccardi commented 11 months ago

That's a good point, in the next days I hope to continue the work with this lib.

fabianoriccardi commented 11 months ago

Add the reference and the images to the wiki page, thanks again!