The general architecture of a DCC control unit
We have seen how an Arduino board can generate DCC signals for speed, function and accessory commands, and even programming.
Between our Arduino board and the rails, we must, of course, amplify these signals so that they can control the engines of the locomotives (via its decoder) from the mains power supply: we need a Booster . This Booster converts a small 0-5 volt signal of a few milliamps into a large current of 2 to 3 amps at +15 to -15 volts (+12 to -12 volts for N).
Then, and above all, you need control devices to decide which DCC commands to send to the rails according to the will of the driver (you): you need one control lever , per user and per train, preferably.
Finally, our control unit must be able to react automatically to certain events such as the detection of the presence of another train which occupies the next block, or a square which requires a stop in front of the traffic light:
for dividing the circuit into Blocks, for regulating traffic, by acting directly on the speed controls of the locomotives,
or for activating the lights or changing the direction of the hands, by acting on the controls of the accessories
Our complete system might look like this general architecture:
all types of throttles, detectors, PCs, tablets, smartphones and their communication protocols (LocoNet, XpressNet, S88, TCP/IP, WiFi, Bus, etc.),and power supplies.
These topics are covered in other articles elsewhere on this site.
But to fix ideas, we are going to describe an example of implementation of a single track for a single train capable of circulating between 2 stations at the ends according to an automatic or manual to-and-fro
All elements of this example can be reused in your project.
Complete the power plant with a Booster
An output pin of an Arduino can only deliver 40 mA maximum (but rather rely on 20 mA): it is therefore impossible to run a loco that needs several hundred milliamps. It is necessary, on the one hand, to amplify the signal and, on the other hand, to raise the voltage to 12-13 Volts (for N) or 15 Volts (for HO).
It therefore requires an interface module called Booster in the railway literature. In reality it is a so-called 4Q chopper (for 4 quadrants or H bridge), reversible in voltage and current whose average output voltage varies between -15V to 15V.
There are ready-made modules on the market that seem made for this (but it’s a happy coincidence!).
The principle of this booster is as follows:
The DCC signal generated by our Arduino is applied to the DIR input which controls the opening of 2 transistors/switches and the closing of the other 2, such that the voltage sent to the rails is either one way or the other. other way. We thus have all the power available but it is positive for 50% of a bit of the DCC signal and negative for the other 50%.
The LMD 18200-based module below fulfills exactly this function.
The DCC signal from our Arduino is connected to the DIR input. This DCC signal will be continuously generated by the Arduino by a process under interrupt, running in the background.
An output pin of the Arduino will be connected to the PWM input: it will allow to control the delivery or the stopping of the current on the rails, from the software (this is important for multiple security reasons that we will see in the software).
The ground of the Arduino is connected to the ground of the Booster and the BRAKE input is grounded because it is not useful in this application (we prefer to use the CV parameters of the loco).
The LMD 18200 circuit also has 2 output signals which are not wired to the terminal blocks:
C/S, analog, is proportional to the current delivered
T/S, digital, indicates if the component temperature exceeds 145°C.
I chose to connect these outputs to Arduino inputs, to monitor the booster and cut the power to the rails in extreme cases.
To do this I soldered 2 wires directly on the legs of the LMD 18200, under the printed circuit:
In the meantime I found a better solution for measuring the DCC current and detecting short circuits: by adding a small current measurement circuit based on Max471, inserted in series in the DC power supply of the LMD 18200, as represented on this picture
Add a controller
It can’t be simpler than a potentio meter, a direction switch and a switch for the light control. In our example, I put 2 potentio meters, one for the forward gear, the other for the reverse gear. This avoids having to use a hard-to-find mid-point potentio meter or direction switch. And the advantage will be that in automatic mode the outward and return speeds may be different.
The simplest TCO will here consist of 3 LEDs:
a green LED to indicate forward gear,
a red LED to materialize the stop,
one yellow LED to indicate the reverse gear,
a 2-line, 16-character LCD display to display the parameters useful for driving.