We present you a new version of the controller for model railways. About 5 years ago since the publication of this article, I was approached about the production of a small control unit that will use PWM modulation to control a DC motor in both directions (Bidirectional controller for a model railway). It was supposed to be a direct replacement for the well-known transformer PIKO FZ1. Since then, many suggestions have been made to improve this controller, and the new version already includes all the following changes:
- short-circuit / overload detection at the output (may occur when crossing switches)
- addition of an input rectifier for the possibility of power supply by the transformer itself (it also serves as protection against polarity reversal)
- replacement of the output relay with an electronic H-bridge
Connect the power supply to the input terminal block, it is possible to connect a DC power supply in the range of 7 – 30 V and an AC power supply in the range of 6 – 21 V. The output voltage is the same as the input voltage, only lower by the drop on two diodes in the rectifier bridge. In the power supply part of the connection there is a linear stabilizer 7805, which stabilizes the voltage to the value of 5 V for powering the microprocessor. Blocking capacitors according to the catalog sheet are connected in the vicinity of the linear stabilizer. One blocking capacitor is directly on the power terminals of the ATtiny85 microprocessor. The direction and speed are set using a potentiometer. Zero speed is in 50% of the potentiometer position and this is indicated by a lit LED. By slowly turning the potentiometer in one direction, the output is regulated by means of PWM modulation, when turning in the other direction, the opposite. The double H-bridge L293D is fitted here as a switching element. Here, only half of its potential is used, but in another connection with it it is possible to control a stepper motor, or two DC motors with polarity rotation, or 4 motors in one direction. A 0.33 Ohm sense resistor is connected between the GND of the H-bridge and the GND of the controller itself, on which the voltage drop is measured. Using Ohm’s law, the current flowing current can be calculated. The maximum current that this controller can supply is 600 mA continuously and 1.2 A peak. The above-mentioned short-circuit detection limits the output when the current flows higher than 1A, this detection is signaled by 3 flashes of the LED diode. If a current higher than 600 mA will flow for more than 3 seconds, the controller itself will start limiting the PWM output to reduce the current flowing as well. The motor can be connected to the output terminal block, the polarity does not matter, in the opposite direction it is enough to swap the motor wires connected to the terminal block.
The size of the PCB is 41 x 39 mm (22 mm height), on one side there is a potentiometer with a signaling LED diode, on the other side there are terminals for connecting the power supply and the motor. The PCB was designed for mounting in a box. The printed circuit board is double-sided with perforations.
Placement plan and PCB:
Placement plan and PCB are at 1:1 600 dpi (How to print a PCB design can be found in the post How to print PCB design). Real size PCB is 40,7 x 39,0 mm. PCB templates are always from the view side, bottom layer on the left, top layer on the right.
|C1, C4||100nF ceramic|
|C2, C3||100uF/35V electrolytic|
|IO1||7805 voltage stabilizer|
|R3||10k linear (another value can be used )|
|D2||LED diode 5mm 20mA|
|U1||ATtiny85 + HEX program|
|K1, K2||screw terminal, 2pin, RM = 5mm|