Building simple circuits

Pelsea's picture

One of the joys of model railroading is it provides the opportunity and motivation to learn new skills. One skill many avoid though, is building electronic circuits. I admit circuit building is intimidating, and not terribly necessary since so much is available RTR, but it is particularly satisfying to turn on the power and see things light up (most DIY circuits involve lights) knowing you put that part together from scratch.

You do not have to go to engineering school to learn circuit building. In fact, many ee programs do not include practical circuit building-- all lab work happens on breadboards or in computer simulations. The best way to learn these skills is to get some electronics kits and put them together. If you are a guitar or bass player, an excellent sources for interesting kits is Build Your Own Clone, a company that specializes in classic and cutting edge stop boxes and effects. Their web site is a cornucopia of information-- especially see the "confidence booster" kit-- it doesn't do much (it's a simple volume control) but the instructions are a complete lesson in soldering and parts handling.  Another excellent site is Adafruit, which has a section called "learn' with guides to simple and complex projects and topics for the glow in the dark, performance art, Arduino widgets crowd. Another goto resource is SparkFun, which slants a bit more to the robotics fan-- all of the parts needed to build a stepper motor indexed turntable can be found here. Finally, (Definitely not least) is Make, which is a magazine/ publishing house dedicated to DIY in many forms. Their Electronics PDF bundle is a perfect resource for the beginner.

In addition to these, the web has thousands of tutorials and projects including the hobbyprojects.com Model trains section and a site full of circuits from Mark Rollins.

My intent with these notes is to let you get a toe in the water by showing how to build some very basic circuits*, starting with a simple track power detector. I'm not going to teach any theory here, just the actual building skills needed to make a schematic into a board.

pqe

*Suggestions welcome

Comments

Circuits

Great thread.

Been doing that since 1954 with first Heathkit.

Etched my own PC boards. Have bought some circuits through

http://home.cogeco.ca/~rpaisley4/CircuitIndex.html

Doing SMD circuits is a real challenge.

Rich

Vero board

I have used Very board for circuit building. There is an app for designing a circuit PC board. Google Vero board.

Rich

Pelsea's picture

Veroboard

Yes, Veroboard is a proto board with all pads in a row connected as a single strip. You then cut the strips where you don't want connections. You don't get as many wire jumpers, but it is more difficult to change your mind.

pqe

Tim Latham's picture

Good stuff!

Good information! Thanks!

Tim

Tim Latham

Mississippi Central R.R. "The Natchez Route"

HO Scale 1905 to 1935

https://model-railroad-hobbyist.com/blog/timlatham

 

Vero board

Just Google Stripboard Veroboard design software.

I got my supply from the UK vie ebay about six years ago. Price and supply was very resoanable.

Rich

 

 

 

Pelsea's picture

Think inside the box

The previous project was built on a panel, suitable for mounting on a fascia. Sometimes we want to put our projects in a full enclosure. Enclosures can be had in any size and shape from a pill box to a refrigerator, and made of plastics, aluminum, steel or more exotic stuff. You don't have to use purpose built enclosures, many household items of a box-like nature will do. (I once taught a class in building audio mixers in lunchboxes.) You should pick a size that can hold your circuit board without crowding. The convenience of a small footprint can cost you in building difficulty and reliability.

Here's the circuit of the day:

This is a version of the  DCC polarity tester I have already published. If you want to confirm you have wired your tracks with correct polarity, or if the polarity is being switched appropriately, this is the tool to use. This will be built with the point labeled DCC A buss attached to a green wire and an alligator clip, the B buss to a red wire, and the frog connection to a blue wire. Why these labels? The circuit is also handy for detecting the position of turnouts with powered frogs. Build it on a panel with the connections as shown, and the red LED will light when the turnout is one way and the green one otherwise. (To change the light colors, just swap the buss connections.)

The circuit works because the two DCC rails are mirror images of each other- when one is positive, the other is negative. If both sides of an LED are connected to the same rail, it won't light up, but if connected to the A and B rail, it will light half of the time. The D in LED stands for diode, and current will only flow when the anode (back of the arrow) is more positive than the cathode (the crossbar).

 

 

 

I've picked a pretty small box for this build, because there's not much in it. Here it is, along with the board and some of the parts:

I have already cut the board and drilled the box. I used the same procedure as before- cut the proto board to fit inside the box, clamp the board on the back of the box (foil side down) and use holes in the board to mark out the holes in the box. The mounting holes are 1/8" and countersunk for a 4-40 screw and the LED holes are just a bit bigger than 3/16". (Drill a 3/16" hole and touch it with a tapered reamer.)

As before, I dry fitted the board into the enclosure to align the LEDs for soldering. It is important to get the LEDs in right way around. The marking on an LED is pretty subtle, just a slightly flattened spot next to the cathode (crossbar) lead.

I used 1/4" standoffs, which can be tricky to persuade into place. (Remember those kid's games where you had to roll a marble into a hole by tilting the box?) For bigger projects I prefer to use standoffs that are threaded for 4-40 screws. Then they can be permanently screwed to the panel, with the board held in by screws in the back. I'll demonstrate that on the next build.

Next step, remove the board and add the resistor. One end of the resistor needs jumpers to each LED:

Here's a trick I use when soldering several short wires into a circuit. The wire is just bent around the lead it will connect to, and if the other end is loose it tends to flop around and may even fall off. If I use a long wire wire I can connect the other end for the next jumper. I solder both ends, then cut the wire to the appropriate lengths to finish both connections:

At this point I discovered a mistake. I had one of the LEDs in backwards. I had to remove the connections I had just soldered to turn the LED around. Solder is removed with solder-wik. This is a braid of fine copper wires saturated in rosin. If you lay it on a solder joint and heat everything, the solder will get wicked up into the braid and the part will be free.

Once that was corrected, I could get on with the build.

Next parts needed are the 1N415 diodes. They are there because while LEDs are diodes, they are not particularly good diodes. Some will pass a fair amount of current backwards. When I was testing early versions of this project, I discovered that if the frog wire was not connected one LED might glow a bit as the other leaked current from buss to buss. Adding two real diodes fixed that. The cathode on a normal diode is marked by a black or silver band. The part number is stamped on the side,and you have to look it up to discover details like power rating. The currents involved here are so small that practically any diodes will do.

Here is the board with everything wired in, including the wires to the outside world.

It's not shown, but those wires had to be threaded through the box before connecting, because the alligator clips were already on them.

And here is the finished box in action:

Next, something with an IC in it.

pqe

(Portions of this build were edited for narrative purposes.)

 

 

 

edfhinton's picture

Diode choice?

I was thinking of using this circuit, but the closest diode in the variety packs of electronic components I bought is 1N4148. Is that close enough for the circuit or do I need to buy the one listed?

Thanks,

-Ed

 

----------------------------------------------------------------------

Proprietor - Northern New England Scenic (V3). N scale NH B&M Eastern and western coastal routes in the late 1950s.

https://nnescenicmodelrr.com

 

Pelsea's picture

Diode choice

1N4148 is fine. That's probably the most common diode out there.

pqe

edfhinton's picture

Doing the math for the resister...

Sorry for so many questions - but I like to understand the details of anything I do.

So my question is about the selection of the 2K resistor.  I am trying to understand why that value.

Here is how I would have done the math, and I am hoping you can explain why I might end up selecting the wrong resistor if I went by my math. 

So the red and green LEDs seem to both be listed as between 1.8V and 2.2V forward voltage with suggested current of 16mA-18mA.  So playing it at the lower current end I started out figuring to shoot for 16mA.    Forward voltage for a 1N4148 is listed as1V.

Based on Ohms law with DCC being a 12V source, to get 16mA current I get:

R = V / I

R = (12 / .016) = 750 Ohms

But if I understand correctly I need also to account for the voltage drop across the LED and the diode. Using 1.8V for the LED and 1V for the diode, then the voltage drop across the limiting resistor I calculate as 12V - (1.8V + 1V) = 9.2V.  If so, then I would have.

R = (9.2 / .016) = 575 Ohms.  

In either case, of the resistors I have the closest that is greater than or equal to these would be a 1K resistor.

So doing the math the other way with a 1K resistor, I get:

I = (9.2 / 1000) = 9.2mA

My understanding is that the forward voltage drop may be a bit lower across the LED and diode at lower than their rated current, but just to be safe if I assume only the limiting resistor then I get:

I = (12 / 1000) = 12mA

which is still well below the rated range of the LED and diode.

So this leads me to ask, what drives the selection you made of the 2K resistor?  By my calculation, use of a 2K resistor would give me somewhere between 4.6mA and 6mA of current.  Is it simply a matter of LEDs performing well even at that low a current and wanting a higher resistor to cause less stress on the components?  Or is there something in my math or reasoning that I am misunderstanding that when applying these principles in other circuits later could cause me problems?

One last question - I have 1/4W and 1/2W resistors.  By my calculations, even at the rated max current (20mA) of the LED and attributing the full 12V voltage drop to the resistor, I get I*V = .24W, so given the lower current and the nominally lower voltage drop across the resistor I am guessing I can safely use a 1/4W resistor, but I wasn't sure how much leeway I should have on the power rating of the resistor and whether I should therefore go for the larger 1/2W resistor.

Thanks,

-Ed

P.S.:  As an experiment after initially posting this, since I was fairly confident the 1K resistor would not cause damage, I tried it out on the breadboard both ways: with a 1K resistor versus with a 2.2K resistor (I don't have any 2K).  In could not tell the difference by eye in terms of the light output of the LED.  So my guess is that the higher resister value is just to reduce power consumption and therefore might be better for long term life of the components - but I still would appreciate any lessons or advice you might have on my reasoning/math above as well as this conclusion I came to on why the 2K resistor.  

 

----------------------------------------------------------------------

Proprietor - Northern New England Scenic (V3). N scale NH B&M Eastern and western coastal routes in the late 1950s.

https://nnescenicmodelrr.com

 

Pelsea's picture

Your math is impeccable

However, we have to look at the peak voltage in the worst case. When the A rail is in its positive phase, the B rail is in its negative phase. (I'd put a diagram here, but I'm 2500 miles away from my computer.) The NMRA spec allows a voltage swing of +/- 22 volts, so the peak voltage can be as high as 44 volts. (When the A rail is +22, the B rail is -22.) With a 30 ma LED, 2k makes sense.  Typical for HO and O seems to be around +/-14 volts. You can adjust the resistor for your own situation, of course.

In any case, a 1/4 watt resistor will be fine.

pqe

edit-- After all of this was written, I discovered the the DCC spec was written in a confusing manner-- the actual voltage swing is 0-22 volts, with the +/- symbol indicating the two rails are out of phase. So Ed's math is exactly correct.

 


>> Posts index


Journals/Blogs

Recent Blog posts: