Arduino Forum

Community => Exhibition / Gallery => Topic started by: Steve_Massikker on Nov 12, 2018, 03:45 am

Title: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 12, 2018, 03:45 am

Hello friends! I developed a very simple and cozy model trains control system using an Arduino and Android applications. All instructions on my site: www.arduinorailwaycontrol.com (http://arduinorailwaycontrol.com/). I really need your feedback. Here I will answer all your questions. Discussions are welcome!
Title: Re: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 12, 2018, 07:17 am
Probably you will be interested my tutorials on Arduino.PROJECT.HUB:

- Android App Arduino Train Demo  (https://create.arduino.cc/projecthub/Steve_Massikker/arduino-train-demo-67d8a0)
- The URB Unit - Making Arduinos Network  (https://create.arduino.cc/projecthub/Steve_Massikker/the-urb-unit-making-arduinos-network-96251c)
- Using IR & Hall Type Sensors for Train Detection (https://create.arduino.cc/projecthub/Steve_Massikker/using-ir-hall-type-sensors-for-train-detection-210f53)

How order (https://www.seeedstudio.io/-g-1181788) or making (http://arduinorailwaycontrol.com/android.php#urb-unit) the URB unit
Title: Re: Arduino controlled model trains and layout
Post by: Robin2 on Nov 12, 2018, 07:35 pm
Image from Original Post so we don't have to download it. See this  Simple Image Guide (http://forum.arduino.cc/index.php?topic=519037)

(https://forum.arduino.cc/index.php?action=dlattach;topic=578952.0;attach=281579)

...R
Title: Re: Arduino controlled model trains and layout
Post by: Robin2 on Nov 12, 2018, 07:39 pm
It looks interesting but how does it work?

Are the trains controlled through the track using DCC or does each loco have its own Bluetooth receiver?

If the locos have Bluetooth receivers how are they powered? Through the track, or with batteries?

If you have a Bluetooth receiver in each loco can you post a photo of the module in the loco?

And how many different locos can the system control?

...R
Title: Re: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 12, 2018, 11:20 pm
Good question :)
It's work only DC mode (http://arduinorailwaycontrol.com/index.php#faq)
You may use many trains on isolated tracks, so have running an automatic interlocking system (https://www.youtube.com/watch?v=1TdhZOc&t=12s) are possible and simultaneous control of two players (https://www.youtube.com/watch?v=DVYXjd0U42M).
Title: Re: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 12, 2018, 11:34 pm
Robin2, Thanks so much for the guide. Really cool features!
Title: Re: Arduino controlled model trains and layout
Post by: Parodius316 on Nov 12, 2018, 11:38 pm
Good question :)
It's work only DC mode (http://arduinorailwaycontrol.com/index.php#faq)
Noooooooooooooooooooooooooo!
Title: Re: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 12, 2018, 11:56 pm
Yeeeeeeessssss! Owners of DCC systems have many reasons use other Arduino projects. My opinion about DCC here (http://arduinorailwaycontrol.com/v3/gauges.php#ddc1).
And the question to Parodius316, can you do this (https://www.youtube.com/watch?v=IjrQfjLpa-s) or that (https://www.youtube.com/watch?v=1TdhZOc&t=17s) in your DCC system?

And my system works with any scales of model trains (HO, TT, N) and greatly cheaper (http://arduinorailwaycontrol.com/railworks.php#where-to-buy) compared by DCC. :smiley-wink:
Title: Re: Arduino controlled model trains and layout
Post by: Robin2 on Nov 13, 2018, 10:00 pm
I have no problem with a DC system - some competition for DCC is a good thing.

But you have not given us a simple overview of how it works - and your website seems mainly about clever pictures.

...R
Title: Re: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 14, 2018, 03:17 am
The Android application on the phone via Bluetooth or computer via serial connection (USB cable) transmits simple string commands to the communicate Arduino (Communicate URB unit). The sketch converts them into a change in the state of I/O pins or sends them to other Arduino via I2C or via a more complex chain (that is, a routing occurs, which you set yourself). Thus you can build any flexible distributed control system. Response data transfer from any URB units to Android or a computer allows you to apply feedback.

In general, this is a rather complicated system, and I just cannot describe it simple. :smiley-confuse:

And thanks again for Image Guide. Funny trick!
Title: Re: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 14, 2018, 03:31 am
Variants connections between URB
(https://forum.arduino.cc/index.php?action=dlattach;topic=578952.0;attach=281820)
Title: Re: Arduino controlled model trains and layout
Post by: Robin2 on Nov 14, 2018, 09:26 am
In general, this is a rather complicated system, and I just cannot describe it simple. :smiley-confuse:
I can understand that there may be some levels of complexity but at the bottom of the pile a loco has a DC motor which is simple to control - how is that done.

Another way of looking at it is if I want to drive a single train what Arduino bits do I need to buy?


...R

PS ... In my working experience, the "real" experts I dealt with (physics, engineering, economics) had no trouble explaining themselves in simple language for "ordinary folk".

Title: Re: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 14, 2018, 09:31 am
Hmm...http://arduinorailwaycontrol.com/arduino.php#motor-driver (http://arduinorailwaycontrol.com/arduino.php#motor-driver)

All sketches on my project are specially written based on the simpliest classic sketches from Arduino IDE (for example SerialEvent).
Sorry, I do not understand your opinion about "experts" and "not for ordinary folks" :(
Title: Re: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 14, 2018, 10:02 am
Another way of looking at it is if I want to drive a single train what Arduino bits do I need to buy?


...R

PS ... In my working experience, the "real" experts I dealt with (physics, engineering, economics) had no trouble explaining themselves in simple language for "ordinary folk".


Video (https://www.youtube.com/watch?v=SskcDnVkEks) and link (http://arduinorailwaycontrol.com/arduino.php#simple-start) to sketch for an one train.
Title: Re: Arduino controlled model trains and layout
Post by: Robin2 on Nov 14, 2018, 11:06 am
Video (https://www.youtube.com/watch?v=SskcDnVkEks) and link (http://arduinorailwaycontrol.com/arduino.php#simple-start) to sketch for an one train.
I have looked at the link.

It seems to be very traditional DC control of power to the track using a motor driver. I presume that means that the user who wishes to run several locomotives has to implement some form of what model-railway-folks call cab-control.

Does your system manage that? The wiring and switching can be very complex - which is why DCC is attractive.

You might also consider a more modern and more efficient motor driver than an L298. I am using Infineon TLE5206 drivers for a system I am building for a group in my model railway club. Those chips have overload and short-circuit protection and fault indication.


...R
Title: Re: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 14, 2018, 12:05 pm
You're right!
You can use any motor-driver, you only need to change the sketch. I just find it more convenient to use a ready-made module, especially since the L298 has two channels, since my system was designed to control many players simultaneously.
As for the DCC control, then on a system is impossible making even such a simple function as automatic stopping a train before a red signal. Or I'm wrong?
Title: Re: Arduino controlled model trains and layout
Post by: Robin2 on Nov 14, 2018, 02:09 pm
You're right!
You can use any motor-driver, you only need to change the sketch. I just find it more convenient to use a ready-made module, especially since the L298 has two channels, since my system was designed to control many players simultaneously.
You did not answer my question about how your system can control several trains. Or, is your plan that each train is on a completely separate track with no capability to cross from one to the other?

 
Quote
As for the DCC control, then on a system is impossible making even such a simple function as automatic stopping a train before a red signal. Or I'm wrong?
I am not advocating DCC but, yes, you can control trains in great detail with DCC and suitable train detection equipment. Stopping a train before a red signal requires the system (any system - DC, DCC or wireless) to know that the train is approaching the signal.

...R
Title: Re: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 14, 2018, 02:46 pm
Just as in the DC, it is not trains that are controlled, but isolated sections of rails. Together with Arduino it gives advantages (http://arduinorailwaycontrol.com/arduino.php#signal-system).
Moving (https://www.youtube.com/watch?v=DVYXjd0U42M&t=16s) several trains. How it (http://arduinorailwaycontrol.com/arduino.php#update-your-first-sketch) work.

(https://forum.arduino.cc/index.php?action=dlattach;topic=578952.0;attach=281858)

You did not answer my question about how DCC stopping concrete train before red signal. DCC is one-way data send system. How does the DCC-decoder on a train determine that in front of it is the red signal?
I saw that it works the same way as in the DC, it just disable the voltage from the insulated rails in front of the signal.
In the classic DC, and my system as well, you can add several motor-drivers to these rails to make a smooth stopping  and starting  move trains near the signal or Interlocking (https://www.youtube.com/watch?v=1TdhZOc) system.  Or I make an AWS system (https://www.youtube.com/watch?v=IjrQfjLpa-s), on DCC it's impossible.
Title: Re: Arduino controlled model trains and layout
Post by: Robin2 on Nov 14, 2018, 04:56 pm
You did not answer my question about how DCC stopping concrete train before red signal. DCC is one-way data send system. How does the DCC-decoder on a train determine that in front of it is the red signal?
The train does not know there is a red signal with DCC or (as far as I can see) with your system. It is the computer control system that knows when a train  must stop and sends the appropriate instructions to the DCC decoder in the loco telling it to slow down and stop.

Maybe you are creating a dead section of track before the red signal so the loco comes to an abrupt stop when it runs out of power?

...R

Title: Re: Arduino controlled model trains and layout
Post by: sterretje on Nov 14, 2018, 05:05 pm
I broke down my last layout years ago and have not gotten back into model railway. I never used DCC but to my knowledge DCC does not cut power to the track; it definitely does not need to. Simply sending new speed info to the loco will do.

You however need a quite complicated control system that knows which signal has which state and which loco is where.

If I ever build again, I will build using my existing non-DCC locos; but digitally controlled.
Title: Re: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 14, 2018, 06:12 pm
The train does not know there is a red signal with DCC or (as far as I can see) with your system. It is the computer control system that knows when a train  must stop and sends the appropriate instructions to the DCC decoder in the loco telling it to slow down and stop.
It does not work like this :) In order for a computer to know the position of a particular train on a layout, it must receive the coordinates of this train via feedback. In the DCC, it is impossible in principle to organize such a function. Moreover, to determine this position, the decoder on train must constantly read the tags from the track. Therefore, I asked my question.
Title: Re: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 14, 2018, 06:20 pm
You however need a quite complicated control system that knows which signal has which state and which loco is where.

If I ever build again, I will build using my existing non-DCC locos; but digitally controlled.
I agree! I have another Wi-Fi project, but I do not have enough time to develop it. It implements the functions of coordinates, the possibilities are simply fantastic, as in railway computer simulators. The prototype works, but it is too difficult to do alone, and the installation of such a system in the locomotive requires high qualification. You will probably be interested to look at a few photos of the prototype.

(https://forum.arduino.cc/index.php?action=dlattach;topic=578952.0;attach=281868)

(https://forum.arduino.cc/index.php?action=dlattach;topic=578952.0;attach=281872)

(https://forum.arduino.cc/index.php?action=dlattach;topic=578952.0;attach=281874)

On the other hand, the DC control system does not control the train, but rail sections - therefore, it does not have such a problem as in DCC. For example, if a train crosses a sensor, then DC (Arduino) simply smoothly changes the voltage on this track, providing a smooth stop for the train. It is easier to implement and program.
Title: Re: Arduino controlled model trains and layout
Post by: Robin2 on Nov 14, 2018, 06:25 pm
It does not work like this :) In order for a computer to know the position of a particular train on a layoutl,
How does your system know the position of a particular train?

For a layout I am building for myself I plan to put LDRs between the sleepers wherever I need to detect a train.

...R
Title: Re: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 14, 2018, 06:32 pm
What is a LDR?
Title: Re: Arduino controlled model trains and layout
Post by: sterretje on Nov 14, 2018, 07:15 pm
Light Dependent Resistor.

@Robin, have you considered sensing of current to know if a train is in a section?

I know that the L298 is outdated but it provides a current sensing pin. Are there any mosfet based h-bridges that provide that?

Sorry for de-railing ( ;) ) the thread.

Title: Re: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 14, 2018, 07:31 pm
Same solution as LDR - IR sensor between sleepers, I tested it (see end of video (https://www.youtube.com/watch?v=Zixbz4O1xgM)). Unfortunately it works badly. It is necessary to put the foil stripe to the bottom of the cars for correct triggering. Moreover, you need using a complex code for proper determine the signal.  Hall sensors (http://arduinorailwaycontrol.com/arduino.php#aws-and-sensors) are the best solution in my opinion.


Instead L298 you may use VNH2SP30 Motor-Driver or others MOSFET chips
Title: Re: Arduino controlled model trains and layout
Post by: Robin2 on Nov 14, 2018, 08:00 pm
Light Dependent Resistor.

@Robin, have you considered sensing of current to know if a train is in a section?

There won't be any current to sense. The trains are battery powered and radio controlled using nRF24L01+ modules.

In all my tests the LDRs have worked faultlessly and they are very simple to implement. The Arduino just detects an ON or OFF on a digital pin.

...R
Title: Re: Arduino controlled model trains and layout
Post by: Budvar10 on Nov 14, 2018, 08:27 pm
Amazing!
You reminded me my childhood. I had model train in TT size. Just 3 wagons and steam locomotive with moving rods but there were not such possibilities as now.
Title: Re: Arduino controlled model trains and layout
Post by: sterretje on Nov 15, 2018, 03:19 am
Finally had some time to visit your site and ... amazing project.

You must have put a lot of time in (the design and implementation of) this project; 6 years from idea to what you have now if I read it correctly?

The main thing that I definitely would have done differently is the use of the I2C bus; it's not designed for long distances. and hence your setup requires all URBs to be close to each other which will still result in long wires under a layout. I've always visualised my design with RS232/RS422/RS485 which would be better in my view so modules can be closer to the area where they are needed and reducing the wire mess under a layout. It will also be easier for modular layouts.
Title: Re: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 15, 2018, 05:02 am
The main thing that I definitely would have done differently is the use of the I2C bus; it's not designed for long distances. and hence your setup requires all URBs to be close to each other which will still result in long wires under a layout. I've always visualised my design with RS232/RS422/RS485 which would be better in my view so modules can be closer to the area where they are needed and reducing the wire mess under a layout. It will also be easier for modular layouts.
You are absolutely right. I2C bus has a problem with long cables and use RS282 and RS485 is the best solution.
My project has no restrictions on the use of any types of buses, I like CANbus more. The whole idea is to you make design your own control system, as similiar design from LEGO cubes.

But I2C is the only way to make routing between several microcontrollers, simple and very affordable (http://arduinorailwaycontrol.com/arduino.php#introduction-to-I2C-bus) way in Arduino. That's why I chose this solution. Any person who has more than one Arduino board can wield I2C bus without other devices.
Also, It seems to me also a very important a simply applyed software application of I2C bus. For I2C there is a classic library of the Wire (https://www.arduino.cc/en/Reference/Wire), and its use in a sketch is very simple, you just need to specify the address and send one byte of data to it. On my project, send the one byte is more than enough.

You can send commands via the I2C bus to any of the end peripherals connected to any URB on the layout. According to the specification, the maximum length I2C bus when using a twisted pair of about eight meters. In practice, with a total cable length of three meters, everything works correctly.
If you need a large length of wires, you can use a repeater consisting of two URBs, creating a connection I2C-Serial-I2C (see previous posts). Or apply RS485 or similar buses.
Title: Re: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 15, 2018, 05:39 am
Finally had some time to visit your site and ... amazing project.
(https://forum.arduino.cc/index.php?action=dlattach;topic=578952.0;attach=281903)
Title: Re: Arduino controlled model trains and layout
Post by: Robin2 on Nov 15, 2018, 10:06 am
@Steve_Massikker, you seem to have missed my question in Reply #22 "How does your system know the position of a particular train?"

...R
Title: Re: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 15, 2018, 03:26 pm
My system working at DC mode. So, not need detect the position of a particular train.
Title: Re: Arduino controlled model trains and layout
Post by: Robin2 on Nov 15, 2018, 05:53 pm
My system working at DC mode. So, not need detect the position of a particular train.
I understand DC train control but I don't understand how you can control the trains without knowing where they are?

How can your system slow a train when it approaches a red light if it does not know that the train is approaching a red light?

...R
Title: Re: Arduino controlled model trains and layout
Post by: sterretje on Nov 15, 2018, 07:22 pm
Post #25 mentions hall sensors.
Title: Re: Arduino controlled model trains and layout
Post by: Robin2 on Nov 15, 2018, 08:11 pm
Post #25 mentions hall sensors.
And Reply #32 implies that there is no train detection ? ? ?


It's all going to be very confusing for someone who is familiar with DC control of model trains but is not familiar with (and maybe not interested in) Arduinos.


...R
Title: Re: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 16, 2018, 04:46 am
Robin, you have a little de-railing  (http://arduinorailwaycontrol.com/fdfs):) :) :)

I repeat, the DC system control running via change the voltage on the rail - so there is no need to determine the position of the train. It is the train always that runs exactly on this section of the rails.

In the DCC, the train is controlled by a decoder inside the locomotive, and the commands for changing movement come from an external digital console at the address of this decoder. In this case, the rails are used as a one-way data bus from the console to the decoder of a specific locomotive. In this case, the voltage on the rails is not changeble.

You can stop a particular train in front of a traffic light by removing the voltage from the section of rails in front of it, as on classic DC. But the question arises, why then do you need a DCC system?

See WIKI (https://en.wikipedia.org/wiki/Digital_model_railway_control_systems#Feedback), even there is no mention of the control of the engine locomotive - only about sensors and relays.
Title: Re: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 16, 2018, 05:59 am
Hall sensors
(https://forum.arduino.cc/index.php?action=dlattach;topic=578952.0;attach=282001)
(https://forum.arduino.cc/index.php?action=dlattach;topic=578952.0;attach=282003)
Title: Re: Arduino controlled model trains and layout
Post by: Robin2 on Nov 16, 2018, 10:37 am
You can stop a particular train in front of a traffic light by removing the voltage from the section of rails in front of it, as on classic DC.
I did ask in Reply #18 if that is what you do.

It seems to me a very abrupt way to exercise control. All the passengers' coffees will be spilled.

And it's not how the real railway works :)

...R
Title: Re: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 16, 2018, 12:29 pm
It seems to me a very abrupt way to exercise control. All the passengers' coffees will be spilled.
And it's not how the real railway works :)
...R
I don't even know what to say. :) :) :)

All right thank you very much, anyway. It was an interesting discussion.
Title: Re: Arduino controlled model trains and layout
Post by: Robin2 on Nov 16, 2018, 04:42 pm
All right thank you very much, anyway. It was an interesting discussion.
I'm guessing from your comment that you may not have got the sort of response you were expecting. I know you have put a great deal of time and effort into your project and into the website that presents it.

It is often a good idea to get feedback during the course of the development of a project - especially from the people who will be your "customers". In this case I expect that the customers will be people who would like some "tech" control of their model trains without the expense of using DCC.

My guess is that the regular users of this Forum are less likely to be customers for your product simply because they have the skills to develop their own system - keep that in mind when reading the comments.

Have you tried presenting your system on any of the model railway forums such as RMWeb?


I'm not sure if it is my age but I like to get a quick technical overview of something to let me know if it is worth while reading through a lengthy website. I think the essence of your system could be presented in 8 or 10 lines of text - the "skinny" or the "executive summary".

...R
Title: Re: Arduino controlled model trains and layout
Post by: Steve_Massikker on Nov 16, 2018, 05:03 pm
That's what it looked like. Thanks again!
Title: Re: Arduino controlled model trains and layout
Post by: MrKeiman on Jan 18, 2019, 12:40 pm
I have only recently found your project and I am excited about it. I have been around computers and electronics as a profession and as a hobby for over 40 years, but had been drifting away from them until recently. I started to get back into Model railways and have been looking into control system. I started working with Arduino and could see the potential but my programming knowledge is well out of date so I was struggling. then I stumbled across your project and realised that you have done exactly what I had in mind.
I have purchased the URB circuit boards from Seed and am waiting for the other components so that I can build them. Once I have had some time to customise them I will look back at your new designs and see what extras they have for my purpose. I wll be giving an appropriate donation when I have some spare money. keep up the great work.