Shop OBEX P1 Docs P2 Docs Learn Events
determining the right size transistor — Parallax Forums

determining the right size transistor

NosePickerNosePicker Posts: 54
edited 2008-07-30 02:43 in BASIC Stamp
In this example I want to use the basic stamp to detect if a wire is off or on. The problem is when I say "on" means it will have 12v supplied to it.
I am assuming that I can use a transistor and connect as follows:
Base pin connects to the 12v wire.
Collector connects to the stamps vdd pin (+5v)
Emitter connects to a 220ohm resistor which connects to an input pin on the stamp.

It appears that when the 12v is on then the stamp pin is high and when the 12v is off the stamp pin is low.

I have two questions here.
1. Is this the right way to test for 12v being high or low?
2. If 1 is yes then what are the dangers of not using the "right size" transistor and how would you determine the right size?

I have the following transistors KSP2222A, 2N3904.
On the back of the box of transistors has the following ratings but I don't know what they means.
Maximum Ratings
Vcbo:· 60v
Vceo:· 40v
Vebo:· 6v
Ic:····· 200mA
It:····· 300MHz
Dissipation: 350mW



▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thanks

NosePicker

Post Edited (NosePicker) : 7/26/2008 1:53:29 PM GMT

Comments

  • ercoerco Posts: 20,256
    edited 2008-07-26 14:58
    NP: For input sensing, no transistor is needed. Just use a 2-resistor voltage divider to reduce your 12-volt signal down to something the stamp can detect. BTW, any voltage over ~1.4 volts, the stamp reads as HIGH and anything less that 1.4 volts is low. So you don't need 5 volts, or anything much above 2 volts. Try this: put a 4.7K resistor in series with a 1 K resistor. Your Stamp will share a common ground (negative) with your 12 volt supply, that is, your 12 volt negative connects directly with your stamp's 5 volt negative (AKA ground, or Vss). Also connect the free end of the 1K resistor to this common ground. Connect the free end of the 4.7K resistor to your 12V signal, and the resistor junction will connect through a 220 ohm resistor (for safety) to your stamp input pin. With 12 volts applied, your stamp pin will see (12*1/(1+4.7)), or 2.1 volts, which will read high as far as the stamp is concerned.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."

    Post Edited (erco) : 7/26/2008 3:07:03 PM GMT
    330 x 170 - 7K
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2008-07-26 15:37
    For input sensing, the BasicStamp is indeed quite sensitive and no transistor is needed. If anything were really needed for micro sensitivity, an OpAmp would be better. If the voltage is above 5 volts, a voltage divider is required to protect the BasicStamp, but your trigger to HIGH is 1.4 volts.

    12volts plus or minus will easily damage a BasicStamp I/O pin. Any negative voltage is quite dangerous. They are not suppose to get more than 5.5volts, but can manage an accidental 7 volts plus or 0.5 volts minus in a pinch.

    You really need to comprehend some basics before you get too far into connecting wires. The Transistor ratings are maximum voltages across different pairs of the three basic wires. Their is also a polarity that is defined by the type -- either PNP or NPN.

    Regarding your choice of 2n2222 or 2N3904 transitors for project, either will usually work fine with BasicStamps to boost output. But the 2n2222 can control more power. Use the internet to get good information as what you got on the back of a package seems wrong. Also, it is a bit silly to even buy a 2n3904 as the 2n2222 can control more power in similar situations.

    Nearly all transistor will handle at least 40 volts in switching. The real design issues are how much current they can control and what are their high frequency properties. Since digital isn't really concerned with the high frequency issue, one begins to find that many, many different transistors can be used in the same context. It can be confusing to the beginner. The Europeans use their own part number and the Americans use others. Everyone tends to jump in and say this one will work fine, so don't worry about it.

    If you really want to know in detail, the Navy has a series of manuals called NEETS that can be downloaded and studied for free [noparse][[/noparse]beware that there are web sites that will charge for these, but you should search further].

    http://www.phy.davidson.edu/instrumentation/NEETS.htm This link may work. US Government manuals do not have copyrights and are free to all.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    It's sunny and warm here. It is always sunny and warm here.... (unless a typhoon blows through).

    Tropically, G. Herzog [noparse][[/noparse] 黃鶴 ] in Taiwan
  • NosePickerNosePicker Posts: 54
    edited 2008-07-29 12:07
    Hey erco,
    Thanks for your help with the voltage divider but I am having trouble completely understanding the forumla so I can reuse this in the future so I will try to break it down and please correct me where I go wrong.

    You stated the result would be:· (12*1/(1+4.7))
    so obviously the 12 = the input voltage (IV) and the 4.7 is the size in k for the resistor being used from the (IV) to the pin so lets call the 4.7 resistor (IVRes)
    that gives us (IV*1/(1+IVRes)).

    Now my question is if I need to substitute the 1 k resisitor then is that represented by the first 1 or the second 1 or both in the forumla?
    Lets call the ground resistor (GRes)

    (IV*GRes)/(GRes+IVRes))


    By the way that did seem to work, so long as the power was on with the 12v connect. But when I remove the power coming in from IV then it appears the pin on the stamp bounces high and low as if power is flickering above and below 1.4v. When I check it with my volt meter it does appear to be bouncing. Any ideas?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thanks

    NosePicker
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-07-29 14:23
    The problem is "what does the pin see, when the 12V is "off"?"

    If the pin sees an "open", (in other words, the signal is 'floating' not pulled to ground OR to +12) then the pin sees an antenna, which will oscillate with any recieved RF signal, typically the 60Hz "line-noise".

    If that's the case, you can fix this with a 10Kohm resistor attached between the pin and ground. This will give the pin a "soft ground", so it will read zero with no signal applied.

    One other thing you can do is connect the pin to 12 volts using a 22 Kohm resistor. The PIC inside the BS2 has "clipping diodes" which will "clip" the signal to zero and +5 -- BUT, those diodes won't take a lot of current. The 22 Kohm resistor reduces the current enough to let the internal diodes do their job without being destroyed -- for a 12 Volt DC signal, anyway.

    So, have a 10 Kohm resistor going to ground right next to the pin, and connect to +12 through a 22 Kohm resistor, and you've solved both problems.
  • NosePickerNosePicker Posts: 54
    edited 2008-07-29 15:37
    so you are saying use the same diagram that erco posted above but replace the 4.7k with a 22k and replace his 1k with a 10k?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thanks

    NosePicker
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-07-29 16:33
    Yes, I think that should work pretty well.· Except I wouldn't connect -12 volts to the BS2 Vss.· You DO have a "ground" wire for the +-12 volt signal, right?
  • NosePickerNosePicker Posts: 54
    edited 2008-07-29 20:26
    Right, in fact for testing I am just using a 12v battery. So what I want to do is know when the battery is connected and when it is not. So if I have a wire from the +12v battery connected to a 22k res and the 22k res connected to a stamp pin. Then connect the -12v wire to to the ground on my circuit. Then connect a 10k res from the circuit ground to the same stamp pin.

    Once I build that circuit I want to be able to connect and disconnect the wire from the positive side of the battery and have the stamp pin go high and low.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thanks

    NosePicker
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-07-30 02:43
    Well, if all you have is a +12 volt battery, I'd call the other lead "ground", not "-12".

    But yes, if you build that circuit (and keep the 12V battery ground tied to Vss) then you should be able to connect the battery + line and detect it's connected, or disconnect the battery + line and detect it's not connected.
Sign In or Register to comment.