PC Control of MTH Engines by Radio Connection to the TIU
-
SanDiegoMark
- Posts: 10
- Joined: Tue May 17, 2016 1:09 am
PC Control of MTH Engines by Radio 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. He connected to the TIU using a tether (phone cable).
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:
http://ogrforum.ogaugerr.com/topic/wond ... 9459030161
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 wanted 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 videos (Screen Captures) of the operation of my RTC or Remote Train Control program. These videos demonstrates part of its use:
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. The program and source code are freely available on my web page. It is distributed under the GNU Public Licenses.
Understanding the protocol over the tether is what is most useful. Mike 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. (Something that you could do 60 years ago but can't do today!)
The DCS patent does not talk about the serial protocol. 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.
The original wired tethered connection to the TIU was the next to be replaced. I dug into understanding the radio connection between the Remote and TIU. Again, searches on the Internet provided the frequencies used. A hint on a blog pointed me toward OOK (On-Off Keying) as the mode of data transmission. I guessed that the command protocol over the radio was the same as used on the tether (it was). I learned about two different boards that use the TI CC1101 radio. This radio covers the frequencies required and speaks OOK.
I learned how to program the CC1101 from scratch. I searched the Internet and got little bits of help. I found a program called SmartRF Studio 7 from TI which helps set the values needed for the CC1101 configuration registers. Months of digging through the CC1101 data sheet and test code for the Arduino's Atmega328p MCU finally led me to a working receiver. Then a working transmitter. I called my Arduino program "RTCModem". I could communicate between the PC and the TIU with my Remote Train Control program. (note: this paragraph took about 5 months actual work.)
I wrote RTC 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 better 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 to the TIU 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.
So the program is free from my web page. You can build a tether interface for a few dollars or buy one of two different radio implementations (about $50-$60). Not bought from me, one radio from a company in Spain and one from a company in China. Details on my web page.
Conclusion
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 most of the train control commands and AIU commands. It can handle lashups and conventional operation. It can do routes and scenes. I've started writing the TMCC code but I need to borrow a TMCC system and engine as I don't have any.
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.
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. He connected to the TIU using a tether (phone cable).
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:
http://ogrforum.ogaugerr.com/topic/wond ... 9459030161
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 wanted 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 videos (Screen Captures) of the operation of my RTC or Remote Train Control program. These videos demonstrates part of its use:
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. The program and source code are freely available on my web page. It is distributed under the GNU Public Licenses.
Understanding the protocol over the tether is what is most useful. Mike 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. (Something that you could do 60 years ago but can't do today!)
The DCS patent does not talk about the serial protocol. 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.
The original wired tethered connection to the TIU was the next to be replaced. I dug into understanding the radio connection between the Remote and TIU. Again, searches on the Internet provided the frequencies used. A hint on a blog pointed me toward OOK (On-Off Keying) as the mode of data transmission. I guessed that the command protocol over the radio was the same as used on the tether (it was). I learned about two different boards that use the TI CC1101 radio. This radio covers the frequencies required and speaks OOK.
I learned how to program the CC1101 from scratch. I searched the Internet and got little bits of help. I found a program called SmartRF Studio 7 from TI which helps set the values needed for the CC1101 configuration registers. Months of digging through the CC1101 data sheet and test code for the Arduino's Atmega328p MCU finally led me to a working receiver. Then a working transmitter. I called my Arduino program "RTCModem". I could communicate between the PC and the TIU with my Remote Train Control program. (note: this paragraph took about 5 months actual work.)
I wrote RTC 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 better 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 to the TIU 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.
So the program is free from my web page. You can build a tether interface for a few dollars or buy one of two different radio implementations (about $50-$60). Not bought from me, one radio from a company in Spain and one from a company in China. Details on my web page.
Conclusion
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 most of the train control commands and AIU commands. It can handle lashups and conventional operation. It can do routes and scenes. I've started writing the TMCC code but I need to borrow a TMCC system and engine as I don't have any.
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.
Re: PC Control of MTH Engines by Radio Connection to the TIU
Well Mark, it's a good read but it's all Greek to me, and I'm a DCS user. But it sounds like most couldn't make it work unless they are programmers, and this makes me think that you will be attacked on THIS forum 'cause we have some of the most bitter anti MTH members ever right here. The mere mention of MTH or DCS just sets 'em off.
When ya get it down to just a 4 or 5 Meg download and install, ya might have a chance! But congrats for the achievement of your hard work.
When ya get it down to just a 4 or 5 Meg download and install, ya might have a chance! But congrats for the achievement of your hard work.
If you agree with the Progressives, it's freedom of speech. If you disagree, it's hate speech. There are no alternatives.
-
SanDiegoMark
- Posts: 10
- Joined: Tue May 17, 2016 1:09 am
Re: PC Control of MTH Engines by Radio Connection to the TIU
Thanks. Actually its really simple. You order an assembled panStamp radio from Spain. Plug it into a USB port. Download and install the RTC program and run it. No soldering, no programming, get the radio and run the program.
Re: PC Control of MTH Engines by Radio Connection to the TIU
Mark, very impressive! And doing this by interpreting the packets (which use a public domain protocol) should keep the MTH legal department at bay.
Do you have any plans to expand the commands available or to recruit others to assist in developing a full-fledged interface?
Well done!
George
Do you have any plans to expand the commands available or to recruit others to assist in developing a full-fledged interface?
Well done!
George
What is a 'Conservative'? "Someone who wants society and policy to recognize objective reality- economic, biological, and historical."
—Katy Faust
—Katy Faust
-
SanDiegoMark
- Posts: 10
- Joined: Tue May 17, 2016 1:09 am
Re: PC Control of MTH Engines by Radio Connection to the TIU
I'll take any help anyone cares to give. Everything that I learned is on my web page. All of the commands, their format, the protocol, the source code for my program, RTC. Code for the radios.
RTC, the program, handles about 90% of the TIU commands. You need all of the MTH hardware for this to work.
I'm hoping that someone who knows JAVA and JMRI can program this interface for that system.
RTC, the program, handles about 90% of the TIU commands. You need all of the MTH hardware for this to work.
I'm hoping that someone who knows JAVA and JMRI can program this interface for that system.
Re: PC Control of MTH Engines by Radio Connection to the TIU
Mitch wrote: and this makes me think that you will be attacked on THIS forum 'cause we have some of the most bitter anti MTH members ever right here. The mere mention of MTH or DCS just sets 'em off.![]()
I can certainly appreciate and celebrate Mark's work regardless of how I feel about the quality of product put out by MTH.
And make no mistake, my unhappiness with MTH is directly related to the poor design quality of their electronics, the shoddy manufacturing processes employed, and their callous disregard for customers and other's intellectual property. MTH is good at generating concepts and inventive product ideas. It's the execution that generally sucks.
I do happen to like a number of their freight cars, e.g. PRR N6b cabin cars. When it comes to producing freight cars without electronics, they do have a shot at my business.
I take issue with your characterization of "anti-MTH members". I've been objective in my criticism. Everything MTH has gotten from me has been deserved.
George
What is a 'Conservative'? "Someone who wants society and policy to recognize objective reality- economic, biological, and historical."
—Katy Faust
—Katy Faust
Re: PC Control of MTH Engines by Radio Connection to the TIU
I take issue with your characterization of "anti-MTH members". I've been objective in my criticism. Everything MTH has gotten from me has been deserved.
He means Neil
Re: PC Control of MTH Engines by Radio Connection to the TIU
G3750 wrote:Mitch wrote: and this makes me think that you will be attacked on THIS forum 'cause we have some of the most bitter anti MTH members ever right here. The mere mention of MTH or DCS just sets 'em off.![]()
I take issue with your characterization of "anti-MTH members". I've been objective in my criticism. Everything MTH has gotten from me has been deserved.
George
Wow, George! Have a bit of a guilt complex? I mentioned no person in particular.
If you agree with the Progressives, it's freedom of speech. If you disagree, it's hate speech. There are no alternatives.
Re: PC Control of MTH Engines by Radio Connection to the TIU
A lot of nice detective work there. Good job and good luck.
There have been a couple of attempts to do this in the past and the people doing the "research" received threatening letters from MTH's counsel to basically cease and desist.
I had trouble getting technical information for a LHS owner to help with issues he had doing "repairs" on early PS-2 boards. The problems revolved around the RS-232 interface on his shop computer. I was trying to get the actual specs for the basic serial transmission protocol. I was asked why did he need to know this. When I explained what was happening the response was he should buy a new computer. I could have spend a lot of time running up and down all of the combinations of baud rate, data bits, start/stop bits, and parity to try to figure out what was "wrong". Thankfully one one of the early pioneers that was trying to do what you are doing it turned out the real solution was to get an upgraded PCI serial interface card for about $14.
There have been a couple of attempts to do this in the past and the people doing the "research" received threatening letters from MTH's counsel to basically cease and desist.
I had trouble getting technical information for a LHS owner to help with issues he had doing "repairs" on early PS-2 boards. The problems revolved around the RS-232 interface on his shop computer. I was trying to get the actual specs for the basic serial transmission protocol. I was asked why did he need to know this. When I explained what was happening the response was he should buy a new computer. I could have spend a lot of time running up and down all of the combinations of baud rate, data bits, start/stop bits, and parity to try to figure out what was "wrong". Thankfully one one of the early pioneers that was trying to do what you are doing it turned out the real solution was to get an upgraded PCI serial interface card for about $14.
Once I built a railroad, I made it run,
Made it race against time.
Once I built a railroad, now it's done --
Brother, can you spare a dime?
Made it race against time.
Once I built a railroad, now it's done --
Brother, can you spare a dime?
Re: PC Control of MTH Engines by Radio Connection to the TIU
gregj410 wrote:I take issue with your characterization of "anti-MTH members". I've been objective in my criticism. Everything MTH has gotten from me has been deserved.
He means NeilI love my MTH locos and DCS seems to be functioning fine for now. However, I always have that sinking feeling when I fire up the trains that it will eventually fail. That's not a good feeling. There's never an operating session that I don't get the infamous "engine not on track" message.
I am all too familiar with that sinking feeling. I couldn't live with it and the 50:50 chance of things not working. I got so depressed that I ignored the layout for 2 months during that time.
I hope your DCS keeps working.
George
What is a 'Conservative'? "Someone who wants society and policy to recognize objective reality- economic, biological, and historical."
—Katy Faust
—Katy Faust
- Rufus T. Firefly
- Posts: 42207
- Joined: Wed May 16, 2007 7:52 am
- Location: To be Determined
Re: PC Control of MTH Engines by Radio Connection to the TIU
G3750 wrote: I am all too familiar with that sinking feeling.
Sort of like playing in the band on the Titanic?
The owls may indeed not be what they seem but still serve an imperative function: they remind us to look into the darkness.
-
SanDiegoMark
- Posts: 10
- Joined: Tue May 17, 2016 1:09 am
Re: PC Control of MTH Engines by Radio Connection to the TIU
Well, if you get my program, RTC, you can have more fun with your trains.
RTC has a recording function that records the commands sent to the TIU. You can start up all of your engines, toot the whistles, ring the bells and start them down the track. With your AIU, you can throw switches and activate accessories. Once you record it, you can play it back over and over.
The recorded file is just a plain ASCII text file so you can edit it if you don't like exactly how your recording goes.
Makes a layout demo much easier.
RTC has a recording function that records the commands sent to the TIU. You can start up all of your engines, toot the whistles, ring the bells and start them down the track. With your AIU, you can throw switches and activate accessories. Once you record it, you can play it back over and over.
The recorded file is just a plain ASCII text file so you can edit it if you don't like exactly how your recording goes.
Makes a layout demo much easier.
- Rufus T. Firefly
- Posts: 42207
- Joined: Wed May 16, 2007 7:52 am
- Location: To be Determined
Re: PC Control of MTH Engines by Radio Connection to the TIU
SanDiegoMark wrote:Makes a layout demo much easier.
You may have just guaranteed yourself of getting a little note from MTH,
The owls may indeed not be what they seem but still serve an imperative function: they remind us to look into the darkness.
Re: PC Control of MTH Engines by Radio Connection to the TIU
Rufus T. Firefly wrote:SanDiegoMark wrote:Makes a layout demo much easier.
You may have just guaranteed yourself of getting a little note from MTH,
Lmao!!!
SanDiegoMark wrote:Well, if you get my program, RTC, you can have more fun with your trains.
RTC has a recording function that records the commands sent to the TIU. You can start up all of your engines, toot the whistles, ring the bells and start them down the track. With your AIU, you can throw switches and activate accessories. Once you record it, you can play it back over and over.
The recorded file is just a plain ASCII text file so you can edit it if you don't like exactly how your recording goes.
Makes a layout demo much easier.
I guess everyone enjoys the hobby in they're own way so who am I to say this makes operation more or less pleasurable? Correct me if I'm wrong but I believe much of this can be accomplished through Legacy with less frustration. I personally gave up on following the latest and greatest with legacy and DCS b/c it simply becomes to much to try to remember. I have 3 pages of apps on my iPhone and most of what I use is on the first page and I only use about 70% of them consistently. For me and much of this forums audience I suspect are looking for simplicity in operations. Just b/c an AIU throws the turnout doesn't mean the mechanics of the turnout will be executed. I can throw turnouts with my cab 2 but I'm not satisfied unless I can physically see that turnout has been rerouted accordingly. I run Ross switches and they're pretty consistent but occasionally one will stick or not throw completely. For me, part of the joy of operations is moving a long consist from an inner loop to an outer loop while doing vice versa. Or pulling trains on a siding and bringing new ones out on the mainline from the yard. I would never be comfortable pre programming all of this with out seeing the physical execution of certain operations, but that's just me.
- Rufus T. Firefly
- Posts: 42207
- Joined: Wed May 16, 2007 7:52 am
- Location: To be Determined
Re: PC Control of MTH Engines by Radio Connection to the TIU
gregj410 wrote:Rufus T. Firefly wrote:SanDiegoMark wrote:Makes a layout demo much easier.
You may have just guaranteed yourself of getting a little note from MTH,
Lmao!!!
Ohhhhh!!!!!!!!! And Mark can write a book, too!!!!!!!!!!!
The owls may indeed not be what they seem but still serve an imperative function: they remind us to look into the darkness.
Return to “O-Gauge, 3-Rail, Model Railroading”
Who is online
Users browsing this forum: No registered users and 49 guests
