# my mosfet not fully off

#### Kim-JiHoon

Joined May 3, 2020
63
Hello, my circuit can't fully off

1. MOTOR 24V/2.5A 3600RPM (300Hz PWM)
2. R1 - 2N2222A(NPN) base
3. R2 - pull down (2n2222a)
4. R3 - pull up (IRLR024N)
5. R4 - gate for IRLR024N
6. C1 - kill ripple

my MCU is Atmega128, 16Mhz, prescale 1024
this is my code
C:
TCCR1A=0x82;
TCCR1B=0x1D;
ICR1=49;
TCNT1 = 0x0000;
if(VALUE==0){
OCRA1=0;
}
else if(VALUE==1){
OCRA1=29;
}
else if(VALUE==2){
OCRA1=49;
}
it works, but when value=0 (OCRA1=0), it NOT FULLY OFF

#### Kim-JiHoon

Joined May 3, 2020
63
... Maybe transistor Q1 is not being turned on completely. Q1 does not require a pull down resistor, R2=10k, but instead a Vbe voltage of approximate!y 0.6 to 0.7 volts.

i changed my code

C:
TCCR1A=0x82;
TCCR1B=0x1D;
ICR1=49;
TCNT1 = 0x0000;
if(VALUE==0){
TCCR1B &= (1<<CS10);
TCCR1B &= (1<<CS11);
TCCR1B &= (1<<CS12);
OCRA1=0;
}
else if(VALUE==1){
TCCR1B=0x1D;
OCRA1=29;
}
else if(VALUE==2){
TCCR1B=0x1D;
OCRA1=49;
}
like this it works!

but i still can't sure, that code is fine

circuit is fine, but..

is that code i corrected can use? any damaged on my MCU?

because a lot of sample code PWM, they are just controlling OCRA1

#### WBahn

Joined Mar 31, 2012
26,398
What's the output voltage of your PWM signal? 5 V? 3.3 V?

Reduce your PWM to a very slow rate (like 0.5 Hz) and measure the actual voltage at the PWM signal. I suspect you aren't saturating the BJT like you think you are.

#### Kim-JiHoon

Joined May 3, 2020
63
What's the output voltage of your PWM signal? 5 V? 3.3 V?

Reduce your PWM to a very slow rate (like 0.5 Hz) and measure the actual voltage at the PWM signal. I suspect you aren't saturating the BJT like you think you are.
it's 5v PWM signal

too low frequency gets more ripple.

is C1 (50v/1000uF) okay? or do i have to raise C1 value?

#### drc_567

Joined Dec 29, 2008
1,156
... In order to get saturation, as suggested, the base current should be at least 1/10 of the collector current.

#### WBahn

Joined Mar 31, 2012
26,398
it's 5v PWM signal

too low frequency gets more ripple.

is C1 (50v/1000uF) okay? or do i have to raise C1 value?
Remove the motor. Or use an oscope to measure the voltage levels.

What is the drive spec on the output. You are asking it to deliver something between 4 mA and 5 mA. Can it do that? I don't know anything about the ATmega I/O, but I would suspect it is something like 20 mA or better, so that's probably not an issue.

But I actually misread the schematic -- you should not be having any problem saturating the transistor. In my mind I had the values of the base and collector resistors reversed.

Last edited:

#### Sensacell

Joined Jun 19, 2012
2,997
I dont see that C1 does anything helpful?

It will acts as a very low impedance when the FET turns on, high currents flow.

What is D1 for?

#### Bordodynov

Joined May 20, 2015
2,993
Having a capacitor in your circuit with such a large capacity can burn the transistor. There are two possible scenarios of failure - open circuit or short circuit. In the second scenario, the transistor will never close again. Use an analog simulator and see what the capacitor discharge current is. Look at the pulse power of the transistor. So you made the mistake of putting a capacitor of such a large value!

#### Kim-JiHoon

Joined May 3, 2020
63
C1 is for kill ripples

if i remove C1 motor turn on/off very slowly (ripples)

so i raised pwm hz(25khz), and FET gets too hot

finally i decreased hz (60hz) + added C1, so kill repples

so far C1 is necessary, and how can i calculation right C1 value?

#### bertus

Joined Apr 5, 2008
21,890
Hello,

When the fet is getting to hot at 25 kHz, you are not switching fast enough.
The fet stays to long in the linear region.
You could use a dedicated mosfet driver to overcome this problem.

Bertus

#### ronsimpson

Joined Oct 7, 2019
2,053
C1 and Q2 make a peak voltage detector. Lets say Q2 is on 25% of the time. When first turned on massive current charges C1 up to 23V and when Q2 of off the motor runs off that stored energy for the rest of the cycle. The voltage across the motor will stay high and not change with changing duty cycle. You must remove C1.

At 300hz you probably can hear the motor speed up and down. So go to 25khz and remove C1. What are you using for D2? You do not need a 1000V diode. 100V would be better. At 25khz you should use a fast diode. Next; Q2 is not turning on fast so it is hot. Change R3 to 1k and R4 to 10.

D1 has no function.

#### Kim-JiHoon

Joined May 3, 2020
63
C1 and Q2 make a peak voltage detector. Lets say Q2 is on 25% of the time. When first turned on massive current charges C1 up to 23V and when Q2 of off the motor runs off that stored energy for the rest of the cycle. The voltage across the motor will stay high and not change with changing duty cycle. You must remove C1.

At 300hz you probably can hear the motor speed up and down. So go to 25khz and remove C1. What are you using for D2? You do not need a 1000V diode. 100V would be better. At 25khz you should use a fast diode. Next; Q2 is not turning on fast so it is hot. Change R3 to 1k and R4 to 10.
View attachment 223254
D1 has no function.
i removed C1, i don't have FR diode now.

can i use FR305 diode?

25khz works good but i can hear a noise.

60khz i can't hear noise, but FET gets too hot

than 25khz and low value C1 (about 1uF, size 3216, smd type) will good?

#### Attachments

• 143.4 KB Views: 2

#### peterdeco

Joined Oct 8, 2019
481
This is the circuit we use for motor speed control. I don't think you need the 2N2222A.

#### Attachments

• 6.1 KB Views: 17

#### ronsimpson

Joined Oct 7, 2019
2,053
can i use FR305 diode?
yes
You can try it.
don't think you need the 2N2222A
When switching at 300hz it is OK to turn on/off the transistor slowly. At 30khz you need to drive current into/out of the Gate of the MOSFET to get it to run fast. I think the micro can not turn the transistor off fast.

#### ScottWang

Joined Aug 23, 2012
7,200
When you using the N MOSFET to drive the motor then you don't need to use the NPN transistor, and then the high duty cycle of PWM signal will match the N MOSFET ON time and motor working time, so you just connecting the PWM signal to the Vg of N MOSFET.

If you want some protection then you can in series with R4 47 ohm.

#### Bordodynov

Joined May 20, 2015
2,993
See

#### Kim-JiHoon

Joined May 3, 2020
63
yes

You can try it.

When switching at 300hz it is OK to turn on/off the transistor slowly. At 30khz you need to drive current into/out of the Gate of the MOSFET to get it to run fast. I think the micro can not turn the transistor off fast.

i tried D1 to FRdiode
R3 1K, R4, 10 <---FET gets too hot over 90 degree in second

my power source is LM7805, so if i remove 2n2222, than LM7805 gets hot

pwm 300hz and C1 470uF -> not working, not fully charging very unstable

pwm 300hz and C1 1000uF, FR Diode works good as my first circuit

but i don't know this is stable (it works good, all my ics doesn't get heat)

i'm sorry i don't know what that's mean

i searched circuit use capacitor in motor

and i use 1000uF like this

and some guy already write post this circuit

#### ronsimpson

Joined Oct 7, 2019
2,053
You are charging C1 at a peak current of 23A. This is not good for C1 and M1.

remove the cap and your current will drop.

#### Kim-JiHoon

Joined May 3, 2020
63
You are charging C1 at a peak current of 23A. This is not good for C1 and M1.
View attachment 223310
remove the cap and your current will drop.
oh, thank you i got it

the reason that i keep trying to use C1 is 'under 1khz pwm' make other IC's get no heat

i don't have ociloscope.

according to that graph, if i use C1 100uF/50v (1000uF / 10), C1 charging 23/10=2.3A right?

#### ronsimpson

Joined Oct 7, 2019
2,053
Lets play SPICE.
Never let a transistor turn on with a capacitor load. If you have to have a capacitor then this is how.
I added L1 so M1 will turn on into a inductor not a capacitor. C1 is across the motor like you want.
I speed up the PWM by 10:1 from your circuit to keep L1 small.

When C1 connects to M1 you had 24A and 20V at the same time on M1. HOT
Now with L1 added M1 turns on with very little current.

#### Attachments

• 2.1 KB Views: 4