# flickering light emulator

Discussion in 'Electronic Design' started by Piglit, Mar 28, 2007.

1. ### PiglitGuest

Have a need to emulate a flickering light, kinda like a faulty
fluorescent.
My first attempt (using a pic) has an 8 bit pseudorandom sequence
generator
the output being compared with the result of an a/d conversion of a
pot
(over turns the light on, under turns it off) hence am able to vary
the average duty
cycle, plus another pot controlling total loop time to slow down or
speed up the
flicker. It doesn't look very convincing - sure it all works as coded,
but it just
doesn't look random enough. Dunno if the brain can remember an 8 bit
pseudorandom
sequence or what. Unfortunately this has to drive a big incandescent
(via an opto
and a triac), so a "real" faulty fluro is out of the question. Any
better ideas ?
M

2. ### MooseFETGuest

If you have an 8 bit psudorandom generator coded and you want to make
more bits without having to think too hard, you can do like this:

byte PsudoRand(byte Prev) {stuff}

int Seed1,Seed2,Seed3;

int BigRand(){
Seed1 = PsudoRand(Seed1);
if (Seed1 & 1) Seed2 = PsudoRand(Seed2);
else Seed3 = PsudoRand(Seed3);

return ((Seed1<<8) | Seed1) \$ ((Seed2<<8) | Seed3);
}

The results are not as good as a read 16 bit psudorandom but still
very hard for mere mortals to predict.

3. ### D from BCGuest

Some notes:
* You may need to match the pattern of a faulty fluro by analyzing a
recorded sample pattern. Then make a matching rnd generator.
* Is a faulty fluro mostly on or mostly off?
* You may need to randomize the trigger time, ton and toff.
* You loose some reality if a faulty fluro has random varying
intensity levels.
D from BC

4. ### Homer J SimpsonGuest

Wouldn't on off pulses be more realistic?

5. ### BobGuest

Stage lighting people sometimes take the crude approach of wiring
a flourscent tube starter in series with a 60watt bulb.

Bob

6. ### Paul Hovnanian P.E.Guest

IIRC, there was a Circuit Cellar project a while back to build an 'LED
candle'. It was a yellow LED driven by a small uC. The designer did some
research to determine what would produce a convincing flicker and
developed an algorithm to produce it.

7. ### LuhanGuest

Hi,

Here's what I did to simulate a candle. The random number generator
has a very long sequence.

http://mondo-technology.com/candle.html

Luhan

8. ### Homer J SimpsonGuest

I'm sure Elektor will have done one in their 300 circuits series also.

9. ### jasenGuest

the equal spacing of the firing times is probably the problem,

change your algorithm so that the on and off durations come in more than 7
different lengths.
trigger the opto using a phototransistor and use a real fluoro to trigger
that.