Go Down

Topic: Arduino controlled model trains and layout (Read 5605 times) previous topic - next topic

#15
Nov 14, 2018, 12:05 pm Last Edit: Nov 14, 2018, 12:08 pm by Steve_Massikker
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?

Robin2

#16
Nov 14, 2018, 02:09 pm Last Edit: Nov 14, 2018, 02:09 pm by Robin2
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
Two or three hours spent thinking and reading documentation solves most programming problems.

#17
Nov 14, 2018, 02:46 pm Last Edit: Nov 14, 2018, 04:49 pm by Steve_Massikker
Just as in the DC, it is not trains that are controlled, but isolated sections of rails. Together with Arduino it gives advantages.
Moving several trains. How it work.



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 system.  Or I make an AWS system, on DCC it's impossible.

Robin2

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

Two or three hours spent thinking and reading documentation solves most programming problems.

sterretje

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.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

#20
Nov 14, 2018, 06:12 pm Last Edit: Nov 17, 2018, 03:10 pm by Steve_Massikker
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.

#21
Nov 14, 2018, 06:20 pm Last Edit: Nov 14, 2018, 06:43 pm by Steve_Massikker
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.

Robin2

#22
Nov 14, 2018, 06:25 pm Last Edit: Nov 14, 2018, 06:29 pm by Robin2
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
Two or three hours spent thinking and reading documentation solves most programming problems.


sterretje

#24
Nov 14, 2018, 07:15 pm Last Edit: Nov 14, 2018, 07:16 pm by sterretje
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.

If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

#25
Nov 14, 2018, 07:31 pm Last Edit: Nov 14, 2018, 07:48 pm by Steve_Massikker
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

Robin2

#26
Nov 14, 2018, 08:00 pm Last Edit: Nov 14, 2018, 08:05 pm by Robin2
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
Two or three hours spent thinking and reading documentation solves most programming problems.

Budvar10

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.
Arduino clone with ATmega1284P   http://forum.arduino.cc/index.php?topic=277260.0

sterretje

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.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

#29
Nov 15, 2018, 05:02 am Last Edit: Nov 15, 2018, 05:21 am by Steve_Massikker
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.

Go Up