Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • Fabian SchwizgebelFabian Schwizgebel
    Participant

    Hello Matt
    thank you for your help. Now it works.

    Also had to

    // If no form signals are used, just set to 0
    const int NUM_SIGNAL_SERVOS = 0;

    << into
    #define NUM_SIGNAL_SERVOS 0

    ————————————————– ———————————————————-

    // SIGNAL CONFIGURATION

    // Number of signals
    #define NUM_SIGNALS 8
    // Maximum number of signal aspects (e.g. red, green, yellow)
    #define NUM_SIGNAL_ASPECTS 3
    // Number of signal LEDs (usually equal to NUM_SIGNAL_ASPECTS)
    #define NUM_SIGNAL_LEDS 3
    // Maximum number of servos for form signals (e.g. one for the primary and another one for the secondary semaphore)
    // If no form signals are used, just set to 0
    #define NUM_SIGNAL_SERVOS 0

    Fabian SchwizgebelFabian Schwizgebel
    Participant

    // MattzoController Configuration
    // Author: Dr. Matthias Runte
    // Copyright 2020 by Dr. Matthias Runte
    // License:
    // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
    // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
    // THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    // This file is the configuration file for the firmware
    // You need to adapt it to the specific requirements of the desired behaviour of the controller
    // The file contains default values for the standard wiring layout of the MattzoLayoutController
    // Check the examples in the “examples” directory for more inspiring creations

    // ***************************
    // Controller wiring specifics
    // ***************************

    // Infos for port expander PCA9685
    // Usage:
    // – If a USE_PCA9685 port expander is connected to your ESP8266, set USE_PCA9685 to true.
    // Wiring:
    // – PCA9685 is usually connected to pins D1 (clock) and D2 (data) of the ESP8266.
    // – VCC is sourced from V3V of the ESP8266.
    // – V+ is sourced from VIN of the ESP8266
    // — VIN should be between 5 and 6 Volts.
    // — According to the documentation, the PCA9685 will also sustain 12V, but this is not recommended and we have not tested it.
    // — We have tested run the board with standard USV voltage (4,65V) and it worked without problems.
    // – Connecting GND is mandatory.
    // – OE should also be connected. If pulled high, servo power is switched off. Good to preserve your servos. Cabling is usually easiest if pin D0 is used as OE.
    // Chaining:
    // – Both PCA9685 and the firmware support chaining.
    // – Board 1 has the address 0x40, the second one 0x41 etc.
    // Servos:
    // – Just connect the servos as designed. Servos connected to PCA9685 must be mapped in SWITCHPORT_PIN_PCA9685.
    // Signals:
    // – Connecting TrixBrix signals to the PCA9685 is somewhat tricky, because of the “common anode” (common plus terminal) of the signal LEDs.
    // – The solution is to connect the middle wire (plus) to V3V of the ESP8266 (NOT the plus pins of the PCA9685 ports), and the outer wires to the PCA9685 pins.
    // – It is important to remember the correct way of setting a pin on the PCA9685 to:
    // — fully on: pwm.setPWM(port, 4096, 0);
    // — fully off: pwm.setPWM(port, 0, 4096);
    // Additional reference: https://learn.adafruit.com/16-channel-pwm-servo-driver?view=all

    // PCA9685 WIRING CONFIGURATION

    // PCA9685 port expander used?
    #define USE_PCA9685 true

    // PCA9685 OE pin supported?
    bool PCA9685_OE_PIN_INSTALLED = true; // set to true if OE pin is connected (false if not)
    uint8_t PCA9685_OE_PIN = D0;

    // Number of chained PCA9685 port extenders
    #define NUM_PCA9685s 1

    // Infos for I/O port expander MCP23017
    // Usage:
    // – If a MCP23017 I/O port expander is connected to your ESP8266, set USE_MCP23017 to true.
    // Wiring:
    // – SCL and SDA are usually connected to pins D1 (clock) and D2 (data) of the ESP8266.
    // – VCC is sourced from V3V of the ESP8266.
    // – GND is connected to GND of the ESP8266 (mandatory!).
    // – RESET is connected with an 10K resistor to VCC
    // – Address ports A0, A1 and A2 according to the desired address (0x20, 0x21, …). All connected to GND means address 0x20.
    // Ports:
    // – The ports of the are numbered as follows:
    // – A0..A7: 0..7
    // – B0..B7: 8..15
    // Chaining:
    // – Both MCP23017 and the firmware support chaining.
    // – Board 1 has the address 0x20, the second one 0x21 etc.
    // – Up to 8 boards can be connected.
    // Sensors:
    // – Connecting sensors to the MCP23017 is simple.
    // – Just connect one of of the cable pair to GND, the other one to one of the ports of the MCP23017.

    // MCP23017 WIRING CONFIGURATION

    // MCP23017 port expander used?
    #define USE_MCP23017 true

    // Number of chained MCP23017 port extenders
    #define NUM_MCP23017s 2

    // SERVO WIRING CONFIGURATION

    // Number of servos
    const int NUM_SERVOS = 12;

    TServoConfiguration servoConfiguration[NUM_SERVOS] =
    {
    {.pin = 0,
    .pinType = 0x40,
    .detachAfterUsage = true},
    {.pin = 1,
    .pinType = 0x40,
    .detachAfterUsage = true},
    {.pin = 2,
    .pinType = 0x40,
    .detachAfterUsage = true},
    {.pin = 3,
    .pinType = 0x40,
    .detachAfterUsage = true},
    {.pin = 4,
    .pinType = 0x40,
    .detachAfterUsage = true},
    {.pin = 5,
    .pinType = 0x40,
    .detachAfterUsage = true},
    {.pin = 6,
    .pinType = 0x40,
    .detachAfterUsage = true},
    {.pin = 7,
    .pinType = 0x40,
    .detachAfterUsage = true},
    {.pin = 8,
    .pinType = 0x40,
    .detachAfterUsage = true},
    {.pin = 9,
    .pinType = 0x40,
    .detachAfterUsage = true},
    {.pin = 10,
    .pinType = 0x40,
    .detachAfterUsage = true},
    {.pin = 11,
    .pinType = 0x40,
    .detachAfterUsage = true}
    };

    // LED WIRING CONFIGURATION

    // Number of LEDs
    // LEDs are used in signals, level crossing lights or bascule bridge lights
    // As an example, 2 LEDs are required for a light signal with 2 aspects
    const int NUM_LEDS = 24;

    struct LEDConfiguration {
    // Digital output pin for signal LED (pins like D0, D1 etc. for ESP-8266 I/O pins, numbers like 0, 1 etc. for pins of the PCA9685)
    uint8_t pin;

    // Type of digital output pins for led
    // 0 : LED output pin on the ESP-8266
    // 0x20: LED port on the 1st MCP23017
    // 0x21: LED port on the 2nd MCP23017
    // 0x22: LED port on the 3rd MCP23017 etc.
    // 0x40: LED port on the 1st PCA9685
    // 0x41: LED port on the 2nd PCA9685
    // 0x42: LED port on the 3rd PCA9685 etc.
    uint8_t pinType;

    } ledConfiguration[NUM_LEDS] =
    {
    {.pin = 0,
    .pinType = 0x20},
    {.pin = 1,
    .pinType = 0x20},
    {.pin = 2,
    .pinType = 0x20},
    {.pin = 3,
    .pinType = 0x20},
    {.pin = 4,
    .pinType = 0x20},
    {.pin = 5,
    .pinType = 0x20},
    {.pin = 6,
    .pinType = 0x20},
    {.pin = 7,
    .pinType = 0x20},
    {.pin = 8,
    .pinType = 0x20},
    {.pin = 9,
    .pinType = 0x20},
    {.pin = 10,
    .pinType = 0x20},
    {.pin = 11,
    .pinType = 0x20},
    {.pin = 12,
    .pinType = 0x20},
    {.pin = 13,
    .pinType = 0x20},
    {.pin = 14,
    .pinType = 0x20},
    {.pin = 15,
    .pinType = 0x20},
    {.pin = 0,
    .pinType = 0x21},
    {.pin = 1,
    .pinType = 0x21},
    {.pin = 2,
    .pinType = 0x21},
    {.pin = 3,
    .pinType = 0x21},
    {.pin = 4,
    .pinType = 0x21},
    {.pin = 5,
    .pinType = 0x21},
    {.pin = 6,
    .pinType = 0x21},
    {.pin = 7,
    .pinType = 0x21},
    };

    // SENSOR WIRING CONFIGURATION

    // Set to true to enable remote sensors.
    // Remote sensors are not electrically connected to this controller, they are triggered via Rocrail commands.
    // Remote sensors can be used for level crossings in Autonomous Mode
    // If you do not control a level crossing in Autonomous Mode with this controller, set to false!
    #define REMOTE_SENSORS_ENABLED false

    // Number of sensors connected or connectable to the controller
    #define NUM_SENSORS 8

    // Constants for type of digital input pins for sensors
    // 0 : local sensor on the ESP-8266 (D0 .. D8)
    // 0x10: remote sensor, triggered via Rocrail message (REMOTE_SENSOR_PIN_TYPE)
    // 0x11: virtual sensor, triggered when bascule bridge is fully open or closed.
    // 0x20: local sensor, connected to a port on the 1st MCP23017
    // 0x21: local sensor, connected to a port on the 2nd MCP23017
    // 0x22: local sensor, connected to a port on the 3rd MCP23017 etc.
    #define LOCAL_SENSOR_PIN_TYPE 0
    #define REMOTE_SENSOR_PIN_TYPE 0x10
    #define VIRTUAL_SENSOR_PIN_TYPE 0x11
    #define MCP23017_SENSOR_PIN_TYPE 0x20
    #define MCP23017_SENSOR_PIN_TYPE2 0x21

    TSensorConfiguration sensorConfiguration[NUM_SENSORS] =
    {
    {.pin = 8,
    .pinType = MCP23017_SENSOR_PIN_TYPE2,
    .remoteMattzoControllerId = -1},
    {.pin = 9,
    .pinType = MCP23017_SENSOR_PIN_TYPE2,
    .remoteMattzoControllerId = -1},
    {.pin = 10,
    .pinType = MCP23017_SENSOR_PIN_TYPE2,
    .remoteMattzoControllerId = -1},
    {.pin = 11,
    .pinType = MCP23017_SENSOR_PIN_TYPE2,
    .remoteMattzoControllerId = -1},
    {.pin = 12,
    .pinType = MCP23017_SENSOR_PIN_TYPE2,
    .remoteMattzoControllerId = -1},
    {.pin = 13,
    .pinType = MCP23017_SENSOR_PIN_TYPE2,
    .remoteMattzoControllerId = -1},
    {.pin = 14,
    .pinType = MCP23017_SENSOR_PIN_TYPE2,
    .remoteMattzoControllerId = -1},
    {.pin = 15,
    .pinType = MCP23017_SENSOR_PIN_TYPE2,
    .remoteMattzoControllerId = -1}
    };

    // STATUS LED WIRING CONFIGURATION

    // Digital output pin to monitor controller operation (typically a LED)
    const bool STATUS_LED_PIN_INSTALLED = true; // set to false if no LED is installed
    const uint8_t STATUS_LED_PIN = D8;
    const bool STATUS_LED_REVERSE = false;

    // SWITCH CONFIGURATION

    // Number of switches
    const int NUM_SWITCHES = 12;

    TSwitchConfiguration switchConfiguration[NUM_SWITCHES] =
    {
    {
    .rocRailPort = 1,
    .servoIndex = 0,
    .servo2Index = -1,
    .servo2Reverse = false,
    .triggerSensors = false,
    .sensorIndex = { -1, -1 }
    },
    {
    .rocRailPort = 2,
    .servoIndex = 1,
    .servo2Index = -1,
    .servo2Reverse = false,
    .triggerSensors = false,
    .sensorIndex = { -1, -1 }
    },
    {
    .rocRailPort = 3,
    .servoIndex = 2,
    .servo2Index = -1,
    .servo2Reverse = false,
    .triggerSensors = false,
    .sensorIndex = { -1, -1 }
    },
    {
    .rocRailPort = 4,
    .servoIndex = 3,
    .servo2Index = -1,
    .servo2Reverse = false,
    .triggerSensors = false,
    .sensorIndex = { -1, -1 }
    },
    {
    .rocRailPort = 5,
    .servoIndex = 4,
    .servo2Index = -1,
    .servo2Reverse = false,
    .triggerSensors = false,
    .sensorIndex = { -1, -1 }
    },
    {
    .rocRailPort = 6,
    .servoIndex = 5,
    .servo2Index = -1,
    .servo2Reverse = false,
    .triggerSensors = false,
    .sensorIndex = { -1, -1 }
    },
    {
    .rocRailPort = 7,
    .servoIndex = 6,
    .servo2Index = -1,
    .servo2Reverse = false,
    .triggerSensors = false,
    .sensorIndex = { -1, -1 }
    },
    {
    .rocRailPort = 8,
    .servoIndex = 7,
    .servo2Index = -1,
    .servo2Reverse = false,
    .triggerSensors = false,
    .sensorIndex = { -1, -1 }
    },
    {
    .rocRailPort = 9,
    .servoIndex = 8,
    .servo2Index = -1,
    .servo2Reverse = false,
    .triggerSensors = false,
    .sensorIndex = { -1, -1 }
    },
    {
    .rocRailPort = 10,
    .servoIndex = 9,
    .servo2Index = -1,
    .servo2Reverse = false,
    .triggerSensors = false,
    .sensorIndex = { -1, -1 }
    },
    {
    .rocRailPort = 11,
    .servoIndex = 10,
    .servo2Index = -1,
    .servo2Reverse = false,
    .triggerSensors = false,
    .sensorIndex = { -1, -1 }
    },
    {
    .rocRailPort = 12,
    .servoIndex = 11,
    .servo2Index = -1,
    .servo2Reverse = false,
    .triggerSensors = false,
    .sensorIndex = { -1, -1 }
    }
    };

    // SIGNAL CONFIGURATION

    // Number of signals
    const int NUM_SIGNALS = 8;
    // Maximum number of signal aspects (e.g. red, green, yellow)
    const int NUM_SIGNAL_ASPECTS = 3;
    // Number of signal LEDs (usually equal to NUM_SIGNAL_ASPECTS)
    const int NUM_SIGNAL_LEDS = 3;
    // Maximum number of servos for form signals (e.g. one for the primary and another one for the secondary semaphore)
    // If no form signals are used, just set to 0
    const int NUM_SIGNAL_SERVOS = 0;

    TSignalConfiguration signalConfiguration[NUM_SIGNALS] =
    {
    // signal 0: light signal with 2 aspects, controlled via Rocrail ports 1 and 2
    {
    .aspectRocrailPort = {1, 2, 3},
    .aspectLEDPort = {0, 1, 2},
    .aspectLEDMapping = {
    {true, false, false},
    {false, true, false},
    {false, false, true},
    },
    .servoIndex = {},
    .aspectServoAngle = {}
    },
    {
    .aspectRocrailPort = {4, 5, 6},
    .aspectLEDPort = {3, 4, 5},
    .aspectLEDMapping = {
    {true, false, false},
    {false, true, false},
    {false, false, true},
    },
    .servoIndex = {},
    .aspectServoAngle = {}
    },
    {
    .aspectRocrailPort = {7, 8, 9},
    .aspectLEDPort = {6, 7, 8},
    .aspectLEDMapping = {
    {true, false, false},
    {false, true, false},
    {false, false, true},
    },
    .servoIndex = {},
    .aspectServoAngle = {}
    },
    {
    .aspectRocrailPort = {10, 11, 12},
    .aspectLEDPort = {9, 10, 11},
    .aspectLEDMapping = {
    {true, false, false},
    {false, true, false},
    {false, false, true},
    },
    .servoIndex = {},
    .aspectServoAngle = {}
    },
    {
    .aspectRocrailPort = {13, 14, 15},
    .aspectLEDPort = {12, 13, 14},
    .aspectLEDMapping = {
    {true, false, false},
    {false, true, false},
    {false, false, true},
    },
    .servoIndex = {},
    .aspectServoAngle = {}
    },
    {
    .aspectRocrailPort = {16, 17, 18},
    .aspectLEDPort = {15, 16, 17},
    .aspectLEDMapping = {
    {true, false, false},
    {false, true, false},
    {false, false, true},
    },
    .servoIndex = {},
    .aspectServoAngle = {}
    },
    {
    .aspectRocrailPort = {19, 20, 21},
    .aspectLEDPort = {18, 19, 20},
    .aspectLEDMapping = {
    {true, false, false},
    {false, true, false},
    {false, false, true},
    },
    .servoIndex = {},
    .aspectServoAngle = {}
    },
    {
    .aspectRocrailPort = {22, 23, 24},
    .aspectLEDPort = {21, 22, 23},
    .aspectLEDMapping = {
    {true, false, false},
    {false, true, false},
    {false, false, true},
    },
    .servoIndex = {},
    .aspectServoAngle = {}
    }
    };

    // LEVEL CROSSING CONFIGURATION

    // General switch for level crossing (false = no level crossing connected; true = level crossing connected)
    const bool LEVEL_CROSSING_CONNECTED = false;

    // Number of boom barrier servos configured for the level crossing
    #define LC_NUM_BOOM_BARRIERS 0

    // Number of signals configured for the level crossing
    #define LC_NUM_LEDS 0

    // Number of level crossing sensors
    const int LC_NUM_SENSORS = 0;

    // Number of tracks leading over the level crossing
    #define LC_NUM_TRACKS 0

    TLevelCrossingConfiguration levelCrossingConfiguration = {};

    // BASCULE BRIDGE CONFIGURATION

    // General switch for bascule bridge (false = no bridge connected; true = bridge connected)
    bool BASCULE_BRIDGE_CONNECTED = false;

    //Must be defined, but are zero
    #define NUM_SIGNAL_ASPECTS 0
    #define NUM_SIGNAL_LEDS 0
    #define NUM_SIGNAL_SERVOS 0
    // Number of bridge Leafs (equals number of bridge servos)
    #define NUM_BASCULE_BRIDGE_LEAFS 0

    TBridgeConfiguration bridgeConfiguration = {};

    // SPEEDOMETER CONFIGURATION

    // General switch for speedometer (false = no speedometer connected; true = speedometer connected)
    bool SPEEDOMETER_CONNECTED = false;

    TSpeedometerConfiguration speedometerConfiguration = {};

    // ****************
    // NETWORK SETTINGS
    // ****************

    // Trigger emergency brake upon disconnect
    const bool TRIGGER_EBREAK_UPON_DISCONNECT=true;

    // WiFi Hostname
    // Hostnames must start with a-z, A-Z, 0-9. From 2nd character, hyphens (“-“) may also be used
    const char* MC_HOSTNAME = “MLC-BHF1_SUD”;

    // Syslog application name
    const char* SYSLOG_APP_NAME = “MLC-BHF1_SUD”;

    Fabian SchwizgebelFabian Schwizgebel
    Participant

    Unfortunately it doesn’t work yet. all LEDs are always on.

    I don’t see anything in the port monitor either.
    If I switch a turnout, I get “Flipping switch index 0 to angle 75” and with sensor as desired “Sensor 1 triggered.” and then “Sensor 1 released.”

    Added the following:

    // LED WIRING CONFIGURATION

    // Number of LEDs
    // LEDs are used in signals, level crossing lights or bascule bridge lights
    // As an example, 2 LEDs are required for a light signal with 2 aspects
    const int NUM_LEDS = 24;

    struct LEDConfiguration {
    // Digital output pin for signal LED (pins like D0, D1 etc. for ESP-8266 I/O pins, numbers like 0, 1 etc. for pins of the PCA9685)
    uint8_t pin;

    // Type of digital output pins for led
    // 0 : LED output pin on the ESP-8266
    // 0x20: LED port on the 1st MCP23017
    // 0x21: LED port on the 2nd MCP23017
    // 0x22: LED port on the 3rd MCP23017 etc.
    // 0x40: LED port on the 1st PCA9685
    // 0x41: LED port on the 2nd PCA9685
    // 0x42: LED port on the 3rd PCA9685 etc.
    uint8_t pinType;

    } ledConfiguration[NUM_LEDS] =
    {
    {.pin = 0,
    .pinType = 0x20},
    {.pin = 1,
    .pinType = 0x20},
    {.pin = 2,
    .pinType = 0x20},
    {.pin = 3,
    .pinType = 0x20},
    {.pin = 4,
    …………………………

    Greetings Fabian

    Fabian SchwizgebelFabian Schwizgebel
    Participant

    Hi Mattze
    Thanks for your reply and correcting.
    I have now corrected my config as you have changed it in the development branch. And will test it tonight.

    Thank you and your team for this great work.
    Wish you a Happy New Year!

    in reply to: Switch Motor Housing #3589
    Fabian SchwizgebelFabian Schwizgebel
    Participant

    Hello everybody
    I designed housings for the SG90 servos.

    1x Lego City switch 60238
    1x Trixbrix switches
    1x Lego double crossing 7996

    https://www.thingiverse.com/thing:4881123

Viewing 5 posts - 1 through 5 (of 5 total)