# convert 12V PWM circuit to 5V PWM using opamp [closed]

I can convert a 12 V PWM signal into 5V signal, by using voltage divider on 12 volt signal , then directing it to base of NPN common emitter transistor with collector connected to 5V simulate this circuit – Schematic created using CircuitLab

How can i do same using Op amp ?

• It is possible to do it but beware of slew rate. If the pwm is too fast, the signal will no longer be square like. Apr 21, 2017 at 11:24
• The main issue with this circuit is that it inverts the signal. So a 10% PWM signal at 12V becomes a 90% signal at 5V. Apr 21, 2017 at 11:30
• This site has a integrated schematic editor. Use it. ASCII art need not apply. Apr 21, 2017 at 11:32
• Depending upon what you're doing with the signal, an op-amp is probably NOT what you want to be using. There are dynamic considerations, and more limitations on the output current than good approaches. Apr 21, 2017 at 12:45
• Yes it's possible. You make a voltage divider on your MCU pin, and put the opamp in a box where you keep stuff for your future projects. Apr 24, 2017 at 11:51

It depends upon your PWM frequency and the shortest mark/space pulses resulting from the nearest PWM positions to 0 % and 100 %.

This would carry out the general function: simulate this circuit – Schematic created using CircuitLab

The op-amp's '-' input is held at 2.5 V (half of 5 V).

The op-amp's '+' input switches between 0 V and around 4 V (about a third of 12 V, more precisely 3.8 V).

You will have to choose a suitable op-amp for your PWM frequency. If your PWM frequency is too high or the mark/space pulses too short, R1 and R2 should be lowered to ensure a fast rise/fall time at the op-amp pins while charging/discharging the stray capacitance there.

• is it non inverting op-amp configuration ? Apr 21, 2017 at 11:42
• what will be the gain formula for this ? .. Also if it is noninverting amplifier then o/p should connect to the feedback resistor like in this link electronics-tutorials.ws/opamp/opamp_3.html but you are connecting Rf=R3 to 5V ? Apr 21, 2017 at 12:00
• @user6363, it's open-loop, there is no feedback. Can you post fully-formed questions or conclusions rather than just bits of thinking, please :-) Apr 21, 2017 at 12:02
• Thanks for reply.. I want to know how output will be 5V when i/p applied will be 12V ..? as per this link nptel.ac.in/courses/Webcourse-contents/IIT-ROORKEE/… .. it seems your circuit is .. open loop differential amplifier .. and its o/p is vo = Ad (vin1 – vin2 ) .. where Ad will be open loop gain .. so for your circuit it will be vo = Ad(3.8 - 2.5) .. so what is value of Ad for this op amp .. that o/p will be 5V ? Apr 21, 2017 at 12:21
• @user6363, it's being used as a comparator. Try searching google for 'op-amp as a comparator' or read www.analog.com/media/en/technical-documentation/application-notes/AN-849.pdf Apr 21, 2017 at 12:23

This is a simple circuit to get the job done. You can use a simple voltage divider followed by a buffer. simulate this circuit – Schematic created using CircuitLab

Choose the op-amp, R1 and R2 to suit your application's requirements. I have chosen R1 = 1K, R2 = 1.5K. When the input is 12V, the output is 4.8V. You may find more suitable values to get 5V on the output.

If you use 5V to power the op-amp you may not get 4.8V on the output because op-amp output voltage is never the same as the op-amp supply voltage. Using 12V supply for the op-amp can give you better results.

Many circuit using opamp can fit your need. There is some point you have to consider :

• The original circuit on your post change the polarity of the PWM (70% duty become 30% duty cycle PWM)
• Opamp have slew rate, this mean, at high frequency, the PWM's waveform may change. Choose your part wisely ;)

How can i do same using Op amp ?

One inverting amp will do. Or two inverting amps if you want to maintain the same polarity.

But there are much simpler ways for you to do that.

If all you are doing is feeding the attenuated signal to an Arduino digital port then just use a resistor potential divider: - Let's say you make R2 = 1 kohm, then R1 has to be 7/5 * 1 kohm = 1.4 kohm

You might choose to make R1 = 1.5 kohm (in case the 12 volt rises a little bit). Check your logic high levels on the Arduino to see how high R1 could be before it fails to register a logic one when 12 volts is at the input.

For instance, a lot of IOs are TTL compatible meaning that 2 volts is the minimum logic 1 so, make a potential divider from 12 volts to 3 volts. This would make R1 = 1.8 kohm.

Using fairly low resistance values means rise and fall times will be largely unaffected at the output (unlike an op-amp or a comparator which will likely worsen the rise times and add a delay). Stay simple if you can.

• You really should explain why this won't work well if it is NOT being used to simply drive an Arduino digital port. Apr 21, 2017 at 12:49
• @ScottSeidman the op shows it connecting to such a port and my words in my answer were reinforcing this. It will work well in the situation and many situations but to generalise situations where it won't work well is perhaps going too far. Apr 21, 2017 at 12:57
• Concern isn't for this poster, but for other beginners who try to use your fine solution in a situation where it isn't so fine. It's an error I see all the time, and probably worth a sentence to help novices avoid it. Apr 21, 2017 at 13:10