Connect with us

Relay question

Discussion in 'Sensors and Actuators' started by Gren, Feb 18, 2020.

Scroll to continue with content
  1. Gren

    Gren

    9
    0
    Nov 17, 2015
    Hello Guys & Gals,

    I hope this is the correct location for my question.

    I am looking for a relay & Other (I think) for a project.

    What I need is the following if anyone has any ideas.
    I need something that is magnet controlled.

    So when i touch a magnet to a sensor it will toggle a relay on and stay on.
    But I need it so it won't allow the magnetic switch to work/trigger again for 5 seconds.
    So if i touch magnet to the switch (momentary) it toggles the relay off or on.
    But if I do multiple touches the switch will not work again for 5 seconds.
    Then if I touch magnet to switch after 5 seconds it will work again and toggle the relay off or on.

    I know there are timers and relays but was hoping to make it much smaller to fit into a small project box.

    I have a magnetic switch whic can be NO or NC.
    But it is the rest that is hard to do in a small project box.

    Is there some Relay board or other Electronic device that has trigger point, timer and relay on same PCB?

    Or is there some other way to keep what I need small?

    Thanks in advance
    Gren
     
  2. Minder

    Minder

    2,955
    624
    Apr 24, 2015
    That would be an ideal job for a small 8pin Microchip, unless that is out of your realm of expertise at this point.
    M.
     
    (*steve*) and hevans1944 like this.
  3. Gren

    Gren

    9
    0
    Nov 17, 2015
    Hello Minder,

    Thanks for the fast reply to my question, I really appreciate it.

    I do have a Microchip Programmer (2) Have not used it in over a year.
    But I will give it a shot, as I forgot about it until you mentioned it.

    I will go grab a few Prototype breadboards and give it a shot.

    Thanks for your idea and help.
    Gren
     
  4. Minder

    Minder

    2,955
    624
    Apr 24, 2015
    For interfacing pic to a relay 12vdc/24vdc coil etc, I use a 2n7000 small logic mosfet.
    Don't forget the BEMF diode across the relay coil.
    M.
     
    hevans1944 likes this.
  5. Alec_t

    Alec_t

    2,821
    754
    Jul 7, 2015
    If you could replace the relay with a switching transistor, that would save space.
    Have you looked into using a latching Hall effect sensor?
     
  6. hevans1944

    hevans1944 Hop - AC8NS

    4,470
    2,084
    Jun 21, 2012
    Replacing the relay with a switching transistor might be difficult if several sets of contacts are required. The OP didn't specify what relay is to be controlled, how much current and voltage it switches, whether the relay switches AC or DC, what sort of coil the relay has. Lots of missing information on the relay.

    I like @Minder's suggestion to use the 2N7000 logic-level MOSFET to switch a DC relay coil, but that may be because I bought a boatload of 'em a few years ago. The 2N7000 can also be used as the load switching transistor if appropriate precautions are made not to exceed its voltage and current maximum specifications.

    A lot of these projects revolve around controlling some AC powered device, either 120 VAC 60 Hz (USA) or 240 VAC 50 Hz (elsewhere). A DC-controlled solid-state switch is often a better choice than a relay for such on/off applications. Intermediate relays might be necessary if the load exceeds ten or twenty amperes or thereabouts, the final switch being a contactor instead of a simple "ice cube" or crystal-can sized relay. Switching a contactor coil is difficult for a PIC because most coils are AC driven. An intermediate relay is necessary, the PIC driving the coil of the intermediate relay from a DC supply, and the intermediate relay contacts driving the contactor coil from an AC supply. Easy peasy and you only need two wires between the contactor coil and the rest of the electronics.

    Hall-effect switches are readily available and affordable, but I have never heard of latching Hall-effect sensors. How do you turn such a device off after triggering it on? A part number or a source of supply would be appreciated. The OP might be better served with a small magnetic reed switch, which requires only a two-wire connection to the PIC microprocessor. Hall-effect sensors with which I am familiar are three-wire devices: power, signal, common.
     
  7. Minder

    Minder

    2,955
    624
    Apr 24, 2015
    Most Contactor suppliers will however supply the DC coil option, I use the DIN rail versions such as Telemecanique who do offer many options.
    For a Pic switching a large contactor, I use a heavier logic Mosfet such as IRL540 etc.and a 24vdc contactor coil.
    Honeywell have the SS400 line of sensors that come with many options, e.g. latch-unlatch version that is achieved with either pole of a button magnet for e.g.
    M.,
     
    Last edited: Feb 19, 2020
    hevans1944 likes this.
  8. Bluejets

    Bluejets

    4,053
    847
    Oct 5, 2014
    You may have to rethink your logic here.
    As Hop says, how can you toggle a device on or off but at the same time have a 5 second delay?

    With a uC would be possible to engage short or long press with differing outcome so perhaps some study in front of you.
     
    hevans1944 likes this.
  9. hevans1944

    hevans1944 Hop - AC8NS

    4,470
    2,084
    Jun 21, 2012
    I thought that was they whole idea behind using a Microchip PIC. You do some house-keeping to debounce the switch input (if necessary), check the state transition clock to see if a 5 second delay (or more) has expired since the last switch state-change was sensed and acted upon, and then change the output state from off to on, or from on to off, depending on its current state. I suppose it could be desirable to have a program write to a non-volatile memory bit to preserve the output state in the event of a power interruption, but that might not be desirable because the PIC outputs need to be initialized after every power-on event. Maybe a sleep mode with battery backup if it is necessary to remember the off or on state of the output after a power failure.

    There are also mechanical solutions that involve two relay coils that alternately latch and un-latch a single set of contacts. I used these in the last century before abandoning diode-relay logic in favor of TTL and CMOS logic. It all depends on what the OP wants to DO. Quoting from @Alec_t's signature line: "Given the right information and resources, it can be built!" We just need a good specification of what @Gren wants to DO before spending anymore time on this. Plus, it appears that @Gren is on the right track anyway and just needs a PIC and a 5 VDC power supply to breadboard some test circuits.

    I found a few years ago that it is important to read the datasheet of the PIC I am going to use, and thoroughly understand it before writing any code.
     
    Minder likes this.
  10. Alec_t

    Alec_t

    2,821
    754
    Jul 7, 2015
    Here are some examples of Hall effect latches. The magnetic field needs to reverse to latch/unlatch them (which may or may not be feasible in the OP's setup).
     
    hevans1944 likes this.
  11. Minder

    Minder

    2,955
    624
    Apr 24, 2015
    Those are virtually the same as the SS400 series.
    M.
     
  12. hevans1944

    hevans1944 Hop - AC8NS

    4,470
    2,084
    Jun 21, 2012
    Thank you, @Alec_t. I reckon i'm just lazy because I should have been able to find those myself.

    I agree that having to reverse the magnetic field (and initially apply it in the correct direction to latch the output!) is not in the best interest of the OP. I recall that it is possible to use a small permanent magnet to bias an ordinary magnetic reed switch to obtain the same latching effect. This was used in burglar alarm systems by ADT (Automatic District Telegraph) to obviate tampering, but I don't know how effective it was in that task. In any case, it does not appear to satisfy the requirement for alternate, time-out inhibited, on/off action as described by @Gren.

    I would be willing to help design this thing if I knew which Microchip PIC Gren was planning to use. I have a few laying around waiting to be put to use from earlier projects that I helped with here at EP a few years ago. Or I can recommend one that I already have if Gren hasn't purchased any yet. Unless you have the skills, I would stay away from the surface-mount devices (SMDs) and stick with the dual in-line package (DIP) versions for this project.

    Adapter boards are available to allow SMD components to be soldered on and converted to DIP devices for prototyping, and I have done this after my first purchase of PICs, but I don't recommend it as a first attempt. Later I did purchase DIP versions of the PICs I was interested in using. However, if I were to really get serious about making things in small packages, SMD is the ONLY way to go. The cost is reasonable to populate and reflow solder a circuit board in a modified toaster oven. Or you can place and solder components one at a time if that suits you. It only costs a few bux to have double-sided circuit boards with plated-through holes (PTHs) made, and for anything reasonably complicated PTHs go a long way toward eliminating layout headaches and avoiding jumper wires on the component side of the board. They are no panacea however. I have sometimes had to cut traces and install 30 AWG insulated wire-wrap wire to correct my layout mistakes, so manufactured boards are no guarantee of immediate success.

    For one-off projects, like this one appears to be, prototyping boards such as Veroboards do nicely and you don't need to learn circuit board layout design. If you want to build a few million of these things and get feelthy rich selling them, before someone in China pirates you intellectual property, you ironically need to have those million circuit boards manufactured and stuffed for you in China. But make sure your PIC code is protected from copying after the PIC is programmed. It might help to file the serial numbers off of all the components, although reverse engineering something this simple should be trivial.

    Hell, since we have now discussed it here on EP, some enterprising Asian may have already "invented" it and made it available on eBay or Ali-Baba. I would carefully check that out before investing too much more time in building one, unless you just want the fun of doing it yourself. Nothing wrong with that, and it is the main reason I still dabble in electronics in retirement.
     
  13. twister

    twister

    172
    7
    Feb 12, 2012
    Here is a simple 8 second timer. You can also use a Schmidt trigger


    0220201204.jpg

    0220201211a.jpg


    [Mod note: cropped and resized huge images]
     
    Last edited by a moderator: Feb 20, 2020
  14. hevans1944

    hevans1944 Hop - AC8NS

    4,470
    2,084
    Jun 21, 2012
    Okay, @twister, WTF is the rest of the circuit that behaves the way the OP wants it to behave? Your so-called timer requires the resistor to be in series, charging the capacitor, NOT in parallel discharging it. Your post is no help at all, and you obviously do not understand what the OP wants to DO.

    A few back of the envelope scribbles are okay here, but showing a CMOS NAND gate and an RC network, improperly connected to produce a time delay, just doesn't hack it. So, go take another toke and try another "back of the envelope" traditional analog design to prove you REALLY understand what is going on. You might want to use Google to check and see how my favorite analog design engineer, Robert Pease (deceased) did it.
     
  15. hevans1944

    hevans1944 Hop - AC8NS

    4,470
    2,084
    Jun 21, 2012
    You need to specify a charging current to calculate a charging delay for a capacitor. Depending on the source resistance and logic power supply voltage, your capacitor may never reach the logic-one level switching threshold. In any event, whatever delay is created only occurs if the switch (you assume a Hall-effect switch) remains actuated during the entire eight second delay.

    The OP wants a momentary switch actuation to cause a change of output state from OFF to ON, or vice versa, with an eight second delay after the switching event before another switch actuation (by means of a permanent magnet) causes another change in output state. What part of this do you not understand? How does your RC timer cause this to happen?

    My brother, who was born in Aurora, Colorado two years after I was born, used to import kilos of fine weed grown in Colorado to Florida every year, up until the day he died of cancer. It is legal to smoke medical marijuana here in Florida, but not recreational marijuana like it is in Colorado. So a few times a year he would make the trip to a farm where a friend of his was growing some fine buds and bring back a boatload, some to sell to pay for the expenses and some to mitigate the effects of his cancers.

    My wife has a medical marijuana card, and I could probably qualify for one too. The industry here rips old people off by requiring an expensive renewal process every year. I have smoked before (had to quit in the 1980s to obtain higher level security clearances for guv'mint work) and I may smoke again in the future, so whether you do or don't is no big thing with me. Not accusing, just observing.

    What makes you think anyone is being driven away from this site? I am not driving anyone from this site except, perhaps, thin-skinned posters who cannot accept any criticism, or drive-by posters who don't hang around long enough to see what is going on. And maybe a few old codgers like myself who probably don't even need to be here but like hangin' out with the younger crowd. BTW, what are you doing here? Your posts go back seven years or so, but are infrequent. Harbor Freight test equipment? Really?

    If you will go back and read my post #12 you will see that I offered to help design this, but I am still waiting for a response from the OP. I don't want to deprive anyone of the pleasure of self-discovery, so I won't post a complete design until after I have actually breadboarded and tested a device that I think meets the OP's specs, and then only if the OP gives me permission to do so. It is, after all, his project not mine nor yours. I have plenty of other things to do with Microchip PICs, so it may be awhile before I get around to doing this.
     
    Last edited by a moderator: Feb 21, 2020
  16. davenn

    davenn Moderator

    13,582
    1,869
    Sep 5, 2009
    OK I have done a tidy-up

    PLEASE, no more personal abuse

    @twister as @hevans1944 said, gave a very incomplete and poor circuit which wouldn't have helped the OP
     
    hevans1944 likes this.
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

-