Skip to main content

March 2015

 

PC Control of MTH Engines by Serial Connection to the TIU

 

To me, MTH makes the best engines and rolling stock for my railroads of choice, the Pittsburgh & Lake Erie Railroad and the Aliquippa & Southern Railroad (where my grandfather worked). MTH has many many engines and dozen of pieces of rolling stock for these railroads. My layout uses only MTH's DCS.

 

DCS has been out for almost 15 years. I've been waiting for a way to control my layout using my PC. I've always used Windows PC's so this effort was done originally using XP and more recently Windows 7 and Windows 10.

 

A few years ago, Mike Hewett presented a PC interface to the tethered mode of operation of DCS. He showed how to sniff out the RS-232 packets running between the Remote and the TIU, how to save those packets and how to later transmit those packets to the TIU from the PC.

 

Mike presented his findings in three videos which he produced around May of 2011. Look at those three videos before you continue with my description.

 

Chapter 1 https://www.youtube.com/watch?v=MxlUb-YccZw

Chapter 2 https://www.youtube.com/watch?v=IBrhLSVHjIo

Chapter 3 https://www.youtube.com/watch?v=oqaeeR3pgPw

 

Look at this OGR Forum thread for a followup:

 

https://ogrforum.ogaugerr.com/t...161#5371679459030161

 

Mike made more progress as shown in this video from 2013

 

https://www.youtube.com/watch?v=Ug5CSZFwo-c

 

I think that I first saw what Mike did around October of 2011 as my earliest date stamps on files that I've saved are from that date.

 

Mike's methodology was to record the packets sent by the Remote when each key on the Remote was pressed. Without regard to the contents of the packets, he saved them in a file. Then, later, his PC program could read up those saved packets and send them to the TIU. He created a very nice touch screen interface and he could run his DCS trains from his PC.

 

I contacted Mike back then and he sent me copies of his program and I was able to build up his interface to the TIU, sniff out the needed packets and I had a way to control my trains from my PC.

 

This worked up to a point. When I added a new engine number, I had to run the packet sniffer again and pick up the packets needed for the new engine number. Mike's program only captured a subset of the many, many types of commands that could be sent to the TIU. Mike did not read back responses from the TIU or process any of those returned packets.

 

I was looking for something more. I needed to understand the protocol over the tether cable.

 

With a lot of effort, I was able to understand almost all of the communications between the Remote and TIU. I am now able to create packets to control the DCS engines. The packets are complete with correct addressing, command syntax and CRC.

 

I figured this out by examination of the packets that I could sniff using Mike's original RS-232 interface design and the port settings that he found. Without Mike's insights into the RS-232 data stream, I don't think that would have been able to get a foothold into this protocol.

 

So again, I figured this out just by looking at the RS-232 stream over the tether cable. No code disassembly, no logic analyzers, no opening up of Remotes or TIU's.

 

 

 

I made up a video (Screen Capture) of the operation of my RTC or Remote Train Control program. This video demonstrates part of its use:

 

 

http://www.silogic.com/trains/RTC_Running.html

 

Mark

 

 

Original Post

Replies sorted oldest to newest

"I'm intrigued by your ideas and wish to subscribe to your newsletter."  

 

Seriously, though very nice work.  I looked into the method of recording the packets  but actually writing them is great.  As I don't own a DCS system or any PS2/3 locos i've been a bit lax in researching this, but I would like to get as much information as you're willing to provide for future use.  I'll have an email on my profile shortly if you'd like to send any info on how to work the data, or the implementation of your program.  

 

Thanks for posting. 

Originally Posted by suzukovich:

This looks good. Now if the program can control the rest of the layout switches/accessories, additional TIU and AIUs, control legacy/TMCC engines at the same time, this could be beneficial for large and somewhat complicated layouts. 

Connecting all the systems, and running everything from one interface is not all that complex, once one knows how each system talks.  TMCC put this information right in the user manual from day one.  Legacy they released about a year ago.  as far as I can tell, Mark here now has all the information needed for control of DCS, so it is surely possible, if he's willing to share.  The problem, from what little information I can find, is that MTH will stomp, hard, on anyone that tries to market a product that talks to their system.

 

Using a $9.99 arduino clone I was able to make a cab1/TMCC issue psudo-dcs commands. Don't own a DCS system, so no real test, but I assumed that Mike, referenced in the original post had done good work, and that the system would read copied packets.  

Mark,

 

This application is very nice, however, be aware that Hikel O Gauge has already done this to an advanced degree.

 

The Hikel system works with both licensed software (Train Controller) and shareware (JDRI), and is operational on a number of layouts, including the Northwest Trunk Lines.

 

I had the Hikel system installed for a while (I decided that I didn't really desire PC control) and can testify that it was very full-featured, including the following:

  • Connected to TIUs, Legacy Command Base and TMCC Command Base. I expect that it would also accommodate a Base 1L
  • Operated DCS, TMCC and Legacy (in TMCC mode) engines, including lashups, with all engine soft keys
  • Operated switch tracks and accessories connected to AIUs
  • Allowed on-screen construction of a layout track plan
  • Allowed automatic block detection of trains
  • Allowed automatic operation for unattended routing of a train from point A to point B
  • The Train Controller version of the system includes abuilt-in web server tho allow train operation, and switch track and accessory operation from a smartphone or tablet, either locally or over the Internet
  • Many other features and functions.

Hikel O gauge has a license from MTH to use the DCS software.

I've used Mike's method to build an Arduino-based system that automatically routes both DCS and TMCC trains.

 

Being able to build the command sequences rather than capture them would be very nice!

 

 

As far as intellectual property goes, no license is required to send commands to the TIU, and reverse-engineering a command protocol is not a violation either of the Copyright Act or the Digital Millennium Copyright Act.

I am replying to this post only because Mark asked me to take a look at his video.

I think he will confirm that I predicted all the responses he has received so far pretty much duplicating the responses I received 3 years ago when I tried to share my project.

Mark has done incredible work and has taken a different approach to the same end i.e. controlling the MTH engine with a PC in lieu of a remote. There is no question that this is not for everybody and it is not Mark's nor was it my desire to make it for every one. Me personally I run up to 8 trains simultaneously on a complex layout and I am much quicker getting timely commands out on a properly designed touch screen then the MTH remote but more importantly to me and many of the folks out there who are using my system, is to control train operations with software and sensors with no remote, when I want to but not necessarily always.

I have continued to give people my solution for free on the internet outside of this forum and have several around the country using it happily. The system has much improved and I have simplified the hardware as I  learned more about computers ,data protocols etc. We have accumulated command data files for nearly every function on  the remote and are controlling multiple TIU's and AIU's. My new friend Tom Niemi who has been using my method for over 3 years, controls both DCS and Conventional engines simultaneously through the TIU connected to a PC with my application.

 

I HAVE NOT RECIEVED ANY THREATING CORRESPONDENCE EVER FROM MTH. As I believe as Professor Chaos that  there are no license or copyright violations.

 

I am interested in Mark's approach to see if there is any improvement in command response time or lost commands when multiple commands are sent close together. So far this has not been a problem with my method. Mark is a lot sharper than I am on this stuff.

Mark's method requires a good working knowledge of  C++/compiler  and binary data communications management and other Display screen software.

Because I am limited in my knowledge of C++ I chose a user friendly Train Brain software, that is C+ based, to execute my engine commands but also control all the other hardware in my layout which includes multiple Train Brain CTI modules, 2 TIU's and an AIU. The Train Brain software contains all the tools to build descent Screen displays and software subroutines that respond either to a time clock/elapse time or various types of sensors.

 

I hope you all will treat Mark with the respect he deserves for sharing  his project with the forum while having no commercial expectations. Even if computers are not your thing it may be for someone else.

 

Professor Chaos I would like to thank you for turning me toward the Arduino ! I have become addicted to programming them and using them all over my layout. I buy the Arduino Nano's and combine them with stepper motors, LED's and all kinds of gadgets that I can construct for my layout combined with my 3D printer. Its been a lot of fun !

My latest completed project is a coal car with a RFID reader, Arduino Nano and a XBEE transmitter contained inside the car that reads RFID credit card type tags under the road beds of the track and transmits its ID and its position to my PC as it moves around the layout. With one of these cars/Dummy Engines behind the lead engine on each of my trains should bring me a step closer to autonomous operations.

 

Mike Hewett

A few things

 

Looks to me everyone is supportive of the cause even though a few have brought up that there were Others doing similar things. 

 

Second, just because you haven't gotten a letter from MTH doesn't mean they are not keeping and eye on the project and if it's offered to others. It has happened in the past to a member of this forum. I imagine as long as it's a personal project they'll leave you alone. 

 

Personally I think it looks pretty dang cool. While certainly not for everyone as you pointed out. 

General guidelines about copyright are you can pretty much do whatever you want for your own use. It's when you try to market it that you get in trouble. You can (and several have) retrieve all the DCS codes and do some programming yourself. You could  even publish a paper with the codes and discuss how they are used.  But when you try to sell "Bob's Train House DCS Controller" you are probably going to have an issue.

 

So far the only person known to have legal rights to market a DCS third party product is Hikel O Gauge, however even the status of that project is unknown at this time.

 

Last edited by cbojanower

I'd like to thank everyone for taking the time to comment on my posting. I've waited to follow up so I could add my thoughts to the comments.

First, I've posted a few more videos on my web page:

http://www.silogic.com/trains/RTC_Running.html

My purpose in what I did was to develop a new way to run my trains.  I'm not competing with anyone else, especially MTH since they don't have a product for PC control that they sell or give away. I'm not selling anything that I've done. Once I determine that it is working fairly well, I am going to send the program to whoever can use it. It will probably be distributed under one of the GNU Public Licenses.

Understanding the protocol over the tether is what is most useful. Mike (skylar) wrote about wanting to build a system with sensors that adds location information to the mix. I can envision something like the operation of the Lionel 132 Automatic Stop Station that you could automate with location sensors and PC control.

The DCS patent does not talk about the protocol over the tether. I've learned from my analysis that the protocol is an industry standard RLL(0,1) which is just a fancy way of saying how often the RS-232 signal changes from 1 to 0. Part of the encoding is actually patented and not by MTH - #5,625,644 issued in 1997. The next part uses Morton or Z-Curve encodings. You can Google that. Third are the commands themselves. They are in ASCII and are based on an Application Note published by Microchip Technology in 2002, look for AN759. These public documents describe the protocol completely, it was just adapted to model train control. All of these documents were found on the Internet.

PC control has one (at least) major drawback and that is the need for a wired connection to the TIU. My program only handles one RS-232 port but there is no reason that a program could not be written that uses 5 RS-232 ports, each connected to the 5 TIU possible. In other words, once the protocol is known, practically anything can be done by writing software. I haven't yet completed my analysis of the protocol. My program knows all of the train control commands and AIU commands. I know how to do lashups but I haven't added that to the program. I've not yet looked at a TMCC interface or conventional operation.

Writing a program that encompasses every aspect of train operation is not something one person can do alone. Maybe because of that, PC control will never be practicable. It is not possible for me to singlehandedly write a program that will satisfy everyone. But I can probably do enough to let enterprising and interested hobbyists have the ability to operate their trains in a different way.

My program, RTC, is nothing special. I wrote it using Borland C++ Builder because that is the software that I used years ago when I was still working. There are probably other better environments which would handle the real-time control aspects (like asynchronous RS-232 characters arriving). C++ Builder is not really good at that. When I started writing the program, I had no idea what the protocol over the tether was. I had to write my program to handle many different protocols, of which all except one turned out to be deadends. For example, I used CRC code that could handle dozens of CRC algorithms. But only one was needed once I understood which one. All of that extra code is still in the program. The CRC code, by the way, was written by Ross Williams, who placed it in the public domain in 1993.

Mark

Mark,

 

Thank you for sharing!  You have something very cool there!  

 

Mike has done some great things in the past for a customer of mine who is unable to run trains with a remote due to physical limitations so there is definitely a need for this.

 

Sorry about all of the internet lawyers posting here.

 

Great job!

 

Dave

 

Excellent job, obviously the result of considerable effort.

 

David:  The so-called "internet lawyers" should not be criticized.  They are understandably protective of a fellow forumite.  I read his posts as indicating he is fully aware of restrictions.

 

I have seen much mention on the forum on Arduino.  Is there any good and understandable basic material, an Arduino 101 if you will, to explain basic concepts.

Add Reply

Post
The DCS Forum is sponsored by

OGR Publishing, Inc., 1310 Eastside Centre Ct, Suite 6, Mountain Home, AR 72653
800-980-OGRR (6477)
www.ogaugerr.com

×
×
×
×
Link copied to your clipboard.
×
×