Shop OBEX P1 Docs P2 Docs Learn Events
driving a switch (relay) — Parallax Forums

driving a switch (relay)

gio_romegio_rome Posts: 48
edited 2014-04-24 12:00 in Propeller 1
Hi,

I need to control a switch that allows AC current (like 2 amps) to flow through a path or not.

A switch as such would be something like: http://www.omron.com/ecb/products/pry/121/g5rl.html

(this precise one has been chosen with no particular care; while we're here let me say that I'm looking for something that can withstand like 15A, for security reasons, with low consumption, being driven with like 5V)

Now as I said I'd probably choose a switch that can be driven with 5V.

But the levels HIGH of the IO Propeller pin are operating at VDD which is usually 3.3 V.

What do I do? Do I need to raise the voltage, or would it suffice?

I have, in the same circuit board, a 5V source, that serves other purposes but can come in handy.

Any suggestions?

Thank you,

G.

Comments

  • gio_romegio_rome Posts: 48
    edited 2014-04-23 02:42
    I've found this, but really would rather not go in something so "complicated"

    https://learn.sparkfun.com/tutorials/using-the-logic-level-converter/hardware-overview
  • ErNaErNa Posts: 1,752
    edited 2014-04-23 03:16
  • Heater.Heater. Posts: 21,230
    edited 2014-04-23 03:21
    All you need is a single transistor. Drive the base through a resistor from the Prop pin. Put the relay coil from the collector to the 5v supply, or whatever the relay requires. Put the emitter to ground. Don't forget a diode around the relay coil.

    Or you can use an FET.

    Google for "relay driver circuit" and you will find hundreds of examples for inspiration and advice on transitor selection etc.

    Like this one perhaps: http://www.pcbheaven.com/wikipages/Transistor_Circuits/
  • gio_romegio_rome Posts: 48
    edited 2014-04-23 07:51
    thank you both,
    i'll have to digest your suggestion and think them through.

    tnx

    G.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-04-23 12:51
    Most relays require less that 100ma of current to their coils, you can likely use a 2n2222 transistor for a 5v, a 6v, a 12v, or a 24 v relay. There is a 0.7v drop with the insertion of a transistor from the supplied voltage. So a 5v supply will provide the coil with merely 4.3v. I generally prefer 12v relays as the 11.3v is not as big a percentage out of spec.

    A solid state relay is really the easiest build. They can accept 3.3vdc and just switch. But they don't come in DPDT.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-04-23 15:21
    Most relays require less that 100ma of current to their coils, you can likely use a 2n2222 transistor for a 5v, a 6v, a 12v, or a 24 v relay. There is a 0.7v drop with the insertion of a transistor from the supplied voltage. So a 5v supply will provide the coil with merely 4.3v. I generally prefer 12v relays as the 11.3v is not as big a percentage out of spec.

    A solid state relay is really the easiest build. They can accept 3.3vdc and just switch. But they don't come in DPDT.

    Loopy, you might be thinking of an emitter follower configuration perhaps which has a 0.6V drop if the load is connected from the emitter to ground. However in the common grounded emitter configuration where the load is connected between a positive voltage and the collector you only have to take Vce(sat) into account. This saturation voltage between the collector and emitter can be less than a 100mv depending upon the transistor and circuit. The popular 2N2222 is specified to have a maximum 300mV Vce for a 150ma load and a base current of 15ma but you will find that the saturation voltage will typically be far less than that.

    Darlingtons such as the ULN2003 on the other hand have rather large Vce(sat)s because of their configuration so you would have a drop of 0.9V typically even at low currents and under heavier load this could hit 1.5V. So 1.5V x 500ma = 0.75W just for one transistor which is why ULN2003s are not suitable for some circuits.

    Now back to the OP's original request, he actually wants to switch a couple of amps AC although I'm not sure of the voltage but SSRs have been mentioned and are a good choice too, even just an optocoupler and triac etc.
  • gio_romegio_rome Posts: 48
    edited 2014-04-24 00:59
    Peter,

    I want to be able to switch up to 10-16Amp, just to be sure. Common amperage would be like 5-10 amps.

    To be precise I'm working on a wallplug adaptor that simply has a switch in it able to disconnect the appliance from the mains. I want to be able to drive the switch with a uC, therefore my post.

    Now (forgive me ignorance + lack of practice),

    (1) I understand I need first to produce some 5v dc out of the mains.
    (2) I will use these 5v dc to raise up the HIGH uC I/O level of the pin that drives the switch,

    therefore piloting the switch itself. The switch would then be a simple SPST.

    (1) : I'd use a voltage converter 230to6v (like Block VB 0,35/1/6: http://www.block.eu/en_US/products/electro_transformers/product/393256/), then a simple diode bridge or other kinds of rectifier. I'd also need ways to level it to 5v. I don't know this thing very well but I understand there are "chip" which have it already all figured it out cleverly. I.e. I wouldnt want something big and heat-generating as this: http://www.ebay.com/itm/AC-to-DC-Power-Supply-converter-Isolation-input-AC-85-265V-220V-Output-DC-5V-1A-/251397219982

    (2) : logic level converter: https://www.sparkfun.com/products/11978

    What do you guys think?

    tnx,

    G.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-04-24 09:07
    I wonder how you are powering the uC. You might already have a +5 volt source.

    If you want to wire up a mechanical relay, here is a link to good options.
    http://www.bowdenshobbycircuits.info/r_ctrl.htm

    But at 16 amps, you mechanical relay or solid state relay will be larger than what you posted above. The higher the amps, the bigger the device.

    +++++++++++
    The solid state relays operate with a DC voltage from 3.3 to 36 volts, so they can directly be controlled from the uC; and can switch 16 amps AC. But again, the size may be a bit larger than you expect... though newer units have gotten quite small.

    You may be looking at 'hockey puck' SSRs for about $35USD each. And they may need heat sinks. http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Dindustrial&field-keywords=solid state relays 240VAC

    You might actually save money by not have to buy so many different items from so many different places..
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-04-24 09:23
    gio_rome wrote: »
    Peter,

    I want to be able to switch up to 10-16Amp, just to be sure. Common amperage would be like 5-10 amps.

    To be precise I'm working on a wallplug adaptor that simply has a switch in it able to disconnect the appliance from the mains. I want to be able to drive the switch with a uC, therefore my post.

    Now (forgive me ignorance + lack of practice),

    (1) I understand I need first to produce some 5v dc out of the mains.
    (2) I will use these 5v dc to raise up the HIGH uC I/O level of the pin that drives the switch,

    therefore piloting the switch itself. The switch would then be a simple SPST.

    (1) : I'd use a voltage converter 230to6v (like Block VB 0,35/1/6: http://www.block.eu/en_US/products/electro_transformers/product/393256/), then a simple diode bridge or other kinds of rectifier. I'd also need ways to level it to 5v. I don't know this thing very well but I understand there are "chip" which have it already all figured it out cleverly. I.e. I wouldnt want something big and heat-generating as this: http://www.ebay.com/itm/AC-to-DC-Power-Supply-converter-Isolation-input-AC-85-265V-220V-Output-DC-5V-1A-/251397219982

    (2) : logic level converter: https://www.sparkfun.com/products/11978

    What do you guys think?

    tnx,

    G.

    I had a long reply drafted earlier which I then discarded it because I realized that what you are asking is a bit technical and more because it also involves mains power and I don't want to be the one that encourages you to mess with dangerous voltages when you are inexperienced in these matters. Some of the statements you made are not quite incorrect and there are also much simpler ways to do this but you have to know and understand the implications if it is not done right. I know how I would do this but I can't see how I can steer you in the right direction while not knowing how to steer you away from messing with mains voltages and currents (shock, fire, death and destruction etc).
  • groggorygroggory Posts: 205
    edited 2014-04-24 12:00
    Here's a SSR that a friend of mine turned me on to...

    http://www.dx.com/p/ssr-25da-25a-solid-state-relay-white-134494

    sku_134494_1.jpg

    $7.54
Sign In or Register to comment.