3.3-5V to 12V PWM Level Shifter

Thread Starter

k1ng 1337

Joined Sep 11, 2020
1,038
Hi, how can I add a level shifter to this circuit to switch the FETs as fast as possible? Currently an ATmega328 controls all PWM inputs @ 1kHz but I'd like to design for 3.3V as well.

Untitled.png
 
Last edited:

crutschow

Joined Mar 14, 2008
38,451
Hi, how can I add a level shifter to this circuit to switch the FETs as fast as possible?
Sorry but "fast as possible" is not a spec.
You don't need low ns switching speeds for a 1kHz PWM frequency.
Currently an ATmega328 controls all PWM inputs
I don't see how an Atmega signal can control that bridge with a 12V supply.
Does the micro use four outputs to drive the bridge?

Also the F9540N is a P-MOSFET, not the N-MOSFET in the schematic.
 

Thread Starter

k1ng 1337

Joined Sep 11, 2020
1,038
Sorry but "fast as possible" is not a spec.
You don't need low ns switching speeds for a 1kHz PWM frequency.

I don't see how an Atmega signal can control that bridge with a 12V supply.
Does the micro use four outputs to drive the bridge?

Also the F9540N is a P-MOSFET, not the N-MOSFET in the schematic.
I fixed the schematic. I want to level shift the 5V signals from the Arduino. The gate resistors were chosen to limit the inrush current to 20mA. The switching frequency is low but I need the FETs to have a quick turn on and turn off time for my project. I don't have a specific value but the shorter the better.
 

crutschow

Joined Mar 14, 2008
38,451
I need the FETs to have a quick turn on and turn off time for my project.
Why?
It you are trying to minimize the power dissipation than how much can you tolerate?
I don't have a specific value but the shorter the better.
Sorry but I don't design to an undefined "the shorter the better" requirement.
I only design to what the project needs.
 
Last edited:

sghioto

Joined Dec 31, 2017
8,634
As far as incorporating a level shifter this transistor arrangement will work. Repeat both circuits for PWM2 and PWM3.
1701914124229.png
EDIT: Corrected orientation of M1 and M2
 
Last edited:

crutschow

Joined Mar 14, 2008
38,451
As far as incorporating a level shifter this transistor arrangement will work.
But the 100kΩ gate-source resistor will certainly give a MOSFET turn-off fall-time much slower that the TS's desired "as fast as possible" since that discharges the large gate-source capacitance. :rolleyes:

Also your P-MOSFETS are shown upside-down.
 

Thread Starter

k1ng 1337

Joined Sep 11, 2020
1,038
Why?
It you are trying to minimize the power dissipation than how much can you tolerate?
Sorry but I don't design to an undefined "the shorter the better" requirement.
I only design to what the project needs.
This is a research project. My goal is to make the print head mechanism in the photo track my hand. I want to track the position of my hand as well as the acceleration curve. I specified as 'short as possible' so I'm not held up by an optimization when I go to code the homing mechanism.

I blew up the rest of my logic level FETs testing which is why the all resistors in the schematic are as they are. The Arduino has push-pull outputs so the pull resistors are there to force a known state at startup.

I didn't give a minimum time because I'm trying to figure out what the limiting factors are. But I think it is safe to say I need it to be as fast as possible because the motor will constantly switch directions which gives me more headroom in the code. I'm asking you to help me fill in some the blanks here because there are many ways I could go about this. I figure slower switching FETs will needlessly add to the minimum response time of the system. My primary design goal is to reduce the response time of the feedback loop to a minimum. There are a lot of factors at play so I'm trying to distill them out in order of priority.

Untitled.png

IMG_20231128_000145181.jpg

As far as incorporating a level shifter this transistor arrangement will work. Repeat both circuits for PWM2 and PWM3.
View attachment 309324
EDIT: Corrected orientation of M1 and M2
Thanks, I'll give this a try. Since you employed 8 transistors, is there a way to make them function more like a push-pull? The voltage gain for emitter followers is unity so obviously that won't work but I suspect there are other clever circuits lurking. As crutchow said, the turn off times are set by the pull resistors which even for 1k resistors may add up. Now that you know what my project is about, how might you change this?

I'm building with discretes for the understanding but I do appreciate the block diagram in the datasheet.
 

dendad

Joined Feb 20, 2016
4,636
Building it from discrete parts is a great idea.
Just a thought 'tho, while developing it, insert a 12V lamp in series with the 12V feed for protection. It will allow the motor to turn ok but if excess current is drawn, like when you turn top and bottom FETs on the same side both on together, hopefully keep the smoke in.
It would be a good idea to build in hardware prevention of this too, not just run each FET from the Arduino.
Maybe use a 74HC139?
EDIT:
H-Bridge-Drive.jpg
You will need to check this but I think it is ok.
 
Last edited:

Thread Starter

k1ng 1337

Joined Sep 11, 2020
1,038
Building it from discrete parts is a great idea.
Just a thought 'tho, while developing it, insert a 12V lamp in series with the 12V feed for protection. It will allow the motor to turn ok but if excess current is drawn, like when you turn top and bottom FETs on the same side both on together, hopefully keep the smoke in.
It would be a good idea to build in hardware prevention of this too, not just run each FET from the Arduino.
Maybe use a 74HC139?
EDIT:
View attachment 309333
You will need to check this but I think it is ok.
My first attempts were using 3904/3906 BJTs. I included a photo of one bad move on my part lol. It was a loud snap and blew out a chunk. Usually they just smoke but this one was hulk angry. I upgraded to FETs which could handle about twice the power of these BJTs but that didn't work either. I'm thinking the problem is how much power is being dissipated during switching.

I have classic gate voltage FETs so I want to redesign the circuit to slam the gates fully on and fully off in the least amount of time possible with discrete components. The power supply in the photo is from the same printer so I have 32V/12V at my disposal. This should be more than enough to switch the FETs in my schematic for my desired current which is about 150mA @ 12V. That will be different if I decide to load the platform with weight so these parameters aren't in stone.

Also, I'm using a 12MHz clock in my Arduino. Right off the bat there is how quick the MCU can do work. Then there is the response time of the detector and finally homing. I might need to upgrade to a faster MCU so I haven't decided a modulation frequency. Still, the switching time is a big problem I need to solve before I move on. If anyone has some formulas on the subject I'd definitely take a look.

IMG_20231206_145823202.jpg
IMG_20231207_005555546.jpg
 

dendad

Joined Feb 20, 2016
4,636
Put the lamp in line. Start with no motor but a couple of LEDs connected in parallel but in reverse, a red and a green, with a 2K2 series resistor. This will let you see if the motor drive is working.
If the lamp lights, you are driving both FETs on one side. That is a no-no.

Use a 5W 12V tail light lamp.
 

MrAl

Joined Jun 17, 2014
13,696
Hi, how can I add a level shifter to this circuit to switch the FETs as fast as possible? Currently an ATmega328 controls all PWM inputs @ 1kHz but I'd like to design for 3.3V as well.

View attachment 309313
Hello there,

"As fast as possible" would mean to me that you want to use the best technology to get the rise and fall times as low as possible.

In that case the usual way to do this is to use dedicated MOSFET driver IC chips. This is by far the fastest.
Second to that are two transistors for each MOSFET gate which can drive the MOSFET gate in both high and low directions. This would involve one PNP and one NPN with the emitters tied together and those emitters drive the gate. The two bases may be tied together also or driven through two separate base resistors. Smaller MOSFETs for this are said to be better though than two bipolars.

BTW, 330 Ohms (in series with the gate) would be quite large when attempting to get very fast rise and fall times. Even 30 Ohms may be too high in some cases. 10 Ohms would be more likely, or even less. Dedicated MOSFET drive IC chips can have very low output impedance which allows driving the gate with at least a 1 amp or 2 amp fast rising current as that's what it really takes.

The reason the dedicated driver chip is the best is because it can supply a higher current than the two transistor option. It can be four times higher. The higher current is needed to charge the equivalent input capacitance. The faster you can charge that capacitance the faster the MOSFET turns on and turns off.

Lastly, when fast rise and fall times are involved, you may find the back EMF from the inductance of the motor causes high spikes to appear across the transistors drain to source. In that case you would need snubbers. Snubbers fit in physically close to the transistor D and S terminals so they can absorb the spike quickly and effectively.
This is why MOSFETs are sometimes driven with controlled currents so that you can get relatively fast rise and fall times yet keep it slow enough to help minimize spikes. This could also involve an asymmetric drive circuit that turns the MOSFET on fast but turns it off a little slower. The MOSFET then dissipates a little more power but that's part of the tradeoff, and if it is not dissipated there it will be dissipated in the snubber.

Ok that wasn't exactly the 'last'.
A hyper modern way to do this is to use resonant switching. This involves switching the MOSFETs only when either the current is zero or the voltage is zero. This may be too complicated for your application though and you'd have to do some more reading on this.
The beauty of this technique is the MOSFET dissipates lower power because the switching losses are very low. This should result in very low spike energy also.
 
Last edited:

dendad

Joined Feb 20, 2016
4,636
The reason the dedicated driver chip is the best is because it can supply a higher current than the two transistor option. It can be four times higher. The higher current is needed to charge the equivalent input capacitance. The faster you can charge that capacitance the faster the MOSFET turns on and turns off.

Also, the IR2103 has built in logic to prevent cross conduction so it cannot turn both top and bottom FETs on at the same time. That is pretty important.
 

MrAl

Joined Jun 17, 2014
13,696
Also, the IR2103 has built in logic to prevent cross conduction so it cannot turn both top and bottom FETs on at the same time. That is pretty important.
Hi,

That sounds great. Often that is the job of the controller circuit but if that functionality is built into the driver itself it should make the controller simpler. Good suggestion I'll have to check that chip out.
 

BobTPH

Joined Jun 5, 2013
11,498
I need it to be as fast as possible because the motor will constantly switch directions which gives me more headroom in the code.
Switching times will be tiny compared to the time to changing the direction of the motor, indeed the PWM period itself (1 msec) is small compared to turning around the motor.
 

sghioto

Joined Dec 31, 2017
8,634
I question the need for PWM on all four mosfets as that would complicated the switching arrangement.
For motor speed control use pwm on the N channel mosfets only.
 

MrAl

Joined Jun 17, 2014
13,696
I question the need for PWM on all four mosfets as that would complicated the switching arrangement.
For motor speed control use pwm on the N channel mosfets only.
Hi,

Since I had worked in that industry I have some insider information.
In this case, there is a preferred switching pattern in order to distribute the losses over all four transistors. That way no transistor gets any hotter than any other. Since part of it is the switch losses, that means we should switch in a way that achieves that distribution.
Of course if you are not manufacturing these things for sale, then you may be able to just overkill on the transistor types, meaning choose much less Rds ON and all that. That means it may not matter as much. This is what a lot of Hobby electronics is all about. You only need one, so design it to be very robust.
 
Top