Please, ask your questions in the forum, this is a Sticky and NOBODY reads the Stickies (well, not every day) Electronics, for the Modder Introduction: This guide is to provide an introduction to basic (and maybe some advanced) electronics for the computer modder. How to add lighting and other stuff running off a 12V or 5V supply and some FAQ answers. Some of the info is in this thread, or links will take you to coverage from other threads. Please ask here or by PM for any general topics you think should be included in the guide, but post specific questions in the main forum. Contents: Basic Electricity 101 and Ohm's Law - Power sources - PC Molex connectors, external mains adaptors, batteries. Materials - what sort of wire to use, connectors. Common Passive Components - switches, relays, resistors, capacitors, transformers and inductors. Active Components - diodes, transistors and ICs, thyristors and triacs - LEDs and opto-isolators. Using a transistor as a switch or as a tap. Wiring up LEDs More
Basics: Voltage, Current and Resistance Voltage, Current and Resistance are difficult to describe but the most common analogy is of a water pipe where: Voltage would be the force that is pushing the water (electrons) forward - the head of water or water pressure. Voltage is another term for Potential Difference, and to find a voltage you subtract the highest or input voltage from the lowest or ground voltage (commonly 0) - just as you can measure water pressure by the difference in water levels in a U-tube manometer. Potential Difference (p.d.) is measured in Volts(V) and usually expressed as V. Current through an electrical circuit is like the flow of water moving through the pipe - the higher the voltage (pressure) the higher the current (flow) for a given circuit (pipe). Current is measured in Amperes or Amps (A) and usually expressed as I. Resistance is a measure of how easily the current can flow. Anything that causes an opposition to the flow of current in the circuit increases the resistance, just as water in the pipe is slowed by narrow sections. Resistance is measured in Ohms, usually expressed as R. Ohm's Law shows the simple relationship between voltage, current and resistance, V=I x R I=V/R R=V/I Most people remember it in a triangle with V at the top and I and R underneath. Along with Ohm's Law is the Power Law, Watts = Volts x Amps, W = V x I W = V2/R W = I2 x R Series and Parallel Circuits A circuit is a group of connected components and a path for electrons to flow through. You can connect components together in two basic ways, series and parallel : Series: A series circuit is when the individual components are connected in a single line, When a circuit is connected like this, the total supply voltage between the ends is shared (often unequally) but the current is the same everywhere along the chain. Parallel: A parallel circuit is when the components are connected from a power supply by separate routes: When a circuit is connected like this the voltage remains constant between start and finish of each path but the total current drawn from the supply is shared out as required by the components on each path. For instance, if 'A', 'B' and 'C' were light bulbs and bulb 'A' needed 2A of current, with bulbs 'B' and 'C' needing 1A, then 4A of current would be drawn out of the battery, 2A of which the bulb 'A' path would receive, with 1A going through each of the 'B' and 'C' paths. The terms parallel and series are often used to describe where to place a component, if someone says "place X in series with Y" then X will directly follow Y, if someone says "place X in parallel to Y" then X will be connected around Y. Getting Power Luckily for the Modder, sourcing power (the first step in building a circuit) from the PC is easy and the most common and safe way is to use one of the Molex connectors that provides 12V and/or 5V power to devices in your PC such as the drives and fans. This is what a Molex Connector looks like: Yellow wire is +12V, the two Black wires are 0V and the Red wire +5V. You can buy a corresponding male connector (or often get an unneeded one with a fan purchase) to fit on your circuit's power leads, Other ways to give your circuit power are available such as batteries, mains adaptors and using other power leads from your PSU, such as the always-on 5Volt Stand-By line. Mains Adaptors Also known as wall-warts (the ones with built-in plug pins that plug straight into a mains socket) and power blocks (the ones with their own mains lead and plug). Three main classes: AC-AC : These transform the alternating current (AC) mains down to a suitable low voltage, but it's still a sine wave alternating both sides of 0V. Used for low-voltage filament bulbs like Xmas Tree lights, not much use for electronics, which 99% of the time needs a DC (Direct Current) supply. AC-DC Unregulated : Include a transformer as with the above, plus a rectifier bridge to convert AC to DC and a smoothing capacitor to level out the rectified waveform. Although cheap, the voltage accuracy is poor. They're rated to deliver a certain voltage at a certain current, say 12V 300mA, but at lower current demands the voltage rises steeply. Limited use as a general-purpose supply, but a 15V unregulated adaptor could be used with a home-made adjustable regulator module to give an accurate and infinitely-variable output voltage covering around 1.5V to 13V. AC-DC Regulated : In addition to the above parts there's a voltage-regulation section that holds the voltage steady over a wide range of current demands. Two main groups, the most common are linear with a standard mains transformer, these days Switch-Mode power supplies (SMPS), which are lighter in weight, more compact and more efficient energy-wise, are getting comparable in price. The ones to go for in most circumstances. What Rating? Here's a typical spec for some that Maplin sell: Code: [B]Specifications: [/B] Input voltage: 230Vac/50Hz Output voltage: See table below Output current: 400mA max. Dimensions: 92 x 56 x 76mm Order Input Output Output Code Power Voltage Power MG76H 2.4W 3Vdc 1.2VA MG77J 4W 4.5Vdc 1.8VA MG80B 6.4W 9Vdc 3.6VA MG81C 13.6W 12Vdc 4.8VA These are the 'Linear' type discussed above and you'll see the efficiency is very low - with the 12V model it's using 13.6W of input at 230V to get 4.8W output at 12V, the other 8.8W is wasted as heat. You'll also see the Power Law in action, Watts = Volts x Amps, so Amps = Watts/Volts = 4.8/12 = 0.4A = 400mA. The rating of an adaptor is the maximum current it can deliver without overheating. With lighter loads it will deliver whatever the load requires, it won't try to force that maximum down the wires. To find a suitable rating just add up all the individual loads you might want to connect to it at any one time and get the next size up. If in doubt go bigger.
Components 1: Power The most common symbols relating to power are shown below, for a basic regulated DC power supply. Starting at the left with V1, the mains supply, first in line is Switch SW1, a single-pole, single-throw (SPST) on/off type. The double-pole single-throw shown below would switch both Live and Neutral lines for extra safety. Next is a Fuse F1 to protect the PSU from faults giving a high current by 'burning out'. Size is picked to stand the expected load. Transformer T1 reduces the voltage from the mains supply into something safer for you to use, and consisting of two separate coils wound round an iron core, isolate the ingoing mains supply from the outgoing low-voltage one. Transformers only work with AC current and will not transform DC. The Bridge Rectifier BR1 contains four diodes arranged so the ingoing alternating current takes one path if it's going clockwise through the transformer, another if it's going anti-clockwise; either way it can only follow the arrows on the diode symbols and come out through the '+' terminal and back in through the '-' one. At this point we have a DC supply, but it's a series of half-sine waves dipping down to zero every half-cycle of the mains. OK for a car battery charger but no good for electronics. The large (4700uF) Electrolytic Capacitor C1 stores the energy during the upward-going period and releases it into the circuit as the wave drops, reducing ripple current. Electrolytic capacitors are cheap and give a high capacity in a small physical size, but they're polarised and must be connected the right way round or they explode! By this stage we have a reasonable DC supply but it's likely to dip in voltage if the load increases and is fairly "noisy" from the residual ripple for sensitive electronics. For greater accuracy and stability the Regulator RG1 controls the outgoing voltage to within ±0.5V. Finally the small (220nF) capacitor C2 removes any high-frequency noise from the supply and helps stabilise the voltage regulator. This is an unpolarised type (see the difference in symbol?) and can be fitted either way round. The 0V power line may be connected to mains safety earth (also known as 'ground') through the equipment case, as shown by the Earth or Ground symbol. Many audio amplifier circuits have both a positive and a negative DC power rail with a mid-point ground (as the audio signal being amplified is AC, it makes the circuit simpler, higher fi, and cheaper ). More on components later.
Components 2 More Switches Switches fall into two main groups, latching and non-latching (also known as momentary or biased). With latching switches, the contacts move to a new position and stay there until you operate the switch again, with non-latching the contacts go back to their original state as soon as you let go. They also come in toggle, operated by a lever, paddle or rocker; rotary, operated by rotating the control knob; and push-button, operated by, erm, pushing a button. The double-throw type SW2 will switch an ingoing line into either of two outgoings (or vice-versa as SW3), sometimes found with a centre-off position, and in single- or double-pole varieties. These could be used to switch a fan between 12V and a lower voltage, using the double-pole version to switch LED indicators at the same time. Rotary switches, sometimes called wafer switches, can have many more poles and throws (aka 'ways'), if necessary by adding more wafers to the shaft. Non-Latching (Momentary) Switches. The most common are push-button, but toggle switches too may be spring-loaded to return to one position after activating. In the catalogues, an (ON)-OFF description means it's only ON while you're holding the lever in place. With push-button, they're more often described as 'momentary-on' (push to make) or 'momentary-off' (push to break). Here's how the two types could be used together to control ON-OFF action by latching a relay, a very common system on industrial control gear. The relay needs to have two or more poles (the switches) which can be change-over (double-throw) or single-throw types. The "On" switch S2 is a push-to-make (momentary on) type, and allows power through to the relay coil when pressed. This becomes an electro-magnet and pulls all the relay switches over to the 'no' (normally-open) position. (With relays, 'normally-open' and 'normally-closed' refer to the switch positions with no power applied to the coil.) Relay switch Sw2 now keeps power running to the relay coil after the "On" button has been released, latching the relay into the 'on' position. Relay switch Sw1 is used to switch power to whatever load you have attached, (Extra relay switches would be used, for example, to control a 3-phase electric motor.) Pressing the "Off" button S1, a push-to-break (momentary off) type, breaks the power circuit, deactivating the relay electro-magnet and sending its switches back to the 'nc' (normally-closed) position. The diode D1 gives an easy path to any voltage spike produced when the relay coil turns off (back-EMF) protecting any sensitive equipment on the same circuit. More information on relays: Electronics in Meccano - a basic guide to how they work. Wikipedia - all the different types available.
Components 3 Resistors Resistors are a very common component in circuits with a few uses, To limit current; by Ohm's Law, if a resistance R is placed in a circuit, the current I through that part of the circuit can never be more than V/R, where V is the voltage available. (The current may be less than V/R if other components such as an LED are using some of the voltage.) To apply a selected voltage at a point in the circuit by using two resistors as a potential divider. The two resistors split the voltage between the extreme ends in the ratio of their values, so if you want to reduce a fan voltage to 8V, a resistor of half the value of the fan's resistance will do that; the 12V supply is split with 1/3 across the resistor and 2/3 across the fan. A very important point, potential dividers only work if any other resistance in parallel with either pot divider resistor is very much larger. When two or more resistors are placed in series, the overall value is their sum, but if placed in parallel, the overall value is 1/Rt = 1/R1 + 1/R2 Resistors values are normally abbreviated using a 'multiplier', for instance, 120R = 120 ohms, 4R7 = 4.7 ohms 10K = 10,000 ohms (10 kilohm), 6k8 = 6,800 ohms 1M = 1,000,000 ohms (1 megohm). 2M2 = 2,200,000 ohms Resistors are available in all values, but certain standard sizes are commonly stocked, known as the E12 and E24 series. These are much cheaper than trying to get a non-standard value. E12 series has 12 different values per decade (shown bold below), E24 includes these and fills in the gaps to make 24 values per decade. 1 Ohms, 10 Ohms, 100 Ohms, 1k0, 10k, 100k, 1M, 10M 1.1 Ohms, 11 Ohms, 110 Ohms, 1k1 11k 110k, 1M1, 11M 1.2 Ohms, 12 Ohms, 120 Ohms, 1k2, 12k, 120k, 1M2 1.3 Ohms, ... 1.5 Ohms, ... 1.6 Ohms, ... 1.8 Ohms, ... 2.0 Ohms, ... 2.2 Ohms, ... 2.4 Ohms, ... 2.7 Ohms, ... 3.0 Ohms, ... 3.3 Ohms, ... 3.6 Ohms, ... 3.9 Ohms, ... 4.3 Ohms, ... 4.7 Ohms, ... 5.1 Ohms, ... 5.6 Ohms, ... 6.2 Ohms, ... 6.8 Ohms, ... 7.5 Ohms, ... 8.2 Ohms, ... 9.1 Ohms, ... Actual values are shown by a series of coloured bands Sensors Sensors are any component that changes in value or produces a voltage output in response to changes in its environment. Light Light Dependent Resistor: The LDR's resistance increases as light level decreases. Cheap light-sensitive switching. Photocells (Solar Cells): Produce a voltage proportional to the light intensity they 'see'. Often used to charge batteries by sunlight. Photodiodes and phototransistors : conduct proportional to the amount of light falling on them. An LED mounted facing a phototransistor in a sealed box makes an opto-isolator, an easy way of interfacing with a motherboard with less risk of b0rking it. Heat Thermistor: A temperature sensor, as temperature increases resistance changes. With a PTC thermistor (positive temperature coefficient) the resistance increases with increasing temperature, with NTC thermistors (N = negative) the resistance decreases. Cheap and can be very small, good for electronics controlling a cooling fan's speed. Very non-linear, so getting a real temperature number needs a PIC to do the maths. IC chips: A few integrated circuit sensors such as the LM34, LM35 and LM335 are available that produce an output of 10mV/degree, with the degrees in Fahreheit, Centigrade, and Kelvin respectively. A linear scale and not difficult to make into a thermometer, main drawback is that the sensor is a bit bulky (small transistor size). Thermocouple: Two different metals or alloys fastened together at one point produce a voltage at that junction that varies with the junction temperature. Wires of two standardised compositions are welded together at their tips to give the sensor bead. Charts (and integrated circuits) are available to convert that voltage to °C. One common pairing, Type S, pure platinum and a platinum, 10% rhodium alloy, is used for temperatures up to 1480°C. Generally expensive and the voltage output is only a few millivolts, need precision instruments to measure. Come into their own at over about 120°C when the above two fail. Pressure Flow Diodes and LEDs Diodes are very simple, they only let current flow through them one way. They are commonly used to protect circuits from the effects of having batteries connected the wrong way round, smoothing or 'rectifying' AC current into DC current, protecting circuits from back EMF from relays and special ones called Light Emitting Diodes (LEDs) are very common as indicator lights. Standard Diode: Simply lets current flow in one way only. Zener Diode: Lets current flow in one way only UNLESS the current trying to pass through it in the opposite way (reverse-bias) is higher than a specific voltage this voltage will be different for different Zener Diodes (usually 2v - 20v). which you should treat as 6 seperate LEDs or with 3 pins which you should treat as a single LED (see symbol below). A Red Green Blue LED can generate all the colours in the rainbow (exaple circuit later in this guide). Thyristors Thyristors are small 3 legged 'discrete semi-conductors' they are used to latch. Transistors Transistors are small 3 legged 'discrete semi-conductors' they are used to SWITCH and AMPLIFY. The three legs are called: the BASE, the COLLECTOR and the EMITTER. When a voltage passes into the BASE of the transistor (this normally has to be over 0.6V) it lets current flow from the COLLECTOR to the EMITTER this is its SWITCHING fuction. When the transistor is in this state it AMPLIFIES the BASE current. So, lets recap, a transistor detects small changes in INPUT signal (BASE) and changes a bigger OUTPUT signal (EMITTER), for it to work there must be more than 0.6V on the BASE and power to the COLLECTOR.
Transistor - switch or tap? A transistor is often used to run a high-current device like a fan or several leds from a low-current output like an op-amp or other IC. You can connect the transistor two different ways depending on the effect you want. The left circuit has the load connected between emitter and ground. If the input voltage goes over about 0.6v the transistor starts to conduct. A small current from base to emitter allows a much larger current from collector to emitter and current flows through the load. Raising the input voltage raises the load voltage (and current) but it's always about 0.6v behind, so the 3.5v input only gives 2.85v output on my simulator. The ratio of the load current to the base current is roughly equal to the transistor gain value hFE so a 200mA fan loading, with the hFE=100 of a 2N2222A, will draw a base current of only 2mA. Example uses, for linear fan speed control and led throbbers. Right-hand circuit has the emitter connected directly to ground. Now when the input goes over 0.6v the transistor starts to conduct. With zero resistance between base, emitter and ground, a base resistor has to be used to limit this current to a safe value. Increasing the input voltage soon turns the transistor fully on (saturates it) so the transistor acts as a switch. The only voltage losses are the same 0.6v as above between base and emitter (which doesn't affect the load voltage) and a loss between transistor collector and emitter, which for a saturated transistor is around 0.2v (my simulator says 0.08v which is optimistic). You can also use a 5v logic signal to switch a 12v fan on & off. To ensure the transistor switches hard on, you make the ratio of load current to base current (set by the base resistor) to always be less than the datasheet transistor gain figure. Example uses are PWM fan control and boosting logic switch capability. NPN and PNP transistors in switching applications As said above, an NPN transistor starts to switch on when the base lead is about 0.6V higher than the emitter, so if the emitter is connected to ground (as with the NPN switch application above), a couple of volts signal voltage will turn it full on, a 0V signal will turn it off. And as said, a small signal current flows from base to emitter allowing a larger current to flow from collector to emitter. With a PNP transistor, it starts to turn on when the base lead is 0.6V lower than the emitter, and the emitter would be connected to the positive supply voltage for a switch, with the load between collector & ground. So you need to apply almost the full supply voltage to the base to keep it turned off, and drop the voltage a volt or so to turn it on. Signal current flow is in the opposite direction to the NPN, from emitter to base, again allowing a larger current to flow from emitter to collector and through the load to ground. To help remember, the arrow part of the transistor shows which way the base current flows, and the fact that it's a bit like a diode symbol shows the voltage difference across it has to get to about 0.6V before anything can happen. This means it's easy to control an NPN switching a 12V load from a 0V/5V signal, but not possible with a PNP.
Using LEDs 101 Using LEDs 101 This tutorial will take you through the basic steps of connecting LED's to your computer. First get everything you need together. LED's, wire, wire strippers, wire cutters, heatshrink tubing, fan splitter or single male molex connector. To connect up your LED's 10/0.10mm hook up cable (or 24G strand in the USA) is a good choice. Another source of suitable wire is 6 core alarm cable (not the solid telephone cable), which is available from most hardware stores. Just remove the outer sheath and use the single cores which happen to be the perfect size for wiring up your LED's. Now cut your wires to the required length, Strip the ends of the wires, Get your LED, and cut the legs to the required length, after checking which is cathode and marking it. The cathode is usually the shorter lead and near a flat on the plastic rim. Now calculate the required resistor value. I worked it out to be 435 ohms for my LED, and the nearest I had available was 470 ohms. The calculation is (Supply Voltage - LED Forward Voltage) / LED Forward Current (remember the forward current is often expressed in milli-amps, but the calculation requires the current in amps. One milli-amp is 1/1000 of an amp.) or use the Bit-Tech Calculator. Now, solder the black wire (or whatever colour you chose as 0V) to the cathode of the LED. I've used white tack to hold the LED and resistor in place for the photo, which works quite well. Then solder the resistor to the LED, and the red wire to the resistor. You will probably want to cut the resistor leads shorter than how they are supplied. Then cut some heatshrink tubing to a length that will be able to cover all bare connections and then slide the heatshrink tubing over the wires and over the resistor. And add gentle heat until the heatshrink is tight round the connections. The LED is now wired up and ready to go, but if you wish to plug it into a molex you need a fan splitter: Cut the end off and strip the wires. Now slide the heatshink tubing onto the wires and then solder them together, making sure you connect black to black and red to red - note that although yellow is the 12V wire on your molex, the 3 pin connector attached is usually colour coded red and black where the red is at 12V potential. Shrink the tubing and we're all done. And it works If you wish to connect several LED's in series, repeat the procedure but without the resistor on every LED. (resistor only needed on one of them) To work out the resistor value you need to add up the voltages of the LED's and use that voltage in place of the forward voltage of one LED in the calculator. The current will still be ~20mA though, NOT the sum of the currents. You can use as many LED's as you wish in series so long as the supply voltage is higher than the sum of the voltages of all the LED's. If you wish to use more LED's than that, you can construct several separate series circuits of LED's and connect each string to your supply. Happy modding!
Optoisolators Consist of an LED (usually Infra-red) and a phototransistor close-coupled in a DIL IC package. Commonly used to isolate two sections of a circuit for safety reasons. An example where you want to swap your case power or drive activity LED for something with a bit more bling, without endangering the motherboard. The optoisolator diode is connected in place of the case LED.
The thing about LEDs are that they are basically diodes. Diodes main function is to allow current in one direction and block in another. In order for this to happen, there is a current-to-voltage relationship. AKA Current-Voltage curve, that looks like this: Now, an LED is a rectifier diode that emits light while doing the basic diode duties. Because of the different chemistry, it has a much higher forward voltage than a rectifier diode when it starts to conduct - usually about 2.0V for red/green/yellow and 3.3V for blue/white. But when you apply voltage to a diode, it doesn't just automatically go to its operating forward voltage. Unlike a resistor, the current changes sharply with small changes in voltage and it will go beyond its safe current if too high a voltage is applied, which burns out the LED. In order to get the LED to stay at its operating forward voltage, you place a resistor in series to 'limit the current'. Hence, you take your supply voltage (ie 5V, 12V, whatever) and subtract the forward voltage from this. This is the desired voltage across the resistor you plan to 'limit the current' with. Taking that left-over voltage, you calculate the Ohms by dividing the voltage by the desired current you want through the LED. Doing this makes the LED draw just enough current till the resistor stops it from going too far (right about where the curve is most sharp). Another trick that people use is to put enough LEDs in series so that thier combined forward voltage matches the supply voltage. It takes advantage of how the current-voltage curve works. Even though this is viable, there is no protection if one of the LEDs starts fail and draws too much current through it at a lower voltage than nominal. Since there is no resistor to stop it from drawing more current, it soon becomes a BED: black emitting diode. This doesnt happen very often, but it still does happen. Considering how cheap resistors are and how easy it is to calculate which resistor to use ( R = [(supply voltage)-(LED forward voltage)]/(desired current) ) it makes little sense NOT to use the resistor to safe-guard the circuit.
Last night I was plaing with ohms law and found somthing was wrong...Well my voltage is 120V the resister I want to use is 100000 ohms and curent is 4.2amps.And I am tring to figure out how much that resister made the voltage drop and using the furmula V=4.2(I)*100000(R) I get V=420000.Now I am very confused so I ask what am I doing wrong and what should be the acual voltage.
You take 2 of the knowns and produce the third unknown. If your supply voltage is 120V (I hope you mean DC volts) and you use a 100kOhm resistor, this will limit your current to 1.2mAmps. When using these equations, you take the static unchanged values and go from there. Most voltage power supplies are regulated and thier values dont change. Resistors are designed to have specific resistance values. This means that the most flexible thing is the current. Now from the explanation used that you quoted, putting a resistor in series with another component will give you a specific voltage. First you will need to know the other components load resistance. You can find this by taking the voltage your giving it and deviding by the current it draws (which you will need to measure). Adding a resistor in series will increase the overall resistance and further limit the current going through both the resistor and the other component. From there, you should be able to calculate the over-all current (I = V/[Rload + Rseries resistor]) and using thatfind the voltage across the series resistor (V = I*Rseries resistor).
Most LEDs will fry if you pass more than 20mA through them Current is a function of voltage and resistance. More voltage over same resistance = more current. You can see it this way: You have got an ultra-cool water cooling system for your new PC. The pressure generated by the pump is voltage, the resistance of filters and whatnot is obviously resistance, and the amount of water passing a certain point per second is current. So when your pipe gets narrower, your resistance increases. Same with electronic resistors. Current is the amount of electrons passing a certain point in one second. The way to figure out if your PSU can handle it is to multiply Voltage and Current to get Power (W). So If you're drawing 20mA @ 12v you get 0.02A*12v = 0.24W or 240mW. Always use Base units (V, A, Ohm, etc) and not derived units (like mW, Kohm, etc) because that'll throw off your calculations. So running a couple of LEDs will cost you almost zero power from your PSU The way to see an LED is to envision a gate that only opens when the water pressure is above a certain point. When the gate is open though, it'll just let current pass. That's why you need a resistor before an LED, to stop too much current passing through. When the LED produces light, it will drop the voltage at an equal amount to it's forward voltage. So when you have 3 2.5v LEDs in series, you get a total voltage drop of 7.5v. When you're using a 12v rail, you get this: 12v -> LED1 - > 9.5v -> LED2 -> 7v -> LED3 ->4.5v ... So as you can see, you could add one more LED before the voltage is too low and the LED won't conduct anymore (2.5v LEDs remember?). But don't be fooled by lower voltages, you still need to limit the total current flowing through the LEDs to stop them frying. did that help?