Welcome to MattzoBricks Forums MattzoTrainController for Power Functions (MTC4PF) L9110 auf 100% trotz korrekter Rocrail-Befehle

Viewing 5 reply threads
  • Author
    Posts
    • #5864
      Stephan CsontosStephan Csontos
      Participant

      Hallo werte MattzoController Freunde

      Ich habe folgendes Problem:
      Wenn ich einen Geschwindigkeitswert über RocRail an den MattzoController sende, wird dieser auch über dem MQTT Broker übertragen. Hier ein kleiner Auszug aus dem SerialMonitor:
      Setting train speed 30 (power: 634) for motor shield index 0
      setMotorShieldPower() called with msi=0, mpi=0, desiredPower=-634
      Setting train speed 35 (power: 673) for motor shield index 0
      setMotorShieldPower() called with msi=0, mpi=0, desiredPower=-673
      Setting train speed 40 (power: 712) for motor shield index 0
      setMotorShieldPower() called with msi=0, mpi=0, desiredPower=-712

      An den PIN D3 und D4 wird aber immer ein Spannung von 3.28V ausgegeben. Jeder Geschwindigkeitsveränderung in RocRail wird an den PIN D3 und D4 nicht ausgegeben.
      Somit resultiert bei jedem Geschwindigkeitsbefehl eine Spannung von 8.8V auf dem Motorshield.

      Hier die Config im Controller:
      // 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

      // ************************************************
      // Example file for a simple train with MTC4PF mini
      // ************************************************

      // *****
      // LOCOS
      // *****

      // 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 = “TGV blau”,
      .locoAddress = 100,
      .accelerationInterval = 100,
      .accelerateStep = 5,
      .brakeStep = 10
      };

      return locoConf;
      }

      // *************
      // MOTOR SHIELDS
      // *************
      // Number of motor shields connected to this controller
      const int NUM_MOTORSHIELDS = 1;

      // List of motor shields that are controlled by this controller
      // The parameters have the following meaning:
      // – locoAddress: loco that this motor shields is attached to
      // – motorShieldType: motor shield type
      // – L298N_enA, L298N_enB: PWM signal pin for motor A / B, if L298N is used.
      // – in1..in4: pin for motor direction control for motor shields L298N and L9110 (in1: forward motor A, in2: reverse motor A, in3: forward motor B, in4: reverse motor B).
      // – 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). In case of LEGO IR Receiver 8884, this is the motor connected to the red port.
      // – configMotorB: same for motor B; if IR receiver: blue port
      // – irChannel: if a LEGO IR Receiver 8884 is used, the selected channel of the receiver. May be 0, 1, 2 or 3. If the loco uses multiple IR receivers on different channels, additional motor shields for the loco are required.
      MattzoMotorShieldConfiguration* getMattzoMotorShieldConfiguration()
      {
      static MattzoMotorShieldConfiguration msConf[NUM_MOTORSHIELDS];

      // 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;

      msConf[0] = (MattzoMotorShieldConfiguration){
      .locoAddress = 100,
      .motorShieldType = MotorShieldType::L9110,
      .L298N_enA = 0,
      .L298N_enB = 0,
      .in1 = D3,
      .in2 = D4,
      .in3 = D5,
      .in4 = D6,
      .minArduinoPower = MIN_ARDUINO_POWER,
      .maxArduinoPower = MAX_ARDUINO_POWER,
      .configMotorA = -1,
      .configMotorB = 0,
      .irChannel = -1
      };

      return msConf;
      }

      // *************************
      // TRAIN LIGHT CONFIGURATION
      // *************************

      // Number of train lights controlled by this controller
      #define NUM_TRAIN_LIGHTS 0

      TTrainLightConfiguration trainLightConfiguration[NUM_TRAIN_LIGHTS] = {};

      // ******************************
      // FUNCTION MAPPING CONFIGURATION
      // ******************************

      // Rocrail functions are used to MANUALLY switch train lights on and off

      // Number of function mappings
      #define NUM_FUNCTION_MAPPINGS 0

      TLocoFunctionMappingConfiguration locoFunctionMappingConfiguration[NUM_FUNCTION_MAPPINGS] = {};

      // *********************************
      // TRAIN LIGHT TRIGGER CONFIGURATION
      // *********************************

      // Triggers are used to AUTOMATICALLY switch train lights on and off

      // Number of train light triggers as defined just below
      #define NUM_TRAIN_LIGHT_TRIGGERS 0

      TTrainLightTriggerConfiguration trainLightTriggerConfiguration[NUM_TRAIN_LIGHT_TRIGGERS] = {};

      // ************************
      // CONTROLLER CONFIGURATION
      // ************************

      // Configuration for motorshield type Lego IR Receiver 8884
      const uint8_t IR_LED_PIN=D5; // pin on which the IR LED is installed that controls all attached Lego IR Receiver 8884s.

      // Digital output PIN to monitor controller operation (typically a LED)
      const bool STATUS_LED_PIN_INSTALLED=true;
      const uint8_t STATUS_LED_PIN=D8;
      const bool STATUS_LED_REVERSE=false;

      // Report battery level
      #define REPORT_BATTERYLEVEL false // set to true or false to allow or omit battery level reports
      #define SEND_BATTERYLEVEL_INTERVAL 60000 // interval for sending battery level in milliseconds
      #define BATTERY_PIN A0
      const int VOLTAGE_MULTIPLIER = 20000 / 5000 – 1; // Rbottom = 5 kOhm; Rtop = 20 kOhm; => voltage split factor
      #define 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
      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 = “MTC4PF-mini”;

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

      Das folgende Board habe ich im Einsatz:
      NodeMCU Lua Amica Modul V2 ESP8266 ESP-12F WIFI WLAN unverlötet mit CP2102

      Danke für die Hilfe

      P.S.:
      Motorshield habe ich bereits gewechselt. Habe aber den Controller noch nicht durch einen anderen ersetzt.

    • #5865
      Matthias RunteMatthias Runte
      Keymaster

      Wenn ich Dich richtig verstehe, klappt anhalten und fahren grundsätzlich, aber beim fahren fährt die Lok immer mit voller Leistung, korrekt? Wenn dem so ist, würde ich Dir empfehlen, mal mit folgenden beiden Parametern zu spielen:

      .minArduinoPower = MIN_ARDUINO_POWER,
      .maxArduinoPower = MAX_ARDUINO_POWER,

      Probier doch mal

      .minArduinoPower = 200,
      .maxArduinoPower = 500,

      oder so etwas, und teste ein bisschen was für die Lok gut funktioniert.

    • #5866
      Stephan CsontosStephan Csontos
      Participant

      Hallo Matthias

      Danke dir für den Tipp, genau dies musste ich im Code anpassen. Die zugewiesenen Werte zu .minAurduinoPower und .maxArduinoPower sind zu hoch.

      Ich musste die werte wie folgt anpassen damit ein brauchbares PWM Signal generiert wird:
      .minArduinoPower = 1,
      .maxArduinoPower = 300,

      Ein Wert von 400 wird im main.cpp der Funktion .minArduinoPower zugewiesen.
      Dieser Wert führt dazu, dass das PWM Signal an den Ausgänge D3/D4 eine gemittelte Spannung von ca. 3.3V erzeugen.

      Warum dies nun bei diesem Microcontroller von AZ-Delivery so ist, kann ich nicht sagen.
      Gemäss Lieferant ist der gelieferte Microcontroller der gleiche, wie der in der Materialliste auf Mattzobricks.com.

      Sei es so wie es ist aber nun funktioniert alles so wie es soll.

      Danke dir und bis bald

      • This reply was modified 8 months ago by Stephan CsontosStephan Csontos. Reason: Schreibfehler
    • #5935
      Guido RamusGuido Ramus
      Participant

      Hallo,
      ich hatte genau das gleiche Problem. Und bei mir mit dem Billig-L9110 und den Standart ESP passten die Werte 100-250 ganz gut.
      Danke für den Tip und für die MTC Sache überhaupt!
      VG,
      Brandse

      • This reply was modified 7 months, 2 weeks ago by Guido RamusGuido Ramus. Reason: Tippfehler
    • #5937
      Matthias RunteMatthias Runte
      Keymaster

      Ich kommentiere das mal im Source Code, dann hat es die Nachwelt etwas einfacher.

    • #6310
      Artyr NikolaevArtyr Nikolaev
      Participant

      Faced the same problem.
      Added to the setup section
      analogWriteRange(1023);

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