Programmable Logic Controller Model Train Project
This long term project is to use a programmable logic controller (PLC) to control a model railroad layout. The parts obtained for this project was from former industrial equipment that was being scrapped and I was able to obtain parts from the machines. The project is not practical by normal means as computer and other controls already exist for model trains. The purpose for this project is to learn how to do programming on the PLC. The model railroad layout provides a "real world" example of controls compared to using a training kit which has buttons and switches for input, and simple LED lights for outputs. The electrical design for the project is based around the components obtained from the scrapped machines which is the only practical means to build this project without a high cost for the parts. Eventually the project will be used to control my layout that is around the wall of my room. This will include a HMI panel for control and input.
First Generation Project (Micrologix 1000 PLC)
The first generation of this project was developed with a Micrologix 1000 PLC. This PLC was chosen because at the time units were available second hand and inexpensive. The software to program it is available for free so the initial cost to develop it was kept low. The first generation build involved designing the controls utilizing the components that were obtained from the scrapped machines. I soon ran into limitations with using this PLC unit. One was the I/O is limited and cannot be expanded so several assumptions had to be made with the hardware development. One example is with the remote switches on the layout. The PLC can control the switches, but had no way to verify that the switch did change or did not jam due to lack of inputs. In addition, the memory size of this PLC is limited and by the time I developed the first interchange program, the memory was almost 75% filled. This meant that developing other train operations would be limited. Below is the page with the first generation development of the project which shows how the interface to the layout was developed.
Second Generation Project (Micrologix 1400 PLC)
With the above mentioned limitations of the PLC and that now the Micrologix 1000 series of PLC's are now discontinued, I decided to upgrade the PLC. I wanted to stay with an industry standard PLC so I chose to purchase a Micrologix 1400 PLC which not only has more memory for programs, but allows for expansion modules for I/O. This required a complete rebuild of the project from almost scratch to accommodate the new PLC but it also allows for an improved design. This PLC has analog input and output so it will now (hopefully) be possible to control and read the throttle from the Lionel transformer. In addition since this unit allows expanding the I/O with modules, it is now possible, for example, to read the remote switch positions to verify that the switch did not jam.
I also changed the layout to have more occupancy block detection on the layout since there is more available inputs with this unit. I also changed the spur track into a team track by adding a fourth remote switch. I also broke up the mainline track power into sections instead of having only one mainline track power control. Construction of this second generation layout can be seen on this page.
During development of the programs in the first generation project I ran into some issues with the way I was writing the programs. The last working program I wrote was the main and side interchange program. Due to some bad programming practices the next routine I was writing would not work. After consulting with others, I got some good information on better programming practices. The best course of action was a complete re-write of the programs, not only to utilize better programming practices, but to accommodate for the newer PLC and the additional I/O it provides. I decided to build the support routines which will be utilized in the train operations. The link below are illustrations of the second generation controls and the new routines that will be utilized in the train operations.
Second Generation Controls and program routines
Tour of the Second Generation Project Video
CW80 Control Program
The next routine written is controlling the CW80's Direction / Whistle / Bell button. I moved the ladders for the train operations down to make room for additional support routines. The CW80 HMI Screen was written to allow control of the buttons and to allow disabling them if I want to run the trains without the bell or whistle enabled.
First Routine Development
During development of the first routine which is going to run the train on the mainline a few issues came up with the testing of the program. This also shows that the diagnostic screens come in handy when troubleshooting problems with the layout.