How to simulate a disturbed power supply?

Hi all,

I'm quite a newbie regarding projects with arduino, so please be patient :slight_smile:
You know how the lighting flickers (in movies sometimes in former times when the electric chair is run, or just in a 3rd world country) when it is connected to a disturbed power supply.
I want to simulate that effect with an arduino.
It's a bit like an electric candle and there's enough examples for that, but this is yet a lot different from that. The lighting is quite constant, with every then and now a ripple in it so the lighting dims somewhat.

Thanks for the help! :slight_smile:

Tell more. What light source are you intending to modulate?

tmd3:
Tell more. What light source are you intending to modulate?

Well, it's for the lighting in my PC and, at the same time, for a school assignment. (it's a custom build, nostalgic/WWII era, looking case) I have gauges with lighting in them mounted on the front of my PC, and I want them to flicker softly, not like a candle but more, crackling or something, I don't know how to decribe it better.. :s

He means, what type of lights are you using?

Are the incandescent, led, ect? How are they powered.

That sort of thing.

A picture might help

Qdeathstar:
He means, what type of lights are you using?

In my case and in the gauges are lightbulbs, but if it's only possible with LED's i could also replace them with LEDs.

TR_7:
... lightbulbs ...

OK, I think you mean that you plan to use small incandescent lamps. Voltage? Wattage? Do you have a commitment to any particular devices for controlling the current to these lamps?

TR_7:
In my case and in the gauges are lightbulbs, but if it's only possible with LED's i could also replace them with LEDs.

I would op for LED - will be easier on power source and you could "drive" it directly from Arduino if less than 20 mA. Modern SMT LEDs take just few mA to light, but you are still limited to max load - I believe 50 mA.
But for "real" feel original incandescent would be better.

Here is a crazy idea - since you are going to use external power supply anyway why not control the power supply?
It would make all "crashes" flicker same ( real cool and realistic ) and most switching power supplies have "overload" shutoff so you could simulate that.

The real issue is - how to bypass the power supply output capacitor so it won't hold the output and discharge gradually.
Maybe small ( value , quick discharge) bleed off resistor.
This is getting tricky.

So what kind of WWII panel have you build ? ( A picture would be appreciated ).

LEDs can be programmed to fade in/out at different speeds too, to simulate the slower turn on/off of the incandescent element that heats up & cools off. They don't just need to be instant on/instant off, which is how an LED typically changes.

Use random()

Use PWM. Drive them at 100% most of the time, dropping to say 75% for a short period of time. Use random to establish when to drop.

dannable:
Use PWM. Drive them at 100% most of the time, dropping to say 75% for a short period of time. Use random to establish when to drop.

Yes. In the past I have had a lot of fun with nested, scaled and integrated probability functions. Go wild.

tmd3:
Voltage? Wattage? Do you have a commitment to any particular devices for controlling the current to these lamps?

My fault, I haven't mentioned it but to control the lighting i will use a mosfet, but that shouldn't be a problem.
So voltage and wattage don't matter regarding the arduino. The only thing i need is the flickering signal from the arduino.

Vaclav:
I would op for LED - will be easier on power source and you could "drive" it directly from Arduino if less than 20 mA. (...)
Here is a crazy idea - since you are going to use external power supply anyway why not control the power supply?

Yeah i'm trying with the bulbs now first and if that doesn't work i'll use LEDs. But since i'd use multiple LED's i'll still have to use a mosfet, current will be over the limit.. But what do you mean by controlling the powersupply? How would that enhance the flickering? I dunno if you've read the whole post but controlling the PSU of my PC doesnt sound really safe to me :stuck_out_tongue: The thing i've built is a custom PC case which has a nostalgic/old/retro look. It's not finished yet, but i'll post a picture. :slight_smile:

CrossRoads:
LEDs can be programmed to fade in/out at different speeds too, to simulate the slower turn on/off of the incandescent element that heats up & cools off. They don't just need to be instant on/instant off, which is how an LED typically changes.

The best example i can give of what i'm trying to achieve is the flickering lamp you see in movies when they run the electric chair in an old prison, like in the green mile or something.
That is a lightbulb and it flickers bacause of the disturbed power supply.
LEDs are more and better manipulable but i dont nescessarily need that, it's only more work to let the LEDs fade in and out, because lightbulbs do that naturally. This way i only need a signal from the arduino to simulate such a disturbed power supply. Sorry if i'm being a bit vague :S i can't really describe it better, and certainly not in english since its not my native language..

dannable:
Use PWM. Drive them at 100% most of the time, dropping to say 75% for a short period of time. Use random to establish when to drop.

Sounds like that would work, but how would i write it so that it looks like it's connected to a disturbed power supply? if it just drops to a constant 75% for a few seconds it doesnt really look natural.. Do you know how i could achieve that?

aarg:
Yes. In the past I have had a lot of fun with nested, scaled and integrated probability functions. Go wild.

How would i create a script that simulates the desired effect with a probability function?
I'm sorry i dont have extensive programming experience..

But what do you mean by controlling the powersupply? How would that enhance the flickering? I dunno if you've read the whole post but controlling the PSU of my PC doesnt sound really safe to me :stuck_out_tongue:

Here are some details for this idea.
I assumed that your WWII panel is using incandescent light bulbs and would be powered from its own power supply, not from PC.
If you use such power supply , even savaged one from PC, you could control the output of it.
"standard AT " PC power supply has such control already build in. It is a single lead if I remember right - it shuts off the power supply.

Other brands PC power supply modules have more complex controls.

I had an opportunity to restore WWII US navy com panel with couple of dozens of lights and discarded using LED's just because it was not authentic.

I'll try some "crash " stuff on my Due LED 13 , I don't think just using random() on digital output will work.
Have fun.

I wonder if you could make something like a light in series with 3 different mosfets. Each mosfet would have a resistor of a different value (maybe a diode as well). By randomly turning the mosfets on or off (including allowing the mosfets to be on at the same time) the voltage to the lamp would be all over the place.

Here's what I think your project will look like, since it doesn't look like you're going to tell us:

All the light bulbs will be connected in parallel. One end will be connected to some positive supply voltage, and the other will be connected to a MOSFET. The other side of the MOSFET will be connected to the power supply ground.

You'll drive the MOSFET with a PWM pin from the Arduino. In normal operation, the PWM value will be the maximum, maybe 255, or 65535, or something, depending on which timer you select for PWM, and which mode you select for that timer.

When it's time for flickering, you'll reduce the PWM value according to some specific profile, to simulate an effect that you're trying to achieve.

You're asking us, "What's the profile?"

Have I got that right?

I would run the LEDs at full brightness and dim them by a random amount, a random number if times and at random intervals.

Turn the LEDs on at full brightness.
Delay for 10 - 30 seconds.
Repeat a for loop a random number of times between 10 and 20
  Dim the leds by a random amount (say 10-75% brightness)
  wait a random length of time (0.05 - 0.3 seconds)
  Leds full brightness
  wait a random length of time (0.05 - 0.3 seconds)
  Back to the start of the for loop.
Go back to the start of the program.

You could use PWM with a mosfet to achieve the dimming.