Just What are CVs?

Originally published in the DCCUK Yahoo group as "CVs and Speed Steps For Beginners".

CVs are Configuration Variables. Think of a variable as a pigeon hole where you can store something. Imagine buying a new TV, you have to tune all the channels so that when you press 1 on the remote control you get BBC1, when you press 2 you get BBC2, etc. What you are doing, in essence, is "programming" variables in the TV which specify which frequency the TV should tune to in response to each button on the remote control. You are configuring the operation of the TV so we could say the TV has CVs for tuning. A decoder with function outputs will have one or more CVs that tell the decoder what to do when you press one of the function buttons on your DCC handset or throttle. For example you can program a CV so that pressing F1 on the throttle causes the headlights to come on. When you switch off your TV it remembers how to tune each channel. Similarly, a decoder remembers all the CVs when the layout is turned off.

So, the first thing you do with a newly installed decoder is "tune" it by "programming" the CVs. You can do this on the programming track connected to your booster. Programming means putting things (numeric values) in the CVs to tell the decoder how to behave in response to commands that are sent by the command station (rather than in the computer programming sense). There's also a way to change CVs whilst a loco is running on the layout called "programming on the main" but that's another chapter.

Every decoder has a number of CVs. Some are mandatory to conform to the DCC specifications. Some are optional and some are "manufacturer specific" to allow decoder manufacturers to differentiate their products. CVs are always 1 byte which means they can have a numeric value between 0 and 255. That doesn't mean that every value between 0 and 255 is valid for every CV.

The most basic CV is the address. New decoders have 3 as their address and you will want to change this since each decoder on your layout must have a unique address.

The full definition of CVs can be found at RP9.2.2 and if you navigate up one level from there you will find all the other DCC specs too.

Other commonly changed CVs are "Vstart" (recommended) and "Vhigh" and Vmid (the latter two being optional CVs which control the minimum, maximum and middle voltage applied to the motor. Vstart defines the voltage applied to the motor[1] at the first speed step allowing us to ensure that the loco will move on the first step. Vhigh defines the voltage applied to the motor at the highest speed step allowing us to restrict the maximum speed to something sensible (Imagine being able to knobble the TV so the kids cannot turn the volume up too far). The decoder can fill in the voltage values for the intermediate speed steps by distributing them equally between Vstart and Vhigh.

The Vmid CV gives us a little more control. Vmid defines the motor voltage for the middle speed step giving us two speed regions, the first from Vstart to Vmid and the second from Vmid to Vhigh. The decoder can fill in the voltage levels in these two regions by spacing the steps in each region equally or by using a more sophisticated curve fitting algorithm. We now have a rudimentary "speed curve". Setting Vmid below the midpoint between Vstart and Vhigh will give finer control at low speed since there are an equal number of speed steps in each region but the first region now covers a smaller voltage range.

This brings us neatly to the speed table. Again optional (do any recent decoders not support a speed table?) the speed table is a group of 28 CVs which allows us to specify the motor voltage at 28 points along our speed curve. The 28 CVs correspond directly to the speed steps in 28 step mode. The first speed table CV corresponds to Vstart at the first speed step and the last CV to Vhigh at the last speed step but we now have 26 "Vmid" values allowing us to more precisely define our speed curve. This is where a tool like DecoderPro is invaluable, by allowing you to visualise the speed curve. DecoderPro even lets you set up standard curves with just a few mouse clicks. Even if you don't have a computer interface for programming (and everyone should!) you can still use DP to design a speed curve and transfer the values manually. In 128 step mode the speed table CVs are distributed equally amongst the 128 speed steps and the decoder will fill in or "interpolate" between the speed table values to determine the motor voltage for the intermediate speed steps.

[1] A decoder actually drives the motor with a pulse waveform but this waveform will have an equivalent average DC value so we can talk about voltage.