Maerklin 4316 Central

You are right, Maerklin 4316 is not a central but a normal waggon. But with a RaspberryPI running srcpd and Rocrail this waggon can be easily turned into a DCC central.

We need a circuit creating a differential protocol from the serial stream of the RaspberryPI Zero W, so for that I had used DigiSpark Mini including a simple timeout check to disable the tracks if no data was arrived. The Pololul MC33926 can be used as a driver stage. At last step we need power. A LiFePo4 battery is much more stable as LiIon. Adding step-up converters and a charger finishes the power stage.

So the idea is to do something like that:

A first check shows everything seems to fit:

Stay tuned for the building instructions… it is already running, see the video:

 

C-Code of Arduino compatible Digispark Mini:

//needs installation of library https://github.com/NicoHood/PinChangeInterrupt
#include "PinChangeInterrupt.h"



volatile int Count = 1001;
bool bLastState = false;

//setup of GPIOs
//P0 DCC IN
//P1 Enable Input of driver stage
//P2 Input 1 of driver stage
//P4 Input 2 of driver stage
const int DccInPin = 0;
const int DccInPCINT = 0;
const int DccEnablePin = 1;
const int DccOut1Pin = 2;
const int DccOut2Pin = 4;



void setup() {
  //setup of GPIOs
  pinMode(DccInPin, INPUT);
  pinMode(DccEnablePin, OUTPUT);
  digitalWrite(DccEnablePin,LOW);
  pinMode(DccOut1Pin,OUTPUT);
  pinMode(DccOut2Pin,OUTPUT);

  //setup ISR
  attachPCINT(DccInPCINT, DccInChanged, CHANGE);
}

//ISR called at DCC IN Pin change
void DccInChanged(void)
{
  //toggle DCC pins
  bLastState = !bLastState;
  digitalWrite(DccOut1Pin,bLastState);
  digitalWrite(DccOut2Pin,!bLastState);
 
  //reset timeout counter
  Count = 0;
}

void loop() {
  for(;;)
  {
      //check timeout happened
      if (Count > 1000) 
      {
        digitalWrite(DccEnablePin,LOW); //timeout - disable driver stage
      } else
      {
        Count++;
        digitalWrite(DccEnablePin,HIGH); //no timeout - enable driver stage
      }
  }
}

2 Comments

    • schreinerman

      well, thanks! I tried to post my ideas and thoughts and result was they deleted my entries because of possible conflicts of author rights regarding reverse engineering.

      So at least for me it is a nice toy, but I don’t know if other nerds and geeks would be as happy as me…

      (edit): In the meanwhile the MFX protocoll was opened by Märklin.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.