Triggering more than 1 OUTPUT pin at the same time

Essentially I want to fire off 3 (or more) flashes at the same time using the Uno…
This is going to be a somewhat lengthy post, but it includes the code, so please bear with it…
So I have this setup shown in the attached image and so far it works fine when I have 1 flash connected. The flash is connected to the jack that uses Pin 11 on the Uno. The 2 LEDs represent (and will soon be replaced by) solenoids to make water drops and take pics of them colliding. Everything works fine this way. I hit the button the relay causes the camera in Bulb mode to open shutter, valves open and close, flash fires and shutter closes.

Camera is a Canon 7D, flash is a Canon 580EX II.

Since I’m using very low power on the flash (manual mode - 1/128the of power) to get the shortest possible burst - the picture will not get much light, so I’m going to add more flashes, and I want to trigger them using connections to pins 12 and 13. Here is where I have a question about firing multiple flashes at the same time… I use this to fire off one and it works fine.

digitalWrite (flash1Pin, HIGH);    //fire flash #1
delay (50);
digitalWrite (flash1Pin, LOW);

How would I get all 3 to go off at the same time? Would this simply do or will it require something more complicated? If so then what would you suggest?

digitalWrite (flash1Pin, HIGH);    //fire flash #1
    digitalWrite (flash2Pin, HIGH);    //fire flash #2
    digitalWrite (flash3Pin, HIGH);    //fire flash #3
    
    delay (50);
    
    digitalWrite (flash1Pin, LOW);
    digitalWrite (flash2Pin, LOW);
    digitalWrite (flash3Pin, LOW);

I have only 1 flash right now to test with, which is not helping me and unless I can get 3 to definitely fire at the same time - I don’t want to spend the $ on 2 more…

Here is the complete code:

const int button1Pin = 2;  // pushbutton 1 pin
const int valve1Pin = 9;    //solenoid valve one
const int valve2Pin = 10;    //solenoid valve two pin
const int flash1Pin = 11;    //flash #1 trigger pin
const int flash2Pin = 12;    //flash #2 trigger pin
const int flash3Pin = 13;    //flash #3 trigger pin

const int relayPin = 3;	    // use this pin to drive the transistor

void setup()
{
  // Set up the pushbutton pins to be an input:
  pinMode(button1Pin, INPUT);
  pinMode(relayPin, OUTPUT);  // set pin as an output

  // Set up the LED pin to be an output:
  pinMode (camerafocusPin, OUTPUT);
  pinMode (camerashutterPin, OUTPUT);
  pinMode (valve1Pin, OUTPUT);
  pinMode (valve2Pin, OUTPUT);
  pinMode (flash1Pin, OUTPUT);
    pinMode (flash2Pin, OUTPUT);
      pinMode (flash3Pin, OUTPUT);
}


void loop()
{
  int button1State;  // variable to hold the pushbutton states

  button1State = digitalRead(button1Pin);
   
  if (button1State == LOW)  // if we're pushing button 1

  {
    digitalWrite(relayPin, LOW);  // turn the relay OFF, this is what works for the camera shutter to turn on. Seems backwards but it works.
  
  delay(1000);              // wait for one second
     
    digitalWrite (valve1Pin, HIGH);    //open the first solenoid valve for 100 miliseconds
    delay (100);
    digitalWrite (valve1Pin, LOW);
    
    delay (300);   //delay between two valves
    
    digitalWrite (valve2Pin, HIGH);    //open the second solenoid valve for 150 miliseconds
    delay (150);
    digitalWrite (valve2Pin, LOW);
    
    delay (200);                      // delay between the valve closing and drops actually hitting the water
    
    digitalWrite (flash1Pin, HIGH);    //fire flash #1
    digitalWrite (flash2Pin, HIGH);    //fire flash #1
    digitalWrite (flash3Pin, HIGH);    //fire flash #1
    
    delay (50);
    
    digitalWrite (flash1Pin, LOW);
    digitalWrite (flash2Pin, LOW);
    digitalWrite (flash3Pin, LOW);
    
    delay (300);
    
    digitalWrite(relayPin, HIGH);   // turn the relay ON and close the camera shutter
  
}
  else
  {
    digitalWrite(relayPin, HIGH);   // turn the relay ON so the shutter stays closed
  }
}

rockandrollnerd:
How would I get all 3 to go off at the same time?

Putting a definition to "at the same time" would be helpful. Within 1 millisecond? Within 1 microsecond?

At precisely exactly same time. All 3 flashes have to fire together.

FYI - A canon 580ex II at 1/128 power has a duration of 1/35000 second. At 1/64 power its 1/30000 second.
Maybe this helps...

At precisely exactly same time. All 3 flashes have to fire together.

Doesn't quite match the math but we'll run with it. Better to be too precise than end up with ugly pictures.

Spend some time here...

Forward Voltage VF – 1.2 1.5 V IF = 10 mA

You may be able to wire the 4N35s in series (one Arduino digital output to drive them all). They will certainly fire at the same time. Is there a reason you don't want to try that?

A canon 580ex II at 1/128 power has a duration of 1/35000 second.

28 microseconds. Over 450 clock cycles at 16MHz

I didn't even think about that! (probably because its 4:15am here and my brain is on strike). That seems like a good idea, now how exactly would I wire them "in series" to run off the same digital output pin? Just connect all 3 flashes to the same 4n35 on the transistor side?

For flexibility, I'd put an opto on separate pins, but make sure the pins are all on the same port.
That way, you can fire then all at the same time, or in sequence.

You could wire them in series on the same pin with one current-limiter, or in parallel, just ensuring that each has its own current limiter.

AWOL:
For flexibility, I'd put an opto on separate pins, but make sure the pins are all on the same port.
That way, you can fire then all at the same time, or in sequence.

You could wire them in series on the same pin with one current-limiter, or in parallel, just ensuring that each has its own current limiter.

I don't understand what you mean by "make sure the pins are all on the same port." Still very new to this...

Right now there are 3 optos on 3 separate pins (11,12,13).

Would wiring them "in series" mean that one opto would trigger the next one?

I don't understand what you mean by "make sure the pins are all on the same port.

Spend some time here...
Arduino Reference - Arduino Reference

rockandrollnerd:
At precisely exactly same time. All 3 flashes have to fire together.

How precisely? You cannot reduce the time difference to zero without breaking the laws of physics, so you need to define how closely they need to be synchronised.

Why don't you trigger one flash and set the other two as slaves. Water drops are slow enough so the delay is not noticeable, and you have a lot less wires going around your setup.

Appears AWOL's response is not sinking in:

This is pretty direct, for example with PortD, having used pinMode in setup to declare these pins as outputs:

PORTD = PORTD | 0b00111000; // set bits 5,4,3. others left alone
PORTD = PORTD & 0b11000111; // clear bits 5,4,3. others left alone

All will occur on same clock edge.

PeterH:

rockandrollnerd:
At precisely exactly same time. All 3 flashes have to fire together.

How precisely? You cannot reduce the time difference to zero without breaking the laws of physics, so you need to define how closely they need to be synchronised.

Maybe I'm just not understanding something, but are you simply saying that its impossible to have 3 pins on the arduino to trigger simultaneously ? I don't see how things happening at the same time break the laws of physics... For example when it rains, i'm pretty sure that some drops hit the ground at the exact same time as others without breaking the laws of physics and creating a black hole whenever it rains :wink:

Shpaget:
Why don't you trigger one flash and set the other two as slaves. Water drops are slow enough so the delay is not noticeable, and you have a lot less wires going around your setup.

Not possible. The master/slave flash setup can't do 2nd curtain which is what is needed here.

Try different slave modes. 40D and YN460 work fine od second curtain. It just flashes two times (preflash before the shutter opens and the actual flash).
Why are you using second curtain anyway? Aren't you shooting in dark and freezing the scene with flash? Don't you get semitransparent and smeared drops in lit room?

edit,
wait, wait...
What has second curtain got to do with anything anyway? You should be syncing flash with the drop release, not the shutter. Shoot in a dark room and you can have exposures started well before the drop release and well beyond the drop.

PeterH:
How precisely?

Reply #2 and Reply #5.

The implication is that port I/O is orders of magnitude faster than what is needed and digitalWrite is very likely fast enough.

Reply #2 and Reply #5.

and #7.

Shpaget:
Try different slave modes. 40D and YN460 work fine od second curtain. It just flashes two times (preflash before the shutter opens and the actual flash).
Why are you using second curtain anyway? Aren’t you shooting in dark and freezing the scene with flash? Don’t you get semitransparent and smeared drops in lit room?

edit,
wait, wait…
What has second curtain got to do with anything anyway? You should be syncing flash with the drop release, not the shutter. Shoot in a dark room and you can have exposures started well before the drop release and well beyond the drop.

I am going to be shooting in pitch black room. The sequence is:

  1. Camera in BULB mode. Press a button which triggers a relay to open shutter
  2. release water drop
  3. release another drop
  4. fire a flash at drop collision
  5. close shutter

I’ve got a 580 connected to the arduino using the pc sync port. If I set it as a master and the other flash (430EXII) as a slave to trigger wirelessly, there is a big delay between them. This is why I’m trying to trigger both flashes using the arduino, instead of wirelessly.

CrossRoads:
Appears AWOL's response is not sinking in:

This is pretty direct, for example with PortD, having used pinMode in setup to declare these pins as outputs:

PORTD = PORTD | 0b00111000; // set bits 5,4,3. others left alone
PORTD = PORTD & 0b11000111; // clear bits 5,4,3. others left alone

All will occur on same clock edge.

This is starting to make sense to me, but its well above my skill level. Thank you! I will try this approach.