HERE'S HOW IT WORKS

WinonaShops Home Page

TNT Software ( The QBASIC software to operate the DCC-MB system )

Email to TNT author


"DCC is a serial protocol. However, it differs from other common serial standards such as RS-232 and MIDI in several significant ways:

- With DCC, bits are sent continuously. There are no pauses between bytes, just a continuous stream of bits. This hardware interface deals with eight of these bits at a time; these eight bits are not necessarily an intact data byte. The hardware couldn't care less - it's the software's job to pack the bit stream into 8-bit pieces.

- DCC encodes each bit as a single cycle of a square wave. A '1' bit has a length (period) of 116 us. A '0' bit is 200 us or more. This interface produces '0' bits that are 232 us, exactly twice the length of a '1' bit. [Note - "zero bit stretching", a motor-cooking way to run one analog loco on a DCC system, is NOT supported.] "

The previous excerpt is from Michael Brandt's description of "How It Works".

The following are my additional comments relevant to Chuck Heller's circuit which I use.

The heart of the system is the interface card, or command station. This card has a timer/clock built in hardware . It has a capacitor and precision resistors (C1,R1,R2) which set the fundamental bit periods for '1' and '0' bits to be sent to the booster. The card also has a shift register which generates an interrupt signal (ACK pin 10) to the computer when eight bits have been sent.

When power is supplied to the interface card/command station the timer/clock starts to occillate which stimulates the shift register to begin sending bits, one at a time, from the data which is stored in the shift registers data register. When the eighth bit is sent the shift register transmits to the computer via the ACK pin on the printer port a short interrupt signal which alerts the computer that more data is requested (or that the last bit has been transmitted).

When the computer receives the ACK interrupt signal it immediately enters into the TNTDCC.COM or DCC-MB.COM parallel port Interrupt Service Routine (ISR) to supply the next byte of data to be sent to the shift register through the parallel port. The shift register receives the data and loads it into the shift registers data register and begins to transmit each bit, one at a time, until all eight are sent, at which time it again interrupts the computer through the ACK pin, requesting the next byte to be sent. This process cycle continues endlessly for as long as power is supplied to the card, or until a valid data link is destroyed by unplugging the port cable or disturbing the parallel port connection.

The TNTDCC.COM or DCC-MB.COM Terminate and Stay Resident (TSR) parallel port driver maintains a data base of locomotive data and packet information that is accessed in sequential fashion to maintain the serial bit stream that is resultant on the interface card shift register output which is inturn sent to the booster. The NMRA packet data is composed of eight bit bytes which are formed by the TNTDCC or DCC-MB TSR port driver. It is called a terminate and stay resident program because, once it is called, it runs its initiation routine and then ends, but is still resident in the computer memory to respond to the ACK interrupt signal from the cards parallel port input. The ACK interrupt signals the computer to go immediately to a short routine which sends the next byte, increments the byte counter, checks for end of packet, and then increments to next loco if done with this loco packet. Setting of auxillary functions like headlight on/off or turnout control is inserted as a special insert packet and are transmitted several times and then the sequential transmission of loco packets is resumed.

TNT interacts with the TNTDCC or DCC-MB TSR parallel port driver by using the CALL INTERRUPT statement from within QuickBasic to access the locomotive and accessory packet information database. TNT also manages the Joystick input values, IR TV remote input, and JMRI COM port communications and transfers this information, in an intelligible manner, to the data base maintained by TNTDCC or DCC-MB. TNT also provides screen output for the interpretation of this data and manages and displays other information pertinent to model railroad operations.

It is a marvelous system. The fundamental frequency or bit timing is hardware defined by the interface card, not the computer. The computer is free to do its chores while the card transmits the eight bit packet bytes. The computer is so very much faster than the time it takes to send the byte wide data out the shift register that it can easily accomplish the mundane tasks of user input and display. Also, the DOS operating system allows data I/O from disk by managing I/O buffers so the process is seamless.

TNTDCC and DCC-MB pack the NMRA packet data into eight bit bytes. NMRA RP's show byte data separated by "0"s thus xxxxxxxx0xxxxxxxx0xxxxxxxx0xxxxxxxx etc. SO, the trick is to get data into bytes that are consistent with this scheme. The assembly language contained within the source code for DCC-MB and TNTDCC shows how this is accomplished. The above then becomes (in byte wise fashion) xxxxxxxx 0xxxxxxx x0xxxxxx xx0xxxxx xxx0xxxx. The actual transmission of this data by the shift register is not separated by the indicated spaces but is, in fact, the originally desired continuous bit stream.

The booster receives this logic level data from the shift register as the Q and /Q signals, one being inverse the other. These signals are presented to the H Bridge MOSFet circuit arrangement in the booster which generates the track level signal.

To achieve the JMRI interface a COM port is opened from within TNT and the LocoNet opcode dialog is serviced as described within the Personal Use Edition of Digitrax LocoNet documentation. JMRI is setup to use Locobuffer com port communication and the two systems are connected with a null modem cable. The data received and sent is communicated to TNTDCC by the TNTJMRI program. The Locobuffer is not required, but if two locobuffers where to be used, one on DOS computer and one on JMRI computer, then a total LocoNet type network might be established. This might be useful for turnout control, signalling, etc., however this is not required. TNTJMRI readily implements the position sensors used with TNT. The four remaining printer control pins on the parallel port are used for train position sensors.

It is interesting to note that opcode packetized data communication is quite similar in many respects to Controller Area Networking (CAN), used in automobiles, marine and manufacturing robotics.