Viewing 4 reply threads
  • Author
    Posts
    • #5085
      Erik SwinkelsErik Swinkels
      Participant

      Hi,
      I am having a lot of fun with the controllers. But now I am having problems with the mtc4pf
      Setup is oke, connection to wifi/mqtt is ok. serial monitor shows the connection is correctly initialized.
      the log:
      MattzoController booting…
      Loaded mattzoControllerId from EEPROM: 13648
      Connecting as MTC4PF13648 to Wifi RocRail
      MattzoController setup completed.
      initializing function pins
      loading loco and motor shield configuration
      initializing built-in motor shield
      stopping all trains
      Setting motor speed: 0 (power: 0) for motor shield TGV1
      Wifi connected. My IP address is 192.168.1.186.
      (Re)connecting to MQTT 192.168.1.161…
      MQTT connected, listening on topic [rocrail/service/command].
      Received MQTT message [rocrail/service/command]: <clock divider=”1″ hour=”14″ minute=”13″ wday=”1″ mday=”14″ month=”2″ year=”2022″ time=”1644844387″ temp=”20″ bri=”255″ lux=”0″ pressure=”0″ humidity=”0″ cmd=”sync”/>

      Parsing XML successful
      Unknown message, disregarded.
      Received MQTT message [rocrail/service/command]: <clock divider=”1″ hour=”14″ minute=”14″ wday=”1″ mday=”14″ month=”2″ year=”2022″ time=”1644844448″ temp=”20″ bri=”255″ lux=”0″ pressure=”0″ humidity=”0″ cmd=”sync”/>

      If i do nothing after booting, it stays oke, and displays the following message every minute:
      Parsing XML successful
      Unknown message, disregarded.
      Received MQTT message [rocrail/service/command]: <clock divider=”1″ hour=”14″ minute=”33″ wday=”1″ mday=”14″ month=”2″ year=”2022″ time=”1644845595″ temp=”20″ bri=”255″ lux=”0″ pressure=”0″ humidity=”0″ cmd=”sync”/>

      And the mqtt log also shows the message and the ping requests:
      1644845662: Received PINGREQ from MTC4PF13648
      1644845662: Sending PINGRESP to MTC4PF13648
      1644845672: Received PINGREQ from MTC4PF13648
      1644845672: Sending PINGRESP to MTC4PF13648
      1644845682: Received PINGREQ from MTC4PF13648
      1644845682: Sending PINGRESP to MTC4PF13648
      1644845692: Received PINGREQ from MTC4PF13648
      1644845692: Sending PINGRESP to MTC4PF13648
      1644845702: Received PINGREQ from MTC4PF13648
      1644845702: Sending PINGRESP to MTC4PF13648
      1644845712: Received PINGREQ from MTC4PF13648
      1644845712: Sending PINGRESP to MTC4PF13648
      1644845716: Received PUBLISH from RocrailService (d0, q1, r1, m255, ‘rocrail/service/command’, … (167 bytes))
      1644845716: Sending PUBACK to RocrailService (m255, rc0)
      1644845716: Sending PUBLISH to MTC4PF13648 (d0, q0, r0, m0, ‘rocrail/service/command’, … (167 bytes))
      1644845716: Received PUBLISH from RocrailService (d0, q1, r1, m256, ‘rocrail/service/info’, … (167 bytes))
      1644845716: Sending PUBACK to RocrailService (m256, rc0)
      1644845716: Received PUBLISH from RocrailService (d0, q1, r1, m257, ‘rocrail/service/info’, … (178 bytes))
      1644845716: Sending PUBACK to RocrailService (m257, rc0)

      so far, no problem.
      But when I give the command to let the train run the following happens:
      i did a reboot of the controller:

      MattzoController booting…
      Loaded mattzoControllerId from EEPROM: 13648
      Connecting as MTC4PF13648 to Wifi RocRail
      MattzoController setup completed.
      initializing function pins
      loading loco and motor shield configuration
      initializing built-in motor shield
      stopping all trains
      Setting motor speed: 0 (power: 0) for motor shield TGV1
      Wifi connected. My IP address is 192.168.1.186.
      (Re)connecting to MQTT 192.168.1.161…
      MQTT connected, listening on topic [rocrail/service/command].
      Received MQTT message [rocrail/service/command]: <lc id=”GROENE” V=”0″ fn=”false” dir=”false” throttleid=”rv14156″ controlcode=”” slavecode=”” server=”infw034F11F4″ fncnt=”0″ f0=”false” f1=”false” f2=”false” f3=”false” f4=”false” f5=”false” f6=”false” f7=”false” f8=”false” f9=”false” f10=”false” f11=”false” f12=”false” f13=”false” f14=”false” f15=”false” f16=”false” f17=”false” f18=”false” f19=”false” f20=”false” f21=”false” f22=”false” f23=”false” f24=”false” f25=”false” f26=”false” f27=”false” f28=”false” f29=”false” f30=”false” f31=”false” f32=”false” mass=”0″ minstep=”0″ maxstep=”0″ pwm=”0″ pwmcorrdiv=”10″ V_step=”0″ V_min=”10″ V_max=”100″ V_mode=”percent” bus=”0″ prot=”P” protver=”1″ spcnt=”255″ oid=”” identifier=”” mode=”stop” iid=”” port=”0″ addr=”10010″ imagenr=”0″ informall=”false”/>

      Parsing XML successful
      <lc> node found. Processing loco message…
      loco id: GROENE
      addr: 10010
      Consuming message for train GROENE (10010)
      dir (raw): false
      direction: backward
      V: 0
      V_max: 100
      Message parsing complete, target speed set to 0 (current: 0, max: 100)
      Received MQTT message [rocrail/service/command]: <clock divider=”1″ hour=”14″ minute=”38″ wday=”1″ mday=”14″ month=”2″ year=”2022″ time=”1644845898″ temp=”20″ bri=”255″ lux=”0″ pressure=”0″ humidity=”0″ cmd=”sync”/>

      Parsing XML successful
      Unknown message, disregarded.
      Received MQTT message [rocrail/service/command]: <lc id=”GROENE” V=”10″ fn=”false” dir=”false” throttleid=”rv14156″ controlcode=”” slavecode=”” server=”infw034F11F4″ fncnt=”0″ f0=”false” f1=”false” f2=”false” f3=”false” f4=”false” f5=”false” f6=”false” f7=”false” f8=”false” f9=”false” f10=”false” f11=”false” f12=”false” f13=”false” f14=”false” f15=”false” f16=”false” f17=”false” f18=”false” f19=”false” f20=”false” f21=”false” f22=”false” f23=”false” f24=”false” f25=”false” f26=”false” f27=”false” f28=”false” f29=”false” f30=”false” f31=”false” f32=”false” mass=”0″ minstep=”0″ maxstep=”0″ pwm=”0″ pwmcorrdiv=”10″ V_step=”0″ V_min=”10″ V_max=”100″ V_mode=”percent” bus=”0″ prot=”P” protver=”1″ spcnt=”255″ oid=”” identifier=”” mode=”stop” iid=”” port=”0″ addr=”10010″ imagenr=”0″ informall=”false”/>

      Parsing XML successful
      <lc> node found. Processing loco message…
      loco id: GROENE
      addr: 10010
      Consuming message for train GROENE (10010)
      dir (raw): false
      direction: backward
      V: 10
      V_max: 100
      Message parsing complete, target speed set to -10 (current: 0, max: 100)
      Setting motor speed: -2 (power: 412) for motor shield TGV1
      Light event reverse
      Light event reverse
      Flipping function 2 to 1
      Setting PWM value of pin 4 to 850
      Setting motor speed: -4 (power: 425) for motor shield TGV1
      Setting motor speed: -6 (power: 437) for motor shield TGV1
      Setting motor speed: -8 (power: 450) for motor shield TGV1
      Setting motor speed: -10 (power: 462) for motor shield TGV1
      Connection to Wifi RocRail lost.

      and the mqtt log:
      1644845903: Sending PINGRESP to MTC4PF13648
      1644845913: Received PINGREQ from MTC4PF13648
      1644845913: Sending PINGRESP to MTC4PF13648
      1644845913: Received PUBLISH from RocrailService (d0, q1, r1, m282, ‘rocrail/service/command’, … (756 bytes))
      1644845913: Sending PUBACK to RocrailService (m282, rc0)
      1644845913: Sending PUBLISH to MTC4PF13648 (d0, q0, r0, m0, ‘rocrail/service/command’, … (756 bytes))
      1644845913: Received PUBLISH from RocrailService (d0, q1, r1, m283, ‘rocrail/service/info’, … (767 bytes))
      1644845913: Sending PUBACK to RocrailService (m283, rc0)
      1644845913: Received PUBLISH from RocrailService (d0, q1, r1, m284, ‘rocrail/service/info’, … (689 bytes))
      1644845913: Sending PUBACK to RocrailService (m284, rc0)
      1644845913: Received PUBLISH from RocrailService (d0, q1, r1, m285, ‘rocrail/service/info’, … (162 bytes))
      1644845913: Sending PUBACK to RocrailService (m285, rc0)
      1644845913: Received PUBLISH from RocrailService (d0, q1, r1, m286, ‘rocrail/service/info’, … (632 bytes))
      1644845913: Sending PUBACK to RocrailService (m286, rc0)
      1644845928: Client MTC4PF13648 has exceeded timeout, disconnecting.

      SO everything works perfectly as long as I do not give a command to do something.
      Sometimes i can give 2 or 3 commands from rocrail, if i do it fast enough. But the wifi disconnect always happens and there is no recovery.

      IS there someone who knows What is going wrong here ?

    • #5086
      Matthias RunteMatthias Runte
      Keymaster

      Can you post your MTC4PF configuration file, please?

    • #5088
      Erik SwinkelsErik Swinkels
      Participant

      update:
      I tested with a second board of the same type, same problem.
      Than I tested with a complete other board… no problems…

      The not correctly working type is this one:”
      https://www.bigtronica.com/5469-thickbox_default/wemos-nodemcu-lua-v3-340g.jpg
      This is a board without the metal shielding… the one that does work has got the shielding.

      I used the board because it has no pins pre-soldered

      My config is a slightly modified one from your examples.. but since it is working fine with the other board… It does not look like a problem with the config… but you’ll never know..
      // 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 needs to stay in the folder of the firmware for the specific MattzoController!

      // Handling of different configurations:
      // It’s a good idea to create copies for all the controllers of this type that you own.
      // Before compiling and uploading the firmware, just include the correct configuration into the firmware code.
      // This allows to manage specific configurations for the different controllers easily.

      // Best practice:
      // 1. Create a copy of this file if required (see above).
      // 2. Go through the settings below and update the settings as required.

      // ***********
      // MattzoLocos
      // ***********

      // Number of locos (aka. MattzoLocos) controlled by this controller
      const int NUM_LOCOS = 1;

      // List of MattzoLocos
      // The parameters have the following meaning:
      // – locoName: name of the loco as setup in Rocrail
      // – locoAddress: address of the loco as setup in Rocrail
      // – accelerationInterval: time interval for acceleration / braking (default: 100 ms)
      // – accelerateStep: power increment for each acceleration step
      // – brakeStep: : power decrement for each braking step
      MattzoLocoConfiguration* getMattzoLocoConfiguration() {
      static MattzoLocoConfiguration locoConf[NUM_LOCOS];

      locoConf[0] = (MattzoLocoConfiguration) {
      .locoName = “GROENE”,
      .locoAddress = 10010,
      .accelerationInterval = 100,
      .accelerateStep = 2,
      .brakeStep = 2
      };

      return locoConf;
      }

      // *************
      // Motor shields
      // *************
      // Motor shields are usually electronical components attached to the MattzoTrainController.
      // They are controlled via PWM signals from the controller and handle the higher currents required
      // for train motors.
      // Beside those physically existing motor shields, they are also partly or completely virtual motor shields as:
      // – LEGO_IR_8884, and
      // – WIFI_TRAIN_RECEIVER_4DBRIX
      // It is important to note that one train can have MULTIPLE motor shields attached to it. This is relevant for the following scenarios:
      // – Infrared LED controls multiple motors in a single train
      // – More than one 4DBrix WiFi Train Receiver installed in a single train.
      // – Combining different motorshields into a single train is also possible (e.g. steam loco with 4DBrix receiver in the front
      // and an additional “push” waggon in the middle of the train with an L9110 motorshield).

      // Number of motor shields controlled by this controller
      const int NUM_MOTORSHIELDS = 1;

      // List of motor shields that are controlled by this controller
      // The parameters have the following meaning:
      // – motorShieldName: usually the same as the name of the loco. If the 4DBrix WiFi Train Receiver is used, you can choose a different name here. Useful if a train has multiple 4DBrix receivers on board and the motor turning direction is different.
      // – motorShieldType: motor shield type
      // – minArduinoPower: minimum power setting for Arduino based motor shields
      // – maxArduinoPower: maximum power setting for Arduino based motor shields (max. 1023)
      // – configMotorA: turning direction of motor A (1 = forward, -1 = backward, 0 = unused)
      // – configMotorB: same for motor B
      // – locoAddress: loco that this motor shields is attached to
      MattzoMotorShieldConfiguration* getMattzoMotorShieldConfiguration() {
      static MattzoMotorShieldConfiguration msConf[NUM_MOTORSHIELDS];

      msConf[0] = (MattzoMotorShieldConfiguration) {
      .motorShieldName = “TGV1”,
      .motorShieldType = MotorShieldType::L9110,
      .minArduinoPower = MIN_ARDUINO_POWER,
      .maxArduinoPower = MAX_ARDUINO_POWER,
      .configMotorA = -1,
      .configMotorB = 0,
      .locoAddress = 10010
      };

      return msConf;
      }

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

      // Type of motor shield directly wired to the controller.
      // (The different motor shield types are defined in MTC4PF.ino)
      // Set to MotorShieldType::NONE if only virtual motor shields are used!
      const MotorShieldType MOTORSHIELD_TYPE = MotorShieldType::L9110;

      // Constants for motor shield type L298N
      #define enA D0 // PWM signal pin for motor A. Relevant for L298N only.
      #define enB D1 // PWM signal pin for motor B. Relevant for L298N only.

      // Constants for motor shield type L298N and L9110
      #define in1 D3 // pin for motor A direction control (forward).
      #define in2 D4 // pin for motor A direction control (reverse).
      #define in3 D5 // pin for motor B direction control (forward).
      #define in4 D6 // pin for motor B direction control (reverse).

      // Constants for motorshield type Lego IR Receiver 8884
      #define IR_LED_PIN D7 // pin on which the IR LED is installed.
      #define IR_CHANNEL 0 // channel number selected on the Lego IR Receiver 8884. May be 0, 1, 2 or 3.
      #define IR_PORT_RED 0 // Usage of red port on Lego IR Receiver 8884: 1 = motor, default rotation; 0 = no motor connected; -1 = motor, reversed rotation
      #define IR_PORT_BLUE 0 // Usage of blue port on Lego IR Receiver 8884: 1 = motor, default rotation; 0 = no motor connected; -1 = motor, reversed rotation

      // NUM_FUNCTIONS represents the number of Rocrail functions that are defined for this controller
      // If changed, the number of array values for FUNCTION_PIN below must be changed as well.
      // You should also check void lightEvent(), which is responsible for switching headlights from white to red etc.
      const int NUM_FUNCTIONS = 2;

      // Digital pins for function output
      // For lights conntected to LEGO IR Receiver 8884, use virtual function pins IR_LIGHT_RED and IR_LIGHT_BLUE
      uint8_t FUNCTION_PIN[NUM_FUNCTIONS] = {
      D0, // white
      D2 // red
      };

      // PWM value for analog output pin if switched on
      // max: 1023
      // PWM values without resistors for bipolar Duo-LED from Tams Elektronik, ordered in January 2022:
      // warm white:
      // warm white: 992 (3,2 V)
      // red: 620 (2,0 V)
      // cold white:
      // white: 961 (3,1 V)
      // red: 651 (2,1 V)
      // MTC4PF mini has 120 Ohm resistors inside, so no reduction is required effectively. Reduced red a bit for general care reasons.
      int FUNCTION_PWM_VALUE[NUM_FUNCTIONS] = {
      1023, // white
      850 // red
      };

      // The loco address for which the function pin will be triggered.
      // You may fill that array up with zeros (0). Meaning: “all trains”. Makes only sense if this controller is handling a single train only.
      int FUNCTION_PIN_LOCO_ADDRESS[NUM_FUNCTIONS] = { 0, 0 };

      // Automatic lights. If set to true, Functions with odd numbers (Fn1, Fn3…) are switch on when loco is going forward, and even numbers (Fn2, Fn4) when reverse. Set to false to disable the feature.
      // To set-up more advanced behaviour, find the lightEvent() function in the MTC4PF code and change it as desired.
      const bool AUTO_LIGHTS = true;

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

      // Report battery level
      const bool REPORT_BATTERYLEVEL = false; // set to true or false to allow or omit battery level reports
      const int SEND_BATTERYLEVEL_INTERVAL = 60000; // interval for sending battery level in milliseconds
      const int BATTERY_PIN = A0;
      const int VOLTAGE_MULTIPLIER = 20000 / 5000 – 1; // Rbottom = 5 kOhm; Rtop = 20 kOhm; => voltage split factor
      const int MAX_AI_VOLTAGE = 5100; // maximum analog input voltage on pin A0. Usually 5000 = 5V = 5000mV. Can be slightly adapted to correct small deviations

      // ****************
      // Network settings
      // ****************

      // Trigger emergency brake upon disconnect
      #define TRIGGER_EBREAK_UPON_DISCONNECT false

      // ***************
      // Syslog settings
      // ***************

      // Syslog application name
      const char* SYSLOG_APP_NAME = “MTC4PF-TGV1”;

    • #5089
      Erik SwinkelsErik Swinkels
      Participant

      found other problems with this type of board:

      https://github.com/Aircoookie/WLED/issues/2503

    • #5105
      Erik SwinkelsErik Swinkels
      Participant

      update: No command is no problem. the PINREQ and PINRESP never stops until a command is send to the loco.
      I tested the same board with the MLC software. This works without a problem. I can send switch commands over and over without any problem.
      So what is going wrong.
      The board is nothing special. board info when uploading a sketch

      Serial port COM4
      Connecting….
      Chip is ESP8266EX
      Features: WiFi
      Crystal is 26MHz
      MAC: 94:b9:7e:14:8f:c2
      Uploading stub…
      Running stub…
      Stub running…
      Configuring flash size…
      Auto-detected Flash size: 4MB
      Erasing flash (this may take a while)…
      Chip erase completed successfully in 7.0s

Viewing 4 reply threads
  • You must be logged in to reply to this topic.