Locomotive decoders: the basics

Benjamin | TrackDrawer.com · published 12 November 2026

A loco decoder is a small circuit board inside the loco that reads the digital commands from the command station. It listens only to its own address, drives the motor at the requested speed and direction, and switches functions such as lights and sound. Many locos have a standard socket you plug a decoder into; in others it has to be hard-wired.

What a decoder does

On a digital layout there is always voltage on the track. That voltage does not go straight to the motor but to the decoder. It picks out the packets carrying its address and does what they say:

  • Motor. The decoder gives the motor exactly as much voltage as belongs to the requested speed step, in the requested direction. Because direction is a command, it does not depend on which way round the loco stands on the track.
  • Functions. Outputs for headlights and tail lights, cab lighting, a smoke generator, a digital coupler or other extras. You switch them with function keys on the command station.
  • Running behaviour. Acceleration and braking with a set delay, a minimum and a maximum speed, and often load compensation (back-EMF) that keeps the speed steady on a gradient.

Which protocol the decoder speaks (DCC, Motorola, mfx or several) decides which command stations it works with. That is covered in detail in DCC and Märklin Motorola; this article is about the decoder itself.

How a decoder gets into the loco

There are three situations.

  1. Digital from the factory. The loco comes with a decoder fitted. The box and the manual say so. You put it on the track and drive.
  2. With a socket. The loco comes as analogue but has a decoder socket. A blanking plug in the empty socket connects the motor straight to the rails. You pull that out and plug the decoder in its place.
  3. Without a socket. Older or simple locos have no socket. Then you solder the decoder wires to the pickups, the motor and the lamps. That is work that needs precision.

The sockets are standardised. You will meet them under names such as NEM 651 (six-pin, common in small locos and N), NEM 652 (eight-pin, long the standard in H0), 21MTC, PluX and Next18. Which one your loco has is in the manual or on the spare parts list. You buy a decoder with the matching plug, or with loose wires if you want to solder.

When fitting, watch three things:

  • Space. The decoder has to fit under the body without being pinched or rubbing against moving parts. In N and Z space is tightest.
  • Plug orientation. A plug inserted the wrong way round can damage the decoder. The loco's manual shows which side pin 1 is.
  • Motor and current. The decoder must handle the motor's current. Older Märklin locos often have a motor that works differently from an ordinary DC motor; not every decoder can drive it. Check the decoder's manual for the motors it is made for.

Wire colours for loose wires

If you have to solder, the wire colours help. Many decoders follow the NMRA colour code:

ColourConnection
redright rail (looking forward)
blackleft rail
orangemotor, first terminal
greymotor, second terminal
whiteheadlight
yellowtail light
bluecommon positive for the functions

On Märklin three-rail the red wire goes to the pickup shoe (the centre conductor) and the black to the wheel ground. Always check the colours in your decoder's manual: not every brand follows the code in full, and extra function outputs have colours of their own.

Address and settings

Every loco needs an address of its own. With DCC you set it yourself: short addresses go up to 127, and for higher numbers you use a long address. Many modellers pick the address from the loco's running number so they do not have to remember it. An mfx loco gets its address from the command station when it registers; with Motorola you set it yourself.

The settings of a DCC decoder are stored in configuration variables, or CVs. A few are the same in every DCC decoder:

CVWhat it controls
CV1the short address
CV2start voltage: how much the motor gets at the lowest speed step
CV3acceleration rate
CV4deceleration rate
CV5top speed
CV29a set of basic settings, such as short or long address and direction

Most other CVs differ by manufacturer. You read and write them with the command station, preferably on a separate programming track so that you do not change every loco at once by accident. If a loco runs jerkily after setting up, see train runs jerkily: it explains what start voltage, momentum and load compensation do to the running.

Functions, sound and stay-alive

How many functions you can switch depends on the decoder, the command station and the protocol. A simple decoder has lights and one or two extra outputs. A sound decoder also has a memory with recorded sounds of the prototype and an output for a speaker, which has to find room in the loco.

A stay-alive is a store of energy, a capacitor that you can connect to many decoders. If contact with the rails drops out for a moment, on a dirty spot or a dead frog, the loco keeps running on that store. How that helps at turnouts is covered in loco stalls on the frog. A stay-alive does not replace clean rails and wheels.

Decoders in coaches too

Decoders are not only for locos. A function decoder without a motor output switches the lighting in a coach or the lamps of a driving trailer. That way the lights of a whole train go on and off with one key, and the lighting of a multiple unit follows the direction of travel.

Does a digital loco still run on analogue?

Many decoders recognise an analogue layout and then run on the controller's voltage, like a loco without a decoder. The manual calls this analogue mode. The reverse does not hold: a loco without a decoder does not belong on a digital layout. Why is explained in analogue or digital control.

Frequently asked questions

Can I give two locos the same address?

Yes, and then they run exactly together, as if you drove them with one controller. That is handy for two locos on the same train, if their motors run at the same speed. If you want to drive them separately, give each its own address.

Why does my loco not respond after fitting a decoder?

First check that the plug is the right way round and that the decoder is on the address you are calling. A new DCC decoder is usually on address 3. Read the address on the programming track; if that fails, the decoder is getting no power or there is a fault in the wiring.

Decoders and TrackDrawer

TrackDrawer plans the track and the fixed equipment: command station, boosters, accessory decoders, feedback modules and signals, with their addresses and a wiring diagram. Loco decoders you set up with your command station. In the app you add your rolling stock to the plan, so the check warns you about any curve tighter than your locos can take.

Read also

Open the app · Glossary