I would like to read analog input on my Raspberry Pi using various resistive sensors I represent in the schematic below as potentiometers (R5 ad R7). I need to be able to switch the circuits on and off (high-side) through GPIO pins. I am new to electronic schematics and figuring out how to build circuits on my own so I have a few amateur questions concerning the base resistors (R1 and R3) and the circuit in general.
Raspberry Pi specific information:
The wiper pins on the potentiometers go to a MCP3008 ADC as the Raspberry Pi does not have analog input pins. I am using a linear voltage regulator to provide 3.3V to avoid using the 3.3V rail which, I have read, can only provide 50mA. The ADC will also be powered by the 3.3V coming from the regulator.
General information:
I have been following a few tutorials which calculate the base resistors of the two PNP transistors (R1 and R3).
A Raspberry Pi specific video states that the base resistor must be calculated using the β value of the resistor and the current of the circuit after the collector (R2+R5 and R6+R7). This would put the base resistor past 3M Ω assuming a β value of 75 and a current (Ic) of 0.06mA. Not that I have experience to judge, but this seems awfully high.
The tutorial on Sparkfun seems to contradict this and states that "1mA to 10mA will usually be enough" in terms of base current. If I use a 1K Ω resistor as the base, I will get 3.3mA to the base of the transistors.
The vast majority of Arduino tutorials, although they use NPN transistors, seem to have less than a 10K Ω resistor on the base of their transistors reguardless of what they are switching.
Questions:
The obvious question here is which calculation is correct? How would I find the amount of current needed to saturate the 2N3906 transistor by its datasheet? I'm not sure which number I'm looking for as I'm not used to reading datasheets or why each value is negative (I assume it's because the transistor is PNP although that doesn't answer my question).
Bonus: Will the circuit behave correctly if the potentiometers (R5 and R7) are replaced by a photoresistor that runs straight to the ADC? Does it matter that the digital pins are from the Raspberry Pi powered and the VCC in this circuit are powered from a different source although the voltage is the same(ish) and they share a ground?
Thanks.
simulate this circuit – Schematic created using CircuitLab
Answer
The Sparkfun tutorial is very bad. The biggest mistake, at least from your point of view, is using a relatively high (75 to 100) value for beta.
Because the transistors are being used as switches, they must be over-driven compared to "regular" linear amplilfier use. This is called being in saturation. The rule of thumb in such cases is to assume a beta of 10, since this will produce very low (0.1 to 0.2) voltages for modest current levels.
In your case, your 50k pots will limit the collector current to such low levels (65 uA or so) that in principle you only need base resistors on the order of 500k. However, at these low levels you'll start running into leakage problems.
You're probably better off replacing your pots with 1k units with 100 ohm limiting resistors, and using something like 10k base resistors.
No comments:
Post a Comment