PROJECT: Simple PC to DCC controller
You will need
15V 4A 60W Laptop AC Adapter Power Supply (Banggood £5.42)
micro
15V DC pulsed on one track and 0 volts on the other then switched for 0 volts and 15V (reversed) so that there is always 15 Volts present on the tracks but the polarity changing with each pulse.
Each pulse represents either a 1 or a 0 dependent on its cycle time.
a 1 is of length 58uS+58uS = 116uS 50% duty cycle ± 6uS (~8.620kHz) ~9to8.2KHz
a 0 is longer at 100us+100uS = 200uS (Minimum) ~5KHz
DCC 1 and 0 pulses
A "packet" of data is encoded into blocks as follows:
each packet sequence starts with a special long "Preamble" block of "1"s, data is 8bits
General Packet Format
Note, portions within square [ ] brackets must occur one or more times.
Preamble:
The preamble to a packet consists of a sequence of at least 12 "1" bits.
Packet Start Bit:
The packet start bit is the first bit with a value of "0" that follows a valid preamble. The Packet Start Bit terminates the preamble and indicates that the next bits are an address data byte.
Address Data Byte:
The first data byte of the packet normally contains eight bits of address information
The first transmitted address bit is the most significant bit of the address data byte.
NOTE: Address Data Bytes with values 00000000, 11111110, and 11111111 are reserved for special operations and must not be transmitted
[
Data Byte Start Bit:
This bit precedes a data byte and has the value of "0".
Data Byte:
Each data byte contains eight bits of information used for address, instruction, data, or error detection purposes.
The first transmitted data bit of each data byte is the most significant bit of the data byte.
]
Packet End Bit:
This bit marks the termination of the packet and has a value of "1"
Speed and Direction Packet For Locomotive Decoders
111111111111 0 0AAAAAAA 0 01DCSSSS 0 EEEEEEEE 1
Preamble Byte One Byte Two Byte Three (Error Detection Data Byte)
Byte One: Address Data Byte = 0AAAAAAA The address data byte contains the address of the intended recipient of the packet.
Byte Two: Instruction Data Byte = 01DCSSSS The instruction data byte is a data byte used to transmit speed and direction information to the locomotive Digital Decoder.
Bits 0-3 provides 4 bits for speed (S) with bit 0 being the least significant speed bit. Bit four of byte 2 (C) by default shall contain one additional speed bit, which is the least significant speed bit. For backward compatibility, this bit may instead be used to control the headlight. This optional use is defined in RP-9.2.1.
Bit 5 provides one bit for direction (D).
When the direction bit (D) has a value of "1" the locomotive should move in the forward direction. A direction bit with the value of "0" should cause the locomotive to go in the reverse direction.
Bits 7 and 6 contain the bit sequence "01" which are used to indicate that this instruction data byte is for speed and direction
Byte Three: Error Detection Data Byte = EEEEEEEE The error detection data byte is a data byte used to detect the presence of transmission errors.
The contents of the Error Detection Data Byte shall be the bitwise exclusive OR of the contents of the Address Data Byte and the Instruction Data Byte in the packet concerned. (e.g. the exclusive OR of bit 0 of the address data byte and bit 0 of the instruction data byte will be placed in bit 0 of the error detection data byte...)
Digital Decoders receiving a Baseline Packet shall compare the received error detection data byte with the bitwise exclusive OR of the received address and instruction data bytes and ignore the contents of the packet if this comparison is not identical.
Reset Packet
111111111111 000000000 0 00000000 0 00000000 1
Preamble Byte One Byte Two Byte Three (Error Detection Data Byte)
Idle Packet
111111111111 0 11111111 0 00000000 0 11111111 1
Preamble Byte One Byte Two Byte Three (Error Detection Data Byte)
Note an interesting open source PC User Interface called DCC++