The Rusty Spike

A Railroad Fan's Website


Chasing Lights (74HC595 Register + TI Launchpad)

Okay ladies and gents, here’s a Chasing Light project using a single Shift Register (74HC595) and a TI Launchpad. (I’m currently following a line of research using the Shift Registers, but there is an easier way to do this with just a Launchpad alone.) It can be easily adapted for many uses. Examples include, but not limited to:

  • Theatre Signs
  • Airport Landing Strip
  • Eat At Dave’s Signs

This particular Launchpad project uses an external device called a Shift Register. Simply put, it’s a device that remembers the 1 or 0 you just put into. If you put another 1 or 0 into it, it shifts all the existing saved 1’s and 0’s over one slot and adds your newest value in. It can hold 8 values, hence the term 8-bits.

Here’s what it looks like when its all put together on a breadboard:

Chasing Lights v1.0 from claymore1977 on Vimeo.

Read More


TI: Yet More Free Samples

In between orders of Texas Instruments Launchpads evaluation boards from Mouser or Newark, Free Samples from TIdon’t forget that TI has a free sample program that can get you a couple free MSP430 chips of varying models. Combine the raw chips with the ability to power and run MSP430’s off the red Launchpad board, and you can have quite the small army of animation and automation circtuis deployed on your layout in no time and very low cost!

Just please remember to keep TI interested in manufacturing the MSP430 processors by actually buying a few now and then. I think that if the hobby of model railroading can provide a significant enough demand for the MSP430 line of microprocessors, then we could help keep the prices low and increase the online support for the Launchpad based chips. Currently, there far more resources for the Arduino. Some of which can be ported to the Launchpad, some cannot.


Pushbutton ‘Bouncing’ and How to Fix It

I recently ran across an article on the TI Wiki that does a great job explaining the strange behavior of a pushbutton when attached as an input to a Launchpad. I was getting very erratic pin HI LO readings when a pushbutton was pressed or released. I have re-posted some of the contents here on my blog for my own personal reference. The original author retains the copyright.

Bouncing occurs while a pushbutton is changing state and during the first few nanoseconds after state has stopped changing. It is a physical machine and the electrical contact is not perfect. We should not expect perfect electrical performance. Pushbutton Bouncing fixWhen controlling a light, LED, or motor directly, these bounce effects are so miniscule that they are often unnoticed. A microcontroller is extremely sensitive to electrical noise and pushbutton bounce is a bit of an issue.

Since bounce is simply unstable performance during state change, a capacitor can be used to smooth out performance. The picture shown depicts a pin (P1.3) attached to a pull up resistor and a pushbutton is used to ground the pin. Note the capacitor wired in parallel to the switch. Wired in this fashion, the capacitor acts as a ‘buffer’ to smooth out the poor electrical performance of the pushbutton.

Again, this information can be found in a bit more detail on TI’s information Wiki.


Basic Electricity 101: Intro

Welcome to Basic Electricity 101, a course for model railroaders. The aim of this series of tutorials is to teach basic fundamentals in a real language, not ‘geek’. That being said, each fundamental will be used in a real world application or two so as to help convey its usefulness. Well, enough talk, lets get to it.


Section 1.1: Terminology

To kick things off, I think we need to first just grit our teeth and nail down some good old fashioned boring definitions. There are only 6 definitions that I think are required knowledge for a model railroader to claim mastery over Basic Electricity:

  • Voltage: Voltage is electrical potential. Think of this as the pressure aspect of a piping system. Measured in Volts(V, mV, uV, KV, MV, etc) and is represented equationally by the Letter E.
  • Resistance: Resistance is a measure of resistance a circuit offers to the flow of current. Think of this as the Head Loss aspect of a piping system. Measured in Ohms (Ω, KΩ, MΩ, etc.) and is represented equationally by the letter R.
  • Current: A measure of the flow of electrons due to Voltage and resistance. Measured in Amperes, or Amps for short(A, mA, uA, KA, MA, etc) and is represented equationally by the Letter I.
  • Power: Electrical power is a measure of Work (or work lost, aka, inefficiency) that a component performs. Real Power is measured in Watts (W, mW, uW, KW, MW) and is represented equationally by the letter P.
  • Capacitance: The measure of an electrical components ability to resist a change in Voltage. Measured in Farads (F, mF, uF, KF, MF, etc.) and is represented equationally by the letter C.
  • Inductance: The measure of an electrical components ability to resist a change in Current flow. Measured in Henry’s( H, mH, uH, KH, MH, etc) and is represented equationally by the letter H.

Measures of the above parameters can be expressed using the metric system:

  • Micro(u): 1/1,000,000
  • Milli(m): 1/1,000
  • Kilo(K): 1,000
  • Mega(M): 1,000,000

To tie these terms together, lets examine a circuit:



In this schematic, a battery is supplying 12 volts worth of electrical potential and a resistor is offering 1 ohm of resistance to the flow of current. The voltage will then push current through the circuit in the direction labeled by I. We now need to stop and examine a typical misconception of current flow.

As humans, we understand things like gravity. Gravity causes water to flow from a high altitude to low altitude. As such, we typically want to think that electrons flowing through a wire will flow from a positive pole on a battery to the negative one. In reality, its exactly opposite. The positive side of a battery is positive due to the LACK of electrons and the negative side is negative due to the EXCESS of electrons. So they are indeed flowing from negative to positive. Weird eh? Tracking the electrons as they flow is called electron current flow, where as tracking the opposite of that, aka, the holes the electrons used to fill in the atoms, the you get a flow in the opposite direction, aka, hole flow. We also call this ‘hole flow’ conventional current flow.


Hole Flow:


Electron flow:


Due to our nature as human beings and for reason beyond the caring of the average model railroader, the human race has adopted the ‘conventional flow’ methodology as common practice. Flowing from positive to negative makes more sense anyway 🙂


Well, back to this schematic:


So the questions abound now: How much current is being drawn? How much power is being consumed by the resistor? Well, let Mr Ohm answer that for you:


Section 1.2: Ohm’s Law

Ah yes, you’ve probably heard of it, dreaded it, feared it… but here it is. And let me tell you, this is as simple as math can get. Plus Ohm’s law answers nearly 99% of the electrical oriented questions you may have asked over the years:


I = E / R

Where E = Voltage(Volts), R = Resistance(Ω), and I = Current (Amps).

Ohm’s law can be re-written to solve for any of the parameters:

I = E / R     Solved for Current

R = E / I     Solved for Resistance

E = I * R     Solved for Voltage


Now, understanding that this is still moderately meaningless, lets put it to use.

Example #1.1:


Given the circuit above, solve for I:

I = E / R     Ohm’s Solved for Current(I)

I = 12V / 1Ω     E = 12 Volts, R = 1 Ohm

I = 12A

Current is expressed in Amps, so our answer is 12 Amps.


How much voltage should we expect to see if we were to measure ‘across’ resistor R1?


Almost obviously, 12 volts.

Something to understand when analyzing a circuit is the assumptions you will have to make. A very safe assumption, when dealing with simple circuits such as these, is to assume that the positive pole of your power source is at full voltage, for us 12V, and the negative side is at 0 (zero) volts. (We do this for analytical purposes only. In reality, its slightly different for an ungrounded DC or floating ground System!) Zero volts is also referred to as ‘ground state’… not be confused with ‘an electrical ground’. We will discuss this later.

So if we start with 12V at the positive side, by the time we trace our circuit all the way back to the negative side of our battery we have ‘lost’ all of our voltage. This is called ‘voltage dropping.’ Since there is only one component in our circuit above, then Resistor R1 must be ‘dropping’ all 12V.

Section 1.3: Power

The most famous measure of electrical power is the Watt, and since its the most common throughout model railroading, we will discuss it exclusively (with the exception of a brief excursion into Volt-Amps). Power has many different equations suitable for many different situations, but for a simple 12V DC application, power is simply this:

Power = Volts * Amps

P = I * E     Power is easy as PIE… snort snort, sorry, geek joke.

Now, its also easy to use Ohm’s Law to adapt this equation to whatever parameters you have available:

P = I * E     Used when you only have the Voltage and Current components

P = (E)2 / R     Used when you only have the Voltage and Resistance components

P = I2 * R     Used when you only have the Resistance and Current components


Example #1.2:

You have a 60W light bulb in your hand. You know it runs off of 120V household voltage. Approximately how much amperage will it draw?

P = I * E     Initial Power EQN

I = P / E     Power EQN solved for Current

I = 60W / 120V     Value substitution

I = 0.5 A     Answer in Amps



Example #1.3:


Back to this circuit. How much power is resistor R1 using? Well, there are several different was to approach this, but since we have already solved for current in an earlier example, we can just use:

P = I * E     Initial Power EQN

P = 12V * 12A     Value substitution

P = 144W     Answer in Watts



P = (E)2 * R     Initial Power EQN

P = (12V)2 / 1Ω     Value substitution

P = 144W     Answer in Watts



P = (I)2 * R     Initial Power EQN

P = (12A)2 * 1Ω     Value substitution

P = 144W     Answer in Watts


So as you can see, there are several ways to skin the Power cat!


Example #1.4:


Lets change up the parameters a bit. Given this circuit, solve for Current and Power.

I = E / R     Ohm’s Law solved for Current

I = 12V / 6Ω     Value substitution

I = 2A     Answer in Amps


P = I * E     Initial Power EQN

P = 12V * 2A     Value substitution

P = 24W     Answer in Watts


Ah, now doesn’t that feel good to exercise those equations a tad? As a note of interest, the resistor in all of the previous schematics represents ‘any given load’ on an electrical system. Motors, lights, LED’s, servos, electro-magnets, etc.. all have resistance and therefore can schematically be represented as a resistor. Granted its probably more intuitive to a schematic reader to see a light represented as a light. 🙂


Example #1.5:


Oh ho ho, getting crazy now! Not really, its just the addition of several more voltmeters and one more resistor.

Adding resistance can be easy, but it can also be quite difficult. Resistors in series are simply added up. What is shown in example #1.5 is 3Ω + 3Ω = 6Ω. Parallel resistors are a tad more difficult, and we will address them soon, but not now.

What we are seeing here is the illustration of voltage dropping as it happens. The voltmeter measuring A to C is registering a full 12V, where as the ones measuring A to B and B to C are only measuring 6V each. Calculating the voltage drop of a component can be an exercise in the ‘chicken or the egg’ scenario as explained here:

We can use Ohm’s law to calculate the voltage drop of a component:

I = E / R     Ohm’s Law solved for Current

E = I * R     Ohm’s Law solved for Voltage

E = I * 3Ω     Value substitution. Note this is the resistance of the component we are solving for (3Ω) NOT the overall circuit resistance(6Ω)

But wait, we haven’t calculated overall circuit current yet!

I = E / R     Ohm’s Law solved for Current

I = 12V / 6Ω     Value substitution

I = 2A     Answer in Amps

Back to calculating the voltage drop of R1:

E = I * 3Ω

E = 2A * 3Ω     Value substitution

E = 6V dropped across R1.     Answer in Volts


Being able to calculate current and voltage drop is VITAL if you want to custom tune brightness and life span of any light bulbs you may have / want to put on your layout.

Example #1.6:

Given the schematic in example #1.5, consider R1 a resistor and R2 a light bulb:

If R2 is a bulb rated for 6V at 0.01A, then what is the required rating for R1 if you want to have the bulb drawing ‘rated’ current?

Firstly, solve for the light bulb’s resistance:

I = E / R     Ohm’s Law solved for Current

R = E / I     Ohm’s Law solved for Resistance

R = 6V / 0.01A     Value substitution

R = 600Ω     Answer in Ohms

And just for curiosity, solve for power of the light bulb:

P = E * A

P = 6V * 0.01A     Value substitution

P = 0.06W or 60mW     Answer in MiliWatts


Okay, we know we have a light bulb rated for 6V with an internal resistance of 600Ω, so now how do we make a 12V source give us only 0.01 amps? Well, we first should solve for the overall circuit resistance requires to limit 12V to pushing 0.01A:

I = E / R     Ohm’s Law solved for Current

R = E / I     Ohm’s Law solved for Resistance

R = 12V / 0.01A     Value substitution

R = 1200Ω     Answer in Ohms

Ah good, we see that a 12V power source needs 1200Ω of resistance to limit current to 0.01A (10 mA). So if we need a total of 1200Ω, and the light bulb has a calculated 600 ohms internal resistance…we need a 600Ω external resistor to keep our light bulb from blowing up! Simple eh? 🙂

But wait, after rummaging through your box of resistors, you can only find a 660Ω! How will this affect your light bulb?

I = E / R     Ohm’s Law solved for Current

I = 12V / 600Ω(lightbulb) + 660Ω(resistor)    Value substitution

I = 12V / 1260Ω(resistor)    Simplify

I = 0.0095A (or 9.5mA)     Answer in Amps

Well it looks like that by using a 660Ω resistor instead of our calculated 600Ω, current flowing through our bulb dropped from 10mA to 9.5mA! The bulb should glow ever so slightly dimmer and the bulb lifespan should be ever so slightly longer.




Basic Electricity 101: Legend

Voltmeter.jpg Voltmeter
Ammeter.jpg Ammeter
battery.jpg Battery
Resistor.jpg Resistor
diode.jpg Diode
LED.jpg Light Emitting Diode (LED)
LightBulb.jpg LightBulb
SPST_Switch.jpg Single Pole, Single Throw switch.
SPDT_Switch.jpg Single Pole, Double Throw switch.
DPST_Switch.jpg Double Pole, Single Throw switch.
DPDT_Switch.jpg Double Pole, Double Throw switch.