Please read the general section first!

MattzoLayoutController

Purpose

The MattzoLayoutController is a powerful combination of:

Functional Description

The MattzoLayoutController services the layout components switches, lights and sensors.

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

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
Wiring Diagram MattzoLayoutController

Switch Motors can be connected on pins D0, D1, D2 and D3. The logic ports 1001 and 1002 are mapped to pins D0/D1 and pins D2/D3 respectively to support double slip switches.

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 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.

Standard Wiring with PCA9685

To extend the number of 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 following diagram shows the wiring of the MattzoLayoutController with one PCA9685 as configured in the configuration file “MattzoLayoutController_Configuration_PCA9685.h”. For demonstration, one switch motor, one signal and one reed sensor are attached to the MattzoLayoutController:

MattzoLayoutController with PCA9685
MattzoLayoutController with PCA9685

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

The logic port mapping, which is required for double slip switches, is as follows:

Logic PortPhysical Ports (on PCA9685)
10010, 1
10022, 3
10034, 5
10046, 7
Logic port mapping in MattzoLayoutController with PCA9685

Four Signals can be connected to the PCA9685 on ports 8 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 activated in the standard configuration, as using the OE-Pin if not compatible with lights attached to the PCA9685.

By default, pins D3, D4, D5, D6 and D7 are configured 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 MattzoSensorController.

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 configuration file “MattzoLayoutController_Configuration_PCA9685.h” can be configured according to the needs of the specific MattzeLayoutController with PCA9685.

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:

Standard Wiring with MCP23017

To extend the number of ports for 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 following diagram shows the wiring of the MattzoLayoutController with one MCP23017 as configured in the configuration file “MattzoLayoutController_Configuration_MCP23017.h”. For demonstration, one reed sensor is attached to the MattzoLayoutController:

MattzoLayoutController with MCP23017

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

For more details of the wiring refer to “Standard Wiring with PCA9685” above. Attaching a MCF23017 is identical to attached 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 files “MattzoLayoutController_Configuration_PCA9685_2x.h” and “MattzoLayoutController_Configuration_PCA9685_and_MCP23017” contain configurations for each two chained port extenders.

“MattzoLayoutController_Configuration_PCA9685_2x.h” allows 16 switches, 16 signal LEDs and 5 sensors to be connected to a single MattzoLayoutController.

“MattzoLayoutController_Configuration_PCA9685_and_MCP23017.h” allows 8 switches, 8 signal LEDs and 21 sensors to be connected to a single MattzoLayoutController.

Power Supply

A MattzoLayoutController may need significantly more electrical power compared to other MattzoControllers, especially when the PCA9685 port extender is connected to it and many switch servos are connected.

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

Casing

We are presently designing a beautiful 3D printed standard case for the MattzoLayoutController. The case will provide space for the microcontroller, and once port extender PCA9685 and MCP23017 each.

This boxed MattzoLayoutController will be able to connect 16 switches, 8 Trixbrix signals and 16 sensors. It will also be possible to control level crossings and bascule bridges with this controller.

The following pictures shows a prototype.

MattzoLayoutController in a box (prototype)

Rocrail Setup

Follow the instructions for the MattzoSensorController, MattzoSignalController and MattoSwitchController for the Rocrail setup.

For setting up Level Crossings, check the instructions for the MattzoLevelCrossingController.

To setup the controller for operating Bascule Bridges, follow the instructions for the MattzoBridgeController.

Leave a Reply

Your email address will not be published. Required fields are marked *