DCC Decoder
The Locomotive Decoder:
As simple as I could make it. Once again I am using an ATMEL AVR for the micro-processor. This is a TINY-25 clocked internally at 16MHz using the PLL High Frequency Clock. You can find this is the fuses and the Datasheet 6.2.2. The track is rectified to provide ~12v DC then regulated to 5v. The 12v feeds the motor driver (and motor) and lamps if you choose not to use LED. The track also connects to the voltage divider to provide a 5v version of the DCC square wave to the AVR. The AVR uses PWM to control motor speed. One NPN transistor control the light. Two NPN's, two diodes and two resistors send the bi-directional pulses back to the track. After you rectify the AC to DC, you will want the biggest capacitor you can fit to stabilize the 12v bus. During the listening time and bi-directions communications your locomotive will be relying on this capacitor for all the power. I recommend a dual layer 'Supercapacitor' for this job.
I have attached the EagleCAD schematics and C code for the AVR. The code is not my best work, but it is still experimental.