Shop OBEX P1 Docs P2 Docs Learn Events
relay switch — Parallax Forums

relay switch

Hi all,

I have a 3v relay trying to use it with a pin.
The pin cannot turn the coil on. Moreover if I do it manually, connect the Vin to Gnd the system rebouts and loses all the values.
I am thinking of using a 3.3 voltage regulator before the coil so that the voltage is the required.
Is there any other way in controlling the Vin using a pin? I have tried connecting the Vin with the Signal and from the other side the Gnd or the other way around still nothing.
The command is a simple high(pin number).

Any ideas would be appreciated!

Comments

  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-10-17 14:48
    Well, wiring up a relay coil is NOT as simple as changing a light switch or installing a light bulb. There are limitations to how much power the Propeller i/o can provide, and there really is a need to protect your i/o from potential damage. Regulated 3.3VDC may help to some extent, but that is not the only item that needs to be included.

    Given you have a 3VDC relay coil, what amount of current does it require? You may be beyond the capactity of the Propeller i/o. And how exactly are you protecting the Proppler i/o from a spike caused by the collapse of the magnetic field when the coil is turned off?

    Trying to wire a relay coil directly -- even a 3 VDC relay coil; creates a lot of hazards and technical problems that may be avoided by a more sophisticated approach to driving relays.

    I guess you are having the Propeller provide the ground side of the relay. To make this work, more details might be helpful -- but what you really should be doing with any relay coil is providing some degree of protection and some degree of isolation from the i/o pins.

    The usual solution is to provide a transistor that drives the relay coil, like a 2N2222. And a diode that traps the fly-back voltage when the coil is turned off. Wanting to eliminate these components creates more risks and more problems.

    The problems you are mentioning seem to indicate that these factors are not being considered. You are at risk for damaging individual Propeller i/o pins -- which can be avoided by a more conservative scheme.
  • Which Microprocessor are you using? There are many examples that can be found using the Search and "Propeller Relay" or "BS2 Relay"
  • I also want to ask about the humidity sensor (https://www.parallax.com/product/27920)
    Has anyone got a C code test and how to connect it? I read the manual yet the code is not working for the propeller and all it does is to charge with rc_time until it hits the max.
    this is what I read: https://www.parallax.com/sites/default/files/downloads/27920-Humidity-Sensor-Documention-S1101-v1.0.pdf
  • I am using ther propeller education kit (https://www.parallax.com/product/32305)
    I just want to control the coil which in turn will open the voltage for a a heating resistor. I cannot understnd why it doesnt open the coil. Prop is suppose to have a 3.3v. Anyway.
    this is the site with all the information: http://grobotronics.com/relay-5v-dpdt-5a-250vac.html
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-10-17 15:28
    The relay has 17 ohms coil resistance.

    V/R = I Ohm's Law
    3.3/17 = 0.194 amps or 194 milliamps.

    Or the specs say a coil current of 176.5 milliamps. (3.0./17 = 176.5)

    Either way, you are not getting enough current.

    The Propeller i/o will only provide 30 milliamps at best, and a greater load may cause damage.

    At this point, you may have to set up a multimeter or an LED with a resistor and verify that you haven't burned out individual i/o pins. If you have dead i/o pins, nothing is going to revive them. And you will have to work around them to have any project work.
  • johnproko wrote: »
    I also want to ask about the humidity sensor (https://www.parallax.com/product/27920)
    Has anyone got a C code test and how to connect it? I read the manual yet the code is not working for the propeller and all it does is to charge with rc_time until it hits the max.
    this is what I read: https://www.parallax.com/sites/default/files/downloads/27920-Humidity-Sensor-Documention-S1101-v1.0.pdf
    You should start a new topic for this.

  • ercoerco Posts: 20,254
    Wrong relay, that one requires WAY too much current. Coil resistance needs to be several hundred ohms, not 17 ohms. They do exist:

  • PublisonPublison Posts: 12,366
    edited 2015-10-17 15:35
    You need a transistor to drive that relay.
    https://www.kiwimill.com/model-making-how-to-transistor-driven-relay-switch/

    You may have already blown 1-4 pin on the Propellor, which could be the problem with reading the Humidity Sensor.

  • Mike GreenMike Green Posts: 23,101
    edited 2015-10-17 15:41
    Most relay coils require much more current than a Propeller I/O pin can supply. There's an excellent Nuts and Volts column that discusses how to use a relay with a Basic Stamp (here column #6). The Propeller is a 3.3V device while the Basic Stamp is a 5V device, but the issues are the same. The base resistor value used with 3.3V will be lower (maybe 150-220 Ohms).

    There are a few reed relays that can be driven directly from a Propeller I/O pin, but their contacts are only rated for maybe 250mA. They're good for switching audio or video signals, not a heater

    The relay you mentioned requires 175mA to switch on. A Propeller I/O pin can supply maybe 20-30mA and there are limits on how much total current can be supplied by a group of I/O pins and by the chip as a whole.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-10-17 16:03
    Since most relay coils require more current than the Propeller will provide, I generally do not bother with these lower voltage relays at all and just use 12VDC relays for everything. Automotive 12VDC relays are handy and rugged for robotics.

    Reed relays might work, but they are famous for bouncing.

    Even when you have contacts rated at 5amps, there are all sorts of loads that will derate the contacts by as much as 60 percent. So I just use 12 amp relays for all and everything in general. With motors, the relays can require a 30 or 60 amp rating.

    These tiny relays are tricky and much easier to damage.
  • First of all thank you for your replies.
    All pins work fine.
    If I use 12v relays that have 30ma for the coil, how am I suppose to make them work since the prop can give only 3.3v?
    Or is this irrelevant?

    Nevertheless I did manage to control the relay through a leftover h bridge. Dont know if this is good or bad, yet it does its job and that is fine. Would like though to learn more about relays. IS there any chance the h bridge to be damaged?

  • Read the Nuts and Volts column I mentioned. It shows how to use switching transistors to control relays from an I/O pin.
  • If it is that you understand that you need some form of power switching device such as a relay to control a heavier load than the processor can switch then you must also understand that this relay and relays in general are "a heavier load" that the processor cannot switch directly. Normally if you want to drive a relay you need a transistor switching circuit so that the processor only needs a few milliamps or less to switch the transistor and then the transistor can handle the 175ma of relay current easily.

    HOWEVER, it may be that if you are using a relay in the mistaken belief that this is the best way of handling a motor or solenoid etc. If however that load is not high voltage then mostly you are better off using a MOSFET which can be driven directly by the processor and so handle many many amps.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-10-18 12:05
    johnproko wrote: »
    First of all thank you for your replies.
    All pins work fine.
    If I use 12v relays that have 30ma for the coil, how am I suppose to make them work since the prop can give only 3.3v?
    Or is this irrelevant?

    Nevertheless I did manage to control the relay through a leftover h bridge. Dont know if this is good or bad, yet it does its job and that is fine. Would like though to learn more about relays. IS there any chance the h bridge to be damaged?

    I am happy to hear that you did not damage anything. Yes, half an H-bridge can control one relay coil nicely and may include fly-back protection.

    I'll try to clear up why I prefer 12VDC relays to the 3.0VDC relays.

    A. First off, the power to pull in the contacts is about the same.

    So Power = Volts x Amps
    For 3.0, you have 3.0 x .1765 = 0.526 watts
    For 12.0, you might have 12 x .050 = 0.600 watts.
    (I doubt you are going to get a 12 volt coil that is 30 ma.)

    B. The advantages with higher voltage are simply that smaller wires can carry similar amounts of power and that voltage drops by transistors, darlingtons, or MOSfets that reduce power by less of a fraction of the whole.

    I try to drive motors at 12 or 24 volts to take advantage of the smaller wires, so the 12 or 24 volts is also available for relay coils.

    MOSfets have been mentioned and they are very, very handy. They have low voltage drops and often built-in fly back diodes that will eliminate coil fly back. Their big draw back is that most of the good ones are surface mount packages, which make them useless to beginners that are breadboarding circuits.

    Using a transistor has a bigger voltage drop. For the usual switch, it is about 0.7 volts. So at 3.3 VDC, the voltage that it will provide to the coil is really about 2.6V; but at 12VDC, the voltage that arrives at the coil is 11.3VDC. Much less power loss. Of course, you still have add in a fly-back diode to eliminate noise and protect the transistor, but the project can be breadboarded.

    The main point here is that microcontrollers never were intended to provide power directly to coils, motors, or heavy loads.
    If you desire to control those loads, something has to go between the microcontroller's i/o and the load that provides the required power and the eliminates the hazard of damaging the microcontroller. Internally, the wires of a microcontroller are extremely small, like whiskers of gold wire. Don't expect them to be your power supply.

    Sure the Propeller is supposed to deliver 30 ma to one i/o pin. But the device as a whole is unable to deliver more than something like 300 ma to all i/o pins without risk of failure. So if you really want to use the Propeller well, that 300 ma budget has to be spread over all the i/o pins and works out to less that 10 ma available per pin.

    The Propeller provides control signals. Power has to come from elsewhere.

  • My bot has each and every pin in use. It would be nice to monitor every one. You can do it manually with VOM and depend on documentation. Monitoring the whole chips current usage would tell you something's wrong after the fact.
  • Why would it be nice to monitor all the I/O pins? The whole idea is to design the various interfaces around your microcontroller so they'll work the way they should unless there's some kind of catastrophic failure ... hopefully one that won't damage your microcontroller. Voltage ratings should be well in excess of what's expected. Current ratings likewise. Monitoring the whole chip's current usage doesn't tell you why the current is high.

    Most of the time, when each and every pin is in use, it's a sign that you need to use some kind of I/O expander to free up some of the I/O pins or maybe offload some of the peripheral management to another device. Two Propellers may simplify your design or a Propeller and some other microcontroller.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-10-20 10:16
    A solid-state relay device will make construction much easier.
  • Mike Green wrote: »
    Why would it be nice to monitor all the I/O pins?

    I would never consider such a thing, I make sure whatever I connect to the microcontroller is compatable, and stays well below the hosts spec's, even though the chip's spec's are below what the chip can handle. Thats good design, Isn't it?
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-10-20 15:51
    It is not about monitoring the whole chip's current usage after the fact. It is about budgeting power in a way that you get a good design outcome.

    We have a lot of people that latch on to that one fact -- an i/o pin may deliver as much as 30ma at 3.3VDC and don't grasp that you can't have all 32 available GPIO pins driving 30ma at the same time without damage.

    Something similar occurs with using voltage regulators. People try to get a full 1 amp out of a 3.3 volt regulator, but want to provide a 12VDC or 18VDC input and no heat sink.... after all, the PDF says that the device can accept 18VDC.

    Power requirements and heat disappation get ignored by novices. The way specs are written are to indicate failure limits, but good practical use.
  • Parallax's dual relay board is a good circuit to copy, along with automotive relay's, It' a safe design.
  • We have a lot of people that latch on to that one fact -- an i/o pin may deliver as much as 30ma at 3.3VDC....

    NQT, an I/O can deliver 3.3V *or* >30ma, but not both. Imagine the CMOS transistors as resistors with a value of around 40 ohms or so. Without a load you will get 3.3V and if you short the output you will get as much current as the structure will pass, but no voltage! So light loading will introduce some drop in the signal voltage but when we are driving LEDs etc we aren't too worried about the output voltage unless of course we are trying to drive some other logic. Total chip current includes the chip itself, that is the current the processor uses in addition to any I/O current. But those ABSOLUTE MAXIMUMs are NEVER to be taken as operating conditions as they often seem to be referred to.
  • ercoerco Posts: 20,254
    edited 2015-10-22 00:49
    WRT low power relays (for 5V anyway), I'm a fan of Aromat's low current TF2-5V. The 312-ohm polarized coil draws just 16 mA at 5V direct. DIP package, DPDT contacts. No problem for my BS2E to drive 3-4 of these at once on Retrobot (video below). Pushin' that envelope!

    When driving a relay or other high-current device directly from a micro, it's also worth noting that in most cases an output pin can sink more current (at considerably less resistance) than it can source. So connect your relay/device from the pin to B+, not ground.



  • Anyone know why Parallax's Dual Relay Board (27114), doesn't respond to my Quickstart's signals, I have only used the board with a BS2, and there is no problem with TTL level signals, now I have a Propeller project in the works and possably have to include a level shifter?
    Documentation states the board can be used with 3.3v signals, could it be the pin current limiting resistors included on the QSB causing the problem, the 3.3v rail measures Ok.
  • PublisonPublison Posts: 12,366
    edited 2016-09-03 15:24
    Which pins are you using to drive the relay board from the QuickStart? Some are connected to CAP switches, and some are connected to LEDS.

    BTW. You should have started a new thread for this question.


  • I have used at least a dozen Relay Boards with the Propellor. 3.3 input is fine.
  • Publison wrote: »
    Which pins are you using to drive the relay board from the QuickStart? Some are connected to CAP switches, and some are connected to LEDS.

    BTW. You should have started a new thread for this question.


    Pins 6&7 are connected to the relay board, and signals were checked moving the pins to 22&23, QS LED's.

    I didn't want to look too dumbfounded, just thought I could sneak a quick question in.
  • MikeDYurMikeDYur Posts: 2,176
    edited 2016-09-03 15:54
    Here's a pic of my setup.

    BTW: relays actuate connecting the signal lines to the QS 3.3v bus.
    1280 x 720 - 465K
  • Suggest moving output pins to P8-15. They are not connectect to any thing.

    • P0 through P7 — General purpose input/output pins. Also connected to the resistive touch
    buttons. When not in use, the buttons will not load the I/O pins, when touched, they will add
    negligible resistive loading.
    • P8 through P15 — General purpose input/output pins.
  • MikeDYurMikeDYur Posts: 2,176
    edited 2016-09-03 16:26
    Thanks Publison, fogot all about the touch switches, moved them to 22&23 and it works, blew an hour on that one. ;)

    P.S.: this project will eventually will be moved to the Propeller Mini, so pin assignments were not a consideration yet.
  • MikeDYur wrote: »
    Thanks Publison, fogot all about the touch switches, moved them to 22&23 and it works, blew an hour on that one. ;)

    P.S.: this project will eventually will be moved to the Propeller Mini, so pin assignments were not a consideration yet.

    Good deal!

    Carry on. :)


Sign In or Register to comment.