Silicon Junction Logo dcc @ silicon junction

Command Station

The command station accepts commands from a PC and outputs a DCC signal directly to the rails. It is based on a PIC 18F2550. It has a very simple command set and depends on the PC based front end for any complex logic. It is suitable for a small layout and does not need much else apart from a PC and a layout. It is largely based on a previous design. The PIC chip has been upgraded from a 16C84 to a 16F876 to now a 18F2550. The port has moved from a bit banged RS232 to a proper RS232 to now a USB port. RS232 serial ports are a dying breed and USB ports are available on any PC. The new PIC also allows development in C making it easier to develop code for it. Support for debugging using the ICD or PICKit modules is an added benefit. It has a faster clock of 40 MHz. It is pin compatible with older PICs allowing me to use the previous design almost intact. The driver circuit has remained unchanged.

Features

The Command Station has the following features.

  • Four outputs - each capable of providing 2A. This provides support for isolated blocks.
  • Uses a USB connection to interface to the PC
  • Uses an ASCII based protocol. It can be tested using a simple terminal program
  • One of the four outputs is a programming track to program decoders in service mode. It can also be used as a normal track.
  • The outputs are independent can can reverse polarity to support reverse loops
  • The outputs are individually protected against short circuits. A short circuit in one block will not shut others down

Command Set

The command set has been kept to the bare minimum. This may be expanded in future. For now, all the complex logic is on the program running on the host PC. The protocol involves sending a command to the command station in ASCII. A command is terminated with a carriage return. The first character defines the command and the rest of it consists of hex digits. The response consists of a line feed, one character or more terminated by a carriage return and line feed. This protocl makes it easy to interact with the command station using a terminal set to local echo for testing.

N nn nn ... <CR>
nn nn => DCC Command bytes including error byte in ASCII hex
Response is Y
The entire contents of the DCC packet to be sent including the error byte are sent. Each byte is represented by two hex digits. The command station comes out of prgramming mode, if in that mode.
P nn nn ... <CR>
nn nn => DCC Command bytes including error byte in ASCII hex
Response is Y if the decoder acknowledges the command and N otherwise.
The comand station goes into programming mode where the three normal rail outputs are shut off and the packets are sent only on the programming track.
Unknown command<CR>
Response is E

Hardware

The old design was based on a PIC 16F876 28 pin DIP. I have noticed that while the PIC has changed over time, the driver circuit has remained almost the same. I am using the L298 dual H bridge drivers, which while not the best around, are still the cheapest option. This time I decided to split the PIC chip circuit and the driver circuit. This should allow me to change either part of the circuit or, better still, use an off-the-sheld SBC for the PIC. At the moment, I am using a Modtronix SBC 44UC based on a 18F4550. The old PCB with the original PIC pulled out has been patched into the SBC. I may design a proper PCB for both the SBC and the driver but, fortunately, this is not a priority.


Circuit Diagram

The PIC side of the circuit is just theory at this point till I replace the SBC. The driver side is pretty straighforward. Two L298s provide the four rail outputs and are driven by the PIC outputs and some NOT gates. The diodes on the outputs protect the L298 outputs. The four transistors are driven by the sense outputs of the L298 and are used to sense a short circuit on any of the four tracks. The short circuit threshold is 2A. The outputs of the transistors are connected in a wired-or and go to one of the PIC input pins. The fifth transistor on the programming track detects the feedback pulse during programming and goes to another PIC input.

Software

code is C

feedback to feedback email