Can someone please verify this circuit for a newbie?

Hey everyone,

Right off the back: I'm a complete newbie to Arduino and circuits and have been playing with the stuff for about 5 days.

The attached file is a screenshot from Fritzing and it shows something I built to control a Canon 7D camera, 2 solenoid valves (represented by two red LEDs) and a Canon 580EXII flash. It will be used to take pics of water drops colliding. Code is at the end of this. I have used the Sparkfun inventors kit and its guide to get an understanding of the basics and the circuit I built is really just a small customization and joining of 2-3 of the example circuits. I admit I do not know whether all the parts on the board are needed or if this should be done another way. The idea here is this:

  1. push a button: camera shutter opens (camera is in Bulb Mode) - I'm using a relay to control camera shutter, as the only thing needed to trigger the camera is shorting of pins.
  2. specific amount of milliseconds later, open and close valve 1
  3. same as #2 for valve 2
  4. wait till the drops hit the surface
  5. Trigger the flash - as with the camera trigger this is done by shorting pins. I'm using same way an LED would be lit up and turned off
  6. Close the camera shutter

As it is currently built - it does the job, BUT... I read somewhere that I should protect the circuit from the flash using optoisolators. I have no idea how they work, but I'll figure that part out.

Here is the part where I need help and hopefully someone that's very experienced with circuits can just look at this and tell me what's going on in a few minutes.

Can you look at this, please, and tell me if any/all parts of this circuit are put together correctly? What is done wrong and how it can be corrected? Remember that this WORKS as is, but I understand that doesn't always mean its correct and should be used like this.

Any advice/help/comments would be appreciated!

Thanks,

Tom

const int button1Pin = 2;  // pushbutton 1 pin
const int camerafocusPin =  6;    // camera focus pin
const int camerashutterPin = 7;    //camera shutter pin
const int valve1Pin = 9;    //solenoid valve one
const int valve2Pin = 10;    //solenoid valve two pin
const int flashPin = 11;    //flash trigger pin

const int relayPin = 3;	    // use this pin to drive the transistor
const int timeDelay = 1000; // delay in ms for on and off phases
const int shutteropen = 8000; // delay in ms for on and off phases

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 (flashPin, OUTPUT);
}


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

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

  {
    digitalWrite(relayPin, LOW);  // turn the relay on
  
  delay(timeDelay);              // wait for one second
     
    digitalWrite (valve1Pin, HIGH);    //open the first solenoid valve for 2 seconds
    delay (100);
    digitalWrite (valve1Pin, LOW);
    
    delay (200);   //delay between two valves
    
    digitalWrite (valve2Pin, HIGH);    //open the second solenoid valve for 1 seconds
    delay (150);
    digitalWrite (valve2Pin, LOW);
    
    delay (200);                      // delay between the valve closing and drops actually hitting the water
    
    digitalWrite (flashPin, HIGH);    //fire the flash
    delay (50);
    digitalWrite (flashPin, LOW);
    
    delay (300);
    
    digitalWrite(relayPin, HIGH);   // turn the relay off
  
   delay (shutteropen);      
}
  else
  {
    digitalWrite(relayPin, HIGH);   // turn the relay off
       // shutter stays closed
  }
     	
}

I apologize if this is in the wrong place on the forums...

looks OK to me. I would definitely use a optocoupler to isolate the flash and I would also swap the mechanical relay for one. Your circuit would simplify and be more efficient.

They are very simple in operation. They consist of an LED and a phototransitor in one package (I tend to use MOCD27M's becuase they house dual optocouplers so I can use one device for both the focus pin and shutter pin. When you power the LED (same as you would any normal LED) the photons will be received by the photojournalism which will cause it to connect its input and output together, so you can just simply connect the pins to be shorted with it.

connected like this http://hardpan.com/images/optocoupler1.jpg (not my website)

Thanks so much for your reply man! I'm not sure what you mean here: "I would also swap the mechanical relay for one" - are you saying replace the relay with an optocoupler? One more question: I know the solenoids have to be powered externally, since they're 12V or 24V. Is there any other component, like an optocoupler, I would need to use between the circuit and the solenoid for protection as well? Can't wait to start actually shooting with this setup :slight_smile:
Again - thanks for your help! Very much appreciated.

Hey no problem!

Yes I would replace the relay with a optocoupler, u can loose the transistor and drive the opto direct from a digital pin :slight_smile:

I'm not sure how you are currently controlling your valves? I would probably use a relay, depending on the current they draw? I would think a relay would provide enough isolation

I have not purchased the valves yet, because I wasn't sure I could pull this off and they're about $50 a piece. I decided to go with the Shako PU220AR-01, because it seems that its a very precise one as far as controlling the size of the drops and providing consistency. Here's the link to the datasheet
http://www.shako.com.tw/products_detail.aspx?pid=404
I guess each one would have to be protected by a relay or optoisolator as well, right?
Since I'm going to use 3 of these solenoids - I'm assuming each one would need a separate 24V power supply or would I be able to power them off the arduino? How do I figure out how many Amps does the power supply need to be? Would something like a 24V 1A be enough for each (or all) ? Sorry if I'm asking too many questions...

Ok, right. I don't know anything about these types of valves other than what I can see on the datasheet. The PU220AR-01 looks to demand 4.8w @24V, which I work out to be about 200mA.

(Power (watts) = Voltage (V) * Current (I))
or I = watts / V.

So yes I would think a clean 1A supply would be fine for the 3 valves.

Here's what I would do.
Use optoisolators on everything. I would use 1 for each of the valves, with their outputs connected to the base of a transistor which I would use to switch 24V from a shared power supply (could probably use a 24V 1A linear regulator for the lot).

So a single 24V 1A power supply should be ok for all 3 valves? They will only be triggered one at a time, but usually in very fast succession, def under 1 second apart, closer to 300-500 milliseconds. Should I just have them plugged into a separate breadboard with one power supply feeding in? Having a hard time imagining how to actually physically power 3 things with one power supply...
You rock - thanks so much!

Yeah from the datasheet it would appear that you could run all 3 at the same time from a 1A supply :slight_smile:

Have you ever used transistors? Should be pretty easy for you to set up using a few PNP's OR NPN's.

I would wire it up as shown below x3.