Flickering fire effect

Author
coffee
Starting Member
  • Total Posts : 84
  • Reward points : 0
  • Joined: 2006/11/29 10:47:09
  • Location: UK
  • Status: offline
2007/03/25 05:24:49 (permalink)
0

Flickering fire effect

Hi,

My dad's asked me if I can put together something that will simulate a flickering fire for use on his model railway.  I was planning to use a 12F509 with a red, yellow and orange leds (possibly 2 of one colour depending on how the colour balance works out, maybe orange).  And I know I'll have to have a play with various resistor values at some point to get the effect right.

My issue is trying to come up with the right approach to getting random flicker effects, while still trying to keep as at least one led lit.  The approaches I've considered so far are a long table approach with semi-random settings for each led with a short delay between updates (seems a lot of work to get the table right), or to try to puzzle through the example in one of Myke Predko's books where he used a "linear function shift register" approach with 6 leds for a pumpkin.  I still can't quite work out what's going on in that approach as it's using a lot of combined bitwise ops in C and I'm more familiar with assembly.

Before I get too stuck on one approach, does anyone have any ideas for other approaches?  Not the code, I really want to work through that myself, but any other methods that might work?  Just a reminder that this chip doesn't have interrupts, and only one 8 bit timer.  If it's going to be a lot easier then I'd consider using the 12F629, but it's just that I've got a few 509s spare.

Thanks for any ideas.

Mike
#1

16 Replies Related Threads

    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    RE: Flickering fire effect 2007/03/25 05:46:58 (permalink)
    0
    Hi, I did exactly this on my dimmer, as a bonus.
    My approach was to have a "dimmer" going on, i.e. some sinewave-clamper standard dimmer (using Triac and MCP3020) or, in case of DC lamps, a PWM with variable dutycycle. This is easily done using hardware PWM or software PWM with a Timer.
    Once you have a variable holding the current level of light, say, ranging from 0 to 63, what I do is Read a timer, scale it down to, maybe, 32, and add a constant (make it 20), and set new light level. This is done once in every 100-500 mSec as preferred. Resulting effect is a "random" light more or less like a fireplace.

    You can play around with parameters: most important is the pick of the random source. The Timer is good enough if it is fast enough and not directly correlated to Code execution, but one could use a random A/D reading, or a floating pin (IMO worse approaches). You can also do some XOR and or mess with Timer bits to generate this random value.
    The scale and offset can be adjusted at one's wish.

    PS: there was also a simple "feedback register" approach, which is used to generate Random Numbers. You can search fot it on the Net.

    GENOVA :D :D ! GODO
    #2
    brevor
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2006/01/20 19:48:14
    • Location: Valparaiso, In. USA
    • Status: offline
    RE: Flickering fire effect 2007/03/25 17:59:10 (permalink)
    0
    http://mondo-technology.com/candle.html
    This guy did a project to simulate a flickering candle flame.
    #3
    Ldanielrosa
    Super Member
    • Total Posts : 285
    • Reward points : 0
    • Joined: 2004/05/01 15:50:06
    • Location: Bellingham, WA. Usania
    • Status: offline
    RE: Flickering fire effect 2007/03/25 20:15:42 (permalink)
    0
    My very first program was not a simple flashing LED, but four each on their own pseudorandom pattern.  It was very annoying, and the first thing I thought was that it would be pretty good for a fire simulator.

    The PRBS took less than thirty lines of code, and isn't likely to repeat when I'd notice.
    #4
    coffee
    Starting Member
    • Total Posts : 84
    • Reward points : 0
    • Joined: 2006/11/29 10:47:09
    • Location: UK
    • Status: offline
    RE: Flickering fire effect 2007/03/26 12:47:43 (permalink)
    0
    Ok, so I've got a pretty good effect going using two feedback shift registers and four leds.  Code for the random SR function is the top code from the piclist link http://www.piclist.com/techref/microchip/rand8bit.htm. I'm incor'ing the two registers together so that the leds are on more often than not, and I'm using one as a random delay count too.

    The only thing that could be better is that because (I think) I'm using two 8 bit shift registers, and the inc-or, there are times when all four leds are on for a noticable time.  Something makes me suspect that if I used smaller registers than 8 bits, that might not happen as much? Maybe a 4 bit and a 5 bit? Or can I just change the "taps" used in the randomising functions?

    Thing is, I'm a bit confused about how to do that within a byte.  Can anyone enlighten me?

    edit - realised I'd confused my inc and x ors... I'm using inc-ors, as corrected above...
    post edited by coffee - 2007/03/27 08:31:17
    #5
    paulbergsman
    Super Member
    • Total Posts : 1517
    • Reward points : 0
    • Joined: 2006/05/25 12:18:23
    • Location: Merion Station, Penna.
    • Status: offline
    RE: Flickering fire effect 2007/03/28 05:45:42 (permalink)
    0
    ORIGINAL: coffee
    My dad's asked me if I can put together something that will simulate a flickering fire for use on his model railway.  I was planning to use a 12F509 with a red, yellow and orange leds (possibly 2 of one colour depending on how the colour balance works out, maybe orange).  And I know I'll have to have a play with various resistor values at some point to get the effect right.

    My issue is trying to come up with the right approach to getting random flicker effects, while still trying to keep as at least one led lit. 


    A simple, quick, and realistic looking flame can be had by doing the following:

    Cut some red cloth into small strips.
    Attach the red strips to a small computer fan.
    Position the fan underneath the red strips.
    Use a small flood lamp in front, or above,  the red cloth, to create red hot flames.
    The results are very realistic.

    I have seen this method in use at Disney World, and by commerical stage productions.




    A second method uses neon bulbs.
    Construct several neon lamp oscilators. 
    Each neon bulb should blink at a differant frequency.
    Place the neon bulbs, in a cluster,  behind a foggy plastic sheet.

    This is not as convincing as the first method.
    But, it uses very little power, and runs forever (on 117v ac.

    post edited by paulbergsman - 2007/03/28 05:53:53

    Paul Bergsman, N3PSO


    For the most cost effective PIC prototyping board around:
    http://mysite.verizon.net/vzes94mj/picprototypingboard
    #6
    coffee
    Starting Member
    • Total Posts : 84
    • Reward points : 0
    • Joined: 2006/11/29 10:47:09
    • Location: UK
    • Status: offline
    RE: Flickering fire effect 2007/03/28 12:20:45 (permalink)
    0
    Cheers Paul, but when it's a N scale layout, I'm not sure you can get a fan that small!

    The 4 led effect I've got so far is pretty good when you have a cone of white paper over the leds...
    #7
    luhan
    Starting Member
    • Total Posts : 51
    • Reward points : 0
    • Joined: 2003/11/07 12:37:45
    • Status: offline
    RE: Flickering fire effect 2007/03/31 06:00:22 (permalink)
    0
    assmebler?  Yep, my spellchecker (Mozilla Composer) apparently does not do links!
    #8
    violin
    Super Member
    • Total Posts : 3301
    • Reward points : 0
    • Joined: 2005/05/09 04:59:48
    • Status: offline
    RE: Flickering fire effect 2007/03/31 06:30:53 (permalink)
    0
    http://members.shaw.ca/novotill/FireLightFlicker/

    Hi. I built from this circuit a few years ago, before getting into pics. It works great. Regards.
    post edited by violin - 2007/03/31 06:34:51
    #9
    stefanodel
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2007/04/10 04:43:09
    • Location: 0
    • Status: offline
    RE: Flickering fire effect 2007/04/10 13:22:37 (permalink)
    0
    ORIGINAL: violin

    http://members.shaw.ca/novotill/FireLightFlicker/

    Hi. I built from this circuit a few years ago, before getting into pics. It works great. Regards.


    I saw the schematic of the circuit, there are the outputs 4,8, 10 and 12 of the Schmitt Trigger inverters (MC14584) connected to the output Q of 41013. This could be very dangerous, because due to different delays of inverters and flip-flop, it is very easy to have for a some time a short circuit between pin 13 of 4013 and the outputs 4,8,10 and 12 of mc14584. I don't understand the reason of this strange configuration, by my point of view wrong.

    In order to simulate a candle I think that a good starting point could be this:
    http://instruct1.cit.cornell.edu/courses/eceprojectsland/STUDENTPROJ/2001to2002/pc59//index.htm

    Regards
    #10
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    RE: Flickering fire effect 2007/04/10 13:30:46 (permalink)
    0
    Nice one, this latest one: lots of environmental parameters!

    As for that previous one, I did notice the short-circuit, but IMO it can work all the same. Of course, when you have a PIC you can do better!

    GENOVA :D :D ! GODO
    #11
    paulbergsman
    Super Member
    • Total Posts : 1517
    • Reward points : 0
    • Joined: 2006/05/25 12:18:23
    • Location: Merion Station, Penna.
    • Status: offline
    RE: Flickering fire effect 2007/04/10 14:21:56 (permalink)
    0
    ORIGINAL: coffee

    Cheers Paul, but when it's a N scale layout, I'm not sure you can get a fan that small!

    The 4 led effect I've got so far is pretty good when you have a cone of white paper over the leds...


    Hello coffee;

    I just got back from a 7-day cruise.  Because the ship uses gas turbine engines, smoking was allowed in only two outside areas.
    I noticed that flickering candles, using LEDs, were used in all religious services. The flicker was quite impressive.
    So, I stand corrected. A rather convincing flickering candle can be simulated with LEDs.



    Paul Bergsman, N3PSO


    For the most cost effective PIC prototyping board around:
    http://mysite.verizon.net/vzes94mj/picprototypingboard
    #12
    violin
    Super Member
    • Total Posts : 3301
    • Reward points : 0
    • Joined: 2005/05/09 04:59:48
    • Status: offline
    RE: Flickering fire effect 2007/04/11 04:13:02 (permalink)
    0
    I saw the schematic of the circuit, there are the outputs 4,8, 10 and 12 of the Schmitt Trigger inverters (MC14584) connected to the output Q of 41013. This could be very dangerous, because due to different delays of inverters and flip-flop, it is very easy to have for a some time a short circuit between pin 13 of 4013 and the outputs 4,8,10 and 12 of mc14584. I don't understand the reason of this strange configuration, by my point of view wrong.


    Hmm. I really don’t understand your bit “This could be very dangerous”. Can you elaborate a bit more on this statement? All I can say is that I can assure you 100% that this circuit works brilliantly. In fact it works so brilliant. That not did I just build one of them, but 8 of them altogether and they have all been properly soaked tested. Also they are all still functioning today. Well apart from the one that I gave away. – That I don’t know off. I guess so, with my building ability.

    I am still can not get over your statement of “very dangerous”. Do you think I would post something here or anywhere if I was dubious of its circuitry? Regards.
    post edited by violin - 2007/04/11 04:14:22
    #13
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    RE: Flickering fire effect 2007/04/11 10:36:52 (permalink)
    0
    Hi Violin, I think (this is what I guessed) that Stefanodel referred to the fact that Q and Q- outputs are connected together via a bunch of inverters. This could, in theory, lead to transient short-circuit between Q and Q-, depending on run-through time of Schmitt-triggers.
    It's going to be nSec, so nothing really bad IMO.

    GENOVA :D :D ! GODO
    #14
    stefanodel
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2007/04/10 04:43:09
    • Location: 0
    • Status: offline
    RE: Flickering fire effect 2007/04/11 10:42:40 (permalink)
    0
    ORIGINAL: violin

    I saw the schematic of the circuit, there are the outputs 4,8, 10 and 12 of the Schmitt Trigger inverters (MC14584) connected to the output Q of 41013. This could be very dangerous, because due to different delays of inverters and flip-flop, it is very easy to have for a some time a short circuit between pin 13 of 4013 and the outputs 4,8,10 and 12 of mc14584. I don't understand the reason of this strange configuration, by my point of view wrong.


    Hmm. I really don’t understand your bit “This could be very dangerous”. Can you elaborate a bit more on this statement? All I can say is that I can assure you 100% that this circuit works brilliantly. In fact it works so brilliant. That not did I just build one of them, but 8 of them altogether and they have all been properly soaked tested. Also they are all still functioning today. Well apart from the one that I gave away. – That I don’t know off. I guess so, with my building ability.

    I am still can not get over your statement of “very dangerous”. Do you think I would post something here or anywhere if I was dubious of its circuitry? Regards.


    I will try to explain again, sorry if my english is not good, it is not my language. In the circuit there are the output "Q" of 4013 and the outputs of  4584 connect together.
    The output of 4013 and the ouputs of 4584 for a short time don't have the same value, due to the delay of 4584. So there is a short circuit at the outputs. The statement of “very dangerous” is referred to this situation. The short circuit could be dangerous for the gates. It is not a good practice short the output of gates. Moreover I don't understand the reason to connect pin Q of 4013 to the outputs of 4584 ,if  you know the reason, please explain it to me.
    I am absolutely sure that you have test the circuit, but for me the circuit has this problem.

    Regards
    #15
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    RE: Flickering fire effect 2007/04/11 11:09:34 (permalink)
    0
    I guess that the reason was to make use of Q output as one more source of power for the led(s), beyond the 4 Ports...

    GENOVA :D :D ! GODO
    #16
    violin
    Super Member
    • Total Posts : 3301
    • Reward points : 0
    • Joined: 2005/05/09 04:59:48
    • Status: offline
    RE: Flickering fire effect 2007/04/12 09:38:26 (permalink)
    0
    I will try to explain again, sorry if my english is not good, it is not my language. In the circuit there are the output "Q" of 4013 and the outputs of  4584 connect together.
    The output of 4013 and the ouputs of 4584 for a short time don't have the same value, due to the delay of 4584. So there is a short circuit at the outputs. The statement of “very dangerous” is referred to this situation. The short circuit could be dangerous for the gates. It is not a good practice short the output of gates. Moreover I don't understand the reason to connect pin Q of 4013 to the outputs of 4584 ,if  you know the reason, please explain it to me.
    I am absolutely sure that you have test the circuit, but for me the circuit has this problem.

    Regards

     
    Ah. I see. When you said “very dangerous” I was thinking you meant it in the way to anyone was operating it. Now I understand you meant it in the way that the circuit will fault.
     
    As already said, I come across this circuit a number of years ago, when my main interest then, was with lights and leds. I can see what you are getting at, but I have never really gone into its theory, I was only interested in building this circuit to test, then to add it to the many other lighting circuits that I have built over the years.
     
    All I can say again, that this circuit does work and without problems when left on over a period off time and hats-off to the person/s who designed it. Regards.
    #17
    Jump to:
    © 2019 APG vNext Commercial Version 4.5