Electronic – BJT not switching (off) fast enough

attiny85avrledpwmtransistors

I have an ATTiny85 with a PWM output (freq. aprox. 1kHz). Connected to this pwm output pin is a NPN general purpose BJT (2N2222) with base resistor of 1k. A LED is in series with this transistor (before the collector). The LED has a current limiting resistor of 470R.

Everything seems to work pretty good, but if my PWM duty cycle is very low (< 30%), then something strange happens. Every few seconds the LED flashes/flickers. But it's not the well known PWM flickering. My flickering is very irregular (just every few seconds).

I used a oscilloscope and did some probing. The PWM output signal directly at the microcontroller pin was ok in my opinion. Then I checked the conductivity of the transistor, connecting my scope probes to the vcc and emitter of the transtistor. This gave me the following result (see picture).

osci

Am I correct, the the transistor is not properly switching off, and "skips one cycle"? This could be the reason, why the LED flickers?

Now the most important questions: Am I using the wrong transistor type – or should I switch to a mosfet-based solution? What would you suggest, to solve this issue?

Thank you very much. You help is greatly appreciated!

Here is the schematic:
schematic

Best Answer

You will get confusing results if you measure Vce because the pullup is nonlinear (due to the LED). Try measuring the voltage across the 470 ohm resistor. Or parallel the LED with 1K and go back and measure Vce again.

I suspect your problem has nothing to do with the transistor and more to do with resetting the micro due to poor bypassing or something of that ilk.

Related Topic