Pages: [1]   Go Down
Author Topic: lightning simulation help  (Read 1965 times)
0 Members and 1 Guest are viewing this topic.
uk
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hi all
i'm looking to find any thing in the forum about thunderstorms but no luck
i am wanting to simulate a thunderstorm with arduno mega nothing flashy just simple i want to drive a strip of led's 900Ma  any help would be appreciated with the code and what hardware to use ie relays or transistors and witch one to use i would like the simulation to work for 3 seconds and a 1 minute pause.

thanks all

marko
« Last Edit: May 09, 2012, 05:40:33 pm by markthespark » Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 224
Posts: 13917
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


this is a starting point for the software , there are three parameters:

BETWEEN is max number of milliseconds between two flashes
DURATION is the max duration of one flash
TIMES is the max number of subflashes in a flash

These numbers are randomized to get random effects (you might want to seed the random function)

it is based upon the tutorial blink without delay to do the timing between flashes - but it uses delay for the flashes themselves -
it can be rewritten completely without delays but that is left as an exercise for the reader smiley-wink

You can extend this to multiple LEDS with their own "rythm"

give it a try (it uses the onboard LED for easy testing)
Code:
//
//    FILE: lightning.pde
//  AUTHOR: Rob Tillaart
//    DATE: 2012-05-08
//
// PUPROSE: simulate lighning POC
//
//
#define BETWEEN 2579
#define DURATION 43
#define TIMES 7

#define LEDPIN 13

unsigned long lastTime = 0;
int waitTime = 0;

void setup()
{
  Serial.begin(115200);
  Serial.println("lightning 0.0");

  pinMode(LEDPIN, OUTPUT);
}

void loop()
{
  if (millis() - waitTime > lastTime)  // time for a new flash
  {
    // adjust timing params
    lastTime += waitTime;
    waitTime = random(BETWEEN);

    for (int i=0; i< random(TIMES); i++)
    {
      Serial.println(millis());
      digitalWrite(LEDPIN, HIGH);
      delay(20 + random(DURATION));
      digitalWrite(LEDPIN, LOW);
      delay(10);
    }
  }
 
  // do other stuff here

}
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

uk
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

thats perfect dude many thanks will an irf530 do the job i have seen on other sites that there compatable with arduino
Logged

uk
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

i have just tried to add this code to the bottom buttom of the one above

i have changed the code myself to blink like eyes


/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 9;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);    
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(150);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(5000);               // wait for a second
« Last Edit: May 08, 2012, 04:12:49 pm by markthespark » Logged

Offline Offline
Edison Member
*
Karma: 36
Posts: 1341
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The software is no big deal...

But the hardware is a big deal...
   You can't just use a MOSFET, because you need constant-current and with 10W LEDs it's not practical to use a linear current regulator.  With a regular every-day 40mW LED, a resistor works fine to control/limit the current.    But, with a high-power LED you end-up needing a high-power resistor and a high-power power-supply to provide the power for the LED plus the extra power wasted in the resistor.

Typically, you'd use a special constant-current switching power supply (example).  You'd need to find a power supply that allows you to "flash" the LED for a few milliseconds, or you'd need to build your own.  I assume that's an easy feature to find, since LEDs are often flashed & dimmed.

As you may know, most medium & hign-power strobe lights use a xenon flash tube.  But, these things are not easy to build either, because they require a high-voltage power supply and a high-voltage trigger circuit. Plus, the light from the flashtube is not directional so you need a reflector.

 
Logged

uk
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

would the relay module do the job ?
i'm powering a 12volt led strip with 12 volts and just need something to do the switching
« Last Edit: May 09, 2012, 01:09:15 pm by markthespark » Logged

uk
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

i used this circuit with an irl520n it works fine any one see any problems ?
a string of led's 900Ma


* pwm-mosfet.png (22.96 KB, 839x1028 - viewed 81 times.)
« Last Edit: May 09, 2012, 04:40:04 pm by markthespark » Logged

uk
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

vid here

http://s491.photobucket.com/albums/rr277/markosillypig/?action=view&current=DSCN1787.mp4
Logged

Dubuque, Iowa, USA
Offline Offline
Faraday Member
**
Karma: 49
Posts: 2546
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Embedded in your LED strips there are resistors that limit the current to the LEDs and in that respect your circuit is inaccurate and/or doesn't match what you described in your initial post at all. Please show some respect for the time that others spend answering your questions in the future.

With that said it's good to see you accomplished your goal.
Logged

uk
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

not a problem arduino is new to me as i'm a pic man at heart and the answers i had confused me
« Last Edit: May 09, 2012, 06:21:16 pm by markthespark » Logged

Pages: [1]   Go Up
Jump to: