Transistor Selection for Switching Relay Coil-with a little bit of info on my "ARSC"


Closed Thread
Results 1 to 25 of 25

Hybrid View

  1. #1
    Join Date
    Oct 2008
    Location
    Ashland, KY
    Posts
    45

    Default Transistor Selection for Switching Relay Coil-with a little bit of info on my "ARSC"

    Hey guys-I'm racking my brains trying to figure out 1) which transistor to use and 2) how to wire it into my current project to use it for switching a 5V relay coil. The code for the project, my "A.R.S.C." (Air Ride Smart Controller), isn't written yet-I want to make sure I've got the hardware aspect of the project covered to ensure correct operation with the proper code, but I've pretty much got most of the code layed out; I just need to play with a few variables and determine which pins will operate relays, which will read the sensors, etc. I'm hoping I can at least get all the hardware right the first time; I don't really have the option to "breadboard" this project, but I did get a PICkit 2 (another great thing this forum has introduced me to) so the code can be changed via ICSP "on the fly", a lot easier than I can change out a transistor or other hardware component.

    I have found at least two other threads on this forum and a few other schematics to go by, but I'm not 100% sure what I have found is compatable with my project. I have done my research, but I wanted to get the opinion(s) and help of somebody that's basically done the same or similar thing with PIC MCUs, somebody who actually knows what they're doing with not only the MCUs, but with transistors (or a similar circuit) also...

    The MCU I'm using with this project is a 16F690, mostly for the A/D channels (I'll only need a total of six including the Vref-one per corner of the car/air spring and another for the tank pressure sending unit), the extra code space (4K, more than most smaller devices) for future upgrades/expansion, and the fact that I have about ten or so on-hand. I'm using PCB-mount Omron G5LA-14 5VDC coil relays (SPDT) with a 1N4001 diode placed across the coil for protection (the MCU outputs to the relay aren't wired up yet, but will be wired to the correct side of the relay's coil in regard to the diode once I know exactly how the circuit will be layed out). The relays are only switching automotive 12VDC current (depending on the state of the battery and alternator, somewhere in the neighborhood of 9V-14.7/15V max) at less than one amp (I believe) to operate the SMC brand "air valves", or pneumatic solenoids to control the flow of air into the air springs (or 'bags) based on the pressure reading obtained from oil pressure sending units installed in each corner and in a tank port on this particular vehicle. The sensors were part of a digital gauge kit designed for air ride applications; even though the sensors were made to work with oil, they still work within a 4psi accuracy (from 100psi or less) when used with compressed air.

    My current dilemma is choosing the right transistor to install between the MCU and the relay. I plan to drive the selected output pin that controls a single relay "high" for a fraction of a second when the analog input that controls it's function gets a "low psi" reading (a small analog voltage signal-under 1.525VDC-from the sending unit that will be preset for this prototype, a non-adjustable constant in this version), then re-checks the psi level and either continues to open the valve (back to same loop if pressure still isn't at it's correct level) or goes on to check the other pressure levels in their respective corners of the vehicle (moves to next corners' pressure reading subroutine)...

    I believe it was on this forum that I read it was highly recommended to use a transistor to "drive" a relay instead of powering the unit directly from CMOS levels. I have a vast array of transistors on hand, mostly plain ol' bi-polar NPN's and PNP's; not many FET's, BJT's, etc. Transistors are one thing that I don't really know much about; I can solder or install one from a schematic to a circuit or breadboard, but as far as using one in a circuit of mostly my own design I have no clue how to properly choose them. If anybody mentions getting my hands on a copy of "The Art of Electronics", I've had my local library order it (I can't believe they didn't have it in stock!) so I could browse through it before buying a copy of my own (it's still not in yet)...

    One frustrating fact is that I don't know how to check and determine which lead is the collector, base, or emitter. I don't have an oscilliscope but I do have a nice Fluke multi-meter. I keep meaning to order a "transistor tester" or a kit/tool that determines whether the transistor inserted in it is an NPN or PNP and lets you know which leads are what. I've seen a couple of them in online stores but have never ordered one because I haven't really needed it until now. I need to get one soon...

    I have a few MPSA2222A's that I thought were the same as (or very similar to) 2N2222(A)'s or PN2222(A)'s, but they apparently aren't. I could only find datasheets for T0-18 case 2N2222's, and the ON Semiconductor datasheet I found for the PN2222(A) did NOT have the same leads/pin-out as the MPSA2222A's I have on hand (when I hooked what the datasheet said was the collector to +9VDC and what was supposed to be the emitter to the 9V battery's ground terminal, that little thing quickly heated up to "burning hot"-I played around with a couple others, testing each with my Fluke meter to verify that 9V stayed on the display; I noticed that each one only got hot when the Fluke display's DC voltage was dropping-one reached 1.6V before I removed it and felt like it was about to explode; yes, I disposed of each one that warmed up), so I really need a method for determining which lead is which, especially on some of the lesser-used/known transistors I have. I do have quite a few 2N3904's, 2N3905's, 2N3906's, and a great deal more of what some would consider "common" transistors. Some of the more common ones should have the same pin-outs regardless of the brand, shouldn't they? I do have at least one manufacturer's datasheet saved for almost each transistor I have, but most of them don't have the manufacturer's logo or name printed on their T0-92 cases...

    To sum the above novel up into a single-dual question, what transistor would be best to use in my case and how do I wire up the collector, base, and emitter of said transistor for use as "driving" a relay-installed between the PCB mounted 5VDC coil of the relay and the PIC16F690 20DIP MCU. I'm planning on driving the selected output pin "high" on the MCU to activate the relay, but I could change it's state to low-with the other side of the coil attached to +5V, if that's what is recommended and works correctly and reliably. Whatever would be the most reliable and dependable choice for this application is what I need-I don't care to buy a few more expensive T0-220 transistors if that's going to create a better and more dependable finished product compared to any T0-92 case transistor I have...

    Also, if anybody knows any good tips or tricks on how to determine whether a transistor is an NPN or PNP stlye (or even determining/deciphering whether the transistor in quesion is bi-polar, an FET, BJT, Darlington, etc.) and how to figure out which leads are the collector, base, and emitter (that's a definate need for the cheap off-brand assortment of transistors I have on-hand), I would greatly appreciate any of them. Thanks in advance for any and all information and help you guys can give me; believe me, it's greatly appreciated!

    Sincerely,
    -Adam Collins

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    What is the coil rating is amps of the relay coil? If not known then what is the resistance?
    If the amperage is less than 20ma then there is know problem driving it from the PIC as long as you have a fly-back diode installed. You need the fly-back for the transistor too.

    The above info is needed even if you use a transistor.

    Simplify things a bit. What is the amperage if the valves that the relays will be controlling?
    Then we pick a MOSFET to drive the device directly doing away with the relay and transistor.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    I wouldn't have any Relays on the PICs 5v Rail if I could possibly avoid it.

    Have a 12v Relay on the 12v line if you have one available, use any medium power NPN Transistor (Emitter to 0v, Collector to Relay). The other end of the Relay is connected to +12. Drive the Transistor Base from the PIC's I/O via a suitable current limiting Resistor (value depends on selected Transistor). You will still need a Diode reverse connected across the Relay coil (Kathode to +12, Anode to Transistor Collector).

    If you are driving multiple Relays, it's less hassle to put in something like a ULN2004. No Resistors needed, you can connect it directly to your PIC, and the suppression Diodes are built-in.

    If you are using ADC or Comparators, and if you are using the 5v rail as VRef, put NOTHING on your PICs 5v line that will unnecessarily load it, spike it, or in any way abuse it - and a Power Relay will.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    rxforspeed,

    If advice is given Melanie and myself, go with Melanie's. She is one of the people I am learning from

    But just for the record. I do have two automatic punch presses using relays to control the solenoids ( air and hydraulic ). I picked the relays to work directly from the PIC. I can not remember why I went that direction, I normally use a MOSFET. Both machines run five days a week and run between 2,000 and 8,000 parts a day depending on the part punched. One machine has been in operation for five years and the other for four.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Oct 2008
    Location
    Ashland, KY
    Posts
    45


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    rxforspeed,

    If advice is given Melanie and myself, go with Melanie's. She is one of the people I am learning from

    But just for the record. I do have two automatic punch presses using relays to control the solenoids ( air and hydraulic ). I picked the relays to work directly from the PIC. I can not remember why I went that direction, I normally use a MOSFET. Both machines run five days a week and run between 2,000 and 8,000 parts a day depending on the part punched. One machine has been in operation for five years and the other for four.
    No need to be so modest, Dave. You still have WAY more experience than I do, so your input is extremely valuable to me-just as much as Melanie's...

    So I take it your punch presses don't have a massive flywheel like a small manual punch (the kind I have more experience operating)? Are these massive industrial punches or smaller interchangable die style punches? Sorry to jump off topic, but this is an area that really interests me...

    Thanks for all the help, guys (and gal)...

    Sincerely,
    -Adam Collins

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rxforspeed View Post
    So I take it your punch presses don't have a massive flywheel like a small manual punch (the kind I have more experience operating)? Are these massive industrial punches or smaller interchangable die style punches?
    These were built to replace the massive flywheel manually operated types. They are more along the lines of the smaller type but the dies are a custom build.

    Picture a 6 inch cylinder driven by a two stage pump on a 15 hp electric motor. That pushes the punch. The other one has two 4 inch cylinders in parallel driven the same way.

    One is designed to punch a set of holes through a 1/4 x 6 x 6 inch piece. The other will take two pieces of 1/4 x 2 x 2 angle and punch a set of holes along with shearing the ends at 45 degrees on one step.

    The plate punch has a feeder that uses an air cylinder to push the part into place from a stack. The angle punch uses a hydraulic cylinder to feed the parts.

    Both machines have sensors, (pressure, mechanical, IR ) to control the operation and check for mechanical errors, like a stuck part or no parts.
    Sorry to jump off topic, but this is an area that really interests me...
    It is your thread
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Oct 2008
    Location
    Ashland, KY
    Posts
    45


    Did you find this post helpful? Yes | No

    Thumbs up Thanks for the help!

    Quote Originally Posted by mackrackit View Post
    What is the coil rating is amps of the relay coil? If not known then what is the resistance?
    If the amperage is less than 20ma then there is know problem driving it from the PIC as long as you have a fly-back diode installed. You need the fly-back for the transistor too.

    The above info is needed even if you use a transistor.

    Simplify things a bit. What is the amperage if the valves that the relays will be controlling?
    Then we pick a MOSFET to drive the device directly doing away with the relay and transistor.
    Omron's datasheet for the relay specifies "360mW coil consumption (max)", and the resistance of the coil averaged around 67-Ohms for the four relays I have mounted on the PCB. The amp rating printed on the top of the relays is 10A at 250VAC (N.O.).

    Here's a link to the same valves we're using: http://www.coastpneumatics.net/displ...VXD2130-03N-6G
    They're the NC 12VDC VXD21XX parts. A link to the PDF datasheet is listed on that page...

    Even that datasheet for the valves doesn't give a lot of information, and they're not in front of me at the present time to check with my Fluke meter. I found a 6W holding power consumption rating in the datasheet for the style of valve we're using; that would put the amperage near 0.5A, wouldn't it (with a 12VDC automotive electrical system)? That would still be over the PIC's 20mA output, so I'm assuming that I would need a MOSFET (or transistor array IC, transistor of another kind, etc.)...

    Quote Originally Posted by Melanie View Post
    I wouldn't have any Relays on the PICs 5v Rail if I could possibly avoid it.

    Have a 12v Relay on the 12v line if you have one available, use any medium power NPN Transistor (Emitter to 0v, Collector to Relay). The other end of the Relay is connected to +12. Drive the Transistor Base from the PIC's I/O via a suitable current limiting Resistor (value depends on selected Transistor). You will still need a Diode reverse connected across the Relay coil (Kathode to +12, Anode to Transistor Collector).

    If you are driving multiple Relays, it's less hassle to put in something like a ULN2004. No Resistors needed, you can connect it directly to your PIC, and the suppression Diodes are built-in.

    If you are using ADC or Comparators, and if you are using the 5v rail as VRef, put NOTHING on your PICs 5v line that will unnecessarily load it, spike it, or in any way abuse it - and a Power Relay will.
    I do have a 12V line on the PCB; it supplies power to the 5V regulator (7805's are the only dedicated 5V regulators I have on-hand, but future versions may incorporate either an LM2931T-5.0 or LM2940CT-5.0 automotive 5V regulator) and will be the tie point for the incoming switchd ignition hot power wire.

    I don't have a problem ordering a few 12VDC relays, I had just foolishly bought about fifty of the 5VDC versions for this specific purpose. I wish I would've found this forum before placing that order...

    The ULN2004 you mentioned-is it similar to the Motorola ULN2068B (quad high-current Darlington array) or the TI ULN2803A (eight NPN Darlington transistor array)? I don't have any of those on-hand, but I can order whichever would be the best for my project with the 12V relays, most likely a quad array because I really only have room for four relays on the prototyping PCB this circuit is being built on...

    I can see why you've recommended what you have-mostly for protection of the PIC and it's A/D Vref (which will be connected to the 5V rail through a resistor-a value yet undetermined-that will reduce the voltage to 1.525V for greater accuracy within the psi range we'll be working with-100psi and less). It makes sense, and I can (for the most part) comprehend and picture it's lay-out. This method would still require a CMOS "high" output from the PIC to the base of the transistor (or array), correct? That would make the transistor act as a switch, grounding the collector side of the transistor (which is connected to the 12V relay coil) through the emitter when the CMOS "high" is applied to its' base from the PIC's output pin. I still get confused with "anode" and "cathode" terminology for diodes (but not LED's), so the +12 would connect to the striped end of the diode (to block +12V from passing through to the other side) and the opposite end without the stripe would connect to the negative (0V) side of the relay coil (for the same purposes, only with negative current), right?

    I do believe I'll order a transistor array-that way there's no confusion as to which lead is which and I can make sure I get the proper datasheet from the same manufacturer. I'll need four 12VDC "sugar cube" PCB mounted relays, a quad NPN transistor array (like the ULN2004 or the ULN2068B), and I'm assuming it would be OK to leave the 1N4001's in place as long as they're connected correctly, right? I do believe I'm going to order a good "transistor tester", like this one from www.electronickits.com: http://www.electronickits.com/kit/co...eas/dt100k.htm

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. Sleep Mode
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th March 2008, 10:31
  3. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  4. Serial Relays
    By tazntex in forum General
    Replies: 3
    Last Post: - 17th May 2007, 17:42
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts