Forums > Photography Talk > Arduino multi-flash sequencing

Photographer

Noah Russell

Posts: 609

Seattle, Washington, US

I wanted to play around with multi flash sequences last night and came up with some code. I have seen loop based code used for a couple projects on this site and thought I would post an alternative. This method is extremely fast and accurate. The project is based of the code I came up with when I made an electronic ignition for my lawn mower a couple years ago back.(because lawn mowers needs timing advance goddamit!)

For the mower I used direct port manipulation, for this sketch I used digitalWrite for simplicity. If you want to shave a few micro seconds off the execution time, search the interwebs for 'arduino direct port manipulation'

Connect your camera's sync port to Pin 2 on the uno and gnd. I was driving the strobes through nte3222 opto isolators connected to pin 12 & 13. You could just as easily trigger the lights first then the camera if that would be helpful.

If you want to know how it works, search the interwebs for "arduino hardware interrupts" and "arduino timer interrupts"

Cheers!
Noah

//This is the code
volatile int count = 0;//increments when the timer interrupt fires

void setup(void)
{
  pinMode(2, INPUT_PULLUP); // Enable the pull up resistor on pin 2 (sync pulse)
  attachInterrupt(0, syncPulseISR, FALLING);//Trigger the ISR when pin2 goes low (Pin 2 = interrupt 0 on UNO)
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);

  // initialize timer1
  noInterrupts();           // disable all interrupts
  TCCR1A = 0;
  TCCR1B = 0;
  TCNT1  = 0;
  interrupts();             // enable all interrupts

}

void loop(void)


{
  //Look Ma',no loop!
  //you could blink some lights here I guess
  delay(100);
}


void syncPulseISR ()
{
  TCCR1A = 0;
  TCCR1B = 0;
  TCNT1  = 0;
  OCR1A = 1500//sets the compare match register for how long  to wait before firing the flash on Pin 13 (value * 1/15624 second)
  TCCR1B |= (1

Aug 17 14 11:39 pm Link

Clothing Designer

GRMACK

Posts: 5436

Bakersfield, California, US

Arduino got my attention!  Sweet little gizmo.  wink

I made my flash sequencer using the 555 timer and a 4011 decade counter feeding the opto-isolators.  Fires 8 units one behind the other.  I mistakenly thought it would fill in a one-second exposure but seems I blew the math and it would take 300 flash units with a duration of 1/300 sec. each to make one second.  Not practical nor cheap, so this was a wasted effort due to my thinking the flash would be like shutter speeds in progression (i.e. Each addition making exposure twice as long.  Opps.).

So I had to turn to series 33 flashbulbs with a 1.75 second duration burn, Meggaflash PF-330 ($75 each in Hollywood, and still being made in Ireland.) or older Sylvania FF-33 bulbs off eBay.

Getting the flash bulb control off the new digital cameras was a mess with timing, but the Arduino Uno and a Seeed Relay Shield that plugs into the top of it did the job.  Both are at the local Radio Shack, $30 & $20 respectively.  I used 3 of the 4 relays on the Seeed Relay Shield to operate the Focus & Metering, Shutter, and Flash for each relay.  All are controlled by the Nikon MC-30A release and the relays act more like the release itself and totally isolated from the voltages of the Arduino and 15 volt flash battery (I stole 9 volts off the flash battery to run the Arduino and relays using 9 volt TO-220 style regulator.).  Release is triggering the Arduino, and two of the relays act like a secondary Nikon release to the 10-pin connector into the body.  Third feeds the flash bulb the 15 volts.

With the code, I can move the synch timing of the bulb left or right over the shutter's open portion so it can be programmed for X, M, FP, V, S, or Megga sync at will.  The Meggaflash bulbs need to be fired way "after" the shutter release, and the smaller Press 40 need to be fired "ahead" of the shutter due to the shutter lag.  You can see the LED's on the Seeed Relay Shield light in the proper timing sequence once the sketch (Program) is loaded and the release is pressed.

Anyhoo, here's the sketch (or Program) and code I made and used for the Press #40 bulbs if anyone wants to play with flashbulbs in the newer camera without resorting to blowing up the camera with higher currents or voltages via the PC or hot shoe:

*********

// Flashbulb Trigger by GRMACK.  This is for Press #40 flashbulbs with Nikon D800E. Turns on LEDs on when the two-stage MC=30A release is pressed (Two-staged SW1 &  SW2).  Start of delay relay timing sketch.
// Flash needs to be delayed until the 45ms shutter lag is completed.  Focus locked in Manual mode, else shutter lag will be need to be changed to 250ms from 45ms for AF mode.

const int LED1 = 4;   // The pin for the Green LED, or Relay Shield relay number 1 (Focus and Metering relay).
const int LED2 = 6;   //The pin for the Red LED, or Relay Shield relay number 2 (Flash relay).
const int LED3 = 5;   //The pin for the Yellow LED, or Relay Shield relay number 3 (Shutter relay).
const int BUTTON1 = 2; // The input pin where the focus switch is connected, or SW1 in remote release. Goes to 10K pullup resistor using 5 volts off Arduino.
const int BUTTON2 = 3; // The input pin where the shutter switch is connected, or Sw2 in remote release.  Goes to 10K pullup resistor using 5 volts off Arduino.

int val1 = 0; // Value will be used to store the state of the input pin.
int val2 = 0; // As above for button 2.
int val3 = 0; // As above.

void setup()
{
  pinMode(LED1, OUTPUT); // Green Focus LED and tell Arduino LED is an output.
  pinMode(LED2, OUTPUT); // Yellow Shutter LED and tell Arduino LED is an output.
  pinMode(LED3, OUTPUT); // Red Flash LED and tell Arduino LED is an output.
  pinMode(BUTTON1, INPUT); // Button 1 is Focus switch and an input.
  pinMode(BUTTON2, INPUT); // Button 2 is Shutter switch and an input.
}

void loop()
{
  val1 = digitalRead(BUTTON1); // Read input value and store it and check whether the input is HIGH (Release button pressed, and first SW1 turned ON.).
  if (val1 == HIGH)
  {
    digitalWrite(LED1, HIGH); // Turn the Green LED ON. This is for Focus and Metering relay.
  }
  else
  {
    digitalWrite(LED1, LOW); // Turn the Green LED OFF.
  }
  
// Following is for Shutter relay and Flash relay.

  val2 = digitalRead(BUTTON2); // Read input value and store it and check whether the input is HIGH (Release button pressed further, and second SW2 turned ON.).
  if (val2 == HIGH)
  {
    digitalWrite(LED3, HIGH); // Turn the Yellow LED ON.  Shutter fires.
  }
  delay (45); // Time delay of Red LED (Flash relay) in milliseconds to delay firing of #40 flashbulb by 45ms or camera's shutter lag time.
  if (val2 == HIGH)
  {
    digitalWrite(LED2, HIGH); // Turn the Red LED ON. Flash fires.
  }
  else {
    digitalWrite(LED2, LOW); //  Turn the Red LED OFF.
    digitalWrite(LED3, LOW); //  Turn the Yellow LED OFF.
   }
}


*********

One needs to flip the Red and Yellow LED's and set the delay number of 45 to 350 for the Meggaflash or Sylvania bulbs.

Enjoy!  smile

Aug 18 14 05:58 am Link

Photographer

Noah Russell

Posts: 609

Seattle, Washington, US

Very cool. The venerable 555 timer and flashtubes no less. Nice work.

Did you have trouble with your trigger switch "bouncing" It's not a problem with a PC cord but a standard momentary switch will register hundreds of button presses.

Also, the arduino has built in 20k pull-up resistors on the inputs, you just enable them in software using INPUT_PULLUP on the input pin.

Cheers!
Noah

Aug 18 14 06:42 am Link

Clothing Designer

GRMACK

Posts: 5436

Bakersfield, California, US

Noah Russell wrote:
Very cool. The venerable 555 timer and flashtubes no less. Nice work.

Did you have trouble with your trigger switch "bouncing" It's not a problem with a PC cord but a standard momentary switch will register hundreds of button presses.

Also, the arduino has built in 20k pull-up resistors on the inputs, you just enable them in software using INPUT_PULLUP on the input pin.

Cheers!
Noah

Didn't know the Uno had internal pullups.  I mounted my own circuit board for that on top of the Seeed Relay Shield (Version 2 of that part that has more rows of inputs on the top of it for stacking more gizmo boards.  Radio Shack had both and Version 1 doesn't allow for stacking so they exchanged it for the newer one which was $5 more.).  Plus, I needed a place for the 220uf trigger capacitor and 1.5K feeder resistor to it for the flashbulb portion anyway.

No issue with switch bounce with the MC-30A remote.  There are two microswitches in it that activate one after the other as you press down.   There is also two springs where you can get the feel for the focus microswitch, and a second stronger one for the shutter switch, as well as a Bulb lock lever.

I was going to do a debouncer code, or a small .1uf cap across the two microswitches, but turns out it isn't necessary as the Nikon requires 5 volts off the Meter and AF line that feeds into the second switch for the shutter.  Shutter will not fire unless it sees that 5 volts off the meter and AF system so it pretty much is guaranteed to not fire unless first switch is locked on (I did it later with the relays going to the 10-pin connector into the body and they don't seem to bounce at all.).  Seems Nikon sort of figured out the debounce part themselves in the remote triggering.

Fwiw, I tried to just operate the camera early on with shorting the shutter pin to ground and it didn't work which sort of puzzled me at the time.  I was going to lock the focus manually anyway (Dense 10 ND stop filter that won't work with AF anyway.) so I thought I could ignore the AF and meter part, but it can't be done the way Nikon set it up with their 10-pin jack.  It needs the metering & AF as well as that line has the voltage to drive the shutter in the switch sequence.

At least it works and hasn't misfired a bulb...yet.  I got a large flip-cover type of toggle switch that looks like a NASA missile launch switch from All Electronics in LA and is pretty fun to play with.  Tells me for sure the thing is armed and ready.

Interesting thing about the Arudino Uno is the thing was actually cheaper to use than building it by individual components.  I did the RC thing on the first attempt, but then the 5 volt AF/Metering line entered and stuff got complex with the millisecond timing.  The Arduino fixed all that, and took me about 2-3 days to figure the code out playing with the LED lights (which became relays) on a breadboard.

Works pretty well, so far, and setting the time via milliseconds (or even microseconds) is a big plus over doing a old-style RC timing circuit with a 555 or whatever.  Plus I can flip the delay in code for the types of flashbulbs that might need to follow the shutter lag, or get ahead if it without a whole new circuit board design.

Aug 18 14 07:21 am Link

Photographer

Noah Russell

Posts: 609

Seattle, Washington, US

GRMACK wrote:

Didn't know the Uno had internal pullups.  I mounted my own circuit board for that on top of the Seeed Relay Shield (Version 2 of that part that has more rows of inputs on the top of it for stacking more gizmo boards.  Radio Shack had both and Version 1 doesn't allow for stacking so they exchanged it for the newer one which was $5 more.).  Plus, I needed a place for the 220uf trigger capacitor and 1.5K feeder resistor to it for the flashbulb portion anyway.

No issue with switch bounce with the MC-30A remote.  There are two microswitches in it that activate one after the other as you press down.   There is also two springs where you can get the feel for the focus microswitch, and a second stronger one for the shutter switch, as well as a Bulb lock lever.

I was going to do a debouncer code, or a small .1uf cap across the two microswitches, but turns out it isn't necessary as the Nikon requires 5 volts off the Meter and AF line that feeds into the second switch for the shutter.  Shutter will not fire unless it sees that 5 volts off the meter and AF system so it pretty much is guaranteed to not fire unless first switch is locked on (I did it later with the relays going to the 10-pin connector into the body and they don't seem to bounce at all.).  Seems Nikon sort of figured out the debounce part themselves in the remote triggering.

Fwiw, I tried to just operate the camera early on with shorting the shutter pin to ground and it didn't work which sort of puzzled me at the time.  I was going to lock the focus manually anyway (Dense 10 ND stop filter that won't work with AF anyway.) so I thought I could ignore the AF and meter part, but it can't be done the way Nikon set it up with their 10-pin jack.  It needs the metering & AF as well as that line has the voltage to drive the shutter in the switch sequence.

At least it works and hasn't misfired a bulb...yet.  I got a large flip-cover type of toggle switch that looks like a NASA missile launch switch from All Electronics in LA and is pretty fun to play with.  Tells me for sure the thing is armed and ready.

Interesting thing about the Arudino Uno is the thing was actually cheaper to use than building it by individual components.  I did the RC thing on the first attempt, but then the 5 volt AF/Metering line entered and stuff got complex with the millisecond timing.  The Arduino fixed all that, and took me about 2-3 days to figure the code out playing with the LED lights (which became relays) on a breadboard.

Works pretty well, so far, and setting the time via milliseconds (or even microseconds) is a big plus over doing a old-style RC timing circuit with a 555 or whatever.  Plus I can flip the delay in code for the types of flashbulbs that might need to follow the shutter lag, or get ahead if it without a whole new circuit board design.

Thanks for the info. I'm glad to see I'm not the only one to get all nerdy with diy gizmos. If you haven't checked out interrupts with the Arduino they are pretty cool.

I have been thinking of building an IGBT flash cut off circuit that hooks inline with a standard studio pack so I can control flash duration. I found some nice surplus 900v 1200amp IGBTs. That's 1200amps continuous and quite a bit more pulsed. We'll see if I blow one up(I doubt it, according to ohms law that thing will handle a shit ton of watts). :-P

I figure I can just crank the pack up to maximum power and vary the flash duration to control power. I could also make the pack asymmetrical. Hmmm.

Cheers!
Noah

Aug 18 14 10:25 am Link