Archive

Posts Tagged ‘avr’

Auditorium Lightning Effect

April 15th, 2011 Comments off

A few years back I was working on a production of Shadowlands for a high school and one of the scenes had thunder and lightning.  We were going to use some simple lighting for the lightning but I had some alternative ideas and spent some time experimenting with them.  The end result was a nice lightning effect that we used for the shows.

I initially started looking at strobe lights to create this effect due to their quick recharge time but quickly turned elsewhere.  There were a number of inexpensive units available but they were all geared towards DJ lighting and could only flash at a fixed frequency.  Not being too familiar with strobe lights like these I wasn’t sure how easy they would be to modify to accept an external trigger.

Next on the list were external camera flashes which can be externally triggered through the hot shoe mount.  The main downside was a 15 second recharge time on the flashes so multiple flash units were needed to have multiple flashes in quick succession.  There was a nice assortment of inexpensive camera flashes available, but to cut the bill to zero I was able to borrow 3 nice Sigma flashes from the journalism department of the school.  I wasn’t able to make any modifications to the borrowed flashes and without any hot shoes for them it was difficult to connect to the hot shoe contacts.

Like most external camera flashes, the Sigma flashes were able to be set in slave mode where they fire when another flash is detected.  I wasn’t sure at first how this worked but the transparent red cover over the sensor was a pretty strong hint that it was detecting the infrared light of the other flash.  Testing this was simple enough by just pointing any IR remote control at it and pressing a button and the flash would fire.

Auditorium Lightning Flashes

With the flashes and triggering method in place it was on to a control mechanism to trigger them.  I had plenty of AVR microcontrollers on hand and assembled a simple control circuit on a breadboard.  The main components were an ATMEGA168, pushbutton, and 4 LEDs.  For testing I initially started out with regular LEDs and once working these were swapped out with IR LEDs for triggering the flashes.

Auditorium Lightning Controller

The code for the AVR was very simple:  wait for the button to be pressed, pulse the LEDs in one of the predefined and timed pattern, repeat.  I ended up only using two flash patterns but the code is easily expanded to include additional ones.  DMX is the typical lighting control protocol but given the constraints for this project the simple pushbutton was used instead.  The full code that was used is shown below.

The flashes were mounted in the auditorium catwalks with two on the left and one on the right.  The IR LEDs were attached to the flashes with gaff tape and then connected to the breadboard with CAT5 cable.

In the end this was a successful project and worked well through all three performances.

#include <util/delay_basic.h>
#include <avr/io.h>

#define FLASH_MS 25
#define FLASH_RECHARGE_MS 15000

void delay_ms(uint16_t ms) {
  uint16_t a = 0;

  while (a < ms) {
    uint16_t d = ms - a;
    if (d > 200) {
      d = 200;
    }

    _delay_loop_2(d << 8);
    a += d;
  }
}

void adj_delay_ms(unsigned short ms) {
  delay_ms(ms - FLASH_MS);
}

void trigger_flash(unsigned char n) {
  PORTD |= _BV(n);
  delay_ms(FLASH_MS);
  PORTD &= ~_BV(n);
}

int main (void) {
  DDRD = 0xff; /* all outputs */
  PORTD = 0x00;

  char program = 0;

  while (1) {
    // wait for flashes to charge
    delay_ms(FLASH_RECHARGE_MS);

    // turn on "ready" LED
    PORTD |= _BV(PD3);

    while (PINC & _BV(PC4)) {
      // wait for button press
    }

    // turn off "ready" LED
    PORTD &= ~_BV(PD3);

    switch (program) {
    case 0:
      trigger_flash(0);
      adj_delay_ms(100);

      trigger_flash(1);
      adj_delay_ms(500);

      trigger_flash(2);
      break;
    case 1:
      trigger_flash(2);
      adj_delay_ms(400);

      trigger_flash(0);
      adj_delay_ms(140);

      trigger_flash(1);
      break;
    }

    program += 1;
    if (program > 1) {
      program = 0;     
    }          
  }     

  return (0);
}
Tags: ,