Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to reduce flickering? #37

Open
gcormier opened this issue Nov 10, 2023 · 7 comments
Open

How to reduce flickering? #37

gcormier opened this issue Nov 10, 2023 · 7 comments

Comments

@gcormier
Copy link

I'm trying to get rid of flicker which happens in the lower half of the brightness options for my specific hardware.

I've been trying fairly unsuccessfully to make this happen in software. The closest I've gotten is setting PWM1 phase to 2, which then makes everything really really dim. Which is almost what I want, but then really cuts down on the range I can choose.

Any tips on how to do so would be apprieciated.

@tedyapo
Copy link
Owner

tedyapo commented Nov 10, 2023

i'm assuming this is V3.x hardware? flicker is related to the flash rate. the overall current draw is proportional to the flash rate and the energy per flash; so generally, you get a lower flash rate and more visible flicker with lower overall current draw and extended runtime.

you won't have much luck in software; you can only change the flash rate there.

what you need to do is change the pulse width, which is set by the '123 one-shot. the R and C in the published BoM were chosen to create a pulse width that translates into a current pulse close to the peak LED efficiency. if you reduce the R, you can generate a shorter pulse, which will generate a dimmer and shorter LED pulse. this will allow you to turn up the blink frequency, reducing flicker, while still maintaining a lower current draw.

you will lose a little bit of efficiency here for two reasons. first, you won't be driving the LED near the peak efficiency current. but, take a close look at the LED efficiency curves -- you can cut the LED current in half or more without effecting the efficiency that much. that will let you drive it with more than twice the frequency, reducing flicker. the second efficiency loss is larger, and that is due to the overhead of waking up the PIC and generating the pulse for each flash. if you crank up the frequency to reduce flicker, you'll be losing more efficiency to this overhead. there isn't much you can do about this.

so, my recipe for reducing flicker at lower current draw is to reduce R3 in the V2.x circuit. this will decrease the pulse width and the peak LED current. once this is done, you can increase the pulse rate in software, and the flicker will be reduced. if you want accurate run-time estimates, you'll need to calibrate the current draw.

my suggestion would be to solder a through-hole resistor on the board in place of R3. use long leads for testing. once you find a resistor that gives you the flicker vs current draw you like, you can solder on an SMD resistor permanently. i might try a value of half the initial R3 value as a start. then, play with flicker frequency, either by running the calibration code and python script, or just tweaking the pulse frequency table to your liking. you might want/need to go up or down in resistor value from there.

if you really want to be scientific about it, leave one copy of the circuit as-is, and use it as a comparison reference. at these light levels, it's easy to fool yourself, especially if the changes are somewhat subtle.

i think this is all i got, but i'm going to leave this issue open for a bit because i'm interested to see where you get with this. good luck!

EDIT: if you only have parts bought for the project, you could solder another identical R3 resistor right on top on the one on the board. that would cut the resistance in half.

EDIT: i was thinking of the unpublished V4.0 in the efficiency discussion above. there's not too much overhead involved in increasing the pulse frequency in V3.x.

@gcormier
Copy link
Author

Hey Ted! Awesome, thanks so much for the response :) I did not expect one.

As I'm using SMD, I might try to figure out a bodge by solering a resistor on top of the existing one to reduce the resistance. Yay, 0402's! :)

I was going to possibly redesign this at the expense of efficiency. I'll try to take some measurements once I find a very-dim option. Ditching the monostable was what I was eyeing, and I noticed the everled fork with an Attiny13A which can approach 1uA standby. This would be taking a step towards your V2.0 I believe which is just a mosfet controlled directly by a GPIO.

For now, I have 18 of these to play with and fix up in time for Christmas presents. I will definitely report back!

image

@gcormier
Copy link
Author

It works!

I am down to 2.5K on R3. I'm using 1 mH inductor and the Cree XPEBGR-L1-0000-00F02 LED.

I will order some 1K resistors to see how low I can go.

I would love to optimize the BOM slightly, the LED is the biggest contributor to cost. I guess it's the price to pay as the brighter LED's translate to higher efficiency/savings at low power?

My use case is for nighttime to prevent smashing into something in the bedroom. Will make great gifts!

@tedyapo
Copy link
Owner

tedyapo commented Nov 12, 2023

cool. what frequency are you running them at, and what's the current draw? if you can put a scope on the led/inductor, i'd be very interested to see the waveform there. the current pulses must be very short and low

@gcormier
Copy link
Author

gcormier commented Nov 12, 2023

Here's my modes.h. Basically, your firmware setting 5 became my dimmest setting 10, as I found 4 and under on yours would be blinking.

#define N_MODES 10
struct run_time period_table[N_MODES] = {
  {1, (int)(31000./762.124721 + 0.5)},
  {2, (int)(31000./662.124721 + 0.5)},
  {3, (int)(31000./562.124721 + 0.5)},
  {4, (int)(31000./462.124721 + 0.5)},
  {5, (int)(31000./362.124721 + 0.5)},

  {6, (int)(31000./262.124721 + 0.5)},
  {7, (int)(31000./124.768381 + 0.5)},
  {8, (int)(31000./78.982934 + 0.5)},
  {9, (int)(31000./56.090211 + 0.5)},
  {10, (int)(31000./42.354577 + 0.5)},
};

I've got a 1K resistor for R3 now and I think that's what I will go with.

image

@gcormier
Copy link
Author

gcormier commented Nov 29, 2023

Here's the scope output, I hope I have these capture labels correct from my memory :)

LED
image

LED Mosfet
image

Wakeup for monostable
image

@gcormier
Copy link
Author

If you want me to mail you one, happy to do so just let me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants