There are 3 ways to control a turnout via DCC++:
For each control method, there are two things you must configure:
With Direct control, you can directly control a DCC Stationary Decoder through DCC++. There will be no feedback on the turnout's actual position.
To control a Stationary Decoder or other DCC-controlled Accessory (using the Base Station's "a" command), follow these steps.
The Hardware Address for a Direct DCC accessory must be the accessory's DCC address. For example, if your Stationary Decoder's switch address is set to 52, the Hardware Address for that turnout should be 52.
The User Name can be anything you like.
In the JMRI Turnout Table...
Entry | Meaning | makes System Name | Mask | Equivalent | Minimum | Maximum |
---|---|---|---|---|---|---|
12 | ID in internal DCC++ table | DT12 | integer | 0 | 32767 |
For Direct mode control, there is no Base Station configuration needed.
Indexed control is the preferred method of controlling DCC Statonary Decoders with DCC++.
With Indexed control, you can control a DCC Stationary Decoder through DCC++, using the Base Station's internal turnout index table.
Each turnout has an entry in the Base Station's turnout table. The base station stores the actual DCC Stationary Decoder address internally, and you assign an ID value (anything from 0-32767) to the turnout. JMRI references the turnout using the ID value, not the decoder address.
Turnout ID values do not need to be sequential. Each turnout's ID can be any unused value within the allowed range (0-32767).
To control a Stationary Decoder or other DCC-controlled Accessory using Indexed control (using the Base Station's "T" command), follow these steps.
The Hardware Address for an Indexed DCC accessory is the ID value assigned in the Base Station's internal Turnout table. For example, if your Stationary Decoder's switch address is set to 52, and that decoder is assigned ID value 13 in the Base Station, the Hardware Address for that turnout should be 13.
The User Name can be anything you like.
NOTE: Turnout configurations stored in the Base Station's EEPROM will be automatically added to the JMRI Sensor Table on startup.
In the JMRI Turnout Table...
Use the JMRI/DCC++ "Configure Base Station" (4.6.x: "Configure Sensors & Turnouts") tool to store the turnout ID and DCC Address in the Base Station.
Note: DCC++ requires the use of an Address/Subaddress pair. If your Stationary Decoder does not have subaddresses, take the address and divide by 4. The result is the address, the remainder is the subaddress. For example, Address 51 (no subaddress) is DCC++ Address 12, Subaddress 3.
Note: On JMRI versions 4.6.x and earlier, if you choose "Save Turnouts" you will not be given the opportunity to write the changes to the Base Station's EEPROM. To write to EEPROM, you must choose "Close" instead of "Save Changes".
Indexed Output Pin control is the only way to control a turnout directly connected to a DCC++ Arduino IO pin from JMRI.
With Indexed control, you can control a DCC++ Arduino IO pin, using the Base Station's internal output index table.
Each Output pin has an entry in the Base Station's Output table. The base station stores the actual Arduino IO Pin number internally, and you assign an ID value (anything from 0-32767) to the output. JMRI references the turnout using the ID value, not the Arduino pin number.
Output ID values do not need to be sequential. Each turnout's ID can be any unused value within the allowed range (0-32767).
When using analog Arduino pins as digital outputs, use the pin's digital pin number. For example, analog pin A0 is digital pin 14
To control an Arduino IO pin using Indexed control (using the Base Station's "Z" command), follow these steps.
The Hardware Address for an Indexed Output is the ID value assigned in the Base Station's internal Output table. For example, if your turnout control is connected to Arduino pin 7, and that output is assigned ID value 13 in the Base Station, the Hardware Address for that turnout should be 13.
The User Name can be anything you like.
NOTE: Output configurations stored in the Base Station's EEPROM will be automatically added to the JMRI Sensor Table on startup.
In the JMRI Turnout Table...
Use the JMRI/DCC++ "Configure Base Station" (4.6.x: "Configure Sensors & Turnouts") tool to store the turnout ID and Arduino pin number in the Base Station.
Note: On JMRI versions 4.7.1 and earlier, if you choose "Save Outputs" you will not be given the opportunity to write the changes to the Base Station's EEPROM. To write to EEPROM, you must choose "Close" instead of "Save Changes".
Turnout and Output IDs do not need to be sequential. You can use any unused value within the allowed range (0-32767). The DCC++ Base Station will also allow a Turnout and an Output to have the same ID and be treated as separate devices (they are stored in separate tables and accessed via different commands).
However, JMRI requires that all (JMRI) Turnout System Names be unique, and therefore the Hardware Addresses assigned to Turnouts and Outputs must be different. For example, while the Base Station will allow a Turnout ID 2 and an Output ID 2, JMRI will not be able to treat these as separate devices, so this is not allowed.
For the same reason, you must choose Turnout/Output ID values that are different from any Direct mode DCC Address Turnouts accessed through the DCC++ Base Station.
If you have multiple interfaces (e.g. a stand-alone LocoNet or a second DCC++ Base Station), each interface has its own "namespace", so you can have a Turnout ID2 on one DCC++ Base Station interface and a Direct Address 2 turnout on a different DCC++ Base Station, and a LocoNet address 2 turnout on a stand-alone LocoNet interface.
Having said that, such overlapping address spaces can be very confusing, so we recommend allocating certain address spaces for each interface so that there is only one "Turnout #42" on the whole system
The DCC++ Base Station Output table allows the output signal to be inverted. JMRI also allows JMRI Turnouts to be inverted in the JMRI Turnout Table entries. This means that a BSOUTPUT mode Turnout can be inverted twice. Please be sure to check both the Base Station settings and the Turnout Table settings to be sure that you achieve the intended result.
The "Configure Base Station" tool is a convenient way to program the Sensor, Turnout and Output tables in your Base Station. It is not, however, required to work with DCC++ within JMRI. You can, for example, set up your Base Station's tables using the DCC++ serial command interface, or the DCC++ Controller software. As long as the IDs assigned in the Base Station match the Hardware Address assigned in JMRI's Turnout Table, all will be well.