DCC Topics

Links

DCC Decoder english -- (para español click aqui)

This page was translated by Ray West. Thank you Ray for your efforts on this!

The main capabilities of the DCC mobile decoder are:

  • 28 and 128 Speed Steps
  • DirectMode CV programming (Programming on the main track)
  • AddressOnly mode (Phisical register addressing)
  • DC Operation if configured in CV29
  • Implementation of the next Configuration Variables
  1. CV1: Address. Obviusly had to be implemented
  2. CV2 : Minimum motor voltage
  3. CV3: Acceleration time
  4. CV4: Desceleration time
  5. CV5: Maximum motor voltage
  6. CV6: Mid voltage configuration
  7. CV7: Manufacturers version.
  8. CV8: Manufacturers code (For this project is always 0xA5 because I don't have a NMRA DCC code)
  9. CV19 : Advanced Consist address
  10. CV29: Configuration variable

One of the challenges of this project was to develop mobile decoders that fit inside each locomotive. Several times I wanted to withdraw from the project because after many hours, days, even weeks, I could not find the problems that caused the decoder to malfunction.

The biggest problem I had to overcome was the electrical noise that made it to the microprocessor which caused it to constantly reset when power was being supplied to the motor. There were reverse voltage peaks whenever the PWM signal was changed.



To try to eliminate these peaks I put capacitors of various types and values in parallel to the motor, but this did not work. I also tried using Zener diodes with a slightly higher voltage than the DCC zener voltage but after destroying some diodes, i decided this was unsatisfactory.

The solution, although it sounds too obvious, as it is a key issue in any course of digital electronics, was to increase the connections to ground. What was happening was that the protoboard where I built the decoder circuit had no adequate direct connections to ground distributed throughout the circuit and this caused the ground level of the microprocessor voltage to vary thus causing the microprocessor to reset. I found this  solution after two months of struggling against these voltage peaks.

 

 

The circuit by stages

The decoder circuit has 5 core modules, although there are some decoders with some additional features that I will describe later.

1. rectification stage(AC - DC)
2. voltage regulation stage
3. processing stage
4. motor power stage
5. function stages (F0, F0, rear front, F1, F2, etc)

1. Rectification stage(AC - DC)

This consists of a rectifier bridge of 4 diodes that receive the track DCC signal and produce a direct current signal to feed the decoder circuit.

At the time of designing the circuit board, ground connections and + DCC must be large enough to handle the maximum current of the motor when it is stalled.

At this stage you could also use a Zener diode in the output of + DCC V to protect the circuit of an overvoltage in the track. I have not included it in my design, however.

Back to Top

2. Voltage regulation stage

The voltage regulation stage is required to supply the microprocessor with a constant voltage of 5 volts. There are designs that work with less voltage, such as 3.3 volts, but it makes little sense to me since this does not need to be a portable device running on low power batteries.

For my design I used the KA78L05A circuit from Fairchild Semiconductor, in a 8-SOP package, 150 thou of inch thick. This circuit also comes in TO-92 and SOT-89 which may have been a better choice. Each of these regulators is able to deliver 100 mA at a constant 5V.

It is necessary to install a small capacitor to the input side (1 to 10 uF) and one of a higher value at the 5V output. This keeps a supply to the microprocessor for a time even if the receiver is disconnected from the track due to dirt or bad point isolation. The duration time is not very long, but may be calculated with the formulae for capacitor discharge.

Back to Top

3.Pprocessing stage

In the design of the decoder, there is one area which is most important, and that is the total size of the components and pcb. With this premise in mind, the initial design used an 8 pin microprocessor  (12F689) which has 1 KB of EEPROM, although in later development the software was too large to fit in that memory.

Another problem with using a small microprocessor is that it could not use all the outputs and an external crystal if using the programmer module ICSP (In Circuit Serial Programming) which is necessary in order to program the PIC once it was installed in the printed circuit board. It was necessary to use an external crystal because I could not design the software to be fast enough to be capable of processing the DCC signals with intervals of 55 uS and at the same time manage the PWM of the motor. If I had managed to produce software to function properly at 4 MHz with the DCC signals I would have been able to use these much smaller microprocessors. However, version 3 of the circuit may use these smaller chips.

I used the PIC16F628A which has 18 pins (16 pins I/O) with a crystal that runs at 20 MHz, which is fast enough to process all tasks of DCC, PWM, lights, etc.

To detect changes in the DCC signal, this module stage does a Capture / Compare, instead of poling a pin specifically to detect its state and therefore its change.

The  value of TMR1 is noted when Capture / Compare mismatches, when the state of RB3 is changed. As soon as the processor detects a change in RB3, either as a rising edge or falling edge, depending on its previous state, TIMER1 starts counting until there is another change in RB3. At that time it is determined if the time corresponds to a logical '1' (58 us) or a '0' logical (100 us).

It is necessary to use a slightly lower resistance compared to other circuits on the Web between the DCC voltage of the track and pin RB3. This resistance is necessary because when the DCC signal is negative with respect to the ground of the decoder, current will be circulated from the PIC. The selected resistance is 4.7K, since with the more usual 10k, the falling edge of the DCC signal was not detected.

RB6, RB7 and RA5 pins are used by the ICSP module to program the microprocessor circuit. This will allow the updating of decoders once any problems are corrected or improvements are implemented. The only drawback of this flexibility in programming the processors is the space required on the printed circuit board for the connector. For future designs and when the software is much more mature, this connector can be left out, allowing a smaller decoder to be built.

Back to Top

4. Motor power stage

The power stage was initially based on the design I found at Mobile DCC Decoder, and it used a dual operational amplifier to handle the motor power. The L272 produced by Fairchild Semiconductor and by STMicroelectronics seemed to be an effective solution to deliver 1 amp to the engine.

 

Entries to the OP AMP are the microprocessor PWM outputs

PWM OUT 1
1
0
0
1
PWM OUT 2
0
1
0
1
Direction of the MOTOR
Right
Left
Stop
Stop

PWM 1 status = 1 and PWM 2 = 1 should not be allowed, since it puts + DCC V on the two motor terminals, this means that there is no potential difference and therefore the motor will not rotate. In MOSFET circuits this condition is not allowed because it will cause the destruction of the transistors.

The problem that I had with this circuit was that the operational amplifiers had a voltage drop of approximately 2 volts and that made the trains run slower, and the L272's also overheated.

It was for these two reasons that I decided to start experimenting with MOSFETS which have a smaller voltage loss, and can handle more current than the L272.

Fairchild Semiconductor have complementary (N and P) MOSETS that can handle up to 7 amps. However I decided to experiment with the FDS8333C that can drive up to 3.4 amp, restricted by the P Channel MOSFET.

The result of these experiments was excellent because even with two motors running at full power there was no overheating in the MOSFETS. The current restricting components are now the bridge diodes in the rectification stage. The circuit with MOSFETS is based on a design that I found on the internet and it worked perfectly. I made some adjustments to the values of the resistors making them more suited to the requirements of surface mount components

In this circuit is very important that PWM1 and PWM2 are not enabled at the same time, since this will cause a short circuit that the microprocessor is unable to detect.

Back to Top

 

5. Function stages (F0, F0, rear front, F1, F2, etc)

 

Volver arriba