In this iteration of the URB Project, I decided to use only the ready-made and most affordable Arduino modules. Old timers of the project can certainly continue using URB units. In my videos you can also see these units, but in the diagrams and sketches accompanying these videos, the URB units are replaced with Arduino Nano Screw terminal shields.
A very important point is the possibility of installing Arduino NANO in the connector on your circuit. You also can connect the wires directly to the pins of the Arduino board, but in this case you will not be able to replace or transfer the Arduino board for reprogramming without destroying your circuit. In addition, the reliability of your system using screw connections is much higher.
When I started experimenting with the most common screw shield for Arduino NANO (hereinafter just the shield), I ran into inconveniences that you will also experience. Firstly, the terminals have a very small size — you will not be able to correctly connect more than one wire to the terminal. This causes big problems when installing power wires to external devices, so the first improvement is the addition of intermediate a common terminals for pins 5V and GND. The secondly, and you will definitely do it, is the incorrect installation the Arduino board turned 180 degrees to the shield. Therefore, add a bright mark or a drop of paint to the corners of the board and shield as a visible key.
This unit is a communicator with local units, and also provides data transfer into an Android application. Since the URB Project allows several players to control your layout, you can connect two Bluetooth modules to the COMM unit. If you want more players, then you will need a more powerful Arduino board, such as MEGA. A feature of the implementation of the Arduino NANO (UNO) board is that when the USB cable is connected to a computer, data transmission via the serial port is carried out through the pins of the D0 and D1 (hardware RX and TX). That is, if you connect the second Bluetooth module to the hardware serial port and also plug the USB cable connected to the computer (this does not apply to the case of connecting power via USB), then nothing will work. That is, you can either use a Bluetooth module connected to a hardware serial port (D0 and D1), or transmit data or updating sketches via a USB cable over computer (this does not apply to the main Bluetooth module connected via a software serial port — D14 and D15).
For the correct operation of the I2C bus, high-level pull-up resistors are needed. There is a rule in the URB Project — to install these resistors only on the COMM unit.
If you have a soldering iron, then you can modify the shield. You will need a regular needle, a four-pin connector and a little time. As you can see, the resistors are also soldered to the reverse side.
You can use any motor-drivers in the URB Project without restrictions, you need only adapt the sketches to your motor-driver. The motor-driver is selected according to the electrical characteristics suitable for your railway. First of all, the voltage and current at the output of the motor-driver matter.
The differences among motor-drivers for the Arduino are mainly in the number of control pins. Basically, there are motor-drivers with three and two control signals (pins) per channel.
All sketches on the site use this motor-driver.
The control of motor-drivers with two wires per channel is somewhat more complicated, since the PWM signal simultaneously sets the direction of rotation. That is, if a low logic level (LOW) is on one pin, then a PWM signal must be output to the second. If you change the situation, then the rotation of the motor will become opposite.
A more then 40mA powerful load can be controlled by Arduino using boosters or relays. One of the options for boosters (current and voltage amplifiers) is the motor-driver discussed above. In most cases, a change in polarity is not necessary, so it is enough to assemble a circuit from several transistors. In the URB Project, instead of transistors, ULN2X03 chips are used, where these transistors are already assembled into a Darlington Array. You can also use any other current output drivers on chip.
If you need blocked a track section on rails, then you need a switch for control it. An electromechanical relay controlled by Arduino solves this problem. Ready-made modules with different number of relays are cheap, but you should pay attention to the principle of their operation. These modules have four states that must be considered when programming of sketches.
By default, the relays are configured for bypass mode. That is, the relay closes the contact to the right NC terminal only when the pin level on the Arduino is LOW.
Several motor shields are built on ULN2003 chips, as well as a stepper motor control module. The connection of these chips to Arduino is simple, a distinctive feature of the circuit with these chips have a common positive wire, in contrast to the usual method with a common GND.
I recommend using new modules with 7 outputs.
The power for an URB control system are divided into two branches, one for moving trains, the second for electronics and devices on the layout. Thus, with short circuits on rails and other troubles with trains, the layout control will not be affected. For simple track-plans use any charger for modern smartphones with a USB connector. The current of such chargers should be about 1 A. For the movement of trains, you can use the transformer you already have from the starter set or any DC power supply with 12V. Please note that the output current also should be about 1 A or more. For larger layouts, use appropriate power supplies.
It is convenient to carry out the connection of wires between the power supply unit and the motor-driver through the power plug-screw terminals. If you want to increase or decrease the voltage for locomotives of your favorite scale (9-18V), then connect the power supply with the voltage you need to the motor-driver.
The ideal solution can be a computer power supply, it immediately gives out voltages both 5V and 12V with protection. Also, you can apply two standard power supplies, to 5V and 12V, by combining their negative wires together.
For users of the URB Project, I have developed several railway devices that you may like. At the heart of all these devices are common and cheap modules for Arduino. You can improve its, copy them freely and, most importantly, share them with your hobby colleagues.
By this mechanism, I am proud as designer! The task was to make such a reliable turnouts switch-mechanism, which will simply and quickly manufactured, while ensuring accuracy of moving the rod to a tenth of a millimeter.
Given the large error in the position of the lever of the cheap servo when stopping after rotation, and the need of convenient adjustment without tools at the installation site, the task seemed to me unsolvable. However, I came up with, and even much more. Shoulders slingshot, as well the mechanism, made of thin galvanized sheet metal, this material is available almost everywhere. So, by bending them with your finger you can adjust the stroke of the rod and, accordingly, the accuracy of the switch position. In addition, these shoulders act as a damper, parrying the errors of the mechanical transmission and securely fix the switch mechanism in the extreme positions. But that is not all. If the servo arm is stop to a position of 90 degrees, the mechanism is unlocked and you can switch the turnout manually.
Unlike other known servo point designs, this design does not require space under the layout. That is, you can place such a mechanism on a table or floor next to the rails. Or, as in the classic Tortoise switch machine, hide the mechanism under the layout.
I also created a modified version of my mechanism with the addition of a Hall sensor. In this modification, the point motor generates a turnout position signal, as when using limit switches. Only it is more reliable, since it does not have mechanical contacts. You can see this mechanism on the video demonstration of feedback in the Pro page.
I have experience in creating three-dimensional objects and have a resin 3D printer. This device allows, in addition to models, to print mechanisms as well.
I redesigned the mechanism shown above and was able to reduce its size. In my accompanying video examples of tracks, you see exactly these devices. The integration of a servo drive mounted on this chassis with a turnout you to place such a mechanism in the inter-track space. 3D files of this mechanism in STL format are available to members of the URB Club.
This really working design was developed a five years ago, and reliably works to this day. The actuators of the barriers is independent, since each barrier is driven by a separate servo. Since barriers can be moved asynchronously and at different speeds, it's more like the real world in which it happens that way. Also in the module use classical flashing lights. The mechanism is made in such a way as to fit completely into the space under the crossing of the move and not to leave its dimensions. This mechanism converts the translational motion of the thrust from the servo to the rotation of the barrier and at the same time has a damper. The horizontal angle of the thrust vector can be set by you in a wide range.
It's design based of the simplest Auhagen 41582 Level crossing kit. Since there are many similar sets, you may use any. And of course, this module work both in automatic mode and in manual controlled mode.
The sources of the train signal about the approach and the departure from the wide railway crossing area are infrared sensors located at a distance from the crossing. The normal servo always rotates at its maximum speed. For different models of servo drives speed is different, there are fast and slow servos, but the speed of rotation is always constant. That is, we can not make the rotation faster than the installed by the servo manufacturer with the help of electronic control (though we can increase the speed mechanically using the reduction gear). But we can lower this speed by rotating the servo shaft to a small angle with a delay, and repeat this process again and again until the servo turns to the desired position. For this I use the alternate library for Arduino VarSpeedServo, very similar in function to the standard Servo library.
Drawings of the mechanism for moving barriers from the video in PDF format can be downloaded below. A discussion about railway crossing management is available to members of the URB Club.
We can apply ANY sensor to Arduino, including such an exotic one as a pressure sensor. However, most of the sensors are large enough, for example, an ultrasonic sensor is very difficult to incorporate into the layout imperceptibly. Also, there are some difficulties with the probability of triggering sensors based on reflection of visible and infrared spectra. In any case, you can experiment and get your own successful designs.
In a situation where you need to get a constant signal while passing the entire train through the sensor zone, the infrared sensor is preferable, only you need to modify its design as on video.
On this module I separated the infrared sensor emitter and receiver. These details deployed relative to the rails by 45 degrees and are located at a certain height above the rails. Also on the receiver is a black slit mask that removes stray radiation. The height of the sensor and the IR-LED above the rails for different scales is selected experimentally based on the minimum horizontal continuous line of wagons in your collection.
This design allows you to get a guaranteed signal of the presence of a train at the sensor zone. The system works correctly at any speed of the train, any the number of cars or types of cars and any length of the train.
As a development of the anther idea of an infrared sensor module like a relay box, I propose a way to mask this system on your railway layout. Glenn Lambert made 3D model for this design and it works really well to hold the sensor and emitter.