-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
improved led dimming #23
Conversation
Hi Roland! Thanks for your interest in this project and also for taking the time to contribute! Firstly, I really like the idea of filtering on the 'line frequency' value. As this device is supposed to be suitable for use in both 50Hz and 60Hz maybe the filter will need a little bit of tuning, but some kind of IIR filter like you have implemented should be a great improvement here.
I've never thought about this before, but having a forward voltage of ~200V could indeed be causing flickering in some cases. I have no idea how 'safe' this dimming method might be, but I can do some testing and if it seems to fix more problems than it causes then I would say it would be ok.
Again this is a really good sugesstion. Using filtering when syncing TIM1 might sort out some more problems. Let me know if you can think of a good aproach for this. James |
In the early days of the Shelly Dimmer, the firmware also had a "center"-calibration mode. Visible in this video. However, in later firmwares this option was removed. I don't know why :-/ |
Tested your changes and it looks to work great for me! We shall see what people with the really bad flickering have to say also |
I have just made one change, which is to make the default value for |
Sorry for my late response. I currently do some simulations with LT-spice. So center dimming with low dimming value will also send very short 317V peaks to the LED and may put too much stress on some (cheap) LEDs. Currently, I have no spare dimmer (waiting for amazon order ;) ) so I play around with LT-Spice. My main goal would be a PLL for the timer mentioned here: https://www.mikrocontroller.net/articles/PLL#Software_PLL but I did not find a good reference implementation. I have found a page with a lot of information. I would use the timer to count from 0..100 and set the prescaler to ~4800 (for 50Hz) Cheers |
DISCLAIMER
This mod may drive the shelly dimmer out of spec, at it may have more switching losses as in trailing edge mode.
Do not use it with capacitive loads.
Hello @jamesturton,
I had similar flickering problems like in #6. I tried the beta firmware and this gives much better results.
My hardware setup is a Shelly Dimmer 2 with LED spots https://www.amazon.de/gp/product/B08C5CMQLM
(They are based on SM2082EG constant current controller - similar to schematic on page 10 http://www.szjuquan.com/upload_files/qb_sell_/pdf/SM2082EG.pdf)
The problem was, that on low dimming voltages, the led flickers. I inspecht the output voltage with the oscilloscope and saw, that the trailing edge is "jittering".
It seems that the stm32 is not always in sync with the line freqency. I tried different things, to improve line sync.
But all I tried, I always ended with some jitter in the output voltage. So I tried a different approach based on the follwing idea:
When dimming to 10%, why use the beginning 10% of the sine wave and not a 10% section later in the sine wave?
A normal trailing edge will always use the sine wave from the beginning.
Example:
5% trailing edge
UPeak ~50v
20 % trailing edge
UPeak ~ 185v
Here we come to the next problem: The LEDs above have a forward voltage from ~200V, so they will start glow somewhere about 185V and run with full brightness if the sine wave has > 200V.
This makes them prone to flickering if the peak voltage jitters around a few volts only.
So my idea is, not to use the beginning section of the sine wave, but a section 30% - current dimming value:
Some examples:
5%
10%
20%
30%
40%
80%
Currently, I use the warmup_brightness value, so I can set it with the ShdWarmupBrightness command. I get better dimming results for a value between 18 and 22.
Unfortunaltely, there is still some flickering, but I wanted to share this idea with you.
Maybe you have some other ideas to improve dimming. I think, the best soluttion will be to find a way to synchronize the timer to the line frequency. Maybe the TIM1 should run with +/-100Hz and EXTI should sync it like a PLL
Cheers
Roland