Building blocks
The hardware for the DCC monitor consists of the following building blocks:
Processor
The µC includes two 'RS-232' interfaces (for daisy-chaining multiple boards with bi-directional communication). In addition, it contains a rather large amount of memory (to allow in possible future versions filtering of duplicated DCC commands). The ATmega162 was chosen, since it offers two 'RS-232' ports, 16 MB of RAM, is available in DIP40 (40pins) housing (to avoid working with small SMDs) and can be obtained from many places at relatively low costs. In addition, this processor is also used by the OpenDCC project in several of it's designs. This is a nice coincidence, since it helps code portability, and people could easily combine software from both projects to implement other functionality.
The board includes some peripherals, like an 11.0592 MHz crystal clock. The value of 11.0592 MHz was chosen because it allows to drive the RS-232 interface at the exact specified rate. In addition, the board supports a reset-button, three buttons for general use and three LEDs which are connected via resistors to limit current through the LEDs. The µC has internal pull-up resistors, so external pull-up resistors are not needed.
DCC interface
The DCC interface was simply copied from the OpenDCC project and Bahn-in-Haan. It converts the DCC input to acceptable levels for the µC, which includes software to decode the Manchester bi-phase code of the DCC signal. The output from the 6N136 opto-coupler is connected to the INT1/ICP3 pin of the processor, which is a versatile pin able to:
The other candidate for this function, INT2/ICP1, misses the feature to trigger on both rising and falling edges, which makes it a non-optimal choice. Measurements indicated that the rising edge of INT1 triggers when it passes 1.8Volts. The µC incorporates a Schmitt-Trigger, which improves signal stability.
RS-232 interface
The RS-232 interface provides both TxD and RxD. Handshaking seems unnecessary; even in cases that the board would be able to overrun a slow PC, XON/XOFF seems adequate since there is hardly any data going from the PC to the board. However, adding hardware handshaking could in principle be done easily, although that would require some additional components to convert between TTL and RS-232-levels.
A MAX232 plus some capacitors are used for all serial connections to convert between TTL and RS-232 levels. It should be noted that the schema labels the serial connectors DTE-relative. Thus, for the serial out (the female 9-pin sub-D connector), the pin marked "TxD" carries data from the PC to the µC, and the pin marked "RxD" carries data from the µC to the PC. This explains why the MAX232 "T1out" pin is connected to the "RxD" pin on the DE9 connector.
Note that an alternative approach to daisy-chain multiple boards would have been to use a different interface (like SPI) to daisy-chain between the boards, and use the RS-232 interface only between the board and the PC. Using RS-232 for all interfaces allows a "stateless" design, however, which doesn't care whether it's directly connected to a PC or chained to another board.
Since RS-232 interfaces at PCs become rare, the monitoring boards may have to be connected to the PC via a serial to USB converter. Alternatively it is possible to connect to the PC via a serial to Ethernet convertor, such as the Wiznet 105, which is used in the "multi-input" version of the DCC monitor board.
Power supply
The µC board operates on 5Volt. A traditional 7805 stabilizes the DC input source. A diode protects from accidentally reversing the power supply and damaging components. Note that cooling the 7805 may be needed, since the RS-232 interfaces consume quite some power.
Jumpers, connectors etc.
The PCB includes the following three jumpers:
Additionally the PCB includes a few buttons and LEDs, including a button to reset the µC. The other bottons and LEDs may be used for testing purposes.