Keep DCCWiki free of advertisements, contribute today.

Configuration variable

From DCCWiki, a community DCC encyclopedia. Please contribute today to keep it free.

(Redirected from CVs)
Jump to: navigation, search

Just like any other computer, decoders must be programmed by the user to reach their full potential. While they come with basic "default" programs, most users will want to customize the decoder address, motor control, lights, sound, and other functions to meet their specific needs. You do so by editing CVs, or Configuration Variables, in the decoder. Some CVs use values ranging from 0 to 255, others use their space in the decoder's memory as a bank of 8 on/off switches. While this lets you do a lot with very little memory, it can get very complex for those of us that aren't on speaking terms with binary code.

There is Software available which simplifies the programming of decoders. Many people agree that JMRI is the best, free, open source software available - often rivals commercially available software.

Contents

[edit] Configuration variables

Configuration variables or CVs are memory locations within a decoder. They are the means for controlling the performance of a DCC decoder. They can be used in a couple of different ways.

  • A CV can store raw data. It can do this as a binary number with a value between "00000000" (decimal 0) and "11111111" (decimal 255), as two binary numbers in high bits/low bits format "HHHHLLLL", or some variant of these. Data can also be spread across multiple CVs if the necessary maximum value exceeds decimal 255.
  • A CV can store information as a series of "bitswitches", each bit controlling the state of a specific function, turning it on or off. For example, CV 29 works in this way.
  • A combination of the above. For example, CV 19 works in this way.

There are NMRA standards for the functions specific CVs are to control, but there is plenty of room left for manufacturers to add their own characteristic or proprietary functions, as well. The current NMRA standards for configuration variables cover only the NMRA specified CVs. See your specific decoder documentation for other capabilities beyond the basic capabilities. It is beyond the realm of this document to list the manufacturer-specific CVs for all available decoders.

[edit] Explanation of binary number/decimal conversion and bitswitches

There are several ways to store data in CVs. The one that causes the most confusion for those who are not acquainted with the inner workings of a computer is the "bitswitch". This system is far simpler that it might appear. Consider the table below:


Most
Significant
Bit
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Least
Significant
Bit
128 64 32 16 8 4 2 1
0 0 0 0 0 0 0 0


Think of the 8 bits of the CV as a bank of 8 simple on/off switches. Each switch is identified by the bold number above it. A value of "0" means the switch is off or in its default mode, a value of "1" turns it on. A decimal number between 0 and 255 identifies a unique setting of every switch in the bank of 8. This allows you to turn on or off any possible combination of these 8 switches by entering the appropriate decimal number into the CV. Here is an example of the best-known CV that uses this technique, CV29:


CV
29
Loco/Acc
Decoder
Reserved 2/4 Digit
Addressing
Speed
Table
Advanced
Decoder
Ack.
Power
Source
Conversion
F0
Control
Loco
Direction
Decimal
Value
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
128 64 32 16 8 4 2 1
0
Off
0
Off
1
On
0
Off
0
Off
1
On
0
Off
0
Off
36


In the above example, 2 bits are on - bits 32 and 4. Add 32+4 and you get 36, the decimal value of the bitswitch settings shown. If you wanted to turn on the speed tables too, then you would add 16 to that value, for a decimal value of 52.

Some times you need to work in reverse-- you read the value of the CV from the decoder, then have to figure out what switches are on and which are off. It's simple, but tedious.
The binary equivalents of the switch positions (as shown in the table above) are 128 - 64 - 32 - 16 - 8 - 4 - 2 - 1.
Start with the value you read from the CV, in this case 52.
52 is less than 64, so there are no 128s or 64s in the CV (ie those switches are off).
52 is greater than 32, so there is a 32 in the CV; that switch is on.
Subtract 32 from 52 giving the remainder of 20.
20 is greater than 16, so there is a 16 in the CV; that switch is on.
Subtract 16 from 20 giving the remainder of 4.
4 is less than 8, so that switch is off.
4 = 4, so that switch is on.
Subtract 4 from 4 giving 0; all remaining switches (2 and 1) are off.
Switches 32, 16, and 4 are on, the rest are off.

[edit] The NMRA standard CV definitions for mobile decoders

CV Name Default
Value
(decimal)
Read Only
1 Primary Address (2 digit) If value = "0", decoder will convert to Alternate Power Source (see CV 12) 3
2 V-start - sets the minimum starting voltage at speed step 1 7
3 Acceleration Rate (starting momentum) 0
4 Deceleration Rate (stopping momentum) 0
5 V-max - sets the maximum voltage at the top speed step 1
6 V-mid - sets the voltage at the middle speed step. A value of

128 applies 50% of the total voltage to the motor at the middle speed step.

Together V-start, V-mid, and V-max give a 3 point speed curve.
1
7 Manufacturer Version Number - Yes
8 Manufacturer ID (assigned by NMRA) -

Some decoders reset when a specified value is written to this CV - check your documentation!
List of IDs.

See decoder reset for details.
- Yes
9 Total PWM Period (optional) -

Reccommended formula is: PWM period in microseconds = (131 + MANTISSA x 4) x 2 EXP

MANTISSA is stored in bits 0-4, EXP in bits 5-7.
0
10 EMF Feedback Cutout (optional) - Sets the speed step above which back EMF is no longer applied. -
11 Packet Time-Out Value - Sets the maximum time that the decoder will maintain speed without receiving a valid data packet from the command station. -
12 Power Source Conversion (optional) -

Determines the secondary power source for the decoder. Available are:

  • 0 0 0 0 0 0 0 1 = Analog Conversion (1)
  • 0 0 0 0 0 0 1 0 = Radio (?) (2)
  • 0 0 0 0 0 1 0 0 = Zero-1 (4)
  • 0 0 0 0 1 0 0 0 = TRIX (8)
  • 0 0 0 1 0 0 0 0 = CTC16/Railcommand (16)
-
13 Analog Mode Function Status (optional) - Selectively sets decoder functions 1-8 to operate in analog mode with bitswitches (bit 0=F1, bit 7=F8) -
14-16 Reserved for expansion -
17-18 Extended Address (4 digit - optional) -
19 Consist Address (2 digit - optional) - Bits 0-6 sets 2 digit consist address and bit 7 sets unit direction relative to the normal direction of travel in CV29. -
20 Reserved for expansion -
21 Consist Address Active for F1-F8 (optional) - Sets whether F1-F8 respond to commands at Consist Address in addition to the locomotive address. -
22 Consist Address Active for FL (optional) - Sets whether F0 (headlight control) responds directionally to commands at Consist Address -
23 Acceleration Adjustment (Acceleration trim - optional) - Modifies CV3. Values below 127 subtract from CV3, above 127 add to CV3. 0=off. -
24 Deceleration Adjustment (Deceleration trim - optional) - Modifies CV4. Values below 127 subtract from CV4, above 127 add to CV4. 0=off. -
25 Speed Table/Mid-range (optional) - Allows selection of factory preset speed tables, and cab throttle position for the middle of the speed table. 0 or 1=off. -
26-28 Reserved for expansion -
29 Configuration Data #1 -

Bit-switches as follows:

    • Bit 0 - Locomotive Direction
    • Bit 1 - Control of F0
    • Bit 2 - Power Source Conversion
    • Bit 3 - Advanced Decoder Acknowledgement
    • Bit 4 - Speed table off/on
    • Bit 5 - 2/4 digit addressing
    • Bit 6 - Reserved
    • Bit 7 - Multifunction/accessory decoder
-
30 Error Information (optional) - Contains manufacturer-specified error code data. 0=no error. -
31 Configuration Data #2 (reserved for future expansion) 0
32 Configuration Data #3 (reserved for future expansion) 0
33 Output Location F0 (forward headlight) (function mapping - optional) 0
34 Output Location F0 (reverse headlight) (function mapping - optional) 0
35 Output Location F1 (function mapping - optional) 0
36 Output Location F2 (function mapping - optional) 0
37 Output Location F3 (function mapping - optional) 0
38 Output Location F4 (function mapping - optional) 0
39 Output Location F5 (function mapping - optional) 0
40 Output Location F6 (function mapping - optional) 0
41 Output Location F7 (function mapping - optional) 0
42 Output Location F8 (function mapping - optional) 0
43-48 Reserved for future expansion -
49-64 Reserved for manufacturer use - Functions unique to a manufacturer will probably be here. -
65 Kick Start (optional) - Extra 'jolt' between speed step 0 and 1 to help start balky motors -
66 Forward Trim (optional) - Lower value to reduce forward speed, raise value to increase forward speed. 0=off. 128
67-94 Speed Table Values (optional) -
95 Reverse Trim (optional) - Lower value to reduce reverse speed, raise value to increase reverse speed. 0=off. 128
96-104 Reserved for expansion -
105 User Identifier #1 (Reserved for customer use - optional) -
106 User Identifier #2 (Reserved for customer use - optional) -
107-512 Reserved for expansion (optional) -

Thanks to Dayton N-Track for permission to reprint this table.

[edit] See Also

  • Decoder - All aboout various decoders.

[edit] External Links

Personal tools