Algorithm question - flickering candle

Go To Last Post
15 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mostly to amuse the kids I've been playing around with trying to get a flickering candle effect from some yellow LEDs, and so far I'm not really happy with the results. I've tried both single LEDs and multiple LEDs to get a "moving flame" effect.

So, anybody had good luck doing this? Any ideas, approaches? I'm not asking about low-level PWM, I know how to do that. It's coming up with a good flow of realistic PWM numbers that's proving a bit difficult.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you're in the US, go to a Dollar Tree dollar store, buy one of their LED candles (for $1), stick a scope on it, and see what they're doing.

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Read the 3rd post in this thread :

He's using a bicolor led so the physical position of the light source is actually really moving. Also, the brightness stays more or less constant that way, like a real candle.
Other than that, it seems to be a random number generator for the amplitude.

http://www.electro-tech-online.c...

"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A 16 Bit LFSR fed into a yellow and red LED offset from each other slightly will do it for you.

Brad

I Like to Build Stuff : http://www.AtomicZombie.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

millwood wrote:
however, since flame brightness is serially correlated, you will need to keep track of not just next brightness but also previous brightness, and extrapolate between the two so a) the flame intensity is random; and yet b) there is smooth transition from one intensity to the next.

Which describes a Gauss markov process. Low pass filtering of white noise is one way to achieve it.

-- Damien

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'd precalculate some sequences and store them in flash, then "randomly" select among them. Start and end them all a point that can be spliced together, and make them different lengths. It's not like anyone's going to memorize the flicker sequence (or care).

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Chuck,

With your Butterfly experimentation history I figured you would aim a Butterfly's photocell at a real candle to measure and record the real-world flicker!

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It'll probably turn out you can take the Butterfly's Für Elise song and play it on an LED at 1/128 speed and have a totally realistic candle flame.

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've always liked this simple CPU monitor. There is source code here: http://www.dockapps.org/file.php...

Maybe the "flame algorithm" section will give you some additional ideas.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

zbaird wrote:
It'll probably turn out you can take the Butterfly's Für Elise song and play it on an LED at 1/128 speed and have a totally realistic candle flame.

I remember some article (can't find it at the moment) were some hackers figured out that that was exactly what some LED candle manufacturers did. They were using cheap / surplus greeting card music ICs to drive a LED.

Stealing Proteus doesn't make you an engineer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
They were using cheap / surplus greeting card music ICs to drive a LED.

Well, maybe I need to stop by the dollar store and buy a candle and play it through a speaker.

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Stealing Proteus doesn't make you an engineer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Holy cow:

Quote:
Just place the light sensor near the LED candle and in many cases you'll hear cheap electronic music coming out the amplifier. The one in the picture below plays "Fur Elise".

I must have ESPN.

I picked up some of these candles at the dollar store this afternoon (2 for a dollar instead of a dollar each, but I had already decided I'd go for 2 bucks, so I now have 4). I'll keep you posted if my magic candles know any ditties.

No chip in my little cheapies - the flicker smarts are built into the LED itself. There's a CR2032 battery, a switch, and the yellow LED, and nothing else. I thought maybe they mounted something inside the switch housing, but with the LED cut loose you can touch its leads to the battery and it flickers. And not too convincingly, I might add.

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

we have several brands/types of eCandles. Some have lousy realism (poor algorithm). Some are very good.