Warning - long post ahead.
My DCC coding rig is actually quite simple - I use a 18200 IC booster (go
here, click on MiniBooster at the bottom) from the MiniDCC system. It is a motor control IC, and pin 3 is connected directly to the output of the serial port. It actually doesn't matter if it is a fully compliant serial port you are using (ie a mainboard port or a USB dongle port) since it doesn't need TTL conversion. What makes it work so well is that pin is actually the motor direction pin - the IC is set to send full voltage output and when the serial port goes high to low (or low to high) it simply reverses polarity on the IC. This is perfect for DCC as it cleans and squares off the signal automatically. No other circuit could do this as efficently and easily.
As for the signal to the track, this took a lot of reading and understanding of how a DCC data string is put together. The NMRA standards documents helped a lot with this. Essentially a "one" on the rails is a short low/high, and a "zero" is a long low/high. The timing of the "one" is crutial, the "zero" can vary in length greatly. A serial port set to 19200 is close enough to the timing standard so that a 0 and 1 sent together on the serial port is read by the loco as a 1, and two or more 0s and two or more 1s sent together is read as a zero. The trick is configuring the 8 bit serial port (with leading and trailing bits) to send that data - it was a LOT of figuring which resulted in some not really pretty coding!! But it does work.
So that gets the data to the track, but I also wanted to control switches, relays for master power, etc. That is accomplished using 4099 8 bit addressable latches in arrays controlled by the parallel port. This could be considered really old school but it is a setup I came up with a long time ago to do home automation and it works for me. Plus the chips are cheap. This could also be done with I2C controllers to really lower the chip count.
If you want to play with this code you're welcome to do so (as long as you don't plan on selling it of course), but it is in VB6 and has been programmed pretty specific to my rig. The function is in there to create the DCC strings but it is kinda buried and I'm awful at my in-program commenting.
Another system you may want to look in to is the
TMWDCC guys. I started with their DOS system which worked great, but it uses a PIC chip feeding from the LPT port and Windows doesn't handle the interrupt based coding very well (actually not at all) so it couldn't be adapted to my plan. TMWDCC2 however is their windows version and was the inspiration for my current system. Lars sent me the code to do the conversion but it was in C++ and I couldn't use it, so I started scratch. Bottom line is the DOS version works very well, and if you want one of the programmed PIC chips to play with I'd be happy to mail it to you. (It also utilizes wired remote controls which are easy to build.) But if you want to jump to serial port control (which you'll kinda need to do for Windows), play with the bare bones verion of TMWDCC2 they have posted. In both cases, you'll still need a booster and that 18200 IC works amazingly well.
Whew! Hope that helps...
Mark