EmbeddedRelated.com

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

Microcontroller
Top Pick STM32G474RET6 STMicroelectronics From our database
STM32G474RET6 is the best overall choice because it gives you the timer, ADC, DMA, and interrupt performance needed for DCC/Railcom timing, 8-channel current sensing, and 16-output control in a production decoder.
Digikey $8.66 (3,759 in stock) Mouser $9.19 (2 in stock)
STM32F303RET6 STMicroelectronics From our database
Good alternative if you want a proven mixed-signal MCU with fast ADCs and timers for current sensing and DCC timing. It has enough peripheral bandwidth for USB configuration plus bus interfaces, though it is less capable than the G4 for future expansion.
ESP32-S3-WROOM-1 Espressif Systems From our database
Useful if you want extra headroom and built-in USB support, but it is less ideal than STM32 for deterministic DCC timing and analog measurement. It can still handle configuration and bus bridging, but the real-time decoder functions are a tighter fit on STM32.
DCC / Railcom Front End
Top Pick TLV9062IDR Texas Instruments
TLV9062IDR is the best pick here because it gives you a cleaner analog front end for DCC/Railcom-related sensing and current measurement while still being easy to use on a 3.3V production PCB.
Digikey $1.10 (7,115 in stock) Mouser $1.10 (3,970 in stock)
LMV358AIDR Texas Instruments From our database
A practical dual op-amp for analog conditioning around DCC/Railcom detection and current-sense signal scaling. It is widely available, runs from 3.3V, and is useful for comparator-like front-end support when paired with proper thresholding in firmware or external comparators.
LMV331IDBVR Texas Instruments
Single comparator that is useful for fast threshold detection in DCC/Railcom-related sensing paths. It is a better fit than a general op-amp when you need crisp edge detection or fault detection with minimal firmware latency.
Occupancy / Current Sensing
Top Pick INA180A1IDBVR Texas Instruments From our database
Top pick: INA180A1IDBVR (Texas Instruments). Low-cost, widely used current-sense amplifier family that is easy to integrate for 8 occupancy channels. It provides a simple analog output proportional to shunt current and is a strong production choice if you want a modern, readily available part.
INA181A1IDBVR Texas Instruments
Similar role to INA180 but with improved accuracy options depending on gain variant, making it attractive for low-current occupancy detection. Good when you need better threshold repeatability across temperature and production spread.
Digikey $0.44 (13,184 in stock) Mouser $0.43 (67,894 in stock)
Actuator / Output Driver
Top Pick ULN2803A Texas Instruments From our database
ULN2803A is the best overall fit for a straightforward 16-output auxiliary decoder because it is simple, cheap, and well understood for low-side accessory driving.
Digikey $1.81 (17,990 in stock) Mouser $1.81 (19,583 in stock)
TBD62083APG Toshiba
Another 8-channel low-side driver with integrated clamp diodes, suitable for driving 16 decoder outputs in a compact design. It is a practical alternative if you want a straightforward sink-driver topology.
Digikey $2.19 (5,704 in stock)
TPS1H100AQPWPRQ1 Texas Instruments
Smart high-side power switch with protection features, useful if the outputs need per-channel fault handling and current limiting rather than simple sinking. Better for production robustness, but more expensive and more complex than a Darlington array.
Short Circuit Protection
Top Pick TPS25940ARVCR Texas Instruments
TPS25940ARVCR is the best choice for production short-circuit protection because it gives you programmable current limiting and fast fault response, which is much better than a passive fuse for a decoder that must survive repeated faults.
Digikey $2.57 Mouser $3.00 (2,403 in stock)
TPS2553DBVR Texas Instruments
Current-limited power switch with fault reporting, useful for protecting accessory power rails or grouped outputs. It is a strong production choice when you want controlled shutdown behavior instead of relying only on firmware.
Digikey $1.00 Mouser $1.20 (21,884 in stock)
BTS50085-1TMA Infineon
High-side protected switch with robust automotive-style protection features, suitable if one or more output groups need strong short-circuit handling. It is more capable than a basic load switch, but also larger and more expensive.
Power Supply
Top Pick XC6206P332MR-G ROHM Semiconductor From our database
XC6206P332MR-G is the best fit for the 3.3V logic rail because it is low power, compact, and appropriate for the MCU and interface circuitry in a production decoder.
Digikey $0.55 (3,365 in stock) Mouser $0.55 (16,390 in stock)
LD1117V33 STMicroelectronics From our database
Simple and widely understood 3.3V LDO with enough current for a modest logic section. It is easy to source, but its quiescent current and dropout are not as attractive as newer low-power regulators.
R-78E5.0-0.5 RECOM From our database
Efficient switching regulator module for generating a 5V rail from a wider input range, which can be useful if the decoder is fed from track or auxiliary power. Better thermal performance than a linear regulator when input voltage is high.
Connectivity
Top Pick MCP2221A-I/SL Microchip Technology From our database
Top pick: MCP2221A-I/SL (Microchip Technology). USB-to-UART bridge with USB configuration support if you want a simple PC configuration interface without implementing a full USB device stack in the MCU. Useful for production bring-up, though it does not replace a native USB peripheral if you need richer USB features.
Loconet Interface
Top Pick 6N137 Lite-On
6N137 is the best practical starting point for a production Loconet interface because it gives you isolation and good edge speed, which helps in a noisy model railway environment.
Digikey $0.82 (71,418 in stock) Mouser $1.70 (10,699 in stock)
TLP2361 Toshiba
Fast logic optocoupler that can be used to isolate Loconet signals while preserving timing margin. Better than slow optocouplers when you need cleaner edges and less protocol distortion.
SN74LVC1T45DBVR Texas Instruments From our database
Single-bit level translator for a non-isolated Loconet physical layer when the bus and MCU logic levels differ. Useful if you implement Loconet without galvanic isolation, though isolation is usually preferable in production.
USB Configuration
Top Pick FUSB302BMPX ON Semiconductor From our database
Top pick: FUSB302BMPX (ON Semiconductor). USB Type-C controller with PD support if you want a modern USB-C connector and robust attach detection. It is more than you need for simple configuration, but it can be useful if the product must present a USB-C port.
CH340C WCH AI suggestion - verify availability
Low-cost USB-to-UART bridge with minimal external components, useful if configuration can be done over a serial protocol. It is easy to integrate, but it is not as flexible as a native USB device.
FUSB302B11MPX onsemi From our database
Similar USB-C/PD controller option with broad availability and a modern connector strategy. Best if the product specification explicitly wants USB-C rather than legacy USB.

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)
Add to Digi-Key Cart

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