Forums >
Photography Talk >
Arduino multi-flash sequencing
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 Arduino got my attention! Sweet little gizmo. 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! Aug 18 14 05:58 am Link 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 Noah Russell 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. Aug 18 14 07:21 am Link GRMACK wrote: 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. Aug 18 14 10:25 am Link |