Verfasste Forenbeiträge
-
AutorBeiträge
-
Januar 19, 2023 um 20:40 Uhr als Antwort auf: MTC4PF – MattzoTrainController for Power Functions #5806
Herbert S.
TeilnehmerHi Martin,
as I wrote earlier, The ICE #7897 and the green crocodile #7898 are in my opinion beautiful trains of the Lego train family. The best option would be to convince Mattzo to add it to the MTC4PF, based on Visual Studio code. Martin, did you do your work on Arduino or on Visual studio code? Maybe Mattzo can write his opinion about it. I still hope, that Mattzo adds the trains to the MTC4PF.
best regards
HerbertMärz 14, 2021 um 15:55 Uhr als Antwort auf: MTC4PF – MattzoTrainController for Power Functions #2751Herbert S.
TeilnehmerHallo Mattze,
Danke für die Info,das ist jedenfalls ganz toll. Meine Bitte war aber eher, dass du die IR Befehle vor Power Functions (7897,7898 – schwarze Fernbedienung) aufnehmen könntest. Das wäre sicher für ein umfassendes Lego Projekt sehr wichtig.
Liebe Grüße
HerbertMärz 13, 2021 um 21:46 Uhr als Antwort auf: MTC4PF – MattzoTrainController for Power Functions #2747Herbert S.
TeilnehmerHallo Matthias,
könntest du mir – und somit natürlich der gesamten Lego Community – einen großen Gefallen tun. Aus meiner Sicht sollte es einfach sein, den LEGO_IR_8884 Code um 4 weitere Einstellungen/Kanäle zu ergänzen (nur IR). Die Züge 7897 (wunderschöner ICE) und 7898 (grünes Krokodil) lassen sich auch mit IR steuern. Es gibt 3 Kanäle und einen 4. für 1 bis 3 gemeinsam.
Es gibt nur + und Minus Taste (funktioniert 7 Mal – somit 7 Geschwindigkeiten) und Stop Taste. Jeweils Plus drücken wird der Zug eine Stufe schneller bis zum Maximum (dann kann man zwar weiter drücken, aber der Motor wird nicht mehr schneller), mit Minus drücken wird er langsamer bis er rückwärts wieder bis zum Maximum fährt. Dann gibt es noch die Stop Taste.
Wenn die Befehlsstruktur gleich ist wie beim Power Functions, müsse es einfach sein, das Programm zu erweitern. Wenn es bei PF mehr Geschwindigkeitsstufen gibt, könnte man ja einfach welche doppelt verwenden, damit man das Programm nicht adaptieren muss. Man könnte einfach statt den Kanälen 0-3 (PF), die Kanäle 4-7 in deinem Programm verwenden. Lichter gibt es sowieso nicht, je Kanal somit nur 1 Sender. Da kann man einfach standardmäßig Null setzen. Leider kann ich nicht C programmieren und verstehe das Programm zu wenig.
Die Codes in Hex hätte ich mal ermittelt:
1+:390C76EE
1-:5CF0E634
1stop:F3F4DCF8
2+:1D1F21E0
2-:7D769E4F
2stop:1E61B965
3+:1695FECD
3-:7672B3A
3stop:29F6DFB4
All+:4B7BA39F
All-:B0D3CC54
Allstop:D1637DA9
Einige waren nicht 100%ig eindeutig. Aber die 2. Möglichkeit habe ich noch und könnte einfach mal testen.
Ich hoffe, die Adaption ist so einfach wie ich mir das vorstelle. Wäre jedenfalls eine tolle Erweiterung, speziell, da ich dann 3 Züge mehr verwenden könnte.
PS: Dein Tip mit den IR Sendern war korrekt. Ich kaufte deine Modelle bei Amazon und alles lief perfekt. Jetzt warte ich gerade auf 100 reed sensoren:-)liebe Grüße & Gratulation zu diesem wirklich tollen Projekt
HerbertHerbert S.
TeilnehmerThank you for the info. I will buy this type too.
Actually I used 2 different types:
LED 5mm Infrarot klar 10-40mW/sr 13 7 0,49 3,43
183338 LED-KREATIV-SET S081 IR-LED 5 MM (set of receiver and transmitter)Herbert S.
TeilnehmerHello Forum,
I have a problem with this controller. Mayby someone has an quick idea.My situation: MattzoSwitchController: up and running, MattzoTrainControllerPU: up and running, Problem: MTC4PF: Train is not responding (only once there was a little move of the train)
My configuration: Train with LEGO IR 1884, Motor on red and lights on blue, Standard ESP8266 MOD 12-F from AZ Delivery,only one IR LED soldered on D5 and GND (short leg), power supply: 9V on VIN and GND,
Also tested: a second board with another type of IR LED, both boards also testet with 5V (USB)
The Mattzo Controller looks to be working perfect and send the right commands (see protocol)
Possible problem: I only measure 0,14 V on the IR LED when it is working. It is supposed to has 1,35V. But I have no idea what could be wrong. I tested everything twice with a second board. The power supply of the board is ok (3,3 V on 3V3 and GND).Maybe the value “const int MAX_AI_VOLTAGE = 5100″; is too low, but I didn’t want to change this. It comes from the example file
Has anybody an idea?Find there the protocol from board and the config file:
Received MQTT message [rocrail/service/command]: <lc id=”Gelb_7939″ V=”25″ fn=”true” dir=”true” throttleid=”rv7880″ controlcode=”” slavecode=”” server=”infw0343CA14″ fncnt=”4″ f0=”true” 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=”25″ V_max=”100″ V_mode=”percent” bus=”0″ prot=”P” protver=”1″ spcnt=”255″ oid=”” identifier=”” mode=”stop” iid=”” addr=”7939″ imagenr=”0″ informall=”false”/>
Parsing XML successful
<lc> node found. Processing loco message…
loco id: Gelb_7939
addr: 7939
Consuming message for train Gelb_7939 (7939)
dir (raw): true
direction: forward
V: 25
V_max: 100
Message parsing complete, target speed set to 25 (current: 0, max: 100)
Setting motor speed: 2 (IR speed: 2)
Light event forward
Flipping function 1 to 1
Setting motor speed: 4 (IR speed: 4)
Setting motor speed: 6 (IR speed: 6)
Setting motor speed: 8 (IR speed: 8)
Setting motor speed: 10 (IR speed: 10)
Setting motor speed: 12 (IR speed: 12)
Setting motor speed: 14 (IR speed: 14)
Setting motor speed: 16 (IR speed: 16)
Setting motor speed: 18 (IR speed: 18)
Setting motor speed: 20 (IR speed: 20)
Setting motor speed: 22 (IR speed: 22)
Setting motor speed: 24 (IR speed: 24)
Setting motor speed: 25 (IR speed: 25)
Received MQTT message [rocrail/service/command]: <clock divider=”1″ hour=”18″ minute=”34″ wday=”1″ mday=”1″ month=”3″ year=”2021″ time=”1614620053″ temp=”20″ bri=”255″ lux=”0″ pressure=”0″ humidity=”0″ cmd=”sync”/>Parsing XML successful
Unknown message, disregarConfig File
// **********************************************************************************
// Example file for configuring the MTC4PF to control a train with L9110 motor shield
// **********************************************************************************// ***********
// 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 = “Gelb_7939”,
.locoAddress = 7939,
.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
MattzoMotorShieldConfiguration* getMattzoMotorShieldConfiguration() {
static MattzoMotorShieldConfiguration msConf[NUM_MOTORSHIELDS];msConf[0] = (MattzoMotorShieldConfiguration) {
.motorShieldName = “Gelb_7939”,
.motorShieldType = MotorShieldType::LEGO_IR_8884,
.minArduinoPower = MIN_ARDUINO_POWER,
.maxArduinoPower = MAX_ARDUINO_POWER,
.configMotorA = 1,
.configMotorB = 0,
.locoAddress = 7939
};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::NONE;// 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 D5 // 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 1 // 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 = 1;// 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] = { IR_LIGHT_BLUE };// 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 };// Automatic lights. If set to true, Functions with odd numbers (Fn1, Fn3…) are switch on when loco is going forward, and odd 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 = false; // set to false if no LED is installed
uint8_t STATUS_LED_PIN = D8;// 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”;Herbert S.
TeilnehmerHi Max, thank you for your hint with the Boot/Rst pins. So far I have not even noticed them. I’m a beginner with microcontrollers.So you really have to write some tutorial for Mattzo and Arduino/Controllers. But my problem is still not solved. When uploading everything looks good to me: these are the last messages from Arduino
Compressed 3072 bytes to 128…
Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.0 seconds (effective 1170.3 kbit/s)…
Hash of data verified.Leaving…
Hard resetting via RTS pin…
When I press Boot/RTS, the flashing and rebooting stops, but now, the monitor writes the system is waiting for download again:
Rebooting…
ets Jun 8 2016 00:22:57rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6352
entry 0x400806b8
ets Jun 8 2016 00:22:57rst:0x1 (POWERON_RESET),boot:0x3 (DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_REO_V2))
waiting for download
Rebooting…
ets Jun 8 2016 00:22:57rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6352
entry 0x400806b8
ets Jun 8 2016 00:22:57rst:0x1 (POWERON_RESET),boot:0x3 (DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_REO_V2))
waiting for download
so it is in infinite loop, pressing Boot or Reset by itself had no effect, so far from Arduino I got correctly the MAC Adress, but an original boot with the Mattzo Controller ID did not happen. Right now, I have only one ESP32, so I cannot change the hardware. Any Ideas?Herbert S.
TeilnehmerHi, unfortunately I ran into a problem and I am not able to solve it. I managed to include the libraries. The compilation is without errors. The upload works – the AZ Delivery ESP 32 is blinking red. But the controller keeps rebooting with following message:Rebooting…
ets Jun 8 2016 00:22:57rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6352
entry 0x400806b8
assertion “heap != NULL && “free() target pointer is outside heap areas”” failed: file “/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/heap_caps.c”, line 267, function: heap_caps_free
abort() was called at PC 0x40123513 on core 1Backtrace: 0x400916c0:0x3ffcc720 0x400918f1:0x3ffcc740 0x40123513:0x3ffcc760 0x40084b67:0x3ffcc790 0x40085129:0x3ffcc7b0 0x4000bec7:0x3ffcc7d0 0x400ef386:0x3ffcc7f0 0x400ef46a:0x3ffcc810 0x400d1bd1:0x3ffcc830 0x400d1cf2:0x3ffcc850 0x400d2e37:0x3ffcc8a0 0x400ef9c7:0x3ffcc8f0 0x4008dae5:0x3ffcc910
Rebooting…
line 267 is a counter for the number of Locos, I set it 1 in the config file
Can anybody help me?
One more question. I have to set the IP adress for the MQTT. Is it “localhost” if it is running on the same Win 10 Notebook. Where do I get it?Februar 7, 2021 um 18:44 Uhr als Antwort auf: MTC4PF – MattzoTrainController for Power Functions #2281Herbert S.
TeilnehmerHello, I am new here and very enthusiastic about the idea. So today I have ordered a lot of controllers, reed sensors and other stuff. I have two questions: I have an white ICE 7897 and a green crocodile 7898. These work with IR, but this system was published befor power functions. So is it or will it be possible to control them with an MattzoTrainControll with IR-LED? The second question is about your future plans für the MattzoLayoutController and the new train controller. Will it be the same hardware (ESP8266 / ESP 32) or are there plans to change?
-
AutorBeiträge