Jump to content

Simple DCC controller


kvp

Recommended Posts

A few months ago, i've made a simple DCC controller that lets you control a single DCC locomotive like an analog locomotive. It was made to test decoder installs, but can be used as a single locomotive DCC system. (if you place more than one locomotive on the tracks, they will move together) I think this is the bare minimum a DCC system needs to be usable.

 

The circuit diagram:

post-1969-0-54065900-1411598773_thumb.png

 

The circuit:

post-1969-0-81825500-1411597893_thumb.jpg

 

Operation:

-the PIC microcontroller reads the analog value from the potmeter

 (0: full reverse, 2.5V/center: stop, 5V: full forward)

-translates this into a basic DCC speed packet

-emits this packet on the D0 and D1 pins

-for every locomotive address between 1 and 15

-along with a headlight on command

-the L293DNE H bridge takes the two signals

-and boosts the voltage and the current to the output levels

 

Signals:

-D0: 0 = left rail low, 1 = left rail high

-D1: 0 = right rail low, 1 = right rail high

-only 01 and 10 is used for DCC, 00 removes track power

-for the timing of bits and the packet formats, see the NMRA documentation

 

If anyone has any questions, i would gladly answer them.

Edited by kvp
  • Like 3
Link to comment

Hello kvp,


 


Very simple and elegant!  Is the PIC code complicated?


 


I’ve been thinking of trying to combine DCC, Tomix-compatible HF lighting and DC PWM throttle into one track signal.  If I’m right that DCC uses 10KHz and 17KHz, then that’s probably close enough to the Tomix 21KHz lighting frequency.  And then, maybe you could generate appropriate length dead-spots in a DCC pulse stream (at 1 or 0) to achieve the target PWM duty cycle.  Have you seen anything like that tried before?  Or do you think it would it make DCC decoders barf?

Link to comment
I’ve been thinking of trying to combine DCC, Tomix-compatible HF lighting and DC PWM throttle into one track signal.

 

While the circuit above can be modified to produce a PWM signal with CL (as actually this is a redesigned PWM controller i've designed many years ago), but the DCC signal contains pulses with both polarities. That is not compatible with PWM or a CL circuit. Actually there is a PWM like mode in DCC, called zero stretching (or address mode 0), where a PWM signal is modulated between two DCC packets, but it tends to damage more sensitive motors (due to overvoltage) and quickly heats up all of them, which will damage all of them sooner or later. At the same time the CL circuit sees the DCC signal and turns on both directions, so both the head and the tail lights light up on both ends, which looks very bad. However CL circuits tend to work with most PWM signals, so even a 100 Hz signal is enough to drive them, but it has to be kept single polarity only.

 

So it is possible to make a combined PWM based controller/DCC booster circuit, but it can only operate in one of the modes at a time. If a layout has block control, then it's possible to switch between PWM and DCC modes depending on which type of locomotive is in the block, but mixing the two signals is not possible without damaging the analog locomotives.

 

I've attached the pic code. Actually it's very simple and could be optimised easily, but it works.

As you could notice, i've disabled the emergency stop function, because this way even if you apply full reverse on the throttle, the locomotives will slow down correctly according to their decelation tables and then after they stopped, reverse and accelerate.

 

For the PWM controller, i connect data pin 5 on the PIC to the enable12 input of the H bridge, connect both data signals to all 4 inputs, set enable34 to high and use outputs 1 and 3 for the track signal. This allows a chopped (drive/tri state) pwm signal to be used, which means no extra heating in the motors like in case of an on/off signal. Also any capacitors can be left in the track and the locomotives without causing trouble. Alternatively, it's possible to use a dptt switch for the direction control and use output 1 only, with all inputs wired fixed. In this case only enable12 is connected to the PIC and it's pulsed with the PWM signal. The PWM mode is better operated with 12-14V DC on the input, so only 10-12V DC goes to the tracks, not the 14V DC of the DCC mode. (at least 13-14V is required by many cheaper N scale decoders to avoid going into analog conversion mode and running off without control)

 

If you replace the L293D with something stronger, you can drive a larger layout or a larger scale locomotive from this circuit.

simpledcc1_asm.txt

  • Like 1
Link to comment
Hi kvp,

 

Thank you very much for the detailed explanation.

 

I hadn’t realized that the DCC pulses switched between opposite polarities.  I guess it makes that idea a bit of a non-starter…

 

So for my Tomix DC layout - if I want to try and transmit accessory control signals over the rails - then it sounds like maybe the approach I should take is to encode the control codes onto a PWM’d Tomix-compatible 20KHz CL signal using my own protocol and not bother trying to be compatible with DCC.  If I make sure that the modified CL pulses look as close to the original as possible then there should be no risk of damaging the Tomix motors.  Of course, that means I’d also have to design and build the decoders rather than be able to plug in some DCC ones off the shelf…

 

My other thought is to just take power from the track and use cheap all-in-one 2.4GHz RF transceiver ICs like the Nordic nRF24L01+ to transmit control codes to accessories and updates from sensors.  I’m not sure if I’m looking at Chinese-copies, but it seems you can pick these up now for less than $1 each.  Plus, that would make the system a lot less Tomix-specific.
Link to comment

You can't transmit large amounts of power above the PWM signal. The Tomix CL works by having very little current consumption compared to motors and turnout magnets. Also since CL power is single polarity, too much CL power and the train will start creeping in the set direction. A control signal can be mixed into the PWM signal easily, but will be prone to noise (back emf) from the directly connected DC motors.

 

I would suggest to use a separate power and data bus, which is imho a good idea even with DCC, since routing accessory power over the rails can be catastrophic in case of a derailment short.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...