Please read the general section first!

MLC Prototype
MattzoLayoutController Prototype

History

In the first releases of the firmware, there were different MattzoControllers for switches, light signals and sensors, each with a different firmware. These MattzoControllers were named as follows:

  • MattzoSwitchController,
  • MattzoSignalController,
  • MattzoSensorController.

With increasing number of configuration options and features, the maintenance of these different MattzoControllers became increasingly tedious. Another aspect was, that you could only connect a single type of component to one of the controllers.

For these reasons, these specialized MattzoControllers were bundled into a single MattzoController called MattzoLayoutController (MLC).

At a later stage, support for level crossings, bascule bridges and speedometers was integreated into the MLC firmware.

Purpose

The MattzoLayoutController is a the serve the following hardware components:

  • Servos,
  • LEDs and
  • digital sensors (usually reed sensors, but any other digital sensors also work).

These hardware components can be attached directly to the pins of the controllers or via port extenders.

The following logical (Rocrail) objects can be mapped to the mentioned hardware components:

  • Switches,
  • Signals,
  • Sensors,
  • Level Crossings,
  • Bascule Bridges,
  • Speedometers (non-Rocrail object).

Functional Description

The MattzoLayoutController services layout components like switches, signals and sensors.

One MattzoLayoutController can handle up to 8 switches or 4 standard light signals or 8 sensors or any combination of it. The standard configuration contains a combination of 4 switches, 1 light signal (2 LEDs) and 2 sensors. Other combinations are possible.

MLC Prototype
MLC Prototype

The MattzoLayoutController can be extended with a port extender type PCA9685. If using the port extender, 6 sensors, 22 switches or 11 signals can be controlled. Other combinations are possible.

MattzoLayoutController with PCA9685 Port Extender

Wiring

Required Components

To build a MattzoLayoutController, you need to following components:

  • I/O board with micro controller. We have used a NodeMCU Amica Modul V2 ESP8266 ESP-12F. Similar modules should work as well.
  • LED for optional status LEDs, possibly with some resistors.
  • PCA 9685 port extender board (optional).
  • MCP23017 port extender board (optional).
  • Reed Sensors and LEDs for signals (see MattzoSensorController and MattzoSignalController).
  • Basic stuff like bread board, wires etc.

Standard Wiring without PCA9685

The following diagram shows the wiring of the MattzoLayoutController as configured in the standard configuration (configuration file “MattzoLayoutController_Configuration.h”):

Wiring Diagram MattzoLayoutController

Switch Motors can be connected on pins D0, D1, D2 and D3.

A signal can be connected to pins D4 and D5. Note that the pins are actually pulling the voltage down to ground when activated, so the cathode of the LEDs needs to be connected to them. The anode of the LEDs must be connected to the plus terminal of the LED.

D6 and D7 are configured for sensors.

On pin D8, a status LED can be attached. The status LED indicates to WiFi connection status, the MQTT connection status and lights up when one or more sensors are triggered. The status LED is very handy in practice. Therefore, this wiring option is recommended.

Please note that pin D8 must not be pulled up when the controller starts up, or the controller will not boot correctly. Only if you know exactly what you are doing, the port may be used for other purposes as well, e.g. for reed sensors or to connect the anode of a LED.

MLC with Port Extenders

The number of ports of the MLC can be significantly extended by using port extenders. PCA9685 and MCP23017 are supported.

A point to start is the example configuration file “MattzoLayoutController_Configuration_Port_Extenders.h”, which is using 2 PCA9685s and 2 MCP23017s.

Port Extender PCA9685

To extend the number of switch and LED ports, PCA9685 port extenders can be attached to the MattzoLayoutController. Chaining (attaching more than one PCA9685) is possible – see the “Chaining PCA9685 port extenders” section below.

The PCA9685 supports PWM output (servo control) and digital output (LED control). It can not be used for input, so connecting sensors to the device is not possible.

The following diagram shows an example of how to wire the MattzoLayoutController with one PCA9685. For demonstration, one switch motor, one signal and one reed sensor are attached to the MattzoLayoutController:

Wiring Diagram MLC with PCA9685
Wiring Diagram MLC with PCA9685

In this configuration, eight switch Motors can be connected to the PCA9685 on ports 0 to 15.

Alternatively, eight standard signals (16 LEDs) can be connected to the PCA9685 on ports 0 to 15. Note that the PWM pins are actually pulling the voltage down to ground when activated, so the cathode of the LEDs need to be connected to them. The anode of the LEDs must be connected to the plus terminal of the LED.

On pin D0, the OE-Pin of the PCA9685 is connected. It is used to switch the PWM terminal on the connector bar of the PCA9685 on and off. This may be useful to switch the power supply of motors off after switches have been switched, as this may prevent blocking servo motors from overheating in case of technical problems. Nevertheless, this option is not recommended for all situations, as using the OE-Pin if not compatible with LED attached to the PCA9685.

Pins D3, D4, D5, D6 and D7 can be configured alternatively, e.g. for sensors. Additional sensors can be connected to D0 (if OE-Pin not used; attention: pull-down resistor required!), and D8 (if the status LED option is not used; attention: internal pull-resistor is pulling the pin up, not down). For more details using pins for sensors, see MLC with sensors.

On pin D8, a status LED can be attached. The status LED indicates to WiFi connection status, the MQTT connection status and lights up when one or more sensors are triggered. The status LED is very handy in practice. Therefore, this wiring option is recommended.

Please note that pin D8 must not be pulled up when the controller starts up, or the controller will not boot correctly. Only if you exactly what you are doing, the port may be used for other purposes as well, e.g. for reed sensors or to connect the anode of a LED.

The following pictures show a MattzoLayoutController with PCA9685. A double slip switch with four switch motors, one signal and one sensor are attached. A small yellow status LED is attached to pin D8. To monitor the operation of the OE-Pin, a small red LED is also installed:

Port Extender MCP23017

To extend the number of ports for signal LEDs and sensors, MCP23017 port extenders can be attached to the MattzoLayoutController. Chaining (attaching more than one port extender) is possible – see the “Chaining port extenders” section below.

The MCP23017 supports digital output (LED control) and digital input (sensors). It can not be used for analog or PWM output, so connecting servos or fading LEDs to the device is not possible.

The following diagram shows an example wiring of the MattzoLayoutController with one MCP23017. For demonstration, two reed sensors are attached to the MattzoLayoutController:

Wiring Diagram MLC with MCP23017
Wiring Diagram MLC with MCP23017

In this configuration, 16 sensors can be connected to the MCP23017 on ports 0 to 15.

The following example uses two MCP23017:

Wiring Diagram MLC with 2x MCP23017
Wiring Diagram MLC with 2x MCP23017

For more details of the wiring refer to the PCA9685 section above. Attaching a MCP23017 is similar to attaching a PCA9685 in most aspects.

Chaining Port Extenders

Chaining (attaching more than one port extender) is possible. Basic information and how to setup addressing of chained PCA9685 or MCP23017 port extenders can be found on various sources on the web, for example here.

The example configuration file “MattzoLayoutController_Configuration_Port_Extenders.h” contains a configuration for with 2 PCA9685s and 2 MCP23017s.

Power Supply

A MattzoLayoutController often needs more electrical power compared to other MattzoControllers, especially when servos are connected to the controller. Using port extenders with a lot of LEDs may also consume at lot of power.

To avoid brown outs, a power source of around 5V and at least 2A is required. From four switch motors onwards, I would recommend a power supply of at least 3A.

We have made very good experiences with a power supply device from Pollin (dealer in Germany) that delivers 5,9V at 4 Ampère. With a device of that you are on the safe side. I am sure that these devices will be available throughout the globe if you look around a little bit.

Casing

We are presently designing a beautiful 3D printed standard case for the MattzoLayoutController. The case is designed for a special build of the MattzoLayoutController, the MLC mega. It features a connector for a strong power supply, and has three build-in port extenders (one PCA9685 and two MCP23017s).

This MattzoLayoutController is able to connect:

  • 16 servos (e.g. for 16 switches)
  • 16 LEDs (e.g. for 8 standard light signals), and
  • 16 sensors.

The controller also manages all other land based components like form signals, level crossings and bascule bridges.

The following pictures shows a prototype.

MLC Prototype
MLC Prototype

More information can be found on the do-it-yourself page.

Rocrail setup and specific deployment scenarios

Follow the following instructions for more information of attaching specific logical components to the MattzoLayoutController:

Enjoy!

2 thoughts on “MattzoLayoutController (MLC)

  1. Hallo,
    ich beschäftige mich gerade mit ein genauso Thema und würde Ihnen gerne frage ob Sie mir ein Programm für diese Mattzolayoutcontroller with PCA 9685 Port Extender.

Comments are closed.