What resistor for 5V device?
lardom
Posts: 1,659
The i/o pin resistor for a Ping is 4.7K and 10K for the IR reciever. Both are 5V devices. The current drawn by the pin is ultra low so Ohm's law clearly doesn't apply here. What is the rule? Is powering a 12V motor with a transistor connected to an i/o pin a bad idea?
Comments
I answered for the second, but I see this is in the Propeller 1 forum.
I suppose that you might really want to know something I didn't replay to.
Connecting a 12v motor powered by an actual 12volts directly to a 5v device is a disaster as it is too much voltage. And if it is a big motor, it may be too much current. Devices usually have 0.5 volts of over-voltage they will allow.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Transistors are a bit of a special case as this is usually about driving them to saturation for a heavy load, or non-saturation for linear mode (audio and test equipment)
Futhermore different conditions for output protection and for input protection create different solution.
Foremost is to protect the microcontroller in all situations.
To drive a transistor to saturation... A resistor as little as 220 ohms will protect a BasicStamp at 5V. This 5v/220ohm = about 20 ma. But you often can drive a transistor to saturation with far less, and I often provide only 5ma. You need to learn to read the PDF for the required base current for a saturated condition.
Some transistors such as the 2n2222 are no problem, but others such as at TIP31 would demand too much current and destroy the i/o port. That is one of the reasons that Darlington pair transistors, like the TIP120 were created.
~~~~~~~~~~~~~
That is the core answer for an output to a transistor. Change it to a MOSfet and the whole situation changes. Change to inputs to the microcontroller and for data a much higher resistor can be used.
There is the dillema of source and sink. And these are often confused with data signal. And output to aNPN transistor sources, but in some cases we can use a PNP transistor and turn it on with a ground... that sinks current through the microprocessor.
Similar source and sink conditions can be created with LEDs and the current still needs to be limited to protect the microcontroller.
~~~~~~~~~~~~~
You question is very general. IF you are having problems with a specific hook up, provide a schematic.
In general, if the Propeller is just receiving a signal from a 5V device the resistor value doesn't matter much as long as it's above ~3K (I usually use 10K since I have lots of them). In cases like the Ping, there's a complication since the Prop not only receives a signal from the Ping but also sends a signal to it. This is when a large resistor value can cause a problem. If the device requires both input and output then you want to use a resistor closer to the 3K value so the 5V device will recognize the 3.3V as a logic high.
I've had 5V devices not recognize a Prop's signal if there was a 4.7K resistor in series but would recognize the signal fine without a resistor (this was a one way communication line).
I'll let Loopy and others discuss the transistor issues.
I'm starting to think about controlling larger machines so 'guessing' as I have done up to this point will no longer do. Sorry about the lack of clarity.
Most of the time 2K ohm will make the transistor turn on hard (eg fully on)
>I'm starting to think about controlling larger machines
Then it's time to go with power mosfets.
Here are some example circuit snippets:
Link
Generally the resistors shown are about the minimum advisable values for safety.
Other considerations often apply. These are just the core circuits.
Duane J
@tonyp12, I'll look into power mosfets and opto-isolators.
Good tip. I'll remember that.
I destroyed the ground pin on one of my two ir recievers so I'll just take it apart to see what's inside.
Link
Ok, this is a .png instead of a .jpg.
I intend to edit or add things from time to time.
Duane J
An input above 3.3V will pull the pin voltage up until an input-protection diode starts conducting - its job is to help prevent static electricity discharges
damaging the gate oxide on the input transistors on that pin.
However these protection diodes aren't very big and can only handle (IIRC) about 0.5mA or so continuous without risk of damage in the long term.
The series resistor limits the current to at or below the safe limit.
One consequence of having a series resistor of a relatively large value (10k say) is that it forms a low-pass filter in combination with the input
capacitance on the pin (due to the chip and the pcb traces). Thus the risetime of logic transitions will be somewhat larger - this can matter
with fast clocked interfaces (10's of MHz ballpark)
And with the transistor base - no problem, the base-emitter voltage is limited to at most 1V in most devices (its a forward biased junction),
so the 12V or whatever on the collector isn't relevant (unless you burn up the transistor - then the base resistor has the job of protection)