Arduino controlled model trains and layout

sterretje:
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.

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.

Steve_Massikker:
It does not work like this :slight_smile: 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

What is a LDR?

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 ( :wink: ) the thread.

Same solution as LDR - IR sensor between sleepers, I tested it (see end of video). 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 are the best solution in my opinion.

Instead L298 you may use VNH2SP30 Motor-Driver or others MOSFET chips

sterretje:
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

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.

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.

sterretje:
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 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, 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.

sterretje:
Finally had some time to visit your site and ... amazing project.

Good.png

Good.png

@Steve_Massikker, you seem to have missed my question in Reply #22 "How does your system know the position of a particular train?"

...R

My system working at DC mode. So, not need detect the position of a particular train.

Steve_Massikker:
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

Post #25 mentions hall sensors.

sterretje:
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

Robin, you have a little de-railing :slight_smile: :slight_smile: :slight_smile:

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, even there is no mention of the control of the engine locomotive - only about sensors and relays.

Hall sensors


Steve_Massikker:
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 :slight_smile:

...R

Robin2:
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 :slight_smile:
...R

I don't even know what to say. :slight_smile: :slight_smile: :slight_smile:

All right thank you very much, anyway. It was an interesting discussion.

Steve_Massikker:
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