Digital Command Control - Power
Summary: DCC power may seem very complex, but armed with the proper knowledge, you'll soon understand what makes model trains operate with DCC power.
Are you looking for information about power supplies?
- 1 Overview of DCC Power
- 2 Polarity Does Not Control Direction
- 3 Phase Relationships
- 4 Standards
- 5 Additional Notes
- 6 See Also
Overview of DCC Power
Digital Command Control uses a high frequency digital waveform to provide power and transmit data. One of the main differences between Command Control systems is that DCC, unlike previous Command Control systems, puts a 100% digital signal on the rails and derives both power and information from the same digital signal. The digital data is not superimposed on a DC or AC waveform, nor does it use high frequency signals in addition to the power applied to the track. Since the rails are alternately energized or held to zero, there are no issues with polarity. The digital information is encoded in the time domain, not by amplitude.
Since the signal is digital, the DCC waveform is a square wave. A square wave is the sum of a number of sine waves, each with their own frequency and amplitude. There is a primary frequency, called the fundamental, and a number of harmonics, which are multiples of the fundamental frequency. Mathematically, when summed together a square wave is created. Harmonics are the reason that heavy gauge wires are required with DCC: Harmonics can carry a lot of current, but they do no work.
Is the Waveform AC?
The voltage on each rail alternates from positive voltage (High or ON) to 0 volts (OFF). The booster Energizes Rail A for a period of time while holding Rail B to 0 volts. Then it connects Rail A to 0V and energizes Rail B for a period of time. The On/Off cycle of the track is controlled by the command station's data signal.
Digital does not have the concept of "negative". Digital systems only work with positive signals. A negative voltage would be considered an "Undefined Value". In DCC the presence of only positive voltages on the rails is important: The decoder employs a diode to pick off the digital signal from the track. Physically re-orienting the locomotive has no effect on the decoder. With a negative voltage on one rail, the decoder would not see the digital data if the data detection diode was connected to that rail. Using one diode is a simple and cost effective method of detecting the presence of data on the rails. There are those who will claim it has positive and negative values, this would only be possible if:
- The power supply, with two wires, has an output voltage of at least twice that of the track voltage
- The power supply has three wires supplying both positive and negative voltages plus a common return/reference point.
On an oscilloscope the track voltage appears to indicate the presence of a plus/minus signal, but it really isn't. It "sees" a negative voltage when the booster flips the rails, because the reference point has changed, and it is energized. Another way to look at this is how the current is flowing: It will flow from A to B, then B to A.
If you were to measure the AC voltage at an outlet in your home, one of the probes is connected to the Hot wire, the other to the Neutral wire. The Neutral is connected to ground, which is the Earth itself, and its potential is always zero. The voltage on the hot wire is changing in time with respect to Ground. Your DCC system is not grounded, the rails are floating.
Why Can't I Measure DC Volts?
Mathematically the DCC signal would be written for example as: (0+j14) or (0-j14), where the 0 is time on the X axis, the j operator indicates a voltage on the Y axis. These values show 14V at 90° and 14V at 270° on the oscilloscope display.
Measuring this with a DMM set for direct current voltage results in the equation which sums the two values: (0+j14) + (0-j14) which reduces to j14 - j14 = 0 DC Volts. Time is not important to this calculation as it measures instantaneous values. The meter is not fast enough to respond to a 10kHz DCC signal.
Since the signal changes at a very high frequency, a typical Digital MultiMeter (DMM) cannot read the electrical values accurately. They do not sample at a high enough frequency to calculate the value accurately, as they are typically designed to measure AC in the 50-60 Hertz range. The instantaneous voltages it samples result in an erroneous value. Also, digital multimeters are designed to calculate and display the RMS value of a pure sine wave.
Using a DCV function will not give accurate readings either, due to the changing nature of the signal. It will see an average of zero volts. There are meters available that will accurately measure DCC signal, such as the RRampMeter, which was designed specifically for measuring DCC voltages and currents.
Creating the DCC Waveform
A booster takes DC power from the power supply, and the DCC command information from the Command station, and creates a digital waveform, which is applied as track power. The length of time that the voltage changes provides a method for encoding data. DCC uses a binary encoding system. To represent a one, the time is short (nominally 58µs for a half cycle). A zero is represented by a longer period (nominally 100µs for a half cycle).
The succession of zeros and ones (binary code) contained in the track power signal are the commands being sent to the layout. DCC decoders mounted in model locomotives and accessories then receive this digital information, interpret it, and perform commands such as moving, turning on lights, throwing switches, or making sounds.
A stationary decoder can also be attached to the rails at a fixed spot, to allow control of switches and lights. If you are considering connecting a stationary decoder to the rails, please read: Avoid connecting stationary decoders to rails.
Polarity Does Not Control Direction
Unlike analog (DC) power where polarity of the track controls the direction of the train, with DCC the direction of the train is controlled by the multifunction decoder in the locomotive. The decoder receives instructions from the throttle via the command station and controls the speed and direction thereof of the locomotive's motor accordingly.
Converting DCC signal to DC Voltage on the Decoder
In order for the motor to use the DCC power, the power must be converted to Direct Current. To do this, decoders use a Diode Matrix (see image). A diode matrix routes the digital signal to provide a DC signal to power the decoder. A diode matrix simply consists of 4 diodes (a device that lets electricity flow in only one direction) connected in a specific way. In this example, when Rail A is energized the current will flow through one pair of diodes, returning to the booster via Rail B, until Rail B becomes positive and the other pair of diodes conduct.
There will be an additional diode in the matrix circuit (not shown) which provides the digital signal to the microcontroller's input.
Without the diode matrix, only the pulses on one rail would be used for power, which would result in lower average voltages available to drive the motor and operate the microcontroller and its peripheral circuits. While the voltage on one rail may be enough for the digital circuit, it would vary in average levels, and may cause the microcontroller to reset at times. The matrix allows current to flow from either rail without causing a short circuit.
You can also use a diode matrix connected between the track and your DMM to measure the DCC voltage on the track using the DCV range. This is called a rectified DC Voltmeter.
Remember: You typically lose 0.7V (700 millivolts) through a diode. Factor a loss of 1.4V due to the two diodes completing the matrix circuit.
When used for rectification (converting AC voltage to DC) this circuit is usually called a bridge rectifier.
Okay, so we've explained how we get DC, but if we applied this directly to the motor, it would go in one direction really fast. To account for this, the output of the diode matrix does not connect directly to the motor.
In between the DC power source (the matrix) and the motor is a series of transistors. Since transistors function as a valve, where a small current can be used to control a large one, they can be switched rapidly on and off, making control of a motor or other device possible. With a special arrangement of power transistors (ones that are meant to control large amounts of power) called an H-Bridge, the decoder can make the train go in either direction.
Remember, because there is full voltage on the rails at all times, there is also full voltage available at the power transistors at all times. If the transistors are turned on to pass all the available voltage, the loco will go at full speed. Unlike an analog DC train system, transistors are designed to pass full voltage, or no voltage, much like a switch. You either have full power, or no power. To control the speed, the decoder turns on and off the transistors hundreds, or thousands of times per second. This is like setting your ceiling fan to high, but to control the speed, you are constantly turning on and off the switch several times a second to maintain the speed you want of the fan blades. Please see High-Frequency Decoders for more details regarding the speed at which decoders control the transistors.
The reason this works in both our model trains, and our fan, is that the the transistors are turned on and off hundreds, or thousands, of times per second - so fast that the motor can't respond instantaneously to each pulse. The motor has so much mass to it (including flywheels, or blades) that a single pulse can't budge it. But, a whole lot of pulses can make it go. Since there is full power to the wheels, and ultimately to the engine, this helps the locomotive run so much better on DCC than with DC.
Main article: Reverse sections
Although there is no electrical polarity, you still have to deal with reverse sections on your layout. The phase of the rails is important in DCC. Rail A is aways the inverse of Rail B. If the track turns around back onto itself, the right rail (A) will come in contact with the left rail (B), creating a short circuit by connecting one phase to the other; the same as placing a metal object across the rails.
If the rails are out of phase across a gap, there is a potential difference between them, which can be measured. Should a metal wheel bridge that gap, current can flow from the energized section into the unenergized section, causing a short circuit. An auto reverser will maintain the correct phase relationships between a reversing loop and the approach track.
The same issue can happen if the frog in a turnout is incorrectly phased, or if a wheel bridges across the point rails at the heel of the frog.
The DCC protocol is the subject of two standards published by the NMRA: S-9.1 specifies the electrical standard, and S-9.2 specifies the communications standard. Several recommended practices documents are also made available.
Measuring Track Voltage
- Main article: DCC Power/Measuring Track Voltage
Digital Multimeter Notes
For additional information about Digital Multimeters, see Wiring Tools
Trying to measure the DCC voltage on your track will introduce new problems and additional confusion. First problem: They are designed for 50/60Hz AC. Outside of that frequency, the results get interesting, as the sample rate is not fast enough for signals such as the DCC waveform. Which introduces a huge amount of error and uncertainty.
Most digital multimeters display AC as the Average Value. This assumes a pure Sinusoidal waveform. Unless stated as a "true RMS" meter. RMS performance is sometimes claimed for meters which report accurate RMS readings only at certain frequencies (usually low) and certain waveforms (essentially always sine waves). Some manufacturers, such as Fluke, have a True RMS feature, which is really accurate compared to other brands, and especially compared to really cheap DMMs. Better DMMs (such as those by Fluke and other quality instrument makers) use additional calculations to arrive at the RMS value. Cheaper DMMs will use simpler, lower cost circuits to determine the voltage. The factory will simply adjust the meter to read the RMS value. Then there are the accuracy of the calibration standards used at the factory as a reference to calibrate the DMM.
Do not rely on the meter as being 100% accurate. For comparative measurements, it is acceptable.
- For an analog signal to be accurately digitized, it must be sampled at a rate at least twice that of the highest frequency present. In other words, the highest frequency should only be no more than half the sampling frequency for accurate sampling and digitization. This underpins many everyday things, like digital audio on Compact Discs.
The maximum signal frequency is called the Nyquist Frequency, and the rule is the Nyquist Theorem.
When a signal is sampled too slowly (there are frequency components above the Nyquist frequency) the resulting digitized waveform is distorted. This distortion is called aliasing. It results from the mixing (or beating) between the signal frequency (in this case, the DCC signal frequency) and the sampling frequency. Low frequency harmonics are recorded instead of the actual signal.
- In general, the sampling frequency should be more than twice the highest frequency to be measured. A value of 5 times would be a good choice. Many analog to digital conversion circuits also contain an anti-aliasing filter to eliminate any signal frequencies above the Nyquist frequency.
What does Aliasing Mean?
A cheap DMM may only sample at 120 or 180 Hertz, as it is designed for a 60 Hz Sine Wave. A better one may use 300 or 360Hz for more accurate measurements. It may also have a filter to cut off any signals above 70Hz. DCC signals are 8 to 10 KiloHertz in frequency. Sampling will result in a lot of aliasing, making your readings inaccurate and misleading. The DCC signal is a square wave, so getting an accurate measurement becomes a problem.
High quality instruments may be able to sample frequencies up to 2kHz accurately, but that comes at a cost.
If you were to use an oscilloscope to measure the line voltage in your house (nominally 120 V AC (RMS)) you would see that the sine wave measures about 340V peak to peak. One half cycle peaks at approximately 170V. The RMS value, which is displayed by measuring instruments, is 70.7% of the peak value. In this case, 120VAC. You should see a nice, pure sine wave, unless you have a lot of distortion, caused by harmonics. A common source of harmonic distortion is a switching power supply.
The same scope would display your DCC waveform as a square wave. It would accurately display the peak to peak value of the waveform. A square wave is actually the sum of sine waves at multiple frequencies, called harmonics. As more frequencies enter the equation, the waveform becomes more square in shape. The frequencies are harmonics of the fundamental frequency. You can calculate a sine wave and plot the result on graph paper, and as harmonics are added, the waveform becomes more and more distorted, until it forms a square wave. (This is how your kids burn out the tweeters in your stereo's speakers.) This is also important in your power bus, as excessive impedance causes distortion, as some frequencies will travel faster than others on the wire.
One solution is to use a rectifier circuit between the track and the DMM and measure the DC output of the rectifier. For more accurate results, you should characterize how the combination of DMM and rectifier works with high frequency complex waveform. Another solution is the RRampmeter mentioned above.
- DCC Tutorial (Power) - The tutorial version of this document.
- Power supply - Details, requirements, and recommendations for power supplies.
- Root Mean Square - Root Mean Square or RMS, additional information (lots of math).
- DCC Ammeter: What you need to build an ammeter that can measure DCC current. Plus other electronics projects for DCC.
Square Waves and Fournier Series
Fournier Series on wikipedia All about how you can create square waves from a sine wave and its harmonics.