This short program will use voltage measurements on the base and collector of a transistor and resistor values entered to calculate the current gain. Of course different value resistors will result in different beta values. I tried to use the smallest collector resistor possible without causing the collector voltage to rise too much. I used the USB (5V) output for the collector resistor, so make sure the collector voltage doesn't rise over 3.3V or I think bad things will happen.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 AnalogIn base_voltage(p15);
00004 AnalogIn coll_voltage(p16);
00005 
00006 int base_resistor, coll_resistor;
00007 float base_current, adj_base_voltage;
00008 float coll_current, adj_coll_voltage, beta;
00009 
00010 int main() {
00011 
00012 printf ("Please enter a base resistor value\n");
00013 scanf ("%i", &base_resistor);
00014 
00015 printf("Please enter a collector resistor value\n");
00016 scanf ("%i", &coll_resistor);
00017 
00018 //calculate base current
00019 adj_base_voltage = (1 - base_voltage) * 3.3;   //voltage across base resistor
00020 base_current = adj_base_voltage/base_resistor;
00021 
00022 //calculate collector current
00023 adj_coll_voltage = (1.515 - coll_voltage) * 3.3;  //1.515 is 5V as 1 is 3.3V
00024 coll_current = adj_coll_voltage/coll_resistor;
00025 
00026 //calculate current gain
00027 beta = coll_current / base_current;
00028 printf ("Transistor beta is %f\n", beta);
00029 printf ("The voltage across Rb is %f\n", adj_base_voltage);
00030 printf ("The voltage across Rc is %f\n", adj_coll_voltage);
00031 
00032 }
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041