Replacing a 5v switch with Propeller/Transistor?
Oldbitcollector (Jeff)
Posts: 8,091
I've got a device that uses a 5v switch to activate a feature on the device.
I want to replace that switch with the following.. Is this safe for the Propeller?
I'm using the LED to prevent a short on the Propeller..
(seems to work in test with the meter)
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with the Protoboard? - Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card? - PropDOS
Need a part? Got spare electronics? - The Electronics Exchange
I want to replace that switch with the following.. Is this safe for the Propeller?
---P0---LED---NPN(Base) Gnd--->NPN(Collector) 5v--->NPN(Emitter)
I'm using the LED to prevent a short on the Propeller..
(seems to work in test with the meter)
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with the Protoboard? - Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card? - PropDOS
Need a part? Got spare electronics? - The Electronics Exchange
Comments
If that is correct then this circuit should suffice.
Cheers
The way you plan to connect things will create a nice puff of smoke and not much else.
For an NPN transistor, you connect the emitter to ground.· You connect the collector to your load with the other end of the load connected to your positive power supply for the load.· You connect the base through a resistor to the I/O pin.· The resistor value depends partly on how big a load you have and what the gain of the transistor (hFE) is.· A Propeller I/O pin can easily handle a 20mA load.· Start with a 150 Ohm resistor.
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with the Protoboard? - Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card? - PropDOS
Need a part? Got spare electronics? - The Electronics Exchange
Ohm's Law is really not that hard to use.· The base to emitter forward voltage is typically 0.6V.· The Propeller's high output voltage is roughly 3.0V.· That leaves 2.4V to drop in the resistor.· I = E / R = 2.4 / 100,000 = 24uA.· That's not a lot of current.· If you have a transistor with a gain of 100 (not unusual), you'd get 2.4mA output current.· That's not a lot of current either, even for use with just an LED.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
What you have drawn is not really correct. You should either draw voltages across components or with respect to ground. They way you have drawn it is with respect to ground but the voltage on the base of the transistor should be 0.6v (because from base to emitter the voltage is 0.6v).
So it is 3v wrt ground on one side of the resistor and 0.6v wrt ground on the other hence 2.4v across the resistor.
Ken,
you make a good point, there is no such thing as a 5v switch really just a switch.
Graham
So I'm going over to Solid State Relays as now I'm controlling more than one switch..
I'm thinking that Digikey: 255-1546-5-ND RELAY OPTO DC 40V 700MA 6-DIP
should fill the need.
Can anyone share their experience with these?
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with the Protoboard? - Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card? - PropDOS
Need a part? Got spare electronics? - The Electronics Exchange
Why does that make a difference?
Graham
The attached circuit didn't work, and I suspect that it's because I should not be using NPN transistors for
this. While it worked for a single switch, it did not handle multiple. I *think* because of the common ground
required for the Propeller.
I submit this "transistorized error" for the experts to advise..
I swear I'm going to master transistor logic if it kills me!
What went wrong?
Edit: Cleaned up the artwork a bit, hopefully a little clearer of how things are wired.
Thanks!
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with the Protoboard? - Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card? - PropDOS
Need a part? Got spare electronics? - The Electronics Exchange
Post Edited (Oldbitcollector) : 7/3/2008 4:01:58 AM GMT
Basic circuit:
Connect transistor emitter to ground.
Connect transistor base through 1K resistor to Propeller I/O pin
Connect transistor collector to Atari input pin
Connect resistor (1K to 3.3K) from Atari +5V supply to transistor collector (and Atari input pin)
A closer look at the actual pins used on a typical joystick
do not include the use of the +5 line. I haven't gotten my
meter on the port itself yet, but it looks like the C64 I/O is
pulled low by the switches in the joystick to ground.
That being the case, the attached schematic replicated
5 times should work no?
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with the Protoboard? - Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card? - PropDOS
Need a part? Got spare electronics? - The Electronics Exchange
Would changing the transistor to a darlington pair significantly change or eliminate the need for the resistor at the I/O pin?
You have to have some sort of current limiting resistor. Otherwise, the base-emitter junction in the transistor will conduct as much current as you supply until either the transistor burns up or the Propeller I/O pin structure burns up. Probably the Propeller will current limit first and nothing will be damaged, but I wouldn't design on that basis.
You need enough current into the base to saturate the transistor. Usually that's given in the transistor's datasheet. A 1K Ohm resistor as I suggested would give a base current of 2.7 mA ((3.3V - 0.6V) / 1K). Even if the transistor had a gain of only 30, that would be a collector current of 80 mA which would certainly take care of a logic input.
With a Darlington, you'd have a base current of roughly 2mA ((3.3V - 1.2V) / 1K). Darlingtons have gains in the 1000's, so that's more than enough base drive.
·
With a Darlington, you essentially create a current multiplier.· For example if the Hfe of one transistor is 20 while the Hfe of another transistor is 50, then the combined Hfe is 1000.· You still however need a base resistor to limit the current.· Remember that each transistor within a Darlington stage adds about 0.6V so your calculations for a base current resistor should be adjusted accordingly.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
The second board worked perfectly! Thanks to you!
I'm glad I stuck it out, as I have gained a better understanding of transistors as a result!
Next up.. Expand the .spin code to include other input devices.
Thinking I'll hook the accelerometer up next, maybe I'll tape it to a wiffle-bat
and play some Commodore Hardball with it. [noparse]:)[/noparse]
Here's a shot of the Nintendo adapter on C= Boulderdash
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with the Protoboard? - Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card? - PropDOS
Need a part? Got spare electronics? - The Electronics Exchange
I guess there is smoke in my near furture then. I have a PNP darlington with no resistor. One is driving a piezo and another driving a fan.