Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Transistors and resistors


  • Please log in to reply
36 replies to this topic

#1 mcinnes01

mcinnes01

    Advanced Member

  • Members
  • PipPipPip
  • 325 posts
  • LocationManchester UK

Posted 15 April 2012 - 10:59 PM

Hi, I'm still a bit newb with electronics so I could do with a little advice.... I have 2 types of transistor one NPN and one PNP, these are 2N3904 and 2N3906. What I intend on doing is using the 3.3v logic from my shift registers to provide the control source for the transistors. So the first question is, what size resistor would I need for this? I guess all I am trying to achieve using the resistor here, is to disipate any excessive current right? This is off the data sheet: VCEsat collector-emitter saturation voltage IC = 10 mA; IB = 1 mA; note 1 - 200 mV IC = 50 mA; IB = 5 mA; note 1 - 200 mV VBEsat base-emitter saturation voltage IC = 10 mA; IB = 1 mA; note 1 - 850 mV IC = 50 mA; IB = 5 mA; note 1 - 950 mV So to calculate the resistor value, do I use the VBE @ 1ma i.e. drop of 0.85v? (3.3v - 0.85v) / 1ma = R R = 2k5 (approx) ? So that is my guess to sink the netduino conntrol voltage. Next is to work out what resistors I will need for higher power circuit that will be switched accross the collector and emittor and this will be switching relays.... The circuit will be supplied with 12v 1amp, there will be 6 relays and 2 fans running off this supply. The relays have a 25ma current drop and can take between 3 and 36 volts to switch them on and off. The fans will take 12v and 120ma. There are also 6 status Leds, these are 12v rated and prewired with a resistor of some description and I have no way of finding out any more details. I do however have a meter, so if anyone can explain how, I guess I could test the voltage/current drop across the LEDs? So the next resistor to calculate is the resistors before the collector and after the emittors for the relays.... What would be the best way of spliting the power supply, parallel or series? If I did it parallel for example, would I treat each circuit as if it were supplied with the full 12v 1amp or is there still some variance to compensate that depends on the combination of transistors that are on or off?

#2 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 16 April 2012 - 03:52 AM

Hello Andy.
From what I understand, you have several kinds of load (relays, leds, fans, etc), and you'd to drive them by using transistors.

The very first task is to collect the voltage drop, and the current required from any of the various loads.
To check whether a particular load could be driven using the transistor mentioned, you should ensure that the required current is below the max allowed. For example, for the 2N3904 is 200mA.
Another check is about the voltage required by your load. If you have a certain supply (e.g. 12V), the load should also accept that voltage. You can't get lower (nor higher) the voltage using the transistor.
Just to be clear, when you connect a normal led, you do NOT change your supply. Instead, you accept it, and you use a resistor to limit the current.
So, if your supply is +12V, any of the loads must be supplied at +12V, without any problem.

Saturation.
The transistor saturation is a particular point of working, which is non-linear. It's useful just because the transistor acts as a switch: nothing more.
When a transistor is saturated, its VCE is very low (about 0.2V), thus it can be ignored from the load perspective.
How to keep the transistor in the saturation?
Simply applying the following formula:
IB > IC / hFE
That is, the base current must be higher than the collector current divided by the hFE, which is the transistor's current gain.
Since the collector current is a value imposed by the load (seen above), and the hFE is somewhat "unknown" a-priori, the simplest way is to use an over-current into the base.

Example.
Let's say your load requires 100mA when is +12V powered.
The required current is below the max allowed for the 2N3904, so you can use this transistor.
Now, let'see the specs: it has a current gain (hFE) of about 30 when the IC is 100mA. The VCE is about 1V, which is pretty higher than the expected 0.2V, but we could still forget the drop.
At this point, let's calculate the equivalent base current:
IB > IC / hFE = 100mA / 30 = 3.3mA
Now, you *never* should use the bound value, because any of the parameter could easily change, and the transistor can quit the saturation.
It's safer to keep the base current pretty far from the 3.3mA limit: let's take it twice or three times higher. Also depends on the current source.
Suppose to feed that current using a Netduino port, which is able to feed up to 8mA.
The base resistor is, correctly, from the formula you have used:
RB = (VDD - VCE) / IB = (3.3V - 0.95V) / 8mA = 293 Ohms
I guess you could use the closest standard value as 330 Ohms, which is still saturation-safe, but also make a bit less current flowing. Bear in mind that 8mA is about the max allowed by the Netduino, so it's better to avoid jump over that bound.

Hope it helps.
Cheers
Biggest fault of Netduino? It runs by electricity.

#3 mcinnes01

mcinnes01

    Advanced Member

  • Members
  • PipPipPip
  • 325 posts
  • LocationManchester UK

Posted 16 April 2012 - 08:43 PM

Thanks Mario!

So a little out with my 2k5! But I guess I was on the right lines with the last formula...

Any way, the estimated current drop of the relays (they are chinese and have absolutely no specs available but looking at very similar relays I guess I can go off this...)

They are opto isolators 25amp rated @ 250v min switching voltage is 3v max is 36v. At a guess the volage drop is around 2.5v and the current drop around 25ma. I have powererd these directly off the netduinos 3.3 through the shift registers with no resistors and haven't damaged anything. So I am going to go with these figures as a fair estimate.

In terms of the LEDs that will be in series with the relays to act as an indicator; that again is no straight science, they are prewire 12v rated but prewired means they already have a reistor. Is there any way I can check what current/voltage is been droped through the prewired LEDs?

Finally there are some 12v 120ma pc fans (2 of to be precice) I could again use the transistors I guess as they are under the 200ma rating of the transistors, but don't mind using something else like some little optos if you suggest them as being better? Although I guess you can safely deal with reverse current on the transistors with a diode right? Any way the pupose of listing the fans is purely to give background on what load the entire power supply will be dealing with.

Based on this how can I go about:

a, Working out the voltage/current drop for the leds and maybe more accurately for the Relays?

b, Once I have the rating for both the LEDs and relays how do I then work out the resistors required?

c, Are there any other considerations in this circuit (I have drawn a rough guess at the schematic see below) perhaps any other protection, and does the circuit have variance based on the number of relays/fans that are drawing current at any one time?

d, How do I distribute the supply 12v 1amp (or 12v 500ma I have both) and in thoeretical terms how does the current flow throughout the circuit (this relates to the above question about current variance) For example do you the transitors (and relays and leds) in series and the resistors change as you go along or do you have them in parallel and have equal reistor values and does the above mentioned variance take any bearing?

e, Finally the Fan circuit I appreciate is slightly different, these will be controlled via PWM either as suggested of the netduinos PWM ports or off the 2 remaining TLC ports. How would I go about this? Are there any examples you can give, and is it possible to use the same transistors with some diodes to catch the reverse current or would you suggest a better approach.

This is ultimately controlling mains voltage so I tend to sway towards 6;catious with things (like my overkill SSR 25amp relays and massive heat sinks).

Thanks again for all the help!

Andy

Posted Image

This was just my first attempt, at the bottom are 3 netduino digital signals (there is my 2k5 resistor there but this would be Mario's correct calculation of 330Ohm.

This shows 3 of the 6 transistors, you can see the netduino control logic signals at the bottom, then the gnd rail and the 12 rail at the top.

The 12v rail is split in parrellel and flows throug resistor A which is unknown, then the relay, then LED (this should be LED then relay on reflection as the LED has an unknown 12v rating) and finally any remaining voltage is removed with unknown resistor B.

#4 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 17 April 2012 - 03:52 AM

Here is a diagram on how to hook up relays using transistors:

Posted Image
Steve


My Other Hobby: Engineer Turned Baker

#5 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 17 April 2012 - 03:54 AM

most 5v leds will work fine with 200 ohm resistors. As long as the amps through the transistor is < the datasheet max then the circuit will be fine. If you have large loads they make beefier transistors like the ones mentioned in the picture above, or use a relay. Basically, you have netduino (arduino) output 3V3 which through a transistor gives you 9-12V which can flip a relay giving you 120V at 15 amps. With these steps you should be able to hook up whatever you want. Let me know if you need any other questions answered.
Steve


My Other Hobby: Engineer Turned Baker

#6 mcinnes01

mcinnes01

    Advanced Member

  • Members
  • PipPipPip
  • 325 posts
  • LocationManchester UK

Posted 21 April 2012 - 10:13 AM

Thanks for the info, could anyone tell me how to work out the currernt through one transistor if there are 6 relays and 6 led and 2 fans. For example is it even or is it dependant up on what is being used? I will check the exact voltage/current later today but for a theoretical example lets say each led drops voltage by 3v and 30ma, each relay drops 2.5v and 25ma and each fan drops 6v and 120ma. There are 8 circuits here 6 containing a relay and led and 2 containing a fan. How does the current flow through the curcuit? Does this vary based on which trasnistors are letting current flow through that part of the circuit? And if so do I need transistors that can cope with the entire current? How exactly should I split the power supply between the 8 circuits? Are there going to be heat considerations for 12v 1amp through 1 transistor (I don't necessarily mean the ones I mentioned earlier they may be a little weak for this application) or will it be an 1/8th of an amp? Do they get hot when they are stopping current flowing through them? How do you deal with resistors, for example if both the fans are off and 5 of the 6 relays are of so all the current is flow through one transistor, how do you deal with this for the relay and led in that circuit? Sorry for all the newb questions, but in terms of electronics I'm still really learning. Thanks again for all the help, Andy

#7 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 21 April 2012 - 10:15 AM

Add up the coil resistances and all other resistances. V=IR
Steve


My Other Hobby: Engineer Turned Baker

#8 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 21 April 2012 - 10:16 AM

Heating concerns with a transistor depend on whether the transistor is rated for your required load. You have to check its data sheet. They will be rated for X amps. If you give me a link to the datasheet or the name printed on your transistor I can tell you its rated amps / volts.
Steve


My Other Hobby: Engineer Turned Baker

#9 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 21 April 2012 - 10:25 AM

This is the second time I am writing this explanation b/c the stupid forum lost the message some how. Here it goes. Hopefully this should be a nice simple explanation for you. Never be afraid to ask questions. Ill even answer them after being up all night. Current can be visualized as moving from a higher voltage to a lower voltage. This convention is the positive current convention and is the main convention due to the fact current was at one time thought to be the movement of protons. However, even though this is not the case as electrons move through the circuit, the convention has stuck. Voltage should be though of the potential to do something. This is the same thing as water flowing down a hill. Water at the top of the hill has a lot of potential energy while water at the bottom has the least, or by convention normally 0. This is the same for circuits. Current flows from the higher voltage to the lowest it can reach, normally 0 volts or commonly refereed to as ground. And per your last question. If it is all on the same loop from a high voltage to a lesser voltage it HAS TO HAVE the same current going through the entire thing. If the circuit like the one below had different currents it would be generating energy and become a perpetual motion machine. +12V --> transistor --> Relay --> Relay --> Relay --> Fan --> LED --> etc. --> ground If you still need anything else explained just let me know.
Steve


My Other Hobby: Engineer Turned Baker

#10 mcinnes01

mcinnes01

    Advanced Member

  • Members
  • PipPipPip
  • 325 posts
  • LocationManchester UK

Posted 21 April 2012 - 02:53 PM

Hi Smarcus,

I have drawn up a fritzing, the resistor values haven't been set, but just to clarify, will the reistor value be the same for each of the transistor circuits i.e. would be relative to 12v 1amp?

Here is my fritzing any comments/ improvements welcome, one question though do you have 12v flowing into the transistor collector then out of the emitter to the leds etc and do you put a resistor between the 12v supply and the transistor or would you have the 12v supply go through a resistor, in to the led and relay then go through a transistor?

Finally for the last component in your circuit chain (i.e. the one next to ground) do you make sure the voltage/current coming out is near to 0v/0a?

Thanks,

Andy

Posted Image

#11 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 21 April 2012 - 06:10 PM

The resistors in each leg will be the same. I would also suggest that you color code your wires in Fritzing so that you do not mix up the hot and neutral wires (5v and gnd). Both the 12V and netduino's ground need to be tied together. The resistor value will be set based on the amount of amps and volts required by the relay's coil so that it can engage. The datasheet will give a current and voltage required. If you give me the datasheet Ill do the calculations in excel so that you can learn how to do them if you want. If you like my responses, please click the green pluses on them.
Steve


My Other Hobby: Engineer Turned Baker

#12 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 21 April 2012 - 06:24 PM

You also need a diode around each relay as shown above to stop backflow.
Steve


My Other Hobby: Engineer Turned Baker

#13 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 21 April 2012 - 06:50 PM

Here is how the circuit should be designed ...

Posted Image
Steve


My Other Hobby: Engineer Turned Baker

#14 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 21 April 2012 - 09:21 PM

Here is how the circuit should be designed ...

Posted Image


I think you got the diode and the LED the wrong way round smarcus3. The larger bit inside the LED is the cathode, and the line on the diode is the cathode.

Posted Image

Also I think it would be better to have the LED (and suitable resistor) on the output side of the transistor (in parallel with the relay coil and its protection diode), rather than on the base.

Paul

#15 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 21 April 2012 - 09:32 PM

Yes I just threw the LED in and didn't pay attention to its orientation. Per the placement, you could do that but I don't think it makes a difference. You need a resistor on the base anyway.
Steve


My Other Hobby: Engineer Turned Baker

#16 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 22 April 2012 - 03:50 AM

I agree with Paul about the led placement. By placing the led in the base wiring has almost nonsense. That's because the led itself causes a voltage drop of about 1.5V (depends on current), the B-E drop is about 0.8V. The sum is 2.3V, which is pretty close to the 3.3V given by the Netduino output. At this point you'll have just 1V of drop on the resistor, over 1kOhm: it's 1mA. With 1mA the led is perhaps visible, but far from being well bright. The diode in parallel to the relay is also reversed. Please, note that you should declare what is the transistor pinout. In this case you are assuming it's: E-B-C (left to right), but not every transistor is the same. For instance, the BC337 is C-B-E (left to right). Cheers
Biggest fault of Netduino? It runs by electricity.

#17 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 22 April 2012 - 06:39 AM

I am more used to the arduino platform where you get 5V, but I use those LEDs to just tell me which pins are activated. Thats it. I do agree with the placement if brightness is a concern.
Steve


My Other Hobby: Engineer Turned Baker

#18 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 22 April 2012 - 07:08 AM

Yes I just threw the LED in and didn't pay attention to its orientation.

Per the placement, you could do that but I don't think it makes a difference. You need a resistor on the base anyway.


LEDs aside, the placement of the protection diode in your fritzing sketch is dangerous.
If you switch to the schematic view in Fritzing I believe you will see the diode is the other way up to the famous relay diagram you linked to above.

As you currently have it, when(if) the transistor turns on the diode will conduct and little or no current will flow in the relay coil. A very large current will flow through the diode and transistor until one of them breaks down.

It must face the other way (the line needs to be facing the positive supply).

Sorry if it feels like you are being ganged up on - I am not trying to ridicule you, I just want to make sure Andy gets everything in the right place.

Regards - Paul

#19 mcinnes01

mcinnes01

    Advanced Member

  • Members
  • PipPipPip
  • 325 posts
  • LocationManchester UK

Posted 22 April 2012 - 05:33 PM

Hi,

Thanks everyone for all the help, I know this is a rather simple concept but understanding this will help me no end with all my projects.

Taking in to account all of the advice and comments you have given I have had another go and have redrawn the fritzing.

To calculate the actual resistors I have gone off the following (which are actual values)

LEDs: 2v Fwd/ 30ma Fwd
Relays: 2.5v Fwd/ 25ma Fwd

Resistor:

(12v - 2v - 2.5v) / (30ma + 25ma) = 7.5v/0.055a = 150Ohm +/- 10%

Does this look right? And is there any other comments, suggestions or additions you would make?

PS Red wires are mains live, green main earth (neutral is not shown but can be assumed to be split for each IEC.
Brown is positive from the 12v supply and blue is the ground for the 12v supply.
The 12v gnd and netduino ground are tied together.

Thanks again,

Andy

Posted Image

#20 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 22 April 2012 - 05:39 PM

I drew that to reference the hand drawn diagram and didn't make sure all the components were perfectly placed. Once again. Reference my first post which has been correct the whole time. Next time Ill take my time to make sure the 'rough' drawings wont be misinterpreted.
Steve


My Other Hobby: Engineer Turned Baker




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.