cptr05

help me automate my trains

Recommended Posts

so I want to automate train. I just don't really know where to start. because I think I have 3 choices

1. 9v trains

2. power functions

3. powered up

so the 9v system is really easy you just need a train a micro controller and a motor controller. but it is getting really expensive.

I do have a lot of power function trains but automating them with IR leds way to seems hard and they are retired now.

and powered up uses Bluetooth which you can use with an Arduino. like power functions uses batteries, i don't like that but unlike both this is new.

so the easiest choice to me seems 9v but i only have one 9v train and 4 power function trains and way more RC track to.

but if i go with battery power how do I know where a  given train is. with 9v this isn't an issue because the track can be on or off.

so is there a way to detect battery trains if you have multiple on the same loop?

or would it be easier to go the 9v route and have to use decade old hardware.

or is there something new with the powered up system that allows me to do things that i wasn't able to do with 9v and or power functions

 

Share this post


Link to post
Share on other sites

Finding the position of the trains is a real challenge especially if you want a system that will work with all the different Lego train types.

One system may be that you have trackside sensors that detect when a train goes by, identifies the train and the direction then that information must go to your control centre.  At least with trackside sensors you can use wires back to train control and there is potential for train control to signal back to control track switches (points).   I am thinking that the sensor would need something like a Arduino and the train would need some marking that could be read by the sensor, a bar code underneath perhaps?

 

Share this post


Link to post
Share on other sites

You always have to discover the actual position of the train.
With 9V you can use the rails (but have to isolate them).

With Powered Up you can sensors, in the train or beneath the track.
With 9V you can (with motor controllers) control the trains via the voltage on the tracks, with Powered Up this is done via Hub in the trains.

The difference with Powered up: you can sent feedback to you microcontroller (I used Mindstorm EV3 for 12V, ESP for BT)
or you don't even need one.

How many trains, on which layout, and how man trains running simultaniously?

Share this post


Link to post
Share on other sites

One simple method is to always start the trains off at their designated known locations. Then the keep track of the sensor inputs.


The fun way to automate is invite a bunch of friends over to run the trains and designate one the dispatcher. 

Share this post


Link to post
Share on other sites

another idea is to use my magnetic train detector. works with all systems because the sensor is seperate of the physical properties of the track (if it conducts electricity or not)

other idea is to use an ldr mounted inbetween the tracks or an actual reed sensor or even hall effect sensor.

hope this helps you.

Edited by XG BC

Share this post


Link to post
Share on other sites
31 minutes ago, XG BC said:

other idea is to use an ldr mounted inbetween the tracks or an actual reed sensor or even hall effect sensor.

Yes, that's how my automatic layout worked, reed sensors. But all of them (6? or 7?) on one input.

And then count in the program.

1. contact : close barrier

2. contact : signal red

3. contact: open barrier

and so on....

https://youtu.be/N-xREk0E2J8

But that works brillant with a color sensor in every train and Powered up, too.

Use ESP and legoino

 

 

Share this post


Link to post
Share on other sites

If you want to be LEGO pure, then I think Powered UP is the most flexible and adaptable.

 


PU colour sensors work too good for keeping trains apart.

 


You can use LEGO servo motors to turn the knob on the 9V train controller or Power Function speed controler.  Most of Powered UP motors have position sensing.

42670724285_fa2ce96f75_z.jpgEV3 Playing Centipede by dr_spock_888, on Flickr

Not Powered UP but similar idea.

 

Share this post


Link to post
Share on other sites
2 minutes ago, dr_spock said:

PU colour sensors work too good for keeping trains apart.

But , dependig on the color of the undegroud of the tracks.

Best colors are res, yellow and white

4 minutes ago, dr_spock said:

You can use LEGO servo motors to turn the knob on the 9V train controller or Power Function speed controler. 

Or the 12V-System:

 

Share this post


Link to post
Share on other sites
13 hours ago, John Hill said:

Finding the position of the trains is a real challenge especially if you want a system that will work with all the different Lego train types.

One system may be that you have trackside sensors that detect when a train goes by, identifies the train and the direction then that information must go to your control centre.  At least with trackside sensors you can use wires back to train control and there is potential for train control to signal back to control track switches (points).   I am thinking that the sensor would need something like a Arduino and the train would need some marking that could be read by the sensor, a bar code underneath perhaps? 

  

The issue I have isn't detecting the if there is a train but more what train it would be if i use battery power because you can isolate tracks on the 9v system and control those individually.  and I am planning on using a raspberry pico W or some Arduino if I every need that for some reason. a bar code or something like that under the tracks is a cool idea but getting a lens that can see and focus at those distances (under the track) would be very hard. if i were to do that I would go the vision route with a rasperry pi and cameras but that is WAAAAY outside my comfort zone.

10 hours ago, Lok24 said:

You always have to discover the actual position of the train.
With 9V you can use the rails (but have to isolate them).

With Powered Up you can sensors, in the train or beneath the track.
With 9V you can (with motor controllers) control the trains via the voltage on the tracks, with Powered Up this is done via Hub in the trains.

The difference with Powered up: you can sent feedback to you microcontroller (I used Mindstorm EV3 for 12V, ESP for BT)
or you don't even need one. 

How many trains, on which layout, and how man trains running simultaniously?

So adding a sensor to the train wouldn't be ideal because i would have to mod them and it wouldn't look as nice or maybe a sensor that faces down that looks for color in the track? (like this?)

but than i would do it the other way around and have a sensor that looks up from the track

and i currently have 1 9v train and 4 power functions train (i could upgrade them to powered up just need the hub and motor) but i want to start small and add stuff as I go on but i wanna make the best informed decision on what I should get invested in

so i think power functions is out because you need (almost) direct line of sight and its older than powered up

7 hours ago, dr_spock said:

One simple method is to always start the trains off at their designated known locations. Then the keep track of the sensor inputs.

this could work but I think this gets really complex the more you scale and if you have multiple trains on the same loop in the same direction

 

7 hours ago, XG BC said:

another idea is to use my magnetic train detector. works with all systems because the sensor is seperate of the physical properties of the track (if it conducts electricity or not)

other idea is to use an ldr mounted inbetween the tracks or an actual reed sensor or even hall effect sensor.

hope this helps you.

so using the magnetic thing you wouldn't have to think about ambient light and that is really cool so that could be a  good alternative for a LDR

using the 12v system isnt really in my mind but also not a terrible idea I just haven't really looked in to it but its really old but less used as far as I know

and thanks for all the feedback!

Share this post


Link to post
Share on other sites
9 hours ago, cptr05 said:

The issue I have isn't detecting the if there is a train but more what train it would be..

I am sorry if you did not understand my post.  I was suggesting a bar code under the train and a trackside sensor to read it and identify the train and which direction it is going.

Share this post


Link to post
Share on other sites
7 minutes ago, John Hill said:

I am sorry if you did not understand my post.  I was suggesting a bar code under the train and a trackside sensor to read it and identify the train and which direction it is going.

The barcode had to be app 4 stubs long per color to be detected properly, I suppose.

9 hours ago, cptr05 said:

but i wanna make the best informed decision on what I should get invested in

Legoino, that's what I recommended , but ueses an ESP, I used the M5Stack ATOM.

 

10 hours ago, cptr05 said:

So adding a sensor to the train wouldn't be ideal because i would have to mod them and it wouldn't look as nice or maybe a sensor that faces down that looks for color in the track? (like this?)

of course, like in the video, that's how i do that.

And as the sensor is assigned to the train (mechanically) you can use one "contact" (like a red tile) on the track, and when a train passes you know what train is

 

10 hours ago, cptr05 said:

this could work but I think this gets really complex the more you scale and if you have multiple trains on the same loop in the same direction

Have a look at the Brick Automation Project

https://lgauge.com/article.php?article=trains/gallery/articles/bap

But you will not find a solution without defining your requirements, cause all solutions do different things.

No model railroader would automate multiple trains on the same loop, that's why you cant't use these ideas and solutions.

 

Share this post


Link to post
Share on other sites
21 hours ago, cptr05 said:

i wanna make the best informed decision on what I should get invested in

 

11 hours ago, Lok24 said:

But you will not find a solution without defining your requirements

So this is really the core of the matter.

Generally, a "best informed decision" on any "system" is simply solidly dependent on your "boundary conditions".

You need to define these before you begin.

"Scalability" seems to be another thing you want to take into consideration. If this is true, then you should address the latter first: How many and what type of remotely controlled items in your envisioned "system" do you want to operate (maximum numbers) in parallel? Never begin with 1 and then see how it plays out, start with the envisioned MAX devices and then figure out whether this is realizable with any available technology (to you) in question.

Examples:

  • PF = 8 channels (16 if you have the LEGO hardware, and you are willing to seriously code),
  • "Authentic" 9V = block operation with some nifty custom electronic hardware and lots of wires, same for 12V.
  • PUp: Go nuts if you are willing to dive into the programming frenzy. As @Lok24 said, when you know how to run ESP32 (compatible) microcontrollers, you can (e.g.! There are other ways as well) implement Legoino on your Arduino IDE and then flash the ESP with your code. Not only one but several, they cost about $10 - $20 each and can comfortably handle 6 PUp hubs each (Yes, they can handle more than that, but let us be grounded - as in: Flawlessly working:pir-laugh:. So this represents real world scalability.

Once you have figured out that, you should move on to the functionality "range". What do you need?

  • PF = IR with no feedback: You need to implement hardware generating feedback. And software to recognize that feedback.
  • 9/12V: Same thing - or you go the hardwired 12V approach, TLG was providing back then. 9V: That is up to you ... 
  • PUp: Either put sensors on the moving train and/or the static layout. You need to program, though - a lot.

Next up: Putting it all together. Who is in control? A smart device? A "computer"? Custom hardware?

I believe you raised a really tough question. If I were you, I would begin with: What are your boundary conditions :pir-huzzah2:

All the best,
Thorsten

Share this post


Link to post
Share on other sites

Hi,

you should definitely take a Look at  mattzobricks.com.

 

This guy did a lot to describe how he automatized his layouts:

 

KR

 

CaL

 

Share this post


Link to post
Share on other sites
On 10/12/2022 at 10:57 PM, Toastie said:
  • "Authentic" 9V = block operation with some nifty custom electronic hardware and lots of wires, same for 12V.

i mean you could also use dcc (that might as well been what you thought) to have fully Independent control over the trains while using less wires (some for track power and some for the position detectors. it all depends on how big of a layout you want to build. if it is like on mine where there is just one train running back and forth then "analouge" 9v is the way to go but for bigger layouts for shure go with dcc.

Edited by XG BC

Share this post


Link to post
Share on other sites

yes, DCC works fine, but

1.) you hve to open each 9V motor to implement the DCC decoder (or use other motors and some pickUp for power)

2.) You need 9V-Rails only

But you can also mix; trains however, switches and signals via DCC (but need then one (for the complete layout)  seperate wire to connect all decoders)

Share this post


Link to post
Share on other sites

yes that is true. also the normal dcc trains use something like 14v which is a little much for the 9v motor (could fix this with a lower voltage psu though). the mixing argument is a good one though as dcc is really only a protocoll which you can implement in any way youd like.

Share this post


Link to post
Share on other sites
On 10/11/2022 at 12:41 AM, cptr05 said:

so is there a way to detect battery trains if you have multiple on the same loop?

I have used some of the methods above, but also I have used rfid detection. An rfid chip somewhere in the train is detected by a loop and tells you when what train is where.

Based on this or using reed detection, and dividing your track in blocks you can do a lot however there is a very big disadvantage compared to DCC. With DCC you control the motor of the train, meaning you can stop and start it whenever you want, without this you need to use the track to cut the power or lower the voltage resulting in the problem that the train needs time to stop. I have automated a lot but have to say this is the most tricky thing to handle.

Currently I am successfully using modeltrain software package (rocrail) which I have connected via DCC++ and my arduino's. With this I am able to control a layout, see where trains are based on 2 sensors per block and control the power of these blocks, the switches, etc.

Maybe in the future I will have a look at dcc, because my current 9v motors are slowly dying and therefore need a heart transplant anyway someday.

Share this post


Link to post
Share on other sites
17 hours ago, XG BC said:

though as dcc is really only a protocoll which you can implement in any way youd like.

No, its also the method to trasfer power and signal via only two cable cores

 

 

Share this post


Link to post
Share on other sites
On 10/13/2022 at 6:57 AM, Toastie said:

Next up: Putting it all together. Who is in control? A smart device? A "computer"? Custom hardware?

Also planning for my layout, several independent control systems.

Trains are built to run autonomously and behave based on colours they detect. This removes errors based on external connectivity and related latency issues.
Use RFID for external guidance.  Can hack pup to recharge from metals rails for longer running time.

Tracks are split into sections and one or more controllers determines which train needs to be in which section.
Under-track switching of colours to halt trains until next section is clear and/or track is switched to correct path.
This would be an Arduino or possible rpi solution.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.