Transistor Switch

Discussion in 'The Projects Forum' started by Oxbo Rene, Sep 2, 2009.

  1. Oxbo Rene

    Thread Starter Active Member

    Feb 20, 2009
    200
    0
    Was trying to figure out a transistor switch to drive a relay.
    Read up a bit and saw where a general consensus dictates that Ib can be 1/10th Ic, so went with that.
    Relay is 5V @89.3ma and went from there. (See attached)
    I tried to put it in simulator but simulator says I need a "Ground Node (Pull down device)" before it will work.
    Can't figure that one out, any help would be appreciated.....
    Transistor just a general type (2N3904)
    (was a little off on Ib, should be 8.993ma)
    Oxbo
     
    Last edited: Sep 2, 2009
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    You are going to need to put a flyback protection diode in parallel with the relay coil or you are going to risk destroying your transistor.

    hgmjr
     
  3. Oxbo Rene

    Thread Starter Active Member

    Feb 20, 2009
    200
    0
    Yep, I have figured that in but forgot to add it in the drawing, etc.....
     
  4. hobbyist

    Distinguished Member

    Aug 10, 2008
    764
    56
    try putting a ground at the emitter and see if it simulates.
     
  5. Ron H

    AAC Fanatic!

    Apr 14, 2005
    7,050
    657
    Like this...
     
  6. Oxbo Rene

    Thread Starter Active Member

    Feb 20, 2009
    200
    0
    Tx's guys;
    Put ground on emitter, now it says "Selected device invalid for spice simulation, something like that......
    So, ground node problem fixed, but simulator doesn't seem to like the relay.
    Going to play around with it some more later, got to get to work now, etc.....
     
  7. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Oxbo,
    Looks like you're using Circuitmaker Student.
    Try using the 5VSPDT relay from the Complete section of the library. Right now you're trying to use just the 5v coil portion, and I'm not sure how to tell you what it needs to work.

    After you replace the 5vcoil with the 5v relay, you will need to connect the center contact of the switch (the common) to ground, or at least something that has a current path to ground, otherwise you will get yet another error. PSPICE emulations just won't work properly unless everything has a current path to ground somewhere.

    Also, you'll need to modify the parameters for the 5VSPDT relay.
    Right-click on it, and select "Edit Device Data..."
    You'll see a bunch of items, but the one you're interested in right now is the one titled "Parameters"
    In that box you'll see:
    alias:XSPDTRELAY
    Change it to:
    alias:XSPDTRELAY {PULLIN=4.5 RESISTANCE=56}
    That tells the simulation that the relay contacts are to close when the voltage across the coil exceeds 4.5v, and that the resistance of the coil is 56 Ohms. If your relays' specifications are different, change them to suit.

    Also, you are basing your Vce(sat) of 1v on what you have observed with Darlington transistors. The 2N3904 is not a Darlington. With 10mA Ice, you'll see a Vce of around 0.2v, and at 50mA Ice, you'll see around 0.3v.

    Although a 2N3904 is rated for up to 200mA Ice, its' practical limit is around 100mA. Your planned-on current is just under 90mA, so you're OK there. A 2N2222/PN2222 is another likely choice, and it's beefier than the 2N3904.

    I see you're using a 12v supply. Is this thing going to be installed on a boat/car, or is this just an experiment with PSPICE?
     
    Last edited: Sep 3, 2009
  8. hobbyist

    Distinguished Member

    Aug 10, 2008
    764
    56
    keeping everything in mind that sgt. wookie suggested, and also if the component is highlighted (selected) it depends on what simulation mode your using, (linear or digital) when a component is highlighted it may not simulate properly in that particular mode. The error signal will usually give you the option to continue with simulation.

    check what simulation mode your using, if it is digital mode that may be the reason for the select error.

    Your circuit needsd to run in analog mode, the synbol with the transistor on the button when you click simulate.

    And again to get the acurate simulation follow what sgt. wookie said about your relay.
     
  9. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Had he not been in Analog simulation mode, Circuitmaker would have told him that certain items (the transistor) couldn't be simulated in the selected mode, instead of actually starting the simulation.
     
  10. hobbyist

    Distinguished Member

    Aug 10, 2008
    764
    56
    I'm not using the student ver. I have the floppy disks old ver.. back in the 90's the complete simulator package,

    drew up and simulated the circuit and Had no errors when using the relay coil alone, it gave me results with multimeter readings and transient readings.

    I don't know why his isn't working properly.
     
  11. Oxbo Rene

    Thread Starter Active Member

    Feb 20, 2009
    200
    0
    Appreciate the info guys.
    Will have to print out Sarge's info to follow slowly while setting up the simulation, etc.
    As you know I'm still hanging in there with the scoreboard (one day a week).
    Finally got the "kit" done and now that I've had time to play with it and get familiar with it, I can state that it does work OK.
    Here's the deal ......
    It'll begin counting up/down but won't stop, just keeps on going through zero, etc.
    But, has an "Equal out" pin (wire) that offers 5V @50ma when the count reaches a preset number (default=0000). One can preset any number into it, then begin the count, and upon reaching that preset number the pin/wire exhibits 5V @50ma, and that is the only way one can make the thing auto-stop counting, even on zero (actually, am going to use a couple more relays activated by the begin auto count buttons== long story= see attached, don't really want to get bogged down in all that at this point (relay current values changed).
    So, I had ordered some little 5V 20ma relays (just came in this afternoon)
    and, yesterday decided to try and design a switching transistor to operate a relay I happened to have on hand (5V@89.3ma), and also decided to play around with the simulation program, thus winding up here on the forum, etc....
    Now that I have the little relays I don't need the switching transistor, but, certainly do want to finish the transistor switch design for possible future use.
    Sadly, I have come to the realization that the "kit" does not offer the option to preset a time, then begin a countdown from that number to zero.
    I was talking to my son as to his wrestling matches, he says they last 2-minutes. So, in order to set the display for 2-minutes, one must continually hit the incremental-up (single digit) button 120 times to get to 2-minutes before being ready for the countdown to begin = UGH ! !
    We timed it doing it as fast as I could hit the button, took 25 seconds to reach 2-minutes, so, he says it'll be OK.
    Is OK with me cause I dad-gummed sure ain't giving up on this thing after all the work I've (and ya'll/forum)) put into it ! ! !
    Will get back to ya tomorrow after playing around with Sarge's info for the simulator, etc.
    Tx's for the help.....
    Oxbo
     
  12. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    I see. Well, I think I have the same Circuitmaker Student version that Oxbo has, as I received a similar error message as he did. There must've been a change in the library between your version and the Student version, and in the Student version, you can't update the library.
     
  13. Oxbo Rene

    Thread Starter Active Member

    Feb 20, 2009
    200
    0
    To get my resistor values I exchanged the relay with a resistor having the same ohmic value as the relay coil, then adjusted the other resistor values to get wanted current/voltages, etc......
    Still, have to see what existing mfg'd resistor values come close to what I came up with, then adjust accordingly etc....
     
  14. Oxbo Rene

    Thread Starter Active Member

    Feb 20, 2009
    200
    0
    Played around with the circuit today using a 2N222.
    Changed R1 (Base resistor) to several diff values, finally settled on 1K.
    Put in simulator (See attached).
    Any comments ?
    Actually am guessing as to R1 value, anyone have a fully legit formula for figuring the R1 ?
    In tests relay clicked on barely at R1=45K, Clicked on good from 1K to 16K.
    At 100K relay didn't click on, Ic=20ma
    At 10K relay clicked on, Ic= 90ma
    And on down to 100 ohms, Ic always stayed at 90ma (maybe my meter is off).
    So settled on 1K.
     
  15. Ron H

    AAC Fanatic!

    Apr 14, 2005
    7,050
    657
    If you were going to make 10,000 of these, and you wantwd to be sure every one worked, you should set Ic/Ib=10. Look at Fig. 2 in the datasheet. The β in that graph means forced beta, i.e., Ic/Ib=10, which is the case for almost all types of general purpose BJTs (i have seen one that specified forced β=20). This would mean R1≈470Ω. Practically speaking, the 1K you chose will probably work at least 99% of the time.
     
  16. Oxbo Rene

    Thread Starter Active Member

    Feb 20, 2009
    200
    0
    Tx's Ron,
    Will have to study your info to fully grasp the idea, etc (print Ron's post).
    Returned here to post another pic of latest results after messing with simulator.
    Evaluation appreciated....
    Breadboarded ckt and works fine, I'm just still in wonder if this value is within the safest range etc....
    I'm really not that great at deciphering the datasheet info when it gets right down to wanted parameters, etc..
    Have a nice day.....
     
  17. Oxbo Rene

    Thread Starter Active Member

    Feb 20, 2009
    200
    0
    OK Ron;
    Here's pic of 470 ohm R1 simulation.
    I changed R2 to 80 ohms and everything seems to jive with
    Ib=Ic/10 (Ic/Ib=10).
    Everything looks good.
    I would think that the less Ib I used the less Pwr (heat) on the base ?
    Tried looking at fig#2 on datasheet, seems to be off a little, etc......
    Tx's for your help
    Oxbo
     
  18. Oxbo Rene

    Thread Starter Active Member

    Feb 20, 2009
    200
    0
    FINAL DESIGN !
    For my official library
    Here's the final pic
    Tx's for everything ....
    Oxbo
     
  19. Ron H

    AAC Fanatic!

    Apr 14, 2005
    7,050
    657
    Ic/Ib doesn't have to be exactly 10. Typically, Ic is determined by the load requirements, and the base current is set to be ≈Ic/10.
    Where did you find an 80 ohm resistor? An 82 ohm 5% part would be fine. A 12V relay would be more efficient. With your 5V relay, a lot of power is wasted in the series dropping resistor. I'm guessing this is part of a larger circuit which is powered by 12V(?).
     
    Last edited: Sep 5, 2009
  20. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Oxbo,
    Don't forget to calculate the power dissipation for R2, and double it to determine the minimum wattage resistor that you will need.

    As Ron_H said, 82 Ohms is the closest standard value of resistance. If you wanted to go lower, 75 Ohms would be the next closest.

    Something you need to be aware of is the analysis setup parameters. These can be accessed from the Menu Bar by clicking on "Simulation", and then "Analysis Setup...".

    In many analog simulations that don't have timing components, the simulator will select default parameters that are quite low in time values. Once you get the "Analysis Setup" menu open, UN-check the box on the lower left next to "Always set defaults for transient and operating point analysis".

    Then click the button above that reads "Transient/Fourier".
    The default Start Time is 0.0 S - (seconds) You'll usually want to leave it like that.
    The default Stop Time is 5.0 uS - (microseconds). The horizontal time scale on the simulated O-scope is much easier to read if you use some even multiple of 3, like 3, 6, 12, etc.
    If you had used a coil instead of a resistor, the current flow through it would start off very low, and then increase over a period of time. 5.0uS is not really enough time for a relatively large inductor like a relay's coil to build up. I used 6.0mS for my simulation, which gives 6 milliseconds, or 1200 times as long as 5.0uS.
    I also changed the step time and max step from 20.0nS to 20.0uS; otherwise it would have taken a very long time for the simulation to finish running. The smaller the step time and max step are, the more data points you will get. However, it's easy to over-do this. Using (Start Time - Stop Time) / 400 for both step time and max step is usually a pretty good trade-off between how much time it takes to run the simulation, and how detailed the resulting O-scope plot is. The numbers don't have to be exact; it's just a "rule of thumb" to get you started.

    At the bottom is a box labeled "UIC"; this means that the simulation should use the initial condition. This is helpful when you are simulating circuits that use inductors and capacitors so that you can observe how they charge or discharge from the start time. Otherwise, the simulation starts off finding the operating point.

    Note that the floating multimeter display shows the average value rather than peak value. You need to look at the O-scope trace to determine the value of current, voltage or power at a given point in time.

    Note that with R1 being 470 Ohms, the Vce(sat) of Q1 is around 50mV with a 2N2222, and around 277mV with a 2N3904. That means the 2N3904 would be dissipating about 5.5 times the power of the 2N2222; it would run a lot warmer.

    Note that you can set your voltage reference point to anywhere on the schematic by holding down the Ctrl key and left-clicking a wire. This is handy for such measurements like across the coil of the relay; Ctrl-LeftClick on the collector of Q1 to set the reference, and then left-click on the wire between the relay's coil and R2 to get the voltage across the coil itself.
    To re-set the voltage reference, Ctrl-LeftClick on a wire that is connected to the ground symbol.

    If you click in the middle of R2, you'll get the power being consumed by the resistor.

    I've attached my version of your circuit; it uses the relay instead of a resistor. Experiment with it a bit. I had to put it in a .ZIP file, as .ckt files are not currently recognized as eligible for upload on the forum.
     
Loading...