RobotDynOfficial / RBDDimmer

The following library is used for work with dimmer, it gives ability to control large ammoun of dimmer. This lib uses with Leonardo, Mega, UNO, ESP8266, ESP32, Arduino M0, Arduino Zero, Arduino Due, STM32.
244 stars 112 forks source link

Timing issue #53

Open darrepac opened 2 years ago

darrepac commented 2 years ago

Hi

Looking at the code for ESP8266, I found something strange about ISR timer: void dimmerLamp::timer_init(void) { timer1_attachInterrupt(onTimerISR); timer1_enable(TIM_DIV16, TIM_EDGE, TIM_SINGLE); timer1_write(timeoutPin); //100 us } The 100us as comment sounds to be the right value (indeed with 50Hz signal, we have 10ms demi-period and so with 100 steps (or %) allowed, we need a 10 000/100 = 100us timer)

yet above is written: int timeoutPin = 435; // 80us

In fact 435 means (0.2*435) = 87us... but why? it should be 100us and so 500... I don't understand it and moreover there is a difference in the code itself: at one place it is written 100us, on another 80us...

Timer being shorter that it should (in my opinion!), it could explain some flickering or at least some not 0W consumption at dimmer = 0

@VSneg as you seem to be one of the writer of this library, I would appreciate your feedback

darrepac commented 2 years ago

Hello

A blog post about how I debugged and corrected the library here : https://blocnote360.wordpress.com/2022/03/20/routeur-solaire/ (sorry, in french...)

yokusan commented 2 years ago

Hello

A blog post about how I debugged and corrected the library here : https://blocnote360.wordpress.com/2022/03/20/routeur-solaire/ (sorry, in french...)

Dear Darrepac, you should try to integrate your corrections into this original Robotdyn Library. All users of the library would benefit from your modifications.

yokusan commented 2 years ago

@VSneg please integrate the modifications by Darrepac into your Dimmer library.

davidmarli commented 2 years ago

Hi, and for esp32 version ?

fbndny commented 6 months ago

Hello

A blog post about how I debugged and corrected the library here : https://blocnote360.wordpress.com/2022/03/20/routeur-solaire/ (sorry, in french...)

Thanks a lot!