Oh, duh, I didn't read your code carefully -- your send SendLcdByte is wrong:
void SendLcdByte( unsigned char command_0_or_data_1, unsigned char command)
{
SendLcdUpperNibble( command_0_or_data_1, command);
// send the lower nibble next
// AS WRITTEN:
P1OUT = (command & 0x0F) | (P1OUT & 0xF0);
// SHOULD BE:
P1OUT = ((command & 0x0F) << 4) | (P1OUT & 0xF0);
Strobe( command_0_or_data_1);
}
Here's an overview of the design process to get you started. I'll let you work out the exact calculations.
I would replace \$R_{\text{load}}\$ with an independent current source \$I_{\text{load}}\$ for your simulation (you can use your CircuitLab schematic for simulation once you add resistor values). Set \$I_{\text{load}} = 25\$mA since that is your worst case.
Pick a relatively large emitter resistor \$R_3\$. This simply provides a load to the transistor if the actual load isn't connected (e.g. \$I_{\text{load}} = 0\$). For example, use \$R_3 = 10\$k\$\Omega\$. If \$V_{\text{out}} = 5\$V then the current through \$R_3\$ is \$0.5\$mA and \$I_{E} \approx 25.5\$mA in the worst case (\$I_{\text{load}} = 25\$mA).
Next you need to determine the worst case (highest) \$I_B\$. Use the lowest \$\beta\$ in the transistor's datasheet (worst case) and then calculate
$$I_B = \frac{I_E}{\beta + 1}$$
Now in order to make the resistor voltage divider "stiff" you need to make sure that the unloaded bias current through the resistors (call it \$I_{\text{div}}\$) is at least 10 times the load current (in this case \$I_B\$ is the load for the voltage divider). Otherwise the load current draws too much current away from \$R_{2}\$, which causes the voltage at the output of the voltage divider decrease too much. This puts a constraint on the maximum value of \$R_1 + R_2\$ since
$$I_{\text{div}} = \frac{15}{R_1 + R_2} > 10I_B$$
This equation plus the voltage divider equation
$$\frac{R_2}{R_1+R_2}15 = 5.6$$
gives you two equations and two unknowns.
Best Answer
Ah, the joys of finding a random circuit on the Internet that happens to have a slick presentation. This is actually a very poor design for several reasons.
First of all, the author should have put a resistor between
D10
and the capacitor, which would have allowed him to use a much smaller capacitor to get the cutoff frequency he needed. The VEE pin of an LCD requires only a tiny amount of current. As it is, he's relying on the output impedance of the Arduino pin to limit the current into/out of the capacitor, which is very poor practice.Secondly, the transistor is being used in a common-emitter mode, not emitter-follower. Using two resistors the way he does doesn't make much sense.
Two reasons:
The Arduino pin by itself can't handle the current required by the backlight. The transistor provides the necessary current gain.
In this case, the goal isn't to turn the PWM signal into a DC level, but instead, to use it to turn the backlight LED on and off rapidly to change the apparent brightness.
Like I said, this isn't an emitter-follower. Because of the resistor in the emitter leg, however, it's operating on the cusp between linear and saturated zones.
I assume that when you say "discard", you mean "ignore". Good question, although it would really be the collector-emitter voltage in this situation. If he was using a circuit configuration in which the transistor would definitely be in saturation, this voltage would be relatively small (about 0.3V), but still significant.
The circuit would be better if the emitter of the transistor were connected directly to ground, and the resistor R1 were placed in the path between Q1's collector and the
LED-
pin of the display.