Welcome to the forum   
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Share
Options
View
Go to last post in this topic Go to first unread post in this topic
Offline RCH  
#1 Posted : 13 July 2025 17:58:46(UTC)
RCH

Netherlands   
Joined: 19/12/2024(UTC)
Posts: 16
Location: Zuid-Holland, Delft
Hi all,

After a long time of studying Stefan Krauss's document, building electronics, writing software and staring at an oscilloscope screen I managed to create a DIY MFX controller. It's called the Alternative Train Controller or ATC.
You can read about my endeavours on my website https://www.alyda.nl/atc.

I do have to thank Mark aka 'revmok' for proofing the text and keeping this a secret. He helped me a lot in the last months. Also his log files containing MFX communication proved to be vital in the creation of the ATC.
Also Stefan Krauss helped a lot to get me going.

Please note, the ATC is meant as a starting point and proves it can be done.

Have fun!

RCH
thanks 3 users liked this useful post by RCH
Offline bobyAndCo  
#2 Posted : 13 July 2025 21:20:16(UTC)
bobyAndCo

France   
Joined: 20/02/2024(UTC)
Posts: 31
Location: France - Bretagne
Hello RCH,

Bravo, I looked at the site on the link you give. You have indeed succeeded in mastering the locomotive controls and also the feedback from the decoders to the control centre, which is probably not the easiest thing to do.

I'm currently on holidays and don't have everything I need to test. I'll try it out when I get back in early August.

I have a few questions to get me going in the meantime.

1° - Which software, which control unit to drive the ESP32 ? What is the protocol between the control interface and ATC? TCP? CAN to be compatible with Marklin's graphical interfaces (MS2...)? But on your diagrams, I see that it's more likely to be USB?

2° - You don't list the components for this feedback circuit as you do for the control unit. It's probably not very difficult to do from the schematic, but could you add it to the site to avoid confusion?

I look forward to hearing from you.

Best regards

Christophe
thanks 2 users liked this useful post by bobyAndCo
Offline RCH  
#3 Posted : 14 July 2025 13:33:52(UTC)
RCH

Netherlands   
Joined: 19/12/2024(UTC)
Posts: 16
Location: Zuid-Holland, Delft
Hi Christophe,

1° - Which software, which control unit to drive the ESP32 ? What is the protocol between the control interface and ATC? TCP? CAN to be compatible with Marklin's graphical interfaces (MS2...)? But on your diagrams, I see that it's more likely to be USB?

The ATC is based only on the ESP32. That's all you need as a controller. No Gleisbox, no CS or whatever. Just the ATC. At this moment you can communicate with the ATC via a text terminal and give it simple commands, like drive forward with a giving speed. I'll elaborate on the software but realise that the ATC and software covers the first steps of the "OSI-model".
And yes, you communicate via the (serial) USB port of the ESP32.
I do however have a version that works with a web interface via Wifi. Handy if you want to walk around your setup with a tablet or so Drool.

2° - You don't list the components for this feedback circuit as you do for the control unit. It's probably not very difficult to do from the schematic, but could you add it to the site to avoid confusion?

The feedback circuit shown in the chapter Feedback is a snip of the complete schematics. In the chapter Schematics you find a pdf link for the complete schematics. The feedback components are included in the components list.

Greetings

thanks 2 users liked this useful post by RCH
Offline osoraku  
#4 Posted : 14 July 2025 21:04:06(UTC)
osoraku

Portugal   
Joined: 22/01/2025(UTC)
Posts: 60
Location: Setubal, Palmela
Dear RCH -

Parabens - a few brief comments/questions to check my understanding.

Sorry, I (lazily) haven't yet read the code which would no doubt answer some questions directly. But based on the schematics, ...

  • The DFRobot motor controller provides track power and modulates it to send the digital signals to the locos and track accessories. Correct?
  • The ferrite inductor and associated circuitry detects the feedback from the loco decoders and any track accessory feedback. Correct?


The motor controller is a neat shortcut to a device that could probably drive DCC and as well.

Osoraku
Offline RCH  
#5 Posted : 15 July 2025 09:15:59(UTC)
RCH

Netherlands   
Joined: 19/12/2024(UTC)
Posts: 16
Location: Zuid-Holland, Delft
Obrigado pelo elogio (what should you do without Google translate...)

Sorry, I (lazily) haven't yet read the code which would no doubt answer some questions directly. But based on the schematics, ...

  • The DFRobot motor controller provides track power and modulates it to send the digital signals to the locos and track accessories. Correct?
    Yes, this is correct. It's a so called H-bridge driver. I was designing a H-bridge driver by myself but found this DFRobot module that does an excellent job. It's capable of driving high currents (up to 10A) at high speeds and it's affordable (€20,= or so). I use a 18/19V laptop adapter for powering the ATC which in turn drives the track.

  • The ferrite inductor and associated circuitry detects the feedback from the loco decoders and any track accessory feedback. Correct?
    Yes, correct. The decoders use current (not voltage) to communicate back to 'a' controller. This controller could be a commercial one or the ATC. The feedback circuit picks up this current signal, amplifies and converts it into (voltage) pulses. I would like to stress that the circuit and software are not copied from any other design or commercial products. The only three things I had when making the ATC was Stefan Krauss's document, Mark's log files and one MFX locomotive.


    The motor controller is a neat shortcut to a device that could probably drive DCC and as well.
    Yes, the ATC can be a nice cheap platform to expand to other protocols as well. As a matter of fact I even included a software switch in my demonstration code to switch between MFX, DCC or analogue. Yes, even analogue because I think (haven't tried it yet) that creating a sinusoidal using a PWM signal with the current design should be possible.
    Mind you DCC nor analogue is not (yet) included in the code. I'm not retired yet and I'm squeezing this 'little' project in between my regular job, family life and other obligations.


    Diverte-te

    RCH
  • Offline bobyAndCo  
    #6 Posted : 15 July 2025 09:23:10(UTC)
    bobyAndCo

    France   
    Joined: 20/02/2024(UTC)
    Posts: 31
    Location: France - Bretagne
    Originally Posted by: RCH Go to Quoted Post

    Sorry, I (lazily) haven't yet read the code which would no doubt answer some questions directly.


    Hello,

    You speak of “reading the code”. But I haven't seen anywhere that the code is published?

    Christophe
    Offline patnaik  
    #7 Posted : 16 July 2025 05:32:30(UTC)
    patnaik

    United States   
    Joined: 22/08/2020(UTC)
    Posts: 41
    Location: Maryland, Silver Spring
    If you could figure out how to simultaneously do MFX and DCC that would be great. Add MM2 and you solve the entire compatibility problem. By using a standard protocol to communicate to the ATC allows the use of well developed software to control the layout.

    Keep up the good work!

    Gopal
    Offline revmox  
    #8 Posted : 16 July 2025 05:39:25(UTC)
    revmox

    Australia   
    Joined: 26/05/2021(UTC)
    Posts: 199
    Location: Australia, East Maitland, NSW
    Congratulations RCH on getting the ATC going.

    Sorry I took so long to reply - some of us retired people have very busy schedules getting around to all those vineyards, resorts and attractions ...

    I know how much effort you put into this project - and to do it all with just one loco, a couple of pieces of track and not even an MS2 is an achievement you can be proud of. At the beginning I said you would probably need some serious therapy if you ventured down the mfx rabbit hole - but you have had a win and still seem reasonably sane.

    I think many have been able to get something going via the CAN bus and track box but this is real "first principles" stuff and mfx is quite complex when you get down to the nuts and bolts level.

    I look forward to seeing where it goes from here and will be very happy to provide further help if you need it.

    Once again, well done. ThumpUp ThumpUp ThumpUp

    Mark (revmox).


    Offline bobyAndCo  
    #9 Posted : 16 July 2025 07:35:24(UTC)
    bobyAndCo

    France   
    Joined: 20/02/2024(UTC)
    Posts: 31
    Location: France - Bretagne
    Originally Posted by: patnaik Go to Quoted Post

    If you could figure out how to simultaneously do MFX and DCC that would be great. Add MM2 and you solve the entire compatibility problem. By using a standard protocol to communicate to the ATC allows the use of well developed software to control the layout.


    Gopal,

    Generating a DCC (or MM) signal is not very different from generating an MFX signal. For DCC, however, you need to think about generating a CUTOUT, the space of about 450µs without any track signal, during which the locomotive DCC decoder returns its information (address etc...).

    On an ESP32, generating the DCC or MFX signal with timers conflicts with the use of WiFi if enabled. Around 30% of frames are out of specification (NMRA). This is even more the case when using two protocols, or even three with MM.

    This is why the developers of DCC-Ex, the DIY reference software for DCC, have used the high-performance RMT technology available on ESP32.

    https://dcc-ex.com/index.html

    I've also done this on my own MFX control unit: https://github.com/BOBIL...blob/main/src/MfxRMT.cpp

    However, I think that RHC is planning for its control unit to work with WiFi in the future. We'll have to take that into account.

    Christophe

    Offline RCH  
    #10 Posted : 16 July 2025 10:01:32(UTC)
    RCH

    Netherlands   
    Joined: 19/12/2024(UTC)
    Posts: 16
    Location: Zuid-Holland, Delft
    Hi all,

    I do agree with Christophe that making this work for DCC shouldn't be much of a problem. It works for MFX so no reason that it shouldn't work for DCC. I started with MFX because this protocol was best descripted by Stefan Krauss. I had to start somewhere...

    About the RMT Christophe descipted, for the none ESP32 users, RMT is a seperate 'device' inside the ESP32 used for generating digital patterns. I think intially intented for generating Remote Control signals like your TV remote. Using the RMT would relieve you from timing issues. You can generate patterns (read MFX commands) that can be send to the track without interference of other unknown, hidden internal ESP32 processes like WiFi. Not using RMT I have seen these unwanted timing interruptions when generating the MFX signals. First of all the MFX decoders are quite forgiving in handling these timing issues. However I circumvented the timing issue to a minimum by using the following:
    - seperate the critical timing and lets say the 'human interfacing' on seperate cores. Note that it is imperative to realise that Wifi (which I'm using in the ATC) takes place on core 0. So critical timing is shifted to core 1.
    - elevated core 1 priority to it's max
    - initiate timing crital timers and/or interrupts on core 1
    - use a good oscilloscope to be able to see if you are doing the right thing....

    While developing the code I had a look at the RMT option. I abandoned this option because I think RMT is ment for burst patterns like your remote. MFX or DCC for that matter is a continuous signal flow where communication is 'embedded' within the flow while maintaning the OLC-rule (see chapter Driving signal). RMT can generate MFX command patterns OR the '0' steady state signal but intertwining the both AND maintaining the OLC rule I'm not sure.
    But please be my guest and try. It's like Revmox mentioned the ATC is "first principle stuff". I do not want to stop progress.

    About the code, it's not released yet. It's more over than a 1000 lines (excluding 500 lines or so of comment...). I want to put in a effort to make it as readable as possible. So please be patient.

    RCH



    Originally Posted by: bobyAndCo Go to Quoted Post
    Originally Posted by: patnaik Go to Quoted Post

    If you could figure out how to simultaneously do MFX and DCC that would be great. Add MM2 and you solve the entire compatibility problem. By using a standard protocol to communicate to the ATC allows the use of well developed software to control the layout.


    Gopal,

    Generating a DCC (or MM) signal is not very different from generating an MFX signal. For DCC, however, you need to think about generating a CUTOUT, the space of about 450µs without any track signal, during which the locomotive DCC decoder returns its information (address etc...).

    On an ESP32, generating the DCC or MFX signal with timers conflicts with the use of WiFi if enabled. Around 30% of frames are out of specification (NMRA). This is even more the case when using two protocols, or even three with MM.

    This is why the developers of DCC-Ex, the DIY reference software for DCC, have used the high-performance RMT technology available on ESP32.

    https://dcc-ex.com/index.html

    I've also done this on my own MFX control unit: https://github.com/BOBIL...blob/main/src/MfxRMT.cpp

    However, I think that RHC is planning for its control unit to work with WiFi in the future. We'll have to take that into account.

    Christophe



    Users browsing this topic
    Guest (4)
    Forum Jump  
    You cannot post new topics in this forum.
    You cannot reply to topics in this forum.
    You cannot delete your posts in this forum.
    You cannot edit your posts in this forum.
    You cannot create polls in this forum.
    You cannot vote in polls in this forum.

    | Powered by YAF.NET | YAF.NET © 2003-2025, Yet Another Forum.NET
    This page was generated in 0.378 seconds.