Loading...
Pages: [1] 2 3   Go Down
Author Topic: Triggering more than 1 OUTPUT pin at the same time  (Read 876 times)
0 Members and 1 Guest are viewing this topic.
NJ, US
Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Code:
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?
Code:
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:
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
  }
}
« Last Edit: January 23, 2013, 03:54:25 am by rockandrollnerd » Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 115
Posts: 10129
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

NJ, US
Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
« Last Edit: January 23, 2013, 04:00:12 am by rockandrollnerd » Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 115
Posts: 10129
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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...
http://www.arduino.cc/en/Reference/PortManipulation
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 115
Posts: 10129
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 136
Posts: 18990
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
A canon 580ex II at 1/128 power has a duration of 1/35000 second.
28 microseconds. Over 450 clock cycles at 16MHz
Logged

Pete, it's a fool looks for logic in the chambers of the human heart.

NJ, US
Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?

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?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 136
Posts: 18990
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pete, it's a fool looks for logic in the chambers of the human heart.

NJ, US
Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 136
Posts: 18990
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pete, it's a fool looks for logic in the chambers of the human heart.

Milton Keynes UK
Offline Offline
Tesla Member
***
Karma: 88
Posts: 6277
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Croatia
Offline Offline
Full Member
***
Karma: 9
Posts: 240
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 240
Posts: 16426
Available for Design & Build services
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17

NJ, US
Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-wink
Logged

NJ, US
Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1] 2 3   Go Up
Print
 
Jump to: