2
\$\begingroup\$

In my recent project, I'm working on 5V DC USB fan's speed controlling.

My fan motor looks like below:

FAN

Here fan controlling is done by PWM which is coming from Arduino NANO controller. For controlling the speed of FAN, I developed one circuit which is below:

Circuit

Now, when I give full PWM means full value 255 and at that time when I measure the voltage across motor then it just around 3.50 V. I just thought it may be full 5 V. I don't know why this much loss happen? Any suggestion regarding this.

And my Arduino code is below:

const int kPinSw1 = 8;
const int kPinSw2 = 9;

const int kPinPWM = 3;

int oneBtnState = 0;         
int lastOneBtnState = 0;

int twoBtnState = 0;         
int lastTwoBtnState = 0;

int count = 0;

void setup() {

  Serial.begin(9600);

  pinMode(kPinSw1, INPUT_PULLUP);
  pinMode(kPinSw2, INPUT_PULLUP);

  pinMode(kPinPWM, OUTPUT);
}

void loop() {

//-------------------------------------//

  oneBtnState = digitalRead(kPinSw1);

  if(oneBtnState != lastOneBtnState)
  {
    if(oneBtnState == HIGH)
    {
      count--;

      if(count <= 0)
      {
        count = 0;
      }
    }
    delay(50);
  }

  lastOneBtnState = oneBtnState;

//-------------------------------------//

  twoBtnState = digitalRead(kPinSw2);

  if(twoBtnState != lastTwoBtnState)
  {
    if(twoBtnState == HIGH)
    {
      count++;

      if(count >= 4)
      {
        count = 4;
      }
    }
    delay(50);
  }

  lastTwoBtnState = twoBtnState;

  Serial.println(count);

//-------------------------------------//

  switch(count) {

    case 1:
            analogWrite(kPinPWM, 0);
    break;

    case 2:
            analogWrite(kPinPWM, 128);
    break;

    case 3:
            analogWrite(kPinPWM, 192);
    break;

    case 4:
            analogWrite(kPinPWM, 255);
    break; 

    default:
            analogWrite(kPinPWM, 0);
    break;
  }
}
\$\endgroup\$
2
  • \$\begingroup\$ As a starting point, determine the current the load (the fan) requires, which is the BJT's collector current IC. The BJT's base current needs to be IB=IC/Beta(sat). For a power BJT Beta(sat) is typically somewhere between 4 and 10; check the datasheet to determine the value of Beta(sat) that the mfgr uses for parametric testing. You'll need to adjust the resistor value to permit a current of IB amps from the DIO pin into the BJT's base. IIRC, a DIO pin can source current up to 40 ma, max, for a logic high output. \$\endgroup\$ Jun 9, 2018 at 9:50
  • \$\begingroup\$ also, what is the voltage of that GPIO? if it is a 1.8 V pin, you need a much lower base resistor. \$\endgroup\$ Jun 9, 2018 at 10:56

3 Answers 3

1
\$\begingroup\$

As a follow up to my earlier comment, if the fan draws a current of 400 mA when it is ON, and you use \$\beta_{sat}=10\$ for the BJT's saturation beta, then

$$ I_{B(sat)}=I_{C_{sat}}/\beta_{sat} = 400\,mA/10 = 40\,mA $$

The ATmega328P's data sheet permits a maximum current of 40 mA per digital input/output (DIO) pin, so with \$I_{B(sat)}=40\,mA\$ you are at that maximum. (n.b. Based on the calculation above for \$I_B\$, when the DIO pin is logic HIGH, the DIO pin must supply (a.k.a., "source") a current of 40 mA into the BJT's base to properly saturate—to fully turn ON—the BJT.)

The "Electrical Characteristics" section of the ATmega328P's datasheet doesn't show (from what I could find) the value of \$V_{OH}\$ (logic HIGH output voltage) for an output current of 40 mA. But given the information in Fig. 33-34 "I/O Pin Output Voltage vs. Source Current (VCC=5V)" in the datasheet I'd estimate \$V_{OH}\approx4\,V\,@\,I_{OH}=40\,mA\$.

You can calculate the value of the BJT's base current limiting resistor as follows:

$$ R_B = \frac{V_{R_B}}{I_{R_B}} = \frac {V_{OH}-V_{BE(sat)}}{I_{B(sat)}} = \frac {(4\,V)-V_{BE(sat)}}{(40\,mA)} $$

where \$V_{BE(sat)}\$ is the BJT's base-emitter voltage when the BJT is operating in saturation mode with a collector current of \$I_{C_{sat}}=400\,mA\$. You can likely determine the value of \$V_{BE(sat)}\$ from the saturation mode information provided in the BJT's datasheet.

The real (physical) resistor value does not need to be exactly equal to the calculated value \$R_B\$, but its value should be close to \$R_B\$. For example, if the calculated \$R_B\$ value is 1234, you could use a 1.2 kohm 5% resistor, or a 1.24 kohm 1% resistor.

When the DIO pin is logic HIGH, the power dissipated by the base current limiting resistor \$R_B\$ is given by:

$$ P_{R_B}=I_{B(sat)}^2 \cdot R_B = (40\,mA)^2 \cdot R_B $$

Select a resistor whose power rating is \$2 \cdot P_{R_B}\$ or higher. For example, if \$R_B\$ dissipates 122 mW, then use a resistor whose power dissipation rating is 244 mW or higher—e.g., you could use a 1/4 Watt (250 mW) resistor or a 1/2 Watt (500 mW) resistor, but you should not use a 1/8 Watt (125 mW) resistor.

\$\endgroup\$
0
\$\begingroup\$

To reduce voltage drop on transistor switch, use MOSFET transistor with low "on resistance" instead of BJT transistor

\$\endgroup\$
0
\$\begingroup\$

Did I read correctly on the picture that the fan draws 0.4 A current?
In that case, assuming \$h_{FE}=100\$, the base current would be 4 mA and cause a voltage drop of 4 V over the 1kOhm base resistor. That's a serious amount of voltage to lose. I'd suggest to make \$R_b=200\Omega\$, or even \$100 \Omega\$ and see what happens with that value.
Even with \$h_{FE}=200\$ you'd lose 2 V, plus \$V_{CE}\$ of about 0.7 V or more as the transistor isn't driven into saturation.
No need for a MosFet. The BJT, if driven into saturation, will have a mere 0.2..0.3 V \$V_{CE}\$ during the on-state.

But gabonator is right for another reason in advising a MOSFet: it will reduce the current burden on the PWM output of 50 mA (indeed the \$h_{FE}=10\$ in the saturation point where \$I_C\$ can be 0.4 A, as Jim Fischer pointed out) if just one BJT is used.
And because linear behavior is not required, it's simply on/off, the MOSFet's non-linearity isn't much of a problem here. Here is a candidate.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Typically, one wants to operate the BJT in saturation mode (fully "ON"), and not in forward active mode (small signal amplifier mode), for this kind of circuit to minimize the "ON" state power that's being dissipated by the BJT. hFE values in the range of 100..300 are for forward active mode. hFE(sat) values are commonly around 10 for small-signal BJTs, and 4..10 for power BJTs. \$\endgroup\$ Jun 9, 2018 at 12:52
  • \$\begingroup\$ That confirms that the base resistor really is the problem. hFE is simply too small to saturate the transistor with that 1kOhm resistor in series. As a consequence the collector voltage will only see a moderate drop and the fan might not even run. \$\endgroup\$
    – HarryH
    Jun 9, 2018 at 15:11
  • \$\begingroup\$ I downloaded the picture, enlarged it and I think it really says 5V/0.4A and 'made in China' ;-) The absolute maximum for \$I_C\$ of a BC547 is 100 mA, so even if its base circuit would be configured correctly, it won't run the fan. Yeah, for a very short while, and then it'll burn out. A better choice would be the 2N2219 or 2N2222 with \$I_{C,MAX}=800 mA\$. \$h_{FE}\[email protected] is 100 for the 2219, 50 for the 2222. \$V_{CE}\[email protected] for the 2219 is 0.2V@\$\frac{I_C}{I_B}=10\$ So even if you take the 2N2219, which in itself could work, you'd need 50 mA current. Buffered output is required. Cool it. \$\endgroup\$
    – HarryH
    Jun 9, 2018 at 15:37
  • \$\begingroup\$ In view of the high base current and low gain in the saturation point I think @gabonator is right in that a MOSFet is the best solution. \$\endgroup\$
    – HarryH
    Jun 9, 2018 at 15:46
  • \$\begingroup\$ But if you'd stick to the BJT, maybe you can use 2 or three PWM output pins, equally programmed, each connected through a resistor of \$200 \Omega\$ to the base of the BJT. Or use a (number of) buffer(s parallel). \$\endgroup\$
    – HarryH
    Jun 9, 2018 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.