Guidance for MOSFET circuit to increase PWM voltage level


I am currently working on a project which includes reading and modifying the values of a 12V sensor that uses PWM signals with a frequency < 450 Hz. My approach is to use Arduino Mega to receive data and then send out either the same signal or one with a different duty cycle or frequency for example. I know that the Arduino operating level is 5V, and such I have been searching for information about how to shift the signal down to 5V and then back up to 12V. My knowledge of designing circuits is very limited compared to my programming, hence I need some guidance to get back on track!

While searching for a way to implement this I discovered that many suggested a simple voltage divider would suffice to get the signal in the right range to not damage the Arduino when reading the values. But for the other way around it wasn't as simple... I came across lots of posts about BJTs and MOSFETS, and I ended up going with the MOSFET AUIRFB8405. When trying to verify the MOSFET circuit I did not succeed yet. I am using the following schedule, where drain is supposed to be hooked up to a 12 V power supply, but I only had a 9V at hand today. The Arduino is powered from the USB at this point since I am still developing the project and both circuits share a common ground.

In blue the original PWM signal at 5V is shown and the yellow is what comes from the MOSFET circuit. I would expect the output level of the yellow signal to be higher and/or also be more responsive. And this is where I need help or advice to analyze my circuit and results. What is happening? It seems as the MOSFET never completely turns on or off, and stuck in some middle land. How can I improve this to get a desired output, which would be a PWM signal at 9V (or 12V when using another power supply)? Do I need to extend this circuit in any way? If anyone could point out where I am going wrong it would be highly appreciated!


Your MOSFET "shorts out" the 12V when it's on... That could blow the MOSFET or your power supply! You need to put the load in series...

If there is no "load" and you just need a 12V "signal", then use a pull-up resistor in place of the load (to pull the voltage to 12V when the MOSFET is off, and to limit the current when the MOSFET is on.)

[u]Here is a MOSFET driver circuit[/u]. The diode across the MOSFET is only required if you are driving a motor (or other inductive load).

You need a logic-level MOSFET if you are driving the gate at 5V. Common power MOSFETs usually need
a minimum of 10V gate drive and are usually driven at 12V.

Otherwise you can feed the Arduino PWM into a MOSFET gate driver chip and drive a non-logic-level
MOSFET - just provide a stable 12V to the MOSFET driver chip (and decouple it, of course).

Most MOSFET drivers take 3 and 5V logic signals and output 12V at significant current levels
to switch a big MOSFET at full speed. There are 100's available from proper suppliers, just
as there are 1000's of different MOSFETs available. I've used a MIC4422 before, it'll driven
anything practically.

Thank you for your replies!

Oops, that certainly wasn't my intention. Since I am only interested in "powering" my sensor signal it seems like I didn't think it through fully when looking at other examples. I will definitely try adding a resistor! So the circuit would be like this then? And the output signal would be zero when the MOSFET is on?

I am pretty sure that the MOSFET I'm using is logic-level already. But I do appreciate your insight about driver chips! Since I already have my MOSFET bought (and ready to use soon I hope) I will give this another try with a pull-up resistor before going for another solution.

You named the AUIRFB8405 which is definitely not logic level.

That mosfet has got Vgs=3..15V, with Vgs from 3V for Ids currents like 0.1-1mA..
It is not logic level.

Logic level mosfets (n) are fully opened by 0.6-1.5V Vgs.

You may use a high-side pnp transistor switching its gate to 12V, with inverted logic (arduino pin=0 switches mosfet on). As the atmega does not have an open-drain pin mode for driving the base of the pnp transistor (ie. via 4k7 resistor), you have to use an npn driver for driving the high-side pnp (not-inverted logic then).

If you don't have proper logic level MOSFET you can easily use BJT for the switching. For both transistor the rising edge may be slow because only resistor drives the signal up. Probably it does not matter at < 450Hz. But if you want nice signal you may use comparator or more complicated circuit from discrete components.

Alright, thanks again guys for all your replies!

I just got back from vacation and now continuing my project, realizing there is an entire world of circuitry I never knew of. About the AUIRFB8405 , from the data sheet I linked previously I looked at Vgs(th) from 2 to 3.9 V and thought it was considered a logic level MOSFET, my bad... anyhow, this leads me to go back and research new and different solutions. I will definitely look at a driver chip circuit or a combination of pnp- and npn-transistors.

In general what would be the better choice for this purpose? I want the circuit to be as simple as possible due to my inexperience of designing circuits from scratch, would the driver be preferred then and still give a nice signal?

You could just use an npn transistor like 2N2222 or 2N3904 in place of the mosfet, open collector output inverts arduino signal.
Mark S.

Can you tell us the application?
What is the sensor and why do you need to modify its output?
What do you do with the modified output?

There may be an easier solution.

Thanks.. Tom.,. :slight_smile:

The application of the project is for making my own test equipment of sorts, where I want to modify the signal from the sensor in order to raise errors on purpose which the system should be able to find. As such the modified signal is fed back to the control module again, just at a different duty cycle. The PWM is actually a throttle position signal and the basic problem for me is that this signal operates at 12 V, and not 5 V as the Arduino. I don't need to drive any load with the PWM, only to shift the output from the Arduino to 12 V level. The idea is like this:

About the AUIRFB8405 , from the data sheet I linked previously I looked at Vgs(th) from 2 to 3.9 V and thought it was considered a logic level MOSFET, my bad...

Yes, you fell into a common trap, threshold is where the device goes from hard off to starting
to leak a tiny amount (100 microamps or so). It takes a lot more gate drive to open the channel fully, typically
3 times the threshold voltage is needed. Typical logic-level devices have Vthr = 0.5 to 1.0 V

Using your device at 5V is likely to put it half-on-half-off, causing unpredictable results and if driving
a lot of power the device may get incandescent.

So I managed to get my hands on a real logic level MOSFET today, and used the same schematic as earlier and it looks really good. Thanks for pointing that out!

But while waiting for the MOSFET to arrive I played around with some transistors I had and searched the forums for similar applications and circuits. Using the circuit below gave me pretty much the same result, but non inverted.

Going a bit of topic about the MOSFET circuit only, I am curious if any of you could help me understand what would be the benefits of using either a MOSFET or npn/pnp-transistor circuit and when to choose what. Is there a fundamental difference in accuracy or such? Disregarding that each transistor or MOSFET can of course have different specs.

As always, I appreciate all your help and effort, this community really is fantastic!

Generally MOSFETs are way superior as switches - very low on-resistance and on-voltage, very
rapid switching, very low power needed to drive the gate.

However small BJT's are easier to come by, MOSFETs are either TO220 (mainly not logic-level),
or surface mount packages.

BJTs need a lot of current into the base, perhaps 5 to 10% of the switched current, to get good
performance (on-voltage lower than 0.5V, ie proper saturation) - this is a cost in power, and
complexity when switching large currents as two stages of BJT may be needed (ie a Darlington)

In analog circuits BJTs have other advantages - very little variation in Vbe (FETs have a lot
of device variation in Vgs), simple circuitry with BJTs makes good current sources/sinks, voltage
follower is easy to do well. In the RF domain there are many variants of BJT and of FETs and
its much more complex design-space.

With analog ICs the internals are usually BJTs. With logic ICs, internally its MOSFETs (they can
be made much smaller and consume much less power)

BJTs are much more rugged to static electricity, of course too.

Thanks, it certainly gave me something to think about!

Revisiting my work and continuing to read about electronics I am now wondering about decoupling caps, as I understood you should always use them for ICs as close to the pins possible and a common starting value is about 0.1uF, but would it be necessary for the application of using a logic level MOSFET switch as this? Or do I need a bigger cap for the power supply?


Logic chips need such fast decoupling right next to the chip because they can malfunction on timescales
of a few ns, ie the rates of change are extremely high.

A big power MOSFET switch is operating on timescales of 100ns or more, and typically the gate and
drain circuits are separate supplies, and the gate circuit is already decoupled. If you use separate
high-current gate driver chip running from 12V that 12V supply needs decoupling of 1uF or more.

It is good to decouple the circuit being switched of course, but typically thats a high current circuit,
10uF or more is typically needed to reduce switching transients on the supply rail. This decoupling
doesn't need the ns timescale response so can be further away.


What about feeding 500v instead of 9v(12v) as per the above schematic?

Does the pull-up resistor's value should be changed?

In my application I need high pulsed voltages with very few milliAmps.