Reputation:
I need to find out the DC voltage required at Base of a Bipolar transistor,(Vbb is DC voltage required at Base) to operate it in three conditions mentioned below
At Vbe = 0.7, Vce = 5, Beta = 50 Transistor in active region
At Vbe = 0.7, Vce = 0.3, Beta = 50 Transistor operating at edge of saturation
At Vbe = 0.7, Vce = 0.2, Beta(forced) = 10 Transistor operating in deep in saturation.
The formulas are given in the code shown below and are correct. My question is should i need to use three separate objects of class BJT to calculate the Vbb for three separate conditions given above or this task can be done with a single object?
#include<iostream>
using namespace std;
const float Rb=10000.0;
const float Rc=1000.0;
const float Vcc=10.0;
class BJT
{
private:
float Vbe;
float Vce;
float Ic;
float Ib;
float Beta;
float Vbb;
void calculate()
{
Ic=(Vcc-Vce)/Rc;
Ib=Ic/Beta;
Vbb=(Ib*Rb)+Vbe;
}
Upvotes: 2
Views: 65
Reputation: 210
If you want to hold these values in a class but have full access to them freely in any time, you can declare them public:
class BJT
{
public:
float Vbe;
float Vce;
float Ic;
float Ib;
float Beta;
float Vbb;
void calculate()
{
Ic=(Vcc-Vce)/Rc;
Ib=Ic/Beta;
Vbb=(Ib*Rb)+Vbe;
}
}
However, if you need to keep them private you can provide "get" function for each required data member.
Upvotes: 1