Documentation > Instruction Manuals
Level Crossing Controller - 2.01.010
Introduction
The Level Crossing Controller (2.01.010) is designed to automate level crossings and can handle a pair of boom barrier motors, a pair of level crossing lights and two IR train detection sensors. The controller can be used with our nControl™ train automation software or stand online.
Computer Controlled Operation
In computer controlled operation the controller is connected to a computer which send instructions to the controller. The instructions can be send manually by clicking tiles or automatically with Python scripts.
Installing the Software and Driver
Start by installing the nControl™ software on the PC, mac or Raspberry Pi you want to control your layout with. You can download the installer from our website. The website also provides detailed installation instructions for the supported platforms.
If you're using Windows or macOS make sure the driver for the controller is installer properly. The Windows installer should install the driver automatically. There is a help page explaining how to check and install the driver on Windows manually. On macOS the driver has to be installer in a separate step. Click here for additional information on how to install the driver on macOS.
Connecting the System
The level crossing controller has 4 device ports:

4DBrix Level Crossing Controllers for LEGO trains.

  • port 1:
    Controls the boom barrier motors. This is a generic servo motor port so it can also control other 4DBrix™ servo motor based devices like track switch motors, decouplers, etc. When you're using boom barrier motors, you can use the Y-split cable to connect two boom barrier motors to port 1. Do not use a Y-split cable when connecting other motors, e.g. track switch motors. By doing so you risk to draw too much current and damage the controller.
  • port 2:
    Controls the level crossing lights. You can use a Y-split cable to connect two level crossing lights to port 2. Port 2 can also control train traffic lights.
  • Port 3:
    Controls an IR train detection sensor.
  • Port 4:
    Controls an IR train detection sensor.
Start by connecting all the motors, lights and sensor to your controller. If you're using Y-split cables, make sure you connect the cable in such a way that the colors of the wires match.
Next connect the sensor to a USB port using the USB cable that came with your controller. The Level Crossing Controller is powered by the USB port to which it is connected. USB ports of computers provide only a limited amount of power. It's advisable to use a powered USB hub to ensure the controller has sufficient power. Furthermore, not all USB ports have a fuse, to protect your computer always use a USB hub that has over-current protection.
The USB cable that comes with your Level Crossing Controller has thicker power lines than standard USB cables. If you wish to use another USB cable, or a USB extension cable, make sure the cable has 24AWG power lines. Standard USB cables with 28AWG power lines are not be able to provide sufficient power to the controller.
Configurating the System
Click on the links below for the getting started guides:
These guide don't use level crossing controllers but all 4DBrix™ controllers have to be configured in a similar way, so you can use the exact same procedure to set-up your automation system with level crossing controllers.
Programming the Level Crossing
We made a demo project that controls a level crossing. You can download the project with the button below.
The project works as follows: when a sensor detects a trail, it closes the level crossing. When the other sensor detects the train it reopens the level crossing. The sensor tiles have all the scripts required for the level crossing to function. The only thing you have to do is select the correct controller/ports to which you connected your motors, lights and sensors. You can also customize the code in the script to fine-tune the behavior of the level crossing for your layout.
nControl project to control a level crossing.
Stand Alone Operation
In stand alone operation the controller is not connected to a computer; the microprocessor of the controller will operation the level crossing. In stand alone operation the controller is running fully autonomously, the user does not have to / cannot intervene in it's operation.
Connecting the System
The system has to be installed like for computer based operation, see above. The only difference is the USB cable: it does not need to be connected to a computer. It can be connected to any USB port that provides power to the controller: wall mount charger, USB battery pack, computer port, etc. Once the controller is powered it will boot up in stand alone mode. The controller takes a couple of seconds to boot up, once it's ready it will immediately start operating the level crossing.
Configuring the Controller
The controller has been preprogrammed to control a level crossing: detect trains, open/close the boom barriers and switch the lights on/off. It executes the following procedure:
  • When a sensor detects a train, the controller will start blinking the lights and close the barriers.
  • When the other sensor detects a train the level crossing and will open the barriers and switch off the lights.
  • The direction from where the train is arriving does not matter, the first time a sensor detects a train it is assumed the train is entering the crossing. When the other sensor detects a train it is assumed the train is leaving. After that the controllers waits for the next train to arrive.
This is the general process, there are however a number of parameters to customize the behavior. You can customize the controller's parameters with nControl: connect the controller with the USB cable to the computer and select Controller > Configure Controller in the main menu. You can modify the parameters and they will be stored in the controller when you click the OK button.
The following parameters can be customized:
Boom Barriers
  • Trim Open: This is a correction angle for the boom barriers when they are open. With this parameter you can fine tune the boom barrier position to get it perfectly vertical.
  • Trim Closed: This is a correction angle for the boom barriers when they are closed. With this parameter you can fine tune the boom barrier position to get it perfectly horizontal.
  • Delay Closed: This is a delay, expressed in seconds, for the boom barrier to close. When the sensor detects a train it will wait for the specified time before closing the barriers.
  • Delay Open: This is a delay, expressed in seconds, for the boom barrier to open. When the sensor detects a train it will wait for the specified time before opening the barriers.
Lights
  • Blink Interval: The interval, expressed in seconds, between changing the lights. The smaller the interval the faster the lights will blink.
  • In Phase: This parameter specifies how the lights blink. If In Phase is selected both LEDs will light up together, if the option is off the LEDs will light up in an alternating way.
  • LED Power: Defines the brightness of the LEDs.
  • Delay On: This is a delay, expressed in seconds, for the lights to start blinking. When the sensor detects a train it will wait for the specified time before switching on the lights.
  • Delay Off: This is a delay, expressed in seconds, for the lights to stop blinking. When the sensor detects a train it will wait for the specified time before switching off the lights.
Sensors
  • Threshold: Defines the level of detected IR light that should be considered as a train passing by.
  • Idle Time: Defines the interval, expressed in seconds, during which the sensor is switched off after detecting a train.
The getting started page on train sensors explains those parameters in detail.
Fine-Tuning the Behavior / Troubleshooting
These are some tips on how to fine-tune the behavior or the controller:
Delays
You have to put a sensor before and after the level crossing. When the train is detected by the first sensor it will switch on the lights and close the barriers. By adding a delay to close the barrier, the lights will blink before the barriers close which gives a more realistic effect. When the train is detected by the second sensor it will open the barriers and switch off the lights. The sensor however detects the front of the train so it might open the barrier too soon. To avoid that you can add a delay to open the barrier and switch off the lights. If you make the delay for the lights larger than the delay for the barrier, the lights will keep on flashing for some time after the barriers are open.
Trimming
Depending on the size of your barriers or the boom barrier motors you're using, the boom barriers might not be perfectly horizontal or vertical. Use the trimming angle to fine-tune the position of the boom barriers until they are perfectly horizontal / vertical.
Sensors
Sunlight and most artificial light contains an amount of infra red (IR) light. The sensor will pick that up and this might trigger false train detection events. If that's the case increase the threshold value of the sensor or reposition the sensor so that it's shaded from the external infra red source. If the trains are not detected, you need to lower the threshold value. You can visualize the amount of ambient IR light and/or the amount of IR light reflected by your trains by connecting the controller to a computer and creating a sensor tile in nControl. This will provide real time feedback on the amount of IR lights detected by the sensor and should help you get the threshold values you need.
If, when the train is leaving the level crossing, the barrier open and immediately close again the sensor might be trigged by the last cars of the train. When this happens, check how long it takes between the first and last car passing in front of the sensor. The idle time should be larger than that, if not the last cars might retrigger the sensor.