Showing posts with label Electronics. Show all posts
Showing posts with label Electronics. Show all posts

Saturday, October 1, 2011

Electronics Part 4: DCC Wiring

First of all, I apologize for not having this post up on Monday. It has been a crazy week for me, because the textbook for one of my classes came in on Monday and I had a lot of homework to make up for it. Anyways, better late than never, right?

This is my last electronics post, and I will focus on DCC. Many people use DCC on their layouts because it is extremely versatile and user-friendly. However, many people do not use DCC because of the high price and because of fear. Many people believe that DCC is complicated and impossible to wire without an electrical engineering degree. I am writing this post to tell the world that this is all false. Wiring a layout for DCC is as easy as pulling it out of the box and plugging it in.

Before DCC, people would wire layouts using DC block control. To run more than one train at a time, you had to divide the layout into electrical blocks to power the tracks. Power then had to be routed from the appropriate throttle to the appropriate electrical block, and this was done through extremely complex switching circuits with more toggle switches than you can believe. People with small switching layouts would wire the entire layout on one electrical block, or very few, to minimize how complicated the wiring could get. They would simply run feeders to all the tracks and anything that was on the layout would move. DCC changed all that. With each locomotive having its own address, you could now run any train you wanted, wherever you wanted, without the complex switching logic. Many people believe that because DCC is a more complicated power source, it must be more complicated to set up.

DCC is simple. Wire they layout as if you were putting the whole thing on a single DC block, and then connect the bus wires to the DCC power source. Plug in the throttle and you're good to go. It really is that simple. Bigger layouts often need boosters so more power is available for more trains. These simply get wired the same way. More detailed instructions can be found in your DCC owner's manual, but it is not hard at all.

The harder part is the decoders. One drawback to DCC is that every locomotive must have a decoder. The decoder takes the DCC signal and does all the fancy stuff to make the locomotives go and give you control over lights and sound. Many locomotives today come with DCC on board or DCC ready. When DCC comes with the locomotive, simply program and address into the decoder and you're good to go. DCC ready means there is a plug inside the locomotive. Buy a decoder, plug it in, program an address, and you are good to go. It gets tricky when you buy a locomotive that is not DCC ready, but even this isn't that hard when you get used to it.

National Model Railroad Association (NMRA) made a set of standards when DCC was becoming popular. They standardized the color coding for decoders, so no matter what decoder you buy, the color coding is the same, which makes installation easy. The color coding is as follows:
Red wire: right side electrical pickup.
Black wire: left side electrical pickup.
Orange wire: right side motor lead.
Grey wire: left side motor lead.
Blue wire: Common (positive) wire for all functions.
White wire: Front headlight, negative lead.
Yellow wire: Rear headlight, negative lead.
Some decoders also have a green and a purple wire, which are the negative leads for ditch lights. One wire goes to the right side ditch light, the other to the left side ditch light. It does not matter which wire goes to which light.

James wrote an article back in December about installing a decoder and lights in an Athearn locomotive that was not DCC ready. Click here to read that article.

I will not get into programming too much, because that is a beast that is different with each DCC system and decoder that you use. You can usually find the manual for your decoder online, which will tell you how to do both basic and complex programming with your decoder to make your trains do all sorts of cool stuff. I will, however, talk a little about what is available.

First and foremost, your decoder needs an address. This is a 1-4 digit number unique to that decoder. Most decoders come factory programmed as address 03, but you can program it to anything between 0 and 9999. Most people program their decoders to correspond with their locomotive numbers so they are easy to remember. Next you need to program your lights. Front and rear headlights are usually factory programmed, but ditch lights often need to be programmed by the user. Your decoder's manual will walk you through that process, as it is different for each decoder. You can also set acceleration and deceleration variables, which allow the locomotive to slowly build up speed or coast to a stop. This can take some getting used to, but really enhances the realism of your models. You can set a starting voltage, peak voltage, and sometimes a mid voltage, which are the voltages that end up going to the motor. For example, if you find that your model locomotive reaches its prototype's maximum speed at 10.7 volts, you can program your decoder never to send more than 10.7 volts to the motos so the model cannot go faster than the real thing. Many sound decoders come with several sound options, which you can choose from during programming. Again, your decoder's manual will walk you through all this.

Well, that's it for my electronics series. I hope it has helped you understand electricity and how to use it for model railroading. Next week we will start getting back to the product reviews and tutorials we normally write about!


Monday, September 19, 2011

Electronics Part 3: Electronic Components

Last week I mentioned relays. We are going to talk about those this week, along with switches, light bulbs, LEDs, diodes, resistors, and turnout motors.

I'll sart with the simpler stuff and work my way to the more complicated. Light bulbs and LEDs give off light. We all know this. Last week I showed you how to use them as headlights. They can also be used as marker lights, interior lights, structure lights, signals, or indicator lights for panel boards using similar circuits that I used yesterday. They all have a voltage and current rating. If the voltage rating is below the voltage of your power source, you need a resistor, which I showed you how to do last week. I also showed you how to put two LEDs or bulbs in parallel on the same resistor. You can also put them in series with each other. For example, the 2 volt LEDs that I use can be wired without a resistor at all if I put 6 of them in series on a 12 volt power source, because each of them uses 2 volts so the whole string uses the full 12 volts.

Diodes let current pass in one direction but not the other. An LED is actually a diode that emits light (light emitting diode) but we don't often use them as diodes. Diodes can be used in locomotives with DC power to establish directional headlights. Reversing the locomotive in DC mode means reversing the polarity, so putting a diode on the front headlight means it only lights when the locomotive is going forward. The same can be done with the reverse headlights. Diodes have many uses in electronics, but not a lot in model railroading.

Resistors are just that...they use up electricity and do nothing. But they are very helpful. We use them to drop voltages to useable levels. They are not polarity or voltage sensitive, which makes them easy to use. Simply put them in the circuit in series with whatever needs a lower voltage, and you're good to go. We covered the calculations involved two weeks ago.

We all know what a switch is, but let me introduce you to a few different kinds. All switches have a common terminal and one or two travelers, or switched leads. Some switches have multiple poles, which means they have multiple sets of what I just described. Switches are used on panelboards to route power to different places. They can turn interior lights in structure on or off, they can throw powered turnouts, they can change signal indications, they have many uses. Rotary switches are switches with more than two possible positions. They can be used for complex yard ladders to select which track you want to go on and throw the turnouts accordingly. That is a more complicated circuit that I have not tried, so I will not talk about it. There are two good articles about it in recent Model Railroader issues if you want to look it up.

Turnout motors are used to automatically move the points of a turnout with the throw of a switch on the panelboard. They work by reversing the polarity on the motor, which moves a stiff wire, which moves the points. Reversing the polarity can be done in two different ways. The easy way is to take a double pole, double throw switch (a toggle switch with six contacts) and connect the two motor leads from the turnout motor to the two common leads on the switch. Next, connect the power source to two of the traveler leads, both on the same throw but opposite poles. Next, connect those two travelers diagonally across the switch to the other two travelers, so the polarity is reversed at that point. That way, when you throw the switch, the polarity to the switch motor changes.

A second way to accomplish this is by using a 2 phase power source. This is easier to do than it sounds. Simply take two identical 12 volt DC power sources and connect the negative on one of them to the positive on the other. This creates a common wire, and the other negative and positive left over create the negative and positive wires. Now you get 12 volts DC at opposite polarities across either the negative and common wires or the positive and common wires, and you get 24 volts DC across the negative and positive wires. A similar setup, but with AC, is what gets you both 120 volts and 240 volts in your house. Take the common wire and connect it to one lead on the turnout motor. Take the negative and positive wires and connect them to the two travelers on a single pole, double throw switch. Connect the common lead on the switch to the other motor lead on the turnout motor. Now you can change the polarity to the turnout motor.

Turnout motors have another useful feature built into them. They have a relay, which is nothing but an electrically or mechanically activated switch. They have a common and two travelers, or two commons and four travelers, like any toggle switch. These can be used to change signals, they can throw other turnouts on complex yard ladders, and on DC powered layouts they can be used to not allow power to the track that has the turnout set against it. However, turnout motors aren't the only place you can find relays. If you need more then the two sets of contacts on the turnout motor, you can buy relays on websites such as allelectronics.com. I've used some relays from there and they work great. Just make sure the rated voltage and current is what you need.

That brings us back to where I left off last week. I wanted to run ditch lights on both ends of my locomotive with only 2 available functions. To do this, I got a double pole, double throw miniature relay. I connected the wires for the reverse headlight function to the reverse headlights and to the relay coil. I connected the wires for the ditch light functions to the commons on the relay, and then the travelers went both forward and backward from the relay to light the ditch lights. Now, when the forward headlights are on, the relay coil is not energized, and the power for the ditch lights is routed to the front of the locomotive. When I change the direction of the locomotive, the reverse headlights come on, the relay coil is energized, and power for the ditch lights is routed to the back of the engine. This is all done through the magic of DCC, which I will talk about next week in the last installment of this series.

Monday, September 12, 2011

Electronics Part 2: Model Railroading Applications

So now that I've thoroughly confused you last week, let's clear it up a little this week and talk about something more familiar: model trains. Specifically, what on earth does last week's post have to do with model trains? Well....

Let's look at something I've been working on recently. Most of my locomotives don't have working headlights, and I want to fix that. I want LED headlights because they look great, but I can't afford the prices that some of these manufacturers charge. Instead I found a website that sells LEDs and other electronics cheap, but they aren't marketed for a specific purpose. Because of that, the manufacturers can't know what the applied voltage will be on the consumer end, and can't make a resistor recommendation to the customers, meaning I need to figure out what resistor size to get on my own. The manufacturer does, however, say that the LEDs use 2 volts and draws 20 milliamps, or 0.02 amps.

Let's set up the problem. We have a few knowns: First, we know that the LED takes 2 volts. Second, we know that the applied voltage is 12 volts. Because of this, we know that we need a resistor in series with that LED, and we know this resistor must use up 10 volts. We also know that the LED draws 0.02 amps, and because this is a series circuit, we know the resistor and power source current values are also 0.02 amps. So the two things we need to know are the resistance value and power consumption of the resistor so we get the right size. Let's draw a diagram:

What we need to know are the two unknown resistor values, which is easy to figure out. To find resistance, simply divide voltage by current, or 10 volts divided by 0.02 amps. This gives us a resistance value of 500 ohms. To find power usage, multiply voltage and current together for a power value of 0.2 watts. You should never buy a lower value resistor than you need, so if the value you need isn't available, get the next higher value. I bought 510 ohm resistors rated at 1/2 watt just to be on the safe side, and they work fine.

This circuit is great for a single ditch light. You will need two of these circuits, wired on separate functions, for a flashing ditch light effect. I will not get into the programming in this series, but I will cover it at some point. However, my locomotives have two headlight bulbs, one just above the other, and I need an LED in each one. I could use two of these circuits wired to the same function, but I think it is easier to run both LEDs off the same resistor. However, this changes the resistor value, so let's take a look at that circuit.

This is called a series-parallel circuit, because the two LEDs will be in parallel with each other but both in series with one resistor. This complicates the math a bit. Let's identify our known values and fill in a diagram, and I will walk you through the math. First, we know the source voltage is 12 volts. We are using the same LEDs, so we know they use 2 volts and draw 0.02 amps each. They are in parallel with each other, so the voltage stays the same, so the resistor still has to use 10 volts. However, the current is additive in a parallel circuit, so now we have 0.04 amps going through the resistor instead of 0.02. Let's draw a diagram:

This problem looks more complicated, but it's actually just as simple as the last one once you sill in the knowns. We are looking for the same values as last time, the resistance and power ratings of the resistor, and we will find them the same way. Let's divide 10 volts by 0.04 amps. This gives us a resistance value of 250 ohms. Multiplying our voltage and current together gives us a power usage of 0.4 watts. Again, we will use the next higher available value, so in this case I bought 270 ohm resistors rated at 1/2 watt and they worked just fine.

One last thing on my headlight project. My fictional railroad, the Merrimack & Souhegan Railroad, is a short line based in southern New Hampshire. Because the branch lines do not have turning facilities, and the locals are run as turns and in most cases with a single locomotive, this means that most road switchers on my layout will have to run long hood first pretty regularly. This means that they need ditch lights on both ends of the locomotive. In real life this is a common practice in New England. However, since each ditch light needs its own function, that means I need four functions to run the ditch lights. Since I also need two functions to run the headlights, this means I need either a six function decoder, which is expensive, or a separate function-only decoder in addition to the motor decoder, which is also expensive. In both cases, I also have some advanced programming to do so that the correct ditch lights come on at the correct time. I am no master at programming and I don't have the money to spend on expensive decoders, so I sat down to figure out a way to use a regular four function decoder to run all these lights. And guess what? I did. I found a way to simplify programming, save space under the shell, and save money all at the same time by using technology that's been around about as long as electricity: the electromagnetic relay.

But that is next week's topic!

Monday, September 5, 2011

Electronics Part 1: Ohm's Law

Today I am starting a series on electronics which will likely go through the whole month. We are going to start with the basics, this week we are learning about Ohm's Law and how it works and how to make calculations based on it. Ohm's Law is the absolute most basic thing there is in electronics. Next week we will learn to apply Ohm's Law to modeling and learn about calculating LEDs and resistors. During this series, we will also discuss turnout motors, signals, switch logic, and basic DCC wiring.

Before we get into Ohm's Law, we need to define four types of measurements. These four terms will be used constantly, and it is important that you know what each one is.
Voltage, measured in volts (E), can be compared with water pressure in a pipe. It is not a measure of how much electricity there is, but the "pressure" behind it. In most model railroading applications, the voltage is 12 volts. However, some light bulbs and LEDs use much lower voltages, which we will discuss later.
Current, measured in amperes or amps (I), is a measure of how much electricity a circuit uses. One light bulb takes a certain amount of current to operate correctly. Two light bulbs use twice as much current. Again, we will discuss in more detail this later.
Resistance, measured in ohms (Ω or R), measures how much the circuit fights back. The circuit components are always trying to block the flow of electricity, and resistance is the measurement of the blocking. However, this is useful. Using a resistor, we can bring down the voltage to light an LED. There are more applications as well, which we will discuss later.
Power, measured in watts (W), is actually a measure of energy, not specifically electricity. Power is not actually defined in Ohm's Law, but it is another measurement that we will use. Unlike voltage and current, which can be changed, power is a direct measurement of how much energy a circuit uses based on what is on the circuit. Energy cannot be created or destroyed, only transformed.

Ohm's Law can be defined as "The current in a circuit is directly proportional to the applied voltage and inversely proportional to the circuit's resistance." So what does that mean? Well, let's break it down a bit: the law defines three things, the current, the voltage, and the resistance, and how they are related to each other. "directly proportional" indicates multiplication, and "inversely proportional" indicates division. Let's make a few equations based of this law:
E=IxR
I=E/R
R=E/I
We can also define how power is related to these other measurements:
P=ExI

Let's take a 60 watt light bulb and figure out what the resistance is and how much current it draws. We know two of the numbers, so let's start with that. We know the voltage is 120 volts and the power is 60 watts. By rearranging the P=ExI formula to solve for I, we get I=P/E. We know P and E, so let's divide 60/120. This gives us a current of 0.5 amps. Now that we know both voltage and current, we can find the resistance. By dividing voltage by current, or 120/0.5, we get a resistance of 240 ohms. There, just like that, we figured out a simple light bulb.

However, most circuits are a little more complicated than that. There is a good trick to remembering those formulas:

So what do these circles mean? Easy. The top half divides with one of the ones on the bottom to find the other one on the bottom. The bottom two multiply together to find the top one. So if you are looking for current (I) and know voltage (E) and resistance (R), the first circle tells you to divide voltage by resistance to find current. If you want voltage, multiply current and resistance together. If you want resistance, divide voltage by current. The second circle works the same way, and is used when you know or want to know the power. The formulas can be hard to remember, but the circles are easy. Just draw the circles on the top of your paper before solving the circuit.

Speaking of solving circuits, let's get started with that. Let's use another light bulb, how about a 100 watt bulb this time. This animation will walk you through the steps:


Simple enough, right? Wrong. That's just the basics. There are also series circuits, parallel circuits, and there's even circuits with both. Series and parallel circuits introduce some new rules in the math. Let's start with a series circuit.

In a series circuit, you have more than one device on the same line. That way, the electricity only has one path to get back to the power source: through both devices. Because of this, the voltage gets split between the two devices, and the current passes through both. So to solve a series circuit, here is how the measurements of the different devices interact with each other:
Voltage is additive. If one device uses 60 volts and the other uses 20 volts, the total voltage will be 80 volts.
Current stays the same. If the total current is 5 amps, it will be 5 amps at each device.
Resistance is additive, just like the voltage.
Power is additive, just like resistance and voltage.

Let's take a look at a strand of Christmas lights. You know, those annoying things that manage to tangle themselves every year? We all spend countless hours trying to figure out which one bulb is dead, because that one bulb shuts off the whole strand. This is because these bulbs are wired in series. There is only one path for the current to follow, and if one bulb is dead, the path is broken, or open. All the bulbs have to be working for the circuit to function, or close. Most of the math is the same as before, so rather than doing a whole diagram again, let's do a more simple problem.

Most Christmas light bulbs operate in 2.5 volts. We wire them in series because we plug them into a 120 volt wall outlet. Because voltage is additive in a series circuit, having enough of these 2.5 volt bulbs strung together in series will add up to 120 volts and we can safely plug the strand into a 120 volt source. So how many of these light bulbs have to be in series to go on a 120 volt source? Let's figure it out. This is a simple problem, all we really have to do is divide 120 by 2.5. That gives us 48. So in order to safely operate 2.5 volt light bulbs on a 120 volt source, you must have 48 of them in series with each other to use up the voltage. Current, however, works differently. There is only one path for the current to take, through each light bulb, so the same electricity in the first bulb lights up all 48 bulbs on the strand. In a series circuit, current stays the same everywhere on the circuit. Assuming a resistance of 8 ohms per bulb, which is a normal value for these bulbs, and multiplying that by 48 (remember resistance is also additive in a series circuit), we get 384 ohms. Now that we are talking about total resistance, we must divide the total voltage of 120 volts by 384 ohms to get our current of about 0.3 amps. Each bulb on the strand uses 0.3 amps, and the total usage of the whole strand is also 0.3 amps. Multiplying this by the voltage tells us that the whole strand uses a mere 37.5 watts.

Series circuits are easy. But we don't use them a lot. Parallel circuits are used more. This is when two or more devices are wired together so that there is a separate current path for each one. That way, when one goes out, the rest can stay lit. However, there is a new set of rules for this type of circuit, which is a little more complicated.
Voltage stays the same in a parallel circuit. If the source voltage is 120 volts, the voltage across each device will also be 120 volts.
Current is additive. If one device draws 3 amps and another device draws 5 amps, the total current will be 8 amps.
Power is also additive.
Resistance is where it gets complicated. Resistance can be calculated by the following formula:
Rt=(R1 x R2)/(R1+R2)
where Rt is total resistance, R1 refers to one resistor, and R2 refers to another. To simplify things a little, if all resistor values are the same, you can simply take the value of the resistors and divide that number by the total number of resistors in the circuit to get total resistance. You might be thinking, this doesn't make sense, the total resistance is lower than each resistor! Well, that's true. As more paths are created, it is easier for the electricity to get back to the source, and so the total resistance of the entire circuit is lower than any path individually. Remember also that current is inversely proportional to the resistance, so as the resistance goes down, current goes up, meaning the circuit uses more electricity with more available paths, which is normal.

Let's take a look at an easy parallel circuit. Again, I won't draw a diagram. We will look at more complicated circuits next week, and I will use diagrams then. But for today, let's do an easy one. Let's take two 100 watt light bulbs and put them in parallel with each other on a 120 volt source, and figure out what the total resistance and total power consumption will be. You can get around the hard math by using the total power (100w plus 100w is a total of 200w) and the source (total) voltage, but let's do it the hard way by using the resistance values of the bulbs. We know that the voltage at each bulb is 120 volts because it is a parallel circuit. We also know the power consumption at each bulb is 100 watts. If we divide 100 watts by 120 volts, we get about 0.83 amps at each bulb. Current is additive in a parallel circuit, so we now know that the total current is about 1.67 amps. The resistance of each bulb can be found by dividing voltage by current, or 120 divided by 0.83, which gives us about 144.58 ohms. Both light bulbs are the same, so both resistance values are the same, so we can simply take the resistance value and divide it by the number of bulbs, or 144.58 over 2, to get a total resistance of 72.29 ohms. We've already figured out our total current one way, but now that we have new numbers, let's check our math by dividing 120 volts by 72.29 ohms. This gives us a current value 1.66 amps, close enough when you consider that we rounded our decimal values during the problem.

Clear as mud? Well, that's all for this week. If you're confused, reread this a few times or make up some practice problems if you want. Next week we will cover more complicated circuits and apply what we learned this week to some common model railroading problems. I hope I haven't made you give up on electronics completely!