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.
236 stars 111 forks source link

Output pin uncertain state #8

Open Mesmer88 opened 5 years ago

Mesmer88 commented 5 years ago

Between the two if branches at the end, the state of output pin is inconsistent. Changed this:

Added else clause Set timer counter to 32, in order to cover time between zero cross on 50Hz Increase pulse width to 10

This solved for me the issues with flickering and bad load control.

raduangelescu commented 5 years ago

I tested the fix, and it indeed fixes all the problems I had with blinking and inconsistent controll. Thanks Mesmer88

Mri007 commented 5 years ago

Any Idea about the fix with ESP8266?

Mesmer88 commented 5 years ago

I think it should also work fro ESP8266. You just need to do the same edits in the different header library.

Basically this one:

RBDDimmer/src/esp8266/RBDmcuESP8266.cpp

Mri007 commented 5 years ago

Yeap I tried. But the problem is i can only change the pulse width to 10. And not sure about "Set timer counter to 32,"

There are no option like esp32, "timerAlarmWrite(timer, 32, true)"

Mesmer88 commented 5 years ago

Actually that part is not that important. During my own calculations i thought that the original ones was a bit off, but it shouldn't matter much.

Can you try just changing the PIN loop to this one??

Replace

        if (dimCounter[k] >= dimPulseBegin[k] )
        {
            digitalWrite(dimOutPin[k], HIGH);   
        }

with

        if (dimCounter[k] >= dimPulseBegin[k] )
        {
            digitalWrite(dimOutPin[k], HIGH);   
        } else 
            digitalWrite(dimOutPin[k], LOW);

On line 185 for ESP8266 file?

Mri007 commented 5 years ago

Sure, will try.

Mri007 commented 5 years ago

Update:: Doing so didnt solve flickering :(

raduangelescu commented 5 years ago

while the fix fixed flickering on esp32 for my lamp when I tested it with a heater element it seems that it still doesn't work properly. Setting the power level to 0 seems to not shut down AC on the load, so I am guessing the light thing is just fortunate but the actual range of output is not covered.

ChristopherJBarr commented 5 years ago

I just tried the changes you recommended with the ESP8266 and still got mad flickering (it's probably best if you mute before watching, the robot vacuum was buzzing around me):

https://www.dropbox.com/s/67gne6dozlg0s8e/Video%2017-05-2019%2C%2017%2027%2041.mov

For context, I have a capacitive touch lamp that I'm modding to be a smart lamp. The touch/light level logic is all working fine (tested with an LED), that's what you can see in the serial monitor. It doesn't matter what level I set it to, it's chaos. Even setting it to 0 causes flashing. Here's the slightly different flashing with the original version of the code:

https://www.dropbox.com/s/9bd4i49j05g0xrk/Video%2017-05-2019%2C%2017%2039%2037.mov

I'm going to keep digging into RBDmcuESP8266.cpp, try to understand it more and see if there's anything I can tweak. If anyone has any ideas though...