Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.
Jan Horacek edited this page May 6, 2021 · 12 revisions

MTB library wiki

This wiki describes functionality of MTB.dll dynamic library and its API.

MTB library is used to set and get state of MTB modules on model railroad via simple dll interface. It supports MTB-UNI and MTB-TTL modules with firmware 4.1.

This library could be loaded from any program (be sure to match library and application architecture [e.g. x86 or x86-64]). MTB.dll is currently distributed only in x86 (32-bit) architecture.

The library is implemented in Object Pascal and usually being compiled in Delphi 2009 32-bit.

The library has windows, however, it is fully operable without using them.


  • Fully operable MTB-USB module connected to PC via USB.
  • MTB-USB driver (available in project releases). Driver is custom FTDI driver, installation from unknown sources is required to install this driver.
  • Writeable ./mtb/mtbcfg.ini.

Short intro to MTB

  • MTB is a RS485-based bus which consists of a single master (called MTB-USB) and multiple slaves.
  • There are several types of slaves, each has different features:
  • MTB-UNIm
  • Most common modules are MTB-UNI and MTB-TTL.
  • Both of these modules have 16 digital inputs and 16 digital outputs.
  • This library supports only MTB-UNI, MTB-UNIm and MTB-TTL.
  • This library allows user to detect states of inputs and set states of outputs.
  • Each board has its unique address, 1-255.
  • There are 16 input and 16 output ports on each MTB-UNI, MTB-UNIm or MTB-TLL board, these pins are indexed 0-15.

Sample workflow

  1. Connect MTB-USB board via USB.
  2. Install drivers.
  3. Load the library into you program.
  4. Select one of available MTB-USB boards.
  5. Open device (by calling Open from your app, wait for modules being scanned).
  6. Optional: configure modules (configuration will be saved).
  7. Start communication (by calling Start from your app).
  8. Use the bus (SetOutput, GetInput, ...).
  9. Stop communication by calling Stop.
  10. Close device by calling Close.

RCS API specification

RCS API specification is available here.

Library workflow

  • When initialized, library tries to load default configuration file placed at ./mtb/mtbcfg.ini.
  • Logging can be enabled/disabled in configuration file.
  • Library automatically saves its configuration into the location of last opened configuration file before exiting.