# PWM Voltage Conversion

#### jkoffman

##### Well-known member
Hi folks,

I would love a double check on something. I’m working on a project that I’m reading a 5V PWM signal into a 3.3V only input. The PWM signal is actively driven between GND and +5V and is “active low”, meaning I will see 0V when the PWM output is high.

I’m trying to solve the 5V to 3V conversion, ideally without a true level shifter. I had originally looked at a simple resistor divider as shown here:

But I believe that then the PWM signal goes to +5V I’ll be dumping 5V into the input of my circuit.

So I’m thinking about replacing the lower resistor with a simple 1N4148, cathode towards the PWM signal. The top resistor would go to +3.3V. Like this:

My thought is that when the PWM signal goes to +5V the diode will be reverse biased, and the resistor will act as a pull up. My input should see +3.3V. When the PWM output goes low, the diode would conduct and pull my input to ground.

How’s my thinking?

Next question of course is can I lose the resistor entirely and just use the internal pull-up?

Thank you!

Next question of course is can I lose the resistor entirely and just use the internal pull-up?
That's what I would do (and have done on several occasions).

My thought is that when the PWM signal goes to +5V the diode will be reverse biased, and the resistor will act as a pull up. My input should see +3.3V. When the PWM output goes low, the diode would conduct and pull my input to ground.

How’s my thinking?

This circuit has some limitations which may or may not be a problem. Understanding the issues can help you to anticipate whether it will work well enough, or if those limitations will cause problems.

The main issue is the diode's forward voltage. When the input is logic low, the output will be a slightly higher voltage because of the diode. The rule of thumb is 0.7 for normal silicon diodes, but it does depend on the current and also temperature. If the input doesn't quite get to zero volts for logic low (while it is having to sink the current which flows through the resistor and diode), the voltage you end up with for logic low might not be quite as low as you want.

The other possible issue is slow rise time. The high to low speed will be nearly as fast as the original PWM signal, but low to high depends on the resistance and total capacitance, which includes the pin for whatever receives the output signal. For ordinary PWM with relatively low frequency, the error should be very low. But if you use a higher PWM frequency, this change in rise time will probably result in noticeable error. Maybe a problem, or maybe not.

Of course this circuit also uses much more power than a proper level shifter, and the power usage depends on the PWM duty cycle. Probably not an issue, but something to keep in mind if you have a low power application or you replicate this circuit many times.

Hi all,

I appreciate the replies.

@Paul very interesting, thank you for the insight. This circuit will be directly feeding an input pin on a T4.0. My plan is to try to decipher 3 channels of PWM using FreqMeasureMulti. If possible I’d switch to using the internal pull-up which I think would help the transition timing but I’m not 100% sure.

I’ll need to look at the processor’s data sheet to figure out if the slightly higher low voltage is going to be an issue. Luckily my circuit is pretty straight through, I just don’t know what the chip will accept.

PWM frequency is roughly 25KHz, so I’m not sure what the upper limit of the diode circuit is.

I had been trying to avoid a level shift IC for space and simplicity, but if I had to go that way do you have any suggestions? I’d like to avoid something with too many excess channels if I can, but happy for any tips that I can then jump off of with some research.

Thank you!

I don't understand the reluctance to use a proper 5V tolerant buffer chip. For 3 signals, you'd need 1 chip and 1 decoupling capacitor for good quality results. Seems better than using 6 parts for marginal quality waveforms.

It’s an attempt to save board space and for simplicity. But you’re winning me over. I just need to find a suitable chip and start planning around that.