I have an application that would traditionally be solved by the means of a relay. I have a 12 VDC load that I would like to switch on and off via a 5V microcontroller pin. But, I'm already using some 6134 (rail-to-rail) op amp chips in my project, and I have a free one I could use, since the IC comes with 4 op amps per chip.

Would it be considered a hack if I used my remaining op amp as a comparator instead of adding an additional relay to my circuit? If I put 2.5 V into the inverting input and the microcontroller pin into the non-inverting input, could that replace the relay? The positive rail of the op amp is already my 12 V load, and the negative rail is ground.

  • 3
    \$\begingroup\$ How much current is your "load" drawing? Would it melt the op-amp? If it's not that much a load, wouldn't a simple transistor be better? \$\endgroup\$
    – Majenko
    Commented Sep 10, 2011 at 19:50
  • 3
    \$\begingroup\$ Not many op-amps would be happy about supplying the kinds of current that a load "traditionally handled by a relay" might require. Sounds like a good job for a MOSFET. \$\endgroup\$
    – JustJeff
    Commented Sep 10, 2011 at 20:12

3 Answers 3


You ask that question like it is a bad thing!

If it does what you want, over the conditions you want (voltage, temp, lifespan, etc.) then what's the problem? People use electrical components in "non-traditional" ways all the time. LED's are used as photodiodes. Bipolar transistors are used as diodes. Op-amps are used as voltage comparators. I've even seen CMOS logic devices used as opamps and analog buffers!

The bigger question for you is: Are you using op-amps and relays correctly? And by correctly, I mean within the specs of the devices. Replacing a relay with an op-amp is certainly non-traditional. The two devices are different enough that it raises lots of red flags and other questions, but there are situations where that could be fine. Your question didn't give enough details for us to comment on directly.

So... Your question is, "Is it considered a hack to use an op-amp in place of a relay?" The answer to that is: Yes it is, but there is nothing 'wrong' with that-- provided that it works.


Your questions assumes that a relay was required to switch the load and that it would normally be the "right" answer. However, other things you've said indicate that a relay might be inappropriate or at least overkill in the first place. If the load requires so little current that a 6134 opamp could supply it directly and you don't need isolation, then why do you think a relay is the benchmark to judge other solutions by? That would not be on my short list of solutions to that problem.

Instead of comparing solutions to each other, compare them to the specs. Unfortunately, you provided very few of those except that apparently you need a 12 V high side switch.

The big question of course is what's the current? If it's a few 100 mA or more (which one could infer from your original approach of using a relay), then the opamp by itself won't work. If it's only a few mA and within what a 6134 is specified for, then there's no problem using the opamp.

Since you apparently don't need isolation (another thing relay infers), there are many other possibilities for driving a high side switch from a 0-5V digital output. Two transistors and two resistors can do this easily. Since you have the spare opamp, you can use it to replace the first transistor and resistor. The opamp output drives the base of a PNP thru a resistor, emitter to the 12V rail, and collector to the load.


The use of an opamp is OK for anything that an op amp can do while not violating its specifications.

  • It is possible, BUT it is unlikely that your chosen opamp can do what you want.

The LM6134 opamp (datasheet here) is rated at about 2 mA drive sink or source worst case, typically you may double or triple that and absolute maximuj rating (non operating) is 25 mA.
If your load needs no more than 2 mA your op amp is a potentially good solution.

For more than 2 mA a suitable MOSFET and NOTHING else can work OK, or a small bipolar transistor plus 1 resistor.

A MOSFET could provide any level of load current from 2 mA to amps with no more complexity except a suitably sized FET. With a MOSFET with a suitable low Rdson (on resistance) you could switch 10A+ in a DPak surface mount pkg or even in a SOT23 with due care.

eg dissipation at 10A and 50 milliohm Rdson = 10 x 50 = 500 milliWatt. Lower Rdson allows even lower dissipation.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.