lunedì 3 dicembre 2012

How to use a BJT as a switch

This is a typical application of a BJT, really useful if you want to drive a load from a digital output of a microcontroller, when the current of that output is not enought. Here we study how to design the circuit. Have a look at the typical circuit:
The RLoad is the load we want to drive. Pulse emulates a digital output, it is a square wawe generator we will use next in the analysis to show the circuit at work. We need to calculate the R1 value in order to properly drive the load, so how can we do it ?
We first need to ensure the transistor works in saturation zone: this is the starting point; by working in the saturating zone the BJT works (almost) as a switch, and this is what we need.
Lets say the constraints we need for the design:

  1. BJT must work in saturation mode
  2. BJT must handle the required power.
  3. Digital Output current must be lower than the maximum accepted
  4. Of course, load must be driven with the proper voltage.
A trick to saturate the transistor is to ensure that:
In simple words, ensure that the basis current is a lot greather than the one required to drive the load in linear mode. Here Hfe is the DC gain. Since we need to be safe, consider the minimum Hfe from the datasheet of the used bjt, in this case it is 100. We calculate the current flowing in the load by simply:


Since our Hfe is 100, the basis current required is >> 2.45 mA.
Many digital output for microcontroller drive a current of 20mA, so we can decide to bias the BJT wit a current of 12mA, enought to saturate, but not too mutch for the micro controller. 
With this value we can design resistor R1:




We round this value to 330ohm.
Now we can simulatethe circuit ( I'm using LTSpice ) to see if we are right. Let'see the Vout, and ILoad chart:



As ve can see the red line ( the current flowing in the load ) goes o the expected current when the digital output goes high.
Let'see what happen to the voltage around the BJT, this with the current let us calculated the power:

As we can see, when the current flow inside the BJT, the voltage is around 0.3 V so let's calculated the needed BJT power:


This is really far away from the maximum BJT power, that is from the datasheet 625 mW, so our circuit can safely operate.

So, what we left apart:


  • We did not put a diode in parallel to the load, Why?
    • Because the diode is needed for an inductive load, so put it always you have such a load ( a relay for example ) I would like to show WHY is needed in another post
  • What if the Hfe is not enought so we can't saturate the transistor ? 
    • You must choose another, or use a darlington pair, I would like to show it too in another post.


Nessun commento:

Posta un commento