"Inverted transistor" Control small current with large current
Harrison H Jones
Posts: 22
Hello Parallax Sensors Forums,
I have a simple question I'm hoping has a simple answer. I'm trying to detect if a reed relay is tripped. I'm going to run +5 through it and I want to detect wither or not it is open/closed. I was thinking about opto-isolating it w/ a chip but I Was wondering if there was another way. A simple resistor wouldn't work would it? I don't want to blow my propeller's pins [noparse]:([/noparse]
Thanks for the help!
Post Edited (Harrison H Jones) : 10/3/2009 5:03:57 AM GMT
I have a simple question I'm hoping has a simple answer. I'm trying to detect if a reed relay is tripped. I'm going to run +5 through it and I want to detect wither or not it is open/closed. I was thinking about opto-isolating it w/ a chip but I Was wondering if there was another way. A simple resistor wouldn't work would it? I don't want to blow my propeller's pins [noparse]:([/noparse]
Thanks for the help!
Post Edited (Harrison H Jones) : 10/3/2009 5:03:57 AM GMT
Comments
There are examples of this in the Propeller Education Kit tutorials.
You've got +5V to work with. You want the switch (reed relay contacts) to conduct a little bit of current, but not waste too much. 1mA is usually enough current through a contact to keep it clean and, with the circuit capacitances, you won't get much delays charging things up. 5V / 1mA = 5K. A nice round number close to that would be 10K. You'd have about 1/2 mA and that's ok.
The Propeller pin normally operates at 0-3.3V. Anything one diode drop (0.6-0.7V) beyond that will cause the built-in protective diodes to conduct to either Vdd (+3.3V) or Vss (0.0V). 5V - (3.3V + 0.6V) = 1.1V. The protective diodes are rated at 0.5 mA, but are a bit more robust than that. A 1K resistor will limit the current from the +5V supply to about 1mA. If you want to play it safe, use a 2.2K resistor which will limit the current to under 0.5mA.
Thanks for the information. I understand Ohm's law I just wasn't sure of how to apply it. As I said, I have a very basic understanding of electronics. I understand that the 10K resistor is to "ground" the input pin such that it doesn't float. I understand that the resistance has to be high enough such that when the switch does close most of the current goes through the input pin and not to ground. I'm still a little confused.
If I only had the resistor on the pin(the 1k) wouldn't that drive more than 1ma though the stamp? How do I model the stamp on a schematic? Is it a resistor? inductor? capacitor? mixed?
If you have time, could you please explain a little more?
CMOS IC inputs are high impedance. Virtually no current flows after a brief surge to charge up the capacitance of the gates on the chip.
A microprocessor or any complex chip is represented by a box with the pins/leads labelled with the signals present (from the standpoint of the complex chip). Look at any schematic, like on the web. You'll see.
Again, the reason for the 10K resistor is to provide a "default" signal (ground) when the switch is open. If you left out the resistor, the input pin would "float". It's a high impedance and would respond to random electrical fields and static electricity from the world around. Try it some time. Connect a microcontroller input pin to a long piece of wire (like maybe 30cm). Write a program to display the state of that input pin then wave your hand over the wire. You'll quickly see that your hand only needs to be close to the wire for the input pin to react.
You want the resistor to be something like 10K rather than perhaps 1K or less so that you don't waste current heating up the resistor (a little) when the relay is closed. That would connect the resistor across the 5V supply. If the value is 10K, roughly 0.5mA flows. If the value is 1K, roughly 5mA flows. If your microcontroller is running off a battery, that amount of current could deplete the battery over a couple of days. A Propeller running at low speed may only draw 50uA or less. A Stamp in SLEEP mode might draw the same.
Post Edited (Mike Green) : 10/3/2009 4:37:41 AM GMT
Also, concerning "drawing" the micro-controller. I realize it's a box w/ all the pins coming out... but how is it modeled? It sounds like it resembles a very high resistor connected to ground(Kinda like a volt-meter?). How high of a resistor are we talking?
When the relay is closed, the contacts connect +5V to one end of the 1K (or 2.2K) resistor that's connected to the I/O pin. The 10K resistor really doesn't enter into this case. The Propeller's I/O pin has a diode built into the structure connecting the I/O pin to Vdd (3.3V) so it will conduct if the I/O pin voltage is raised above 3.3V + 0.6V = 3.9V. The 0.6V is the voltage drop across the diode. With 5V on one end of the 1K resistor and 3.9V on the other end, the resistor will have to drop 1.1V. That allows a current of 1.1mA to flow through the resistor and protection diode. The protection diode probably can withstand the 1.1mA for a while although it's rated to withstand a current of 0.5mA indefinitely. Like I said, use a 2.2K resistor if you want to play it safe. That will limit the current to under 0.5mA (an exercise for the reader!)
By the way, thanks for all the help!
When the input voltage to a Propeller pin is greater than Vdd (normally 3.3V) plus one diode drop (roughly 0.6V ... a function of the materials used to construct the diode and the construction of the diode itself), the "protection" diode will begin to conduct. It will conduct whatever current is available until it either burns out or something else catastrophic happens to the chip. The purpose of the 1K or 2.2K resistor is to limit this "fault" current to something the chip is designed to survive. This mechanism (protective diode) is intended to help the I/O pin circuitry handle static electricity and similar brief, low current discharges. It's also useful for providing a simple mechanism for the I/O pin to handle logic inputs that are greater than 3.3V ... by adding a current limiting resistor.
Normally, when the input voltage to a Propeller pin is in the "normal" range (0V to 3.3V), it draws virtually no current (less than 1uA). It's only when the applied voltage is outside this range that these protection diodes come into play.
Anyways, I'm still not sure why we are using 1ma as our "standard." If the propeller only draws 1uA why don't we do all our calculations using that number? I guess my problem here is that we have two unknowns(Voltage and Current) and, to me, you seem to be arbitrarily setting on of them(voltage = 1.1V) and then calculating current(V=IR).
5v·─ 3.9v = 1.1v
The voltages are fixed (5V, 3.3V, 0.6V) by the power source, choice of devices, and physics.
I really really don't understand how you can regulate voltage w/ only a resistor if you don't know the current draw of the prop on a pin
The Prop is a non-linear conductor. For voltages in the normal range, it has a roughly fixed leakage of about 1uA. For voltages outside that range ( > 3.9V or < -0.6V), it has near zero resistance and will conduct whatever current is applied up until the device is destroyed. This isn't exactly right, the details are actually different, but it's roughly what happens. There are also capacitance effects involved as well, so there is a charging surge involved to charge the input gate capacitance.
So far the limit of my electronic knowledge limits me to knowing how to model resistors, capacitors, inductors, variable voltage supplies, current sources, and constant voltage supplies. Is it possible to model this circuit(With the reed relay, resistors, and prop) with only those components? So far I'm thinking of the prop as a resistor with 3.9M ohm resistance. The problem with that model is that if the prop only allows a current of 1uA though it that means only 1uA is going through the 1K resistor which doesn't allow for enough voltage drop.
Should I model the propeller another way w/ those components or is it beyond the scope of my knowledge?
The 1K resistor is there mostly to protect the diodes which become forward biased at voltages beyond the Propeller's normal operating range for an I/O pin. If the current through these diodes is too high, they and their interconnections on the chip can overheat and melt. The excess current through the Vdd and/or Vss busses on the chip can cause voltage shifts due to I x R drops and the inherent resistance of the on-chip power wiring and these voltages can damage other parts of the chip.
Most electric circuitry have fixed voltage sources (they don't tell you in ECE class).
Most microcontrollers use TTL or CMOS voltage levels. That means your voltage is fixed at around 5V or 3V. So voltage is a constant, and you vary the resistance (or impedance) to get the appropriate current through your circuit parts.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don't worry. Be happy
Post Edited (dev/null) : 10/4/2009 8:45:24 PM GMT
Ok, here's the situtation. Even though y'all have been very helpful I'm still having a hard time understanding this resistor problem. I talked with my ECE professor and we came up with the following circuit:
(If it doesn't show up see the attachment)
This "way" of doing it makes much more sense to me. All the resistances can be calculated given the desired voltage drops because they are all on the same "loop" (I1). Since the prop isn't going to consume that much power we can treat it like a broken wire and this we can use KVL analysis.
Would this way work?
I don't have time right now but I'm also going to put up the circuit for the other way(with the resistor(R1) going to the prop pin) and I'm hoping y'all can explain exactly how to find the reistances w/ some kind of analysis I'm used to.
Post Edited (Harrison H Jones) : 10/10/2009 4:34:50 AM GMT
@Mr. Green - Thanks for all the help. I realize it must have been trying to deal with me when the answer is so simple and obvious.
When I get time later tonight I'm going to post my "solution" with math and all for the other circuit to help any other forums members out. If anyone would be so kind as to check that solution when I post it that would be greatly appreciated!