1. Overview & operating principle
railDECOacc is a stationary decoder for DCC accessory commands. It is intended for layout equipment, not locomotive motor control. A PIC receives the digital commands through an optocoupler and switches an eight-channel ULN2803A output driver.
Four accessory pairs
Outputs 1/2, 3/4, 5/6 and 7/8 form pairs 1–4. Each pair has two selectable sides and one shared timing CV.
Separate power
The DCC input carries the commands. An external DC supply powers the electronics and the accessories, so accessory current is not drawn through the DCC input.
Remembered state
The firmware stores output state information in EEPROM and restores it at power-up. This can restore lights and refresh turnout positions.
Timed and continuous operation
A non-zero timing value gives a nominal on-time in steps of approximately 10 ms. A value of zero disables the timeout for that pair: an activated output stays on until an explicit off command changes it. The two sides are not motor-polarity terminals and are not a servo interface.
There is no RailCom transmitter in this circuit. The programming LED provides local acknowledgement only; it is not a bidirectional data link or confirmation of a turnout’s physical position. With the separate supply and isolated DCC input, the command station cannot read CVs through current acknowledgement.
2. Hardware & electrical safety
Main components
| Component | Role | Important detail |
|---|---|---|
| PIC16F84A / PIC16F628A | DCC decoding and timing | Requires the firmware intended for the fitted PIC. |
| 8 MHz crystal | External processor clock | The firmware timing assumes this clock. Do not select an internal oscillator instead. |
| 6N137 | Optically isolated DCC receiver | DCC is a signal input, not the accessory power input. |
| ULN2803A | Eight low-side switching channels | Outputs sink current towards local ground; they do not supply a positive voltage. |
| 78L05 regulator | 5 V logic supply | Check regulator temperature and input-voltage suitability. |
| Programming LED and transistor | Local acknowledgement | The retained ACK circuit draws from the external supply, so its current change is not detectable at the DCC input. |
Supply and load limits
The circuit reference marks the accessory supply 12 V DC and the logic supply 5 V. Use a regulated, current-limited DC supply appropriate to your assembled board and loads, observing polarity. A voltage used successfully on another installation is not automatically a safe rating for your board.
The ULN2803A is commonly described as a 500 mA-per-channel driver. That figure is not a guarantee that eight channels can each carry 500 mA simultaneously. Package dissipation, duty cycle, voltage drop, board tracks, connectors and ambient temperature all matter. Check the actual manufacturer’s data and the accessory’s current demand.
A stalled or permanently energised coil can overheat even below the driver’s headline current rating. Use suitable fusing/current limiting and accessories with appropriate protection. Firmware timing is not an independent safety cutoff.
Keep the power domains separate
Do not join a rail connection to accessory GND to “complete the circuit”. The optocoupler provides signal isolation. Check turnout lamps and any shared wiring: an accessory with an internal lamp tied to a rail can unintentionally bridge the isolated power domains.
The load-driver clamp common must be connected as required by the board design, normally to accessory positive. The ULN2803A common pin is a clamp-diode connection, not its ground pin.
Known schematic issue: the retained ACK circuit
CV writes can still be accepted, and the LED can show local acknowledgement. Firmware verify operations can also produce a visible LED response when a value matches, but they do not provide automatic CV reading by the command station. A programmer that requires a current ACK may report failure or stop its programming sequence even though an individual write was accepted.
For the separately powered design, the retained circuit must not be represented as a functioning DCC readback interface; at most, its LED is a local indicator. Providing current-based readback would require a hardware redesign that makes the acknowledgement load visible to the DCC source. Do not bridge the isolated power domains or change the board wiring to try to restore this function.
3. Connections & installation
Identify terminals from the markings and schematic of your actual board. The connector names below refer to the archived RailPIC circuit reference; do not infer physical pin order from the position of a connector in this table.
| Connection | Role | Wiring |
|---|---|---|
| J1 / J7 | DCC signal | Two connections to the DCC accessory bus or track signal. The two headers are wired in parallel in the circuit reference. |
| J6 / J8 | External DC power | Accessory positive and GND. The two headers are wired in parallel; check polarity before connecting. |
| J5 | Pair 1 / outputs 1 and 2 | Two switched outputs and common accessory positive. |
| J4 | Pair 2 / outputs 3 and 4 | Two switched outputs and common accessory positive. |
| J2 | Pair 3 / outputs 5 and 6 | Two switched outputs and common accessory positive. |
| J3 | Pair 4 / outputs 7 and 8 | Two switched outputs and common accessory positive. |
Twin-coil accessory
For a compatible three-wire, common-positive twin-coil turnout drive, connect its common to accessory positive and its two coil wires to the two outputs of a pair. Start with the shortest suitable pulse time and increase it only as required by the mechanism.
If the displayed turnout direction is reversed, swap the two coil wires with power off, or reverse the controller’s logical direction. Do not swap supply polarity.
LEDs and steady loads
For an LED, connect accessory positive through a suitable current-limiting resistor to the LED anode, then its cathode to the switched output. With the output active, the ULN2803A sinks current. Size the resistor for the actual supply voltage and allow for the driver’s voltage drop.
Use common-positive lighting assemblies. A common-negative signal cannot be connected by simply treating the driver as a positive-voltage source. For steady lighting, set the pair’s timing CV to zero and send explicit on/off commands.
Output mapping at the PIC
| Pair | Side A / output | Side B / output | Timing CV |
|---|---|---|---|
| 1 | 1 · RB0 · PIC pin 6 | 2 · RB1 · PIC pin 7 | 515 |
| 2 | 3 · RB2 · PIC pin 8 | 4 · RB3 · PIC pin 9 | 516 |
| 3 | 5 · RB4 · PIC pin 10 | 6 · RB5 · PIC pin 11 | 517 |
| 4 | 7 · RB6 · PIC pin 12 | 8 · RB7 · PIC pin 13 | 518 |
These pair labels are accessory channels, not locomotive function keys F1–F4. Operate them with DCC accessory commands.
4. Programming the firmware
Installing the firmware requires a PIC programmer that supports the fitted device. Select the exact PIC in the programmer software and use the matching image. Do not rename or interchange the two HEX files.
| Version / device | HEX filename | Configuration word |
|---|---|---|
| v6.01 · PIC16F84A | DCCDECOMANOLO_V6_01.HEX | 0x3FF6 |
| v7.01 · PIC16F628A | DCCDECOMANOLO_V701.HEX | 0x3F06 |
Both images use the external 8 MHz clock with the watchdog enabled. Use the configuration supplied by the matching HEX rather than copying a setting from a different PIC.
Published firmware packages
The HEX checksums below identify the images documented here. Check the extracted HEX, not the ZIP container:
PIC16F84A · DCCDECOMANOLO_V6_01.HEX db912d9178565a443b509d33b735033da5a3b9538e8a25c24a4cec9130eb0c8a PIC16F628A · DCCDECOMANOLO_V701.HEX 6896258de05a6b5151f942d8356724f4f334d6124708a20408a6cf41d285a3b6
For example, in PowerShell:
Get-FileHash .\DCCDECOMANOLO_V701.HEX -Algorithm SHA256
Programming sequence
- Disconnect the DCC input, external supply and all loads. Prefer a suitable programming socket/adaptor unless in-circuit programming has been verified for the board.
- Read the PIC and save a backup, including EEPROM, before erasing it. This preserves your current CV settings and remembered outputs.
- Select the correct device, open the matching HEX and enable programming of program memory, configuration and the EEPROM data provided in the file.
- Program and verify all supplied regions. Do not substitute a blank EEPROM or an EEPROM image from a different version.
- Disconnect the programmer and install the PIC in the correct orientation. Check the 8 MHz crystal and 5 V supply before applying power.
- Perform the first-run tests with loads disconnected. Only connect a coil after output timing and startup behaviour have been checked.
ICSP reference for both 18-pin devices: VDD pin 14, VSS pin 5, VPP/MCLR pin 4, ICSPCLK/RB6 pin 12 and ICSPDAT/RB7 pin 13. The last two also drive accessory outputs, so attached hardware may load the programmer. This pin list is not approval for unverified in-circuit programming.
5. First run & output behaviour
Initial configuration in the documented HEX files
| Setting | Initial value |
|---|---|
| Address fields | CV513 = 0, CV521 = 0. Configure an explicit address before layout installation. |
| Output-enable mask | CV514 = 255: all eight outputs enabled for commands. |
| Pair timing | CV515–518 = 10: approximately 100 ms per activation. |
| Identification bytes | CV519 = 0; CV520 = 0. The version is identified by the selected package, not these bytes. |
| Configuration byte | CV541 = 128. Leave it unchanged. |
| Remembered outputs, v6.01 | 0x00: no output initially selected. |
| Remembered outputs, v7.01 | 0x80: output 8 initially selected at startup. |
- Inspect soldering, supply polarity, PIC orientation and driver orientation.
- Apply the external DC supply with current limiting and no loads connected. Verify the logic supply is approximately 5 V.
- Provide a valid DCC signal. Configure the decoder address and required timing CVs.
- Use a suitable low-current test load to check each pair and both sides, including an explicit off command. Confirm actual pulse duration.
- Power-cycle and check which outputs are restored. Do not assume they remain off while waiting for the first command.
- Switch everything off and connect one real accessory at a time.
Timed operation
An on command starts the selected output and restarts its timer. A valid off command can turn it off earlier. Repeated on commands can extend energisation; the nominal CV duration is not a maximum under all command patterns.
Continuous operation
A timing value of zero removes the automatic timeout. Switching one side on does not provide a guaranteed interlock that turns the other side off. For a two-aspect signal, explicitly switch the unwanted side off before switching the desired side on.
Power-up and signal loss
Remembered state is restored to the outputs on power-up. For pulsed accessories this can refresh the stored position; for lighting it can restore the display. There are no physical position sensors, so the stored command is not proof that a turnout moved.
Do not rely on signal loss to turn a load off. The watchdog and output-memory logic are not an independent emergency-stop circuit. Switch off the accessory supply to guarantee removal of load power.
6. CV programming & addressing
A CV is a configuration variable stored in EEPROM. This decoder uses the accessory CV numbering 513–521 and 541. These are not railDECOrc’s locomotive or secondary-address CVs.
Programming methods
| Method | Use | Important condition |
|---|---|---|
| Direct service-mode byte access | CV writes; verify instructions can produce a local LED response. | The controller must support CV numbers above 512 and sending writes without a detectable current ACK. Automatic CV reading is unavailable. |
| Paged service-mode access | Alternative CV write path; acknowledgement remains local to the LED. | Requires a compatible controller that can send the sequence without current ACK feedback. Do not substitute locomotive CV numbers or a guessed page value. |
| Accessory operations-mode programming | Addressed CV writes without moving the decoder to a separate programming setup. | Requires the accessory programming packet format supported by this firmware, not locomotive PoM. |
| Local acknowledgement | The programming LED flashes after an accepted operation or a successful verify. | No detectable current ACK reaches the DCC source in this separately powered design. There is no RailCom readback either. |
The firmware requires repeated identical programming packets. Let a compatible command station generate the sequence; a single manually transmitted packet is not sufficient. Bit-manipulation programming is not documented as a supported method here.
Do not select automatic service-mode CV reading. This hardware cannot return the current ACK needed for it. Confirm writes through the local indicator and practical output checks, or inspect EEPROM with a PIC programmer when an exact stored value must be established.
Address fields
The raw decoder-address format is N = CV513 + 64 × CV521, with CV513 containing the lower six bits (0–63) and CV521 the upper three bits (0–7). Do not write the entire displayed turnout number into CV513.
Many controllers show four consecutive turnout addresses per decoder. Under the common one-based convention, decoder address N = 1 corresponds to turnouts 1–4, and N = 5 corresponds to 17–20. Other controllers apply a numbering offset. Establish the mapping on a bench test before assigning layout addresses.
The stored initial address fields are zero; do not assume that this means “turnouts 1–4” on every controller. For first commissioning, set CV513 = 1 and CV521 = 0, then test the four pairs using your controller’s documented numbering.
After changing an address
For operations-mode writes, send each change to the address currently in use and expect the destination to change when the address fields change. For initial setup or recovery, service-mode programming avoids needing to know the old accessory address. Always verify the result using a harmless load.
7. CV reference
All values in this table are decimal. Defaults are taken from the EEPROM data in the documented firmware images.
| CV | Initial value | Purpose |
|---|---|---|
| 513 | 0 | Lower six decoder-address bits. Use 0–63; see the address-isolation and numbering notes in chapter 6. |
| 514 | 255 | Output-enable mask. Bits 0–7 correspond to outputs 1–8; 1 accepts commands, 0 inhibits that output’s command handling. |
| 515 | 10 | Pair 1 timing: outputs 1 and 2. Zero = continuous; non-zero = nominal 10 ms steps. |
| 516 | 10 | Pair 2 timing: outputs 3 and 4. Same scale. |
| 517 | 10 | Pair 3 timing: outputs 5 and 6. Same scale. |
| 518 | 10 | Pair 4 timing: outputs 7 and 8. Same scale. |
| 519 | 0 | Stored version-identification byte; protected against normal writes. It does not contain 6.01 or 7.01. |
| 520 | 0 | Stored manufacturer-identification byte; protected against normal writes. Do not assume the DIY identifier 13 is stored here. |
| 521 | 0 | Upper three decoder-address bits, 0–7. Higher-group isolation requires checking before layout use. |
| 541 | 128 | Stored accessory configuration byte. Leave at 128; it is not a user-selectable lighting mode or factory-reset command. |
CV514 bit weights
| Output | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|
| Bit | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| Weight | 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128 |
Add the weights of the outputs whose commands you want enabled. For example, 15 enables outputs 1–4; 252 enables outputs 3–8. The mask is not an immediate all-off command: it does not guarantee that an already active or restored output is cleared. Send off commands before disabling outputs, and disconnect load power for electrical isolation.
Timing values
Nominal duration ≈ value × 10 ms. Examples: 5 ≈ 50 ms; 10 ≈ 100 ms; 20 ≈ 200 ms; 50 ≈ 500 ms. The byte accepts 0–255, with zero reserved for continuous operation. Actual pulse duration depends on firmware operation and the command stream; measure it for a coil load.
Do not write unspecified CVs. No factory-reset command such as “CV8 = 33” is defined for this accessory firmware.
8. Configuration examples
Use a compatible accessory CV programmer. For first setup, isolate the decoder and use service mode with its external supply present and loads disconnected. Examples use the raw CV numbers, not zero-based EEPROM offsets.
A. Four timed turnout pairs
CV513 = 1 CV521 = 0 CV514 = 255 CV515 = 10 CV516 = 10 CV517 = 10 CV518 = 10
All eight outputs accept commands. Each pair has a nominal 100 ms on-time. Under the common one-based numbering convention, select turnouts 1–4; confirm the controller’s mapping before attaching mechanisms.
B. A longer pulse for pair 2
CV516 = 20
Pair 2, outputs 3 and 4, now uses approximately 200 ms. The other timing CVs are unchanged. Increase coil energisation only if the accessory permits it; repeat commands may extend the pulse.
C. Continuous lighting on pair 1
CV515 = 0 Show side A: output 2 OFF output 1 ON Show side B: output 1 OFF output 2 ON
Use the controller’s accessory activate/deactivate commands. Continuous mode does not convert the pair into an automatically interlocked signal controller. A controller that only transmits brief activation pulses followed by off packets may need different settings for steady lighting.
D. Enable commands only for outputs 1–4
First send OFF to outputs 5, 6, 7 and 8. CV514 = 15 1 + 2 + 4 + 8
Do not use this mask as a substitute for disconnecting a load during maintenance. To re-enable commands for all outputs, write CV514 = 255.
E. Move to decoder address 5
CV513 = 5 CV521 = 0
Under the common one-based convention, the four turnout numbers become 17–20. Other controllers can use a different offset. When writing by operations mode, account for the address changing after CV513 is written.
Keep a configuration record
Record the fitted PIC, HEX version, both address CVs, mask and four timing CVs, plus the controller’s displayed turnout numbers. Note which outputs operate on power-up.
9. Troubleshooting & recovery
| Symptom | Checks |
|---|---|
| No outputs respond | Check the separate DC supply, 5 V logic supply, PIC and firmware match, external crystal, DCC signal, address mapping and CV514. DCC alone does not power the loads. |
| An accessory moves at power-up | Output memory is restored at startup. The documented v7.01 image initially selects output 8. Test without coil loads after programming. |
| The wrong turnout number operates | Check raw decoder versus turnout numbering, controller offset, pair mapping and address isolation. Do not compensate blindly by changing CV521. |
| Other address groups also operate this board | Disconnect loads and isolate the module. Verify the fitted firmware and high-address filtering before connecting multiple decoders on the layout. |
| Lights go off immediately | Set the pair timing to zero, then check whether the controller is sending an off/deactivate packet immediately after on. Also check the mask and wiring. |
| Both sides of a steady pair stay on | Send an explicit off command to the unwanted output. Do not assume selecting the other side provides an interlock. |
| Coil or driver becomes hot | Remove accessory power immediately. Check timing is non-zero, repeated commands, stalled mechanism, current, supply voltage and simultaneous loads. |
| LED flashes, but programmer reports failure | The LED load is powered by the external supply, not the DCC source. Its current ACK cannot be detected by the command station. An individual write may have succeeded; check it locally or inspect the PIC EEPROM. Do not join the power domains. |
| Automatic CV reading always fails | This is a known limitation of the separately powered, isolated circuit. The retained ACK hardware cannot provide DCC current readback. Changing controller settings or retrying reads will not repair that hardware limitation. |
| LED does not flash | Check a compatible accessory CV packet and repeated writes. Verify LED polarity and its driver; a physical LED fault can hide an accepted command. |
| Output-enable mask does not switch a load off | The mask inhibits command handling rather than forcing all outputs low. Re-enable the output if necessary, send off, then set the intended mask. Disconnect power for a guaranteed stop. |
Recover an unknown address
Disconnect all loads and other decoders. Use an isolated service-mode setup that supports accessory CV numbers and sending writes without current ACK feedback, then rewrite CV513/CV521. If service programming is unavailable, read and back up the PIC using a programmer, then reinstall the matching documented image including its EEPROM.
Reloading the HEX restores its initial EEPROM contents, including its startup-output state. There is no documented CV reset shortcut. A DCC reset packet is part of service programming and must not be confused with a factory reset.
10. Acknowledgements & references
Thanks to the modelling community
RailPIC thanks all the railway modellers who have helped over the years by building boards, testing ideas on their layouts, sharing experience, reporting problems and offering practical advice. Their generosity and enthusiasm have made these projects possible.
The accessory firmware credits Dean Probst, Mike Bolton, G. Ising and Stefano Curtarolo, with its technical roots in the MERG DCC work. Their decoder and programming contributions are gratefully acknowledged.
The RailPIC project history also acknowledges Le monde du DCC as a circuit reference and Paco Cañadas for contributions through his model railway electronics designs. The RailPIC adaptations and output-memory behaviour build on this wider body of shared knowledge.
Thank you also to everyone who contributed in less visible ways: a careful test, an encouraging message, a useful question or a willingness to try a circuit on a real model railway.
Project and technical references
- tren.enmicasa.net — project website.
- RailPIC accessory decoder project page — project description and published firmware packages.
- MERG — Model Electronic Railway Group.
- Paco’s model railway electronics website.
- NMRA S-9.2.2 — configuration-variable definitions. This manual retains the accessory CV numbers used by the documented firmware.
Refer to the manufacturer’s documentation for the fitted PIC, ULN2803A, optocoupler and regulator when checking electrical limits. Component ratings do not by themselves certify the assembled board.
Scope of this manual
This manual describes the two published firmware images identified in chapter 4. Their HEX checksums and initial EEPROM data have been checked against the stored files and the packages currently downloadable from the project website. This is not a claim of new physical testing, a complete firmware audit, or NMRA certification.
Before installation, confirm the fitted board revision, supply/load limits, practical controller numbering and address isolation on the installation.
Attribution and redistribution
Acknowledging an author does not itself grant redistribution rights. This manual links to the project’s existing public packages without embedding third-party manuals, photographs or PCB artwork. It does not assign a new licence to the firmware or other authors’ work.