Connect with us

Electronic switch

Discussion in 'General Electronics Discussion' started by Bikonja, Jul 4, 2013.

Scroll to continue with content
  1. Bikonja

    Bikonja

    16
    0
    May 4, 2012
    Hi everyone,

    I am a complete novice in electronics. However, I've decide I want to use my Arduino for a project. In this project, I would like to have, amongst other things (which I think I can do myself) a switch. What I don't really understand though is how I would do this.

    To get into a little more detail so it's clearer what I want to achieve - I have a camera (a Canon EOS 600D/Rebel T3i) which has a standard 2,5mm stereo plug for remote shutter release. It's really simple to do your own remote, which I have done with an old mouse (pre-optical :cool:). Everything's great - connect ground to one of the stereo rings to get focus, other for shutter release, with the mouse button switches - easy peasy.
    Now I want to expand this so my Ardunio can let this still be the case, but add another switch to the circuit, in parallel. This switch should do the exact same thing (only the shutter release, not the focus), but be controlled by the Arduino. So, I want my Arduino to short-circuit two wires when I tell it to (every x seconds, when a sensor detects something, etc...).
    I can visualize the circuit for parallel buttons that can release the shutter when you press either of them, that's really basic, but since the other button is not really a button, but an Arduino controlled switch that short-circuits two wires, I'm not sure what I should put in there. From what I know and have researched, it should either be a switch-transistor or a relay. But, I really don't know what exactly as I have to have the Arduino send a signal which just short-circuits two wires and doesn't actually send current, is only controlled by it.
    Can anyone help me out here?

    I feel like this is pretty basic stuff, yet I don't know what to do :(
     
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    11,517
    2,652
    Nov 17, 2011
    Look into the workings of optocouplers (also known as photocouplers). The arduino can control the LED (input) the built-in transistor can operate as switch (output).

    Heres more info on your specific issue.
     
  3. Bikonja

    Bikonja

    16
    0
    May 4, 2012
    Thank you very much!

    The link helped me realize an important trick here which is what was troubling me.
    I am ashamed to say I never really understood what transistors do (even though I've soldered some onto PCBs designed by other people and as a programmer should have really understood them), but now I think I understand what they do - the collector and emitter is basically a regular ol' switch/button that is "pushed" by passing current to the base.
    So the voltage that comes into the base of the transistor doesn't really have anything to do with the voltage in the circuit that is closed by the collector and emitter.
    Except, since the base is physically connected to the emitter and collector, even though it's not supposed to interfere with the "other side", if there's an error of whatever kind, it could potentially send a big voltage spike to the other side of the circuit which is why this book suggests using an optocoupler which is essentially a transistor without the danger of this happening.
    Have I finally understood this?

    If so, since the camera input works on 3.3V (according to the article I read on making a remote in the first place) and the Arduino has a 3.3V pin and overall the Arduino would be powered by probably a 9V battery (maybe even 3x1,5V), would it be safe to just use a regular transistor since the camera tip/ring is connected to the collector, the sleeve to the emitter and the Arduino pin to the base (via a resistor?) or is there a possibility (realistically) that let's say the whole 9V passes to the camera and fries it?

    Sorry for the even longer response than the original question, but you've really intrigued me, I've always been puzzled at what transistors actually do and now that I think I've got it finally, I have to go for the whole 9 yards :)

    Thank you very much for all your help!
     
    Last edited: Jul 4, 2013
  4. Harald Kapp

    Harald Kapp Moderator Moderator

    11,517
    2,652
    Nov 17, 2011
    Your understanding of a transistor is partly correct - as long as the transistor is operated as a switch.
    A transistor has another mode of operation, equally if not more important, that is analog. The emitter-collector connection is not only on or off (as for a switch), but can be controlled by the base current to conduct to varying degrees. That's what is used in analog amplifiers.

    You may be able to connect the arduino and the camera directly, but I would disencourage you to do so. Unless you are pretty sure of where the grounds, signals and supply volategs go, there's always a risk of connecting some circuit parts that do not like to be connected. Using the photocoupler is the safe way and not too much expensive.
     
  5. Bikonja

    Bikonja

    16
    0
    May 4, 2012
    So how do you set the transistor mode to switch or analog?
    Is this mode actually like a potentiometer (as opposed to the regular switch) where instead of your fingers rotating it (and fingers pressing the button) there is a varying degree of current (on/off for button)? Except, a potentiometer adjusts resistance so when it is 0, the full power goes through the current and when it is it's max value it is what the designed minimum was. Is the transistor in a similar fashion letting current through based on the current in the base - no current means the semiconductor doesn't conduct and the more current in the base, the more the semiconductor conducts. How would I know when the semiconductor turns full-conductor and what if I push stronger current to the base than that?

    I will use the photocouplers. Difference in using them from the transistors is I need to close the circle on both ends, not just one, right? (as in, close the circuit to light up the LED so the other side circuit is closed)

    Mr. Kapp, you are very helpful and I'd like to buy you a beer! (can't afford more than that, but at least a beer)
    Do you have paypal?
     
  6. Harald Kapp

    Harald Kapp Moderator Moderator

    11,517
    2,652
    Nov 17, 2011
    You don't set it. It is the interaction between the different voltages and currents on the transistor's pins. Here is a tutorial.
    It is not very much like a potentiometer. The relation between current and voltage is highly nonlinear. Therefore analog amplifiers use feedback and other mechanisms to linearize the transfer characteristic.

    Thanks, but my help here is free. Keep the money and have a beer yourself when you have understood transistor operation :)
     
  7. Bikonja

    Bikonja

    16
    0
    May 4, 2012
    Ok, I've read the tutorial and I think I have a better understanding of transistors now, although I would still say I'm not comfortable with them, but we'll put that aside, for now at least.

    I've drawn the most basic diagram of what I think the circuit needs to look like (for only the ring/shutter, I left out tip/focus for simplicity sake) and, if I did it correct, I still have some questions.

    Here's the diagram:
    [​IMG]

    So, I connect the 9V battery to the Arduino's Vin and Gnd pins to get power to the Arduino. I then connect an optocoupler (U1) on an Arduino output pin (Shutter pin) and Gnd, with a resistor (R1) between the Shutter pin and U1. And then I connect U1 to the camera as shown in the diagram. To release camera shutter, set Shutter pin to HIGH for a short period.

    Now, firstly, is the diagram correct (from basics like 9V plus going to Vin and 9V minus going to Gnd instead of vice-versa to everything else, like if the resistor is needed and in the correct place)?
    If the diagram is correct, what value should the resistor be? I've found info that Arduino pins on HIGH output 40mA of current (found here), but I haven't found the voltage there (well, I found a person believing it's 5V, but nothing certain - EDIT: didn't see that on the same page where it says 40mA that it's 5V - the part where it talks about pullup resistors).
    I would buy these optocouplers if they're suited to my needs (are they?) and it says in the info that the input current is 20mA. The Arduino documentation specifies a resistor of either 470 Ohm or 1 KOhm, but if the 5V info is true, Ohms law would suggest a 125 Ohm resistor, wouldn't it?

    And last question, how would I know which leg of the optocoupler is what? EDIT: Apparently, it's how I'd figure it would be, according to this datasheet (when looking at it from top, with the model number right-way up, the legs are "standard" placement.

    Thank you very much for your help and while I myself would also give my help for free, keep in mind you HAVE helped me a lot and if you change your mind about the beer, or I can help you with programming or something else I'm good at, feel free to contact me!
     
    Last edited: Jul 7, 2013
  8. Harald Kapp

    Harald Kapp Moderator Moderator

    11,517
    2,652
    Nov 17, 2011
    This diagram looks perfect.

    The resistor can be calculated from general rules for LEDs, see this tutorial.
    The photocouplers you mention seem good for the job. The LEDs forward voltage is 1.2V...1.4V. Recommended operating current is 20mA. Assuming a 5V output of the arduino that gives:R=(5V-1.4V)/20mA= 180Ohm

    The datasheet shows all pins, note the black dot in the lower left of the case marking pin 1.(anode).
     
  9. Bikonja

    Bikonja

    16
    0
    May 4, 2012
    Didn't take into account the forward voltage and used the pin output current instead of needed current... Well, at least the diagram was correct :)

    Thank you very much! Now I'll order the components and while I wait, make a diagram of everything else (buttons and the LCD display and so on) and maybe get started on programming the Arduino sketch for it ;)

    Hopefully my next post will be another thank you with photos/video of the finished project :) Thank you once again very much!
     
  10. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,497
    2,838
    Jan 21, 2010
    I have a T2i.

    Yep

    I did almost exactly this a couple of weeks ago.

    In case you don't know, the shutter release buttons in the camera are already in parallel with the contacts fo the remote shutter release, so you're not doing anything unexpected :)

    The easiest device is a mosfet. I used a pair of 2N2000s from memory.

    The source pins go to ground, the drains go to the tip and ring of the plug, and the gates connect to the outputs from the arduino.

    Simple, cheap, easy, and low current.

    Note that this will tie ground on your camera to the negative supply rail of your arduino. If this is a problem, the optocoupler solution is better.
     
  11. Bikonja

    Bikonja

    16
    0
    May 4, 2012
    I meant adding a third button in parallel :) The original camera button is one, the remote release button I already made is another and now I want the Arduino to be the third :)

    Thank you for the suggestion!
    I really like the optocoupler solution because the camera circuit is seperated from the Arduino circuit and the camera doesn't get any foreign voltage/current in it's circuit.
    If I were more electronics-savy I would probably do what you suggest, but then I wouldn't be on this forum :)
    Thank you very much though and I will let you know how this turns out :)
     
  12. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,497
    2,838
    Jan 21, 2010
    I chose the mosfet solution for this exact reason.

    The mosfet is essentially acting as a switch in this option.
     
  13. Bikonja

    Bikonja

    16
    0
    May 4, 2012
    I've had a rough morning after a late night so I can't really think straight, but I get the feeling that, even though if everything is correctly connected it's essentially the same as with the optocoupler, but if I make a mistake when connecting or there's some other error , the mosfet solution has more potential to cause damage to my camera, right?
     
  14. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,497
    2,838
    Jan 21, 2010
    There are 3 connections to a mosfet. Thus there are 6 permutations of those. one of them has the potential to damage the camera.

    There are (at least) 4 connections to an optocoupler. That means there are 24 permutations of connections. Of the top of my head, none of them could result in damage to the camera.

    If we now look at the fact that you need two of these, the number of permutations rise, as do the ways of making a bad error.

    But frankly, it's not going to happen in either case. The mosfet option is trivial to test and the optocoupler solution not a lot more difficult.
     
  15. Bikonja

    Bikonja

    16
    0
    May 4, 2012
    But what if I accidently send too strong a current to the mosfet (with the right connections), would that potentially damage the camera?
    If I understood correctly, it could and in the case of the optocoupler I'm just risking destroying the IR LED inside it and it's a lot cheaper to replace an optocoupler than a camera.
    Or am I mistaken? (which is very possible as I really am extremely tired today)
     
  16. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,497
    2,838
    Jan 21, 2010
    If you're talking about to the gate of the mosfet, the answer is No (they are damaged by too high a voltage though -- but that's not likely in this sort of case).

    In the case of the current coming from the camera, relax -- the current is tiny.

    Too high a current could damage an optocoupler, but not the camera.

    The advantage of a mosfet over an optocoupler is that the optocoupler will require 5 to 10mA where the mosfet will require essentially nothing. Given that you've normally not got the shutter buttons pressed for too long, it's unlikely to be significant.

    If you're happy with the optocoupler, go with that.
     
  17. Bikonja

    Bikonja

    16
    0
    May 4, 2012
    Ahh, great, now I understand what you are talking about. I've already ordered the optocouplers so I'll go with them, but I want to learn as much as I can so this was really helpful! (and I'll read it again once I get out of this rough situation I'm currently in so I can understand it better)

    Thank you very much!

    EDIT: Oh, and if anyone's interested, the manual shutter release I made with the old mouse has been put to good use yesterday, I took photos of lightning :) Since I was already tired and I haven't played with infinity focus on my camera yet (got it just a little while ago), the shots aren't what I aim for, but they're still shots of lightning :) I have a flickr account I can link to if anyone is interested in it. Also, if anyone is interested, I'll post photos of the whole setup and photos/videos I made with the setup when it's done.
     
    Last edited: Jul 8, 2013
  18. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,497
    2,838
    Jan 21, 2010
    Here are some of the photos I took with my arduino powered camera.

    It used a couple of ATMega8's and an ATMega328 and some wireless modules.

    I had what looked like a cable release to trigger everything into operation. It turned on the lights, woke up the camera, focused, then started an approx 2 sec exposure.
     
  19. Bikonja

    Bikonja

    16
    0
    May 4, 2012
    Why such a long exposure? A lot of the subjects ended up blurry. Were your lights not strong enough for a better exposure with a slower shutter speed? The images look grainy, but since they're all sepia toned I'm not sure if that's deliberate or a high-ISO result. Don't get me wrong, I *just* got into photography and portraits are something I've yet to actually play with so these are more questions because I'm wondering about it than because I think it could have been better or something.
    But otherwise, that's very neat, exactly the type of thing I would do - sure, you could manually switch on the lights, wake up the camera, focus, etc... But where's the fun in that when you can do it all with a single button push :)

    Here's my flickr set with some shots with my new 600D/T3i, the last three (lightning) photos were set on Bulb exposure and I used my mouse remote to keep the shutter open for as long as I felt like it or until lightning struck :) (the blue photo took a 71 second exposure, while the purple one took only a 4 second exposure, the third one is a photoshop mix of the previous two).
    There's a whole bunch of other photos there, both in that set and other sets, but they're not electronics related at all so I'm not mentioning them right now :) (although feel free to browse if you want)
     
  20. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,497
    2,838
    Jan 21, 2010
    You might notice the style of dress and posing.

    The probability of blurring was intentional.

    edit: yes the graininess was a result of some very careful post-processing. (ISO 100, smallish aperture and ND filter)

    Your images are nice.

    Here are some more of mine (and other members)

    https://www.electronicspoint.com/eclipse-lens-t254045.html
    https://www.electronicspoint.com/total-lunar-eclipse-t241821.html
    https://www.electronicspoint.com/photos-other-than-electronics-t225931.html
    https://www.electronicspoint.com/hobbies-other-than-electronics-t224000.html
    https://www.electronicspoint.com/20130510-solar-eclipse-pix-t259834.html
     
    Last edited: Jul 8, 2013
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-