Multi-Protocol Auxiliary DCC Decoder with 8-Channel Current Occupancy Sensing
Production auxiliary DCC decoder with 16 switched outputs, 8 current-sense occupancy inputs, USB configuration, RS485, Loconet, Railcom support, and short-circuit protection for model railway control.
Advanced Project
— This is advanced because it combines real-time DCC/Railcom timing, multi-channel current sensing, protected power switching, and multiple external buses (USB, RS485, Loconet) in a production design that must survive noisy railway wiring and fault conditions.
Assumptions:
- The decoder is intended for a model railroad accessory bus and will be powered from track or an auxiliary supply, not from USB alone.
- Railcom support means the design needs a DCC-capable front end and firmware support for Railcom cutout detection/handling, not just a generic serial interface.
- Loconet is required as a physical bus interface, but the exact protocol stack and electrical layer implementation are not specified.
- The 8 inputs are intended to detect load/occupancy via shunt current sensing on each channel, likely with thresholding in firmware.
- Short-circuit protection applies to the 16 outputs and likely requires per-channel or grouped current limiting plus fast fault detection.
- Production use implies a custom PCB, not a dev board, and parts should be available from major distributors.
Bill of Materials
Compatibility Notes
- The MCU, STM32G474RET6 transceiver, and current-sense front end are all best kept on 3.3V logic, which aligns well with STM32G474RET6, STM32G474RET6, and XC6206P332MR-G.
- ULN2803A is a low-side sink driver, so the 16 outputs must be wired for sinking loads or used with external pull-ups/high-side circuitry depending on the accessory type.
- STM32G474RET6#TRPBF outputs analog voltages to the MCU ADC, so you will need careful shunt selection and ADC reference planning to distinguish occupancy current from idle current.
- Loconet via 6N137 implies isolated or at least level-shifted signaling; confirm the bus electrical layer and connector pinout early because Loconet implementations vary in practice.
- TPS25940ARVCR protects a rail or output group, not all 16 channels individually unless you replicate it or partition the outputs into protected banks.
- If you choose CH340C for USB configuration, the MCU firmware can use a UART-based configuration protocol instead of native USB device firmware, simplifying bring-up.
You'll Also Need
- Shunt resistors for each occupancy channel and any sense resistor network for short-circuit detection.
- Flyback diodes or suppression components if any of the 16 outputs drive inductive loads beyond what the driver package already clamps.
- Connectors for DCC input, Loconet, RS485, USB, power input, and the 16 outputs.
- ESD/EMI protection on external ports, especially DCC, Loconet, RS485, and USB.
- PCB layout, thermal copper, test points, programming header, and enclosure/mechanical hardware.
- Firmware for DCC decoding, Railcom timing, Loconet protocol handling, USB configuration, fault logging, and output mapping.
Estimated BOM Cost: $30-35 (based on live distributor pricing)
Design Considerations
DCC and Railcom Timing
DCC decoding and Railcom cutout handling are timing-sensitive, so the MCU should use timer capture/compare and DMA rather than bit-banging in interrupts alone. The STM32G474RET6 has enough timer and ADC resources to timestamp edges and sample current quickly, which is important if you want reliable Railcom detection under noisy track conditions. Budget firmware time for edge-case handling such as missing preambles, malformed packets, and brownout recovery.
Occupancy Threshold Design
For 8 current-sense inputs, choose shunt values so the occupancy current is clearly above noise but does not waste too much voltage. In practice, you want a threshold margin that survives temperature drift and production tolerance, so calibrate the ADC thresholds in firmware and consider per-channel offset storage. The STM32G474RET6#TRPBF makes this practical, but only if the shunt and gain are chosen together.
Output Protection Strategy
Do not rely only on firmware to protect the 16 outputs from shorts, because a hard short can damage the driver before software reacts. Use TPS25940ARVCR or a similar protected switch on the supply rail or output banks, then let the MCU log the fault and disable the affected channel group. If you need per-output protection, the BOM and PCB area will rise quickly, so partitioning into banks is often the best compromise.
Bus Noise and Isolation
Model railway wiring is electrically noisy, with long cable runs and inductive loads, so STM32G474RET6 and Loconet should have ESD protection and a clear grounding strategy. The STM32G474RET6 is a good 3.3V bus transceiver, but the Loconet side may benefit from isolation using 6N137 if the installation environment is harsh. Keep the bus connectors near the board edge and route the sensitive analog sensing away from the high-current output traces.
USB Configuration Architecture
If USB is only for configuration, a UART bridge like CH340C can simplify production and reduce firmware complexity. If you need richer diagnostics or field updates, a native USB stack on the MCU may be worth the extra effort, but it increases validation time. For production, define a simple, versioned configuration protocol and include a bootloader or recovery path.
Production Test and Calibration
Plan for factory test points on every current-sense channel, the DCC input, the bus interfaces, and the protected power rails. A production decoder should be able to self-test outputs, verify occupancy thresholds, and report fault counters over USB or STM32G474RET6 before it leaves the line. Calibrate current-sense offsets and store them in nonvolatile memory so channel-to-channel variation does not cause false occupancy reports.
Want to customize this project or build something different?
Try the Project Advisor


