Pseudo-Random multiple LED fade in/fade out circuit (No MCU/programming)

Thread Starter

AnasMalas

Joined Nov 27, 2015
66
Edit: Many kind users have posted solution different to that of a 4017, one using OpAmps and three using Logic gates (one using a 74HC04; NOT gates and two using 74HC14 "hex inverting schmitt trigger"). These circuits (not tested in real life yet) are supposed to give LEDs a psedo-random FADE in and fade out for esthetic purposes.This is why the title was changed for others to find a good solution more easily. If you want to, you could still read the original text:
.
.
.
.
If you dont like long talk that is not needed. skit until the "TL;DR" part.
Hello! I am sorry if this is the wrong place to post, but i felt like the 4017 doesnt belong to the Embedded and micro section. if it does please tell me, i will close this thread and open one there, alternatively a moderator could move it.

You could have seen my previous (Waaaaaaaaaaaaaay too long) post (more like essay) asking to do this with programming MCUs, specifically 15 LEDs randomly fading and with a button press they would go in a sequence (They are tied to letters of someone's name) that spells out a joke (Example Mad Dad from Adam....) here: http://forum.allaboutcircuits.com/t...ble-microcontroller-for-multiple-leds.117905/

back then i felt the need for doing it how i visioned it (I was a perfectionist back then, but a small sour experience was enough to rip that out of me), and didnt take any proper advice that i should have.
i didnt have time to learn more programming ever since, so ive changed my mind
NOT TO BORE YOU WITH ANOTHER ESSAY, HERE IS MY PROBLEM(TL;DR)

I now want to just have randomly fading in and out LEDs that randomly fade (not a pattern). i want to use chips that dont require programming and heard many talk about 555 + 4017 or other chips, so that is what i need.

Also are EBAY listings like:
http://www.ebay.co.uk/itm/20Pcs-CD4...592812?hash=item3f56f147ec:g:COgAAOSwCypWmGTT
any good? will they come damaged? are there different types of this chip? Thank you.
 
Last edited:

dannyf

Joined Sep 13, 2015
2,197
You would have a much better chance of success if you break up your projects into manageable and soable pieces and tackle them individually.

As to generate random numbers there are quite some approaches. Using adc, relying on phase noises, RS latches' forbidden States, avalanching PN junctions, zeners, quantum effects, .....

Pick one that you are comfortable with and get on with it.

I have a page where I showed two approaches I tried, one without any need for programming.
 

Bernard

Joined Aug 7, 2008
5,784
I do not have a clear picture of " random fading in & out".
Something like a string of toggle flip-flops with outputs driving LEDs thru a RC delay ; toggles driven by a random pulse generator ?
 

Alec_t

Joined Sep 17, 2013
14,280
Would it be acceptable to have 15 (or whatever) LEDs each with a respective fixed (i.e non-random) fade-in-fade-out period different from that of its neighbours, so that the overall appearance of the array would be pseudo-random?
 

Bernard

Joined Aug 7, 2008
5,784
Here's an attempt to illustrate random ramp up & ramp down as might be produced by toggle flip-flops triggered by a random pulse generator. Can you give us a better illustration that will fit your needs?Random Nos 00000.jpg
 

Thread Starter

AnasMalas

Joined Nov 27, 2015
66
Would it be acceptable to have 15 (or whatever) LEDs each with a respective fixed (i.e non-random) fade-in-fade-out period different from that of its neighbours, so that the overall appearance of the array would be pseudo-random?
Yes, i was looking for something like that. as long as the fading is not so predictable. i want to give it a polished look because its ment to be given off after not so much time (2 months max) as a gift that is supposed to last a lifetime and remind my friends of our friendships. I will need to cut wooden pieces, spray them black, carve out my friends' names, paint that red. and add all the LEDs to make a nice effect.

Also, to everyone else. Thank you for your suggestions, however i do no have any idea about any of what you are suggesting and having IGCSEs next month i do not have much time to learn and implement. i would appreciate if you could tell me how to do it, linking any projects that you know of.

also bernard, that doesnt look to be exactly what i want, but if is easy to implement who cares! i assume i would work just as well for 10 LEDs as 5 in your drawing? could you tell me what parts would be needed?
 

Bernard

Joined Aug 7, 2008
5,784
Looks like your best bet is to use Alec-t's suggestion implemented with a 555 or 556, dual 555, one for each LED. Power source has not been addressed yet. For Wendy's Throbbing LED's, 9 V is required, modified with added R ,C & MPSA14, 5 V to 6 V would be about right.
 

Thread Starter

AnasMalas

Joined Nov 27, 2015
66
Looks like your best bet is to use Alec-t's suggestion implemented with a 555 or 556, dual 555, one for each LED. Power source has not been addressed yet. For Wendy's Throbbing LED's, 9 V is required, modified with added R ,C & MPSA14, 5 V to 6 V would be about right.
so a 4017 isnt the correct chip to use, rather each LED gets its own 555 (556 for 2 LEDs)?
that would be pretty bulky wouldn't it? is there like a 559 that has 4 555s? :D

Oh, and i did not mention the power source? its a 1.5$ powerbank! so we are working with 5v.
 

Sensacell

Joined Jun 19, 2012
3,432
A 4017 is not going to give you much in the way of random, unless you clock it with random bursts of clock pulses.

Seems like the simplest approach is to have a separate oscillator for each LED that drives an integrator and current source to create the brightness ramping effect. This could be achieved with a quad opamp.

The "random" nature comes from the analog timing components in each oscillator, they will never be the same exact frequency, so over time they will appear to have totally random phase with respect to each other.
 

Thread Starter

AnasMalas

Joined Nov 27, 2015
66
A 4017 is not going to give you much in the way of random, unless you clock it with random bursts of clock pulses.

Seems like the simplest approach is to have a separate oscillator for each LED that drives an integrator and current source to create the brightness ramping effect. This could be achieved with a quad opamp.

The "random" nature comes from the analog timing components in each oscillator, they will never be the same exact frequency, so over time they will appear to have totally random phase with respect to each other.
Aha, got it. is this the component you are talking about?
http://www.zeroohm.ae/LM358
I dont really have any idea how to use it, could you tell me? is it just connecting this to that or do i need filtering capacitors/resistors/oscillators?
 

Sensacell

Joined Jun 19, 2012
3,432
Here is the basic idea- you need a good modern rail-to-rail opamp. (a 741 would not cut it here)

Component values might need some tweaking. Use non- polarized capacitors.

Depending on input offset voltages, you might need a resistor across the LED to make it go 100% dark.
 

Attachments

Thread Starter

AnasMalas

Joined Nov 27, 2015
66
Here is the basic idea- you need a good modern rail-to-rail opamp. (a 741 would not cut it here)

Component values might need some tweaking. Use non- polarized capacitors.

Depending on input offset voltages, you might need a resistor across the LED to make it go 100% dark.
wow, I really want to thank you for your time, that must've taken some effort to make!
So, just some clarifications that i need as i do not have experience here:
This is randomizing a single LED, would need such a circuit for each LED?
The local supplier only has the 741 (which you said is no good for me), and the LM358N. is that same as the LMV324L you used in the diagram/schematic?

Also i do not really know what an OpAmp is, some explanations on google weren't clear. is it like a Xor gate that requires voltage on the top only?
thanks again.
 

hp1729

Joined Nov 23, 2015
2,304
Hello! I am sorry if this is the wrong place to post, but i felt like the 4017 doesnt belong to the Embedded and micro section. if it does please tell me, i will close this thread and open one there, alternatively a moderator could move it.

You could have seen my previous (Waaaaaaaaaaaaaay too long) post (more like essay) asking to do this with programming MCUs, specifically 15 LEDs randomly fading and with a button press they would go in a sequence (They are tied to letters of someone's name) that spells out a joke (Example Mad Dad from Adam....) here: http://forum.allaboutcircuits.com/t...ble-microcontroller-for-multiple-leds.117905/

back then i felt the need for doing it how i visioned it (I was a perfectionist back then, but a small sour experience was enough to rip that out of me), and didnt take any proper advice that i should have.
i didnt have time to learn more programming ever since, so ive changed my mind
NOT TO BORE YOU WITH ANOTHER ESSAY, HERE IS MY PROBLEM(TL;DR)
I now want to just have randomly fading in and out LEDs that randomly fade (not a pattern). i want to use chips that dont require programming and heard many talk about 555 + 4017 or other chips, so that is what i need.

Also are EBAY listings like:
http://www.ebay.co.uk/itm/20Pcs-CD4...592812?hash=item3f56f147ec:g:COgAAOSwCypWmGTT
any good? will they come damaged? are there different types of this chip? Thank you.
Truly random blinking or just apparently random? Blink how fast? Fade in and out how quickly? Have the pattern change after pushing a button? That sounds like a processor is called for. Generating a random pattern with a processor? Just read program memory (if that is allowed by the processor).
Harvard architecture processors, like PICxxx, have separate program and data memories.
 

takao21203

Joined Apr 28, 2012
3,702
Maybe my LED matrix PCB would be right for the job.

Recently I found its possible instead of a matrix, mount 10pcs RGB LEDs.
Each can be programmed freely. You just need C language and a PIC Flash writer.

Ive had some customers of CD4017 LED chasers asking for programability.
So ive done a few prototypes for RGB LEDS and just now testing with a LED matrix PCB.

Unfortunately color fading isnt possible with analogue electronics.

The PCB can work from 1.2v battery if the dcdc converter is soldered.
 

Thread Starter

AnasMalas

Joined Nov 27, 2015
66
Truly random blinking or just apparently random? Blink how fast? Fade in and out how quickly? Have the pattern change after pushing a button? That sounds like a processor is called for. Generating a random pattern with a processor? Just read program memory (if that is allowed by the processor).
Harvard architecture processors, like PICxxx, have separate program and data memories.
I want apparently random fading just for aesthetics. i used to want to use a button and do a pattern but after many months of trying to learn programming and having not much time i ditched the idea.

So what i want is LEDs that look like they are randomly fading in and out. Speed is not important.
also i havent mentioned that as i am making 15 of these, being a student i dont have enough budget to use lots of expensive components.

Would a combination of 555 and 4017 not produce even random looking blinking? then maybe fading could be sorted if there is time.
 

Alec_t

Joined Sep 17, 2013
14,280
This is a project that is crying out for an MCU solution; but if you are determined to do it without an MCU then a lot of circuitry will be needed, since a separate fader for each LED is involved.
Sensacell has given you one option using opamps. Here is another option, using logic gates:-
Modulated-fader.PNG
This shows a PWM (Pulse-Width-Modulation) triangle generator section and two Fader Module sections (another 13 Fader Modules, all served by the one PWM triangle generator, would be required for your 15-LED project).
Each section uses two inverter gates of a 74HC04 IC, plus two resistors, to make a wide-hysteresis Schmitt trigger. This Schmitt, plus timing components (e.g. R2, C1), make an oscillator. Each oscillator output is taken from across its timing capacitor and is an approximate triangle wave. The PWM frequency, set by R2/C1, is about 370Hz (not critical). The Fader Modules generate much lower, different frequencies (the fade up/down rate), with periods of several seconds (your choice).
Weighting resistors (e.g. R7,R8,) sum the PWM triangle with the Fader Module triangle. The sum is the input to a gate (e.g. U1e) whose output changes state when the sum crosses its switching threshold (about half the supply voltage), resulting in a pulse-width-modulated output from the gate. The duty-cycle of this output ramps up and down in sympathy with the Fader Module triangle voltage, thus varying LED brightness from full on to full off.
Since the Fader Modules have respective different timing components (resistors and/or capacitors) their fades will be non-synchronised, so pseudo-random. Randomness can be enhanced by connecting a coupling resistor from an output (ModOut) of one Module to an input (ModIn) of another Module to modulate its timing (note the varying triangle periods in the yellow trace in the pic). The coupling resistor value shouldn't be less than about five times the value of the timing resistor of the Module being modulated. (For this simulation I used a 220k coupling resistor, with R12 = 39k).
 

Attachments

Last edited:

hp1729

Joined Nov 23, 2015
2,304
I want apparently random fading just for aesthetics. i used to want to use a button and do a pattern but after many months of trying to learn programming and having not much time i ditched the idea.

So what i want is LEDs that look like they are randomly fading in and out. Speed is not important.
also i havent mentioned that as i am making 15 of these, being a student i dont have enough budget to use lots of expensive components.

Would a combination of 555 and 4017 not produce even random looking blinking? then maybe fading could be sorted if there is time.
Random looking blinking, maybe. Fading, no.
 

Sensacell

Joined Jun 19, 2012
3,432
wow, I really want to thank you for your time, that must've taken some effort to make!
So, just some clarifications that i need as i do not have experience here:
This is randomizing a single LED, would need such a circuit for each LED?
The local supplier only has the 741 (which you said is no good for me), and the LM358N. is that same as the LMV324L you used in the diagram/schematic?

Also i do not really know what an OpAmp is, some explanations on google weren't clear. is it like a Xor gate that requires voltage on the top only?
thanks again.
The circuit runs ONE LED- you need one circuit for each LED.

It's best to use a quad opamp (4 amps in one package) this keeps the parts count down. The LMV324L is what they call a "rail-to-rail" opamp, which means that its input and output voltages can go from ground to the positive supply voltage (rail).

The LM358 cannot go all the way to the positive rail, my circuit could be made to work with this part by increasing R2 to reduce the reference voltage down to 1.5 V. Opamps require a supply voltage applied to the power pins - in this case +5V and ground.
 

Thread Starter

AnasMalas

Joined Nov 27, 2015
66
This is a project that is crying out for an MCU solution; but if you are determined to do it without an MCU then a lot of circuitry will be needed, since a separate fader for each LED is involved.
Sensacell has given you one option using opamps. Here is another option, using logic gates:-
View attachment 103885
This shows a PWM (Pulse-Width-Modulation) triangle generator section and two Fader Module sections (another 13 Fader Modules, all served by the one PWM triangle generator, would be required for your 15-LED project).
Each section uses two inverter gates of a 74HC04 IC, plus two resistors, to make a wide-hysteresis Schmitt trigger. This Schmitt, plus timing components (e.g. R2, C1), make an oscillator. Each oscillator output is taken from across its timing capacitor and is an approximate triangle wave. The PWM frequency, set by R2/C1, is about 370Hz (not critical). The Fader Modules generate much lower, different frequencies (the fade up/down rate), with periods of several seconds (your choice).
Weighting resistors (e.g. R7,R8,) sum the PWM triangle with the Fader Module triangle. The sum is the input to a gate (e.g. U1e) whose output changes state when the sum crosses its switching threshold (about half the supply voltage), resulting in a pulse-width-modulated output from the gate. The duty-cycle of this output ramps up and down in sympathy with the Fader Module triangle voltage, thus varying LED brightness from full on to full off.
Since the Fader Modules have respective different timing components (resistors and/or capacitors) their fades will be non-synchronised, so pseudo-random. Randomness can be enhanced by connecting a coupling resistor from an output (ModOut) of one Module to an input (ModIn) of another Module to modulate its timing (note the varying triangle periods in the yellow trace in the pic). The coupling resistor value shouldn't be less than about five times the value of the timing resistor of the Module being modulated. (For this simulation I used a 220k coupling resistor, with R12 = 39k).
I would like to deeply thank you for your detailed and thoughtful reply. I have tried to understand as much as i can. This stuff is why i want to study electrical engineering!
I dont really know how the circuit works, but i will learn that while building it. i just need some clarifications.

1)C1 is a ceramic cap, while c2 to c16 are electrolytic, Is this correct?
2)We need 3 NOT gates for each LED. so Out of every chip, we can run 2 LEDs?
3)The part number is 74hc04 or 74hc14? 74hc14 contains the word "schmitt" which you used. this confused me a little.
4)In case you really meant the 74hc04, why so? can i use any other NOT gate that a local supplier has?
5)Ground here is just the Negative of the USB, correct?
6)R6 and C2 or similar have to be different for each LED to achieve them being out of sync. thus the pseudo random look.
7)What is an .asc file (Schematic?) and how can i open it?

it will take me a couple of days to fully digest, but really thanks!
 

Thread Starter

AnasMalas

Joined Nov 27, 2015
66
I am not sure which to do honestly, Using OpAmps or Logic gates. i do know logic gates but not OpAmps. And so i do not understand
Sensacell's circuit at all. Which would be easier, cheaper and work better?
 
Top