24V relay driver circuit


[Glitch] got his hands on a slew of relays which are meant for use in industrial equipment. They are designed to operate at 24V. He wanted to use these with common microcontrollers and instead of buying a driver he designed and built his own.

There’s a few things to consider with a project like this. You need a power source, a way to level convert the driver pins, and some protection in case something goes wrong with the circuit. Looking at the board above should give you some idea of what’s going on. There’s a big transformer taking up half of the footprint. This steps down mains voltage to something a 7824 regulator can handle. That’s a 24V linear regulator which is fed by a bridge rectifier along with some smoothing capacitors. With the source taken care of [Glitch] uses an optoisolator for both protection and level conversion. After working the bugs out of the design he was able to control the relay using 3.3V, 5V, or 12V.

38 thoughts on “24V relay driver circuit

  1. Maybe it’s my noob showing but I’m struggling to wrap my head around why he used a handful of components and had custom boards manufactured instead of just buying some 5v relays.

    1. It was probably for more of a challenge. The 24V relays are of much higher quality, and they cost a pretty penny (I deal with some sealed 24V relays which sell for $500 a pop).

      Opto-isolation is probably the safest method in this instance, but I didn’t see any diodes to protect from inductive kickback on the relay. Maybe it’s due to the small draw of these relays…

      If you need a simpler solution, I don’t see anything wrong with a Darlington pair and a few protection diodes to drive from the controller’s output.

      1. The relays he’s using cost less than four dollars even bought individually. The 5v version of the same relay costs less than three. I see the accomplishment in working around a problem using parts you already have, but he didn’t do that. Once you have to order a custom PCB you might as well just order the proper relay for all the “hacking cred” it’ll give you. This is buying a flatbed trailer to cart your flat-tire sedan around in instead of just getting a new set of tires.

        1. Yah, I’m not getting it either, unless it’s proof of concept for a thousand amp relay for your quarter shrinker or something that can only be activated with 100V.

          Or unless as mentioned they are some sooooper high quality stuff that has a 5 bajillion cycle life and can switch at 500hz or something.

  2. I have lots of 24V relays, which is frustrating, I need 5V or 12V relays, so I made a circuit with a small voltage doubler and 2n2222 drivers

    7414 @ 50% drives a RF filter for the doubler transformer, typ common emitter for the drivers.

    1. Hey do you have a schematic for that? I’m trying to do something similar. I’m trying to control 24V relays with my 5V arduino and an external 24V power supply. I’m currently planning to just use a 1k resistor from arduino to base, a diode between the relay contacts, and a 2n2222 to switch the power. Will I need to worry about the 24V frying my arduino?

  3. The purpose was using scavenged relays with a board meant to be embedded in the device to be controlled. While there is a footprint for the Aromat relays shown in the pic, it can also be used to control big socket-mounted relays with higher current capacities.

    To re-iterate what’s actually in the write up, the board goes in AC line powered devices to be controlled, while the controller is cabled externally. The PC board just makes assembly faster. Just thought I’d share the design in case anyone else wanted to run a few off.

  4. I realize i might not be the right person to ask this, but how this a hack? He basically connected an opto coupler between a micro and a relay, done.

    It’s also extremely over-engineered, all those capacitors and regulator and all that arn’t exactly necessary. A matched resistor will replace the regulator, and you may need a single capacitor if the relay is extremely fast.

    1. You do need a cap to prevent high-speed relays like the Aromat telecom relay pictured from chattering on 120 Hz DC ripple. A matched resistor divider would probably be fine, but I’ve got a rail of 7824 regulators.

  5. I don’t get why he uses an opto isolator. Isolation from the main is already done through the 24V transformer.
    A driver made with a 2n2222 and 2n2907 is enough too.

    A nice thing would have been to generate the 24V from the 5V rail through a boost stage driven by a couple of pins of the micro : interesting to design, small footprint and great efficiency.

        1. Keep in mind that a 5.1V zener may already start leaking at 5V, especially if you keep in mind tolerances for both zener and 5V supply over the intended temperature range. A slightly high zener voltage would probably be better.

          1. In this specific case it does. Believe what you want but if you put an opto in your design each time you have to drive a relay, your product price will explode.

          2. Of course i wouldn’t put an opto coupler (or a zener) in a mass produced product for this purpose, i would rely on testing to generate a working design.

            For one-offs however using opto couplers to separate voltages can be very profitable in time saved by not having to repair the damn thing every time something goes wrong.

            What we are discussing here (i guess) is however a relay module for use in generic projects where using an opto couopler is very nice to assure that you can’t get back-voltages by for example connecting the common ground wrong (you don’t even need common ground)

      1. And as the note points out, it also takes care of the voltage level conversion. And opto-isolators are usually specified as needing thousands of volts to breakdown, which is nice if the relay happens to fail in some way as to leak mains voltage into the driver circuit. Or anything else. Or any other thing that might go wrong.

        It does the job, it’s cheap, and adds a pretty unbeatable level of protection. A zener might fail, given too much current. The gap inside the opto is pretty much never going to fail. The opto seems to be the optimal solution.

        I might want to add the possibility of driving several relays at once though, giving a whole mains PSU just to drive a relay is a bit over the top. Or as people have said, use a voltage booster.

    1. He’s not isolating from the mains, he’s isolating from the spike you’ll get when the filed collapses on the relay coil after being de-energized. These spikes can be HUGE, and can often mean instant death for microcontrollers. Even if the microcontroller doesn’t get juiced right away, the noise spikes can cause erroneous resets, brown-outs, and random timing errors. A diode should help with this, but it’s not fool-proof.

  6. I’d just use a simple n-type mosfet as a low side driver. Put a diode across the relay, and you’re done. You can get suitable mosfets in SOT-23 packages. An optoisolator is overkill. The relay and transformer already provide isolation.

      1. Yes, I forgot to mention that you need to look for a mosfet that turns on at low gate voltages. These are easy to find, but you have to check it. For a similar application I’ve used the IRLML6346TRPBF, with 80milliohm Rds(on) resistance at 2.5V gate voltage, and less than 15 cents a piece. For a 24V relais, I’d recommend something with a higher drain/source voltage, though.

  7. A relay controlling a relay seems a bit redundant to me.
    There are plenty of micro-controllers on the market that can handle 24v relays directly, such as the kind used in industrial machine control applications.

    1. In the same price-range as the micros us hobbyists normally use? If so, would they have all the same capabilities? Pin Count, ADC, PWM, etc… A familiar programming environmnet? Remember, he was trying to use the Relays because they were free to him, not because of a special fondness for 24V.

  8. I can see the apeal here. I’ve been asked to work on a project for a friend which is just simply going to use a lot of relays no matter how I do it. 5V relays would make the cost too high but I know a place (Mendelson’s in Dayton OH) where NOS 24V relays go for as low as 25 cents each!

    But, this solution, as many have pointed out is more expensive than just buying the 5V relay! What I don’t get is it’s the custom PCB and the opto-isolator that everyone is chiming in about. Sure, there are simpler/cheaper ways to go but that is beside the point. If you are going ot use an optoisolator and custom PCB with your 24V relay you would probably do the same with a 5V one!

    What gets me is seeing a whole power supply built just to supply an alternate voltage to one relay. Where this project could begin to make since financially is when many relays are being powered by that one transformer and regulator. I am guessing this isn’t what the author intended since he had a custom board etched… and with only room for one relay.

    Maybe he just intended to test the idea with one relay for use in a project with several but then why the PCB? Just use a breadboard, perfboard or etch it at home! Perferably skip building the power supply altogether and use a variable bench supply or an old printer wallwart.

    If this is meant for a project with many relays whough I suppose he could tack on some wires to the output of his regulator though and use it to feed additional boards. That doesn’t seem to fit with the ‘neatness’ of having had a custom PCB made though.

        1. More specifically, a pile of both transformers and relays (dozens of each). Almost all of the components were available in my parts bin too, the only thing that needed bought was more DIP package bridge rectifiers. This was originally built on protoboard (several were made, the article pictures one in its final home) but it takes over an hour to build it up point-to-point. The etched PCB is smaller and, when time is factored in, is at least no more expensive than building it on small pad-per-hole boards.

          While there is a footprint for the Aromat relay pictured, I also intend to use the board with much larger external relays.

      1. i was there last summer. Dayton isn’t exactly close for me but my wife had a bike race near there. Normally I only see Mendelson’s once a year at their Hamvention tent. It was my first time to the actual warehouses. They are huge!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s