Back to Contents
Back to DCC

# Decoder CV programming

All decoders have Configuration Variables (CVs) which can be used for configuring the performance of the decoder. We'll cover only CV29, the main configuration CV, but the same principles apply to other CVs for setting not only how well the decoder runs, but also the functions, lights, etc. And of course, sound; if you've got a sound decoder.

## Bits, and the programming of

### A question of terminology...

Some manufacturers of decoders refer to 'the third bit', or 'Bit 2'. This is caused/confused by the fact that convention numbers the bits starting at '0'. So with some you have 'the first bit' to 'the eighth bit', with others it's 'Bit 0' to 'Bit 7'. It's actually not difficult to work out which convention is being used, the instructions given for CV29 will often provide guidance.

Fortunately there are very few CVs that need programming by setting bits...

### Calculating values for programming the decoder

Providing that you're comfortable adding a few figures together it's not difficult to calculate the decimal equivalent to a binary number:

• The first bit (Bit 0) has a value of either '1', or '0'
• The second bit (BIt 1) has a value of either '2' or '0'
• The third bit (Bit 2) has a value of either '4' or '0'
• The fourth bit (Bit 3) has a value of either '8' or '0'
• The fifth bit (Bit 4) has a value of either '16' or '0'
• The sixth bit (Bit 5) has a value of either '32' or '0'
• The seventh bit (Bit 6) has a value of either '64' or '0'
• The eighth bit (Bit 7) has a value of either '128' or '0'

Now supposing we need to set Bits 0,1,2,6 and 7 (that's the first, second, third, seventh and eighth bits) 'on'. Then we need to add the following numbers together (you can see the above list for where the numbers come from):

1 + 2 + 4 + 0 + 0 + 0 + 64 + 128 = 199

So the value you'll need to program in is '199'

### Determining what has been set in a decoder

Of course a variation on the above technique will also work, in reverse, if you're trying to establish what bits have been set for a particular CV. It's probably easiest to explain using an example; there's nothing more than a little simple subtraction required:

Right; let's pick a random number, how about '178'?

Working from the decimal values of most significant bit to the least significant bit we're going to try and subtract each one in turn. If we can, then the bit is set. If it can't be subtracted then it isn't set.

So, '178'.

• Can we subtract the decimal value of the eighth bit (Bit 7) '128'? Yes, we can, so the eighth bit (Bit 7) is set. Leaving 178 - 128 = 50
• Can we subtract the decimal value of the seventh bit (Bit 6) '64'? No, we can't as 64 is greater than 50, so the seventh bit (Bit 6) is not set.
• Can we subtract the decimal value of the sixth bit (Bit 5) '32'? Yes, we can, so the sixth bit (Bit 5) is set. Leaving 50 - 32 = 18.
• Can we subtract the decimal value of the fifth bit (Bit 4) '16'? Yes, we can, so the fifth bit (Bit 4) is set. Leaving 18 - 16 = 2
• Can we subtract the decimal value of the fourth bit (Bit 3) '8'? No we can't as 8 is greater than 2, so the fourth bit (Bit 3) is not set.
• Can we subtract the decimal value of the third bit (Bit 2) '4'? No we can't as 4 is greater than 2, so the third bit (Bit 2) is not set.
• Can we subtract the decimal value of the second bit (Bit 1) '2'? Yes, we can so the second bit (Bit 1) is set. Leaving 2 - 2 = 0
• At this point with '0' as answer we know that none of the less significant bits are set; so the first bit (Bit 0) is not set.

## The main Configuration Variable; CV29

Right, lets deal with a ‘biggie’; CV29. This is the main configuration CV for all decoders. Many decoders have additional configuration CVs for higher functions; but we’ll only concern ourselves with CV29 for the moment. The effects of correctly setting CV29 are not subtle as it controls direction, the number of speed steps, whether the decoder will work on analogue control, speed table, 2-digit or 4-digit addressing and probably one or two other things that are proprietary to the manufacturer of your decoder. For that reason you'll need the manual for the decoder handy before we get down to the nitty gritty.

This particular CV is worth getting to grips with and is the reason that I've decided to include the method for calculating the programming values (above). CV29 is set entirely by selecting what functions (and therefore what bits) you want to set.

### Direction

Should be the simplest and most obvious one to sort out. If the loco goes 'forwards' when it's told to , and the front headlights light up then you're sorted. If, however, your pride and joy merrily rolls off in the wrong direction then this bit will need setting. Beware that if the headlights are not co-ordinated with the direction of travel this can't be remedied by programming. You'll need to swap a set of leads over - either the grey/orange pair on the motor or the yellow/white pair on the lights. Once they're co-ordinated you can then set the direction.

Generally it’s worth going for the highest number of speed steps your controller will support. In my case that’s 28/128; as the ‘Compact’ is normally 28 speed steps. It can be easily re-configured for 128 speed steps; which is lucky really as you have to do it for every loco every time you turn it on! However, the greater the number of speed steps the finer the control you have. The speed difference between the first and last step is still the same; it’s either 128 small steps or 28 (or 14 if you’re using an old system) larger ones. The finer step settings are particularly useful at the slow speed end of the scale.

If you find that you're getting the headlights turning on and off as the loco accelerates or decelerates then the controller isn't set to the same number of speed steps as the decoder. If that happens it's probably worth setting everything to as large a number of speed steps as you can.

### Analogue control

The other function I feel I should draw your attention to. If you’re operating on DCC layouts it’s well worth setting the value required to restrict the loco to digital operation. This does a number of things, firstly; it allows the use of some of the higher functionality in the decoder, which may be disabled by having the decoder capable of driving on analogue. The effects of this may not be subtle and also may not be fully detailed in your decoder manual. A classic example is with the fitting of ‘Power 1’ modules to ‘Gold’ decoders; unless set to digital only, the Power 1 will have no effect on the running at all. And the same is true of fitting the on-board power system to Zimo decoders; it’ll only work if CV29 is set to digital only operation.

Another, surprising, advantage of digital only operation is to do with tolerance of dirt on the track. If the decoder is set to operate on both DCC and analogue it will wait to operate until it has detected whether it’s under DCC or analogue command. So imagine the scenario with the loco bowling along when it hits some dirt. The decoder temporarily ‘glitches’ and the momentum of the loco (especially if it’s got a flywheel) carries it over the dirt. The decoder will then hold off until it’s detected it’s on DCC (or analogue) control and then move off; the result will be something of a lurch as the decoder pauses for a few milliseconds. If the decoder has been programmed for DCC only then the decoder will resume drive as soon as power is returned – frequently with no obvious indication of it ever having stopped.

### Speed Table

All the modern decoders offer programming the speed values by either setting the start, medium and maximum speed values or by programming a full speed table. This bit will need setting if you want to use the speed table option. Most of the time I don't; but I've used the Lenz LE1025 in some American diesel locos by Atlas and Proto-2000 with the speed table set and I feel it's been worth it to get them all performing identically.

It's a lot of faff though, even with the SPROG.