TuxTown

Automation solutions

Recommended Posts

I wonder if anyone has ideas about the future of lego train automation.

Last months I have been looking at BAP, the automation project for PowerUP gear. Great concept, great tool. However it doesn't scale, which may be due to the use a bluetooth. The only device in house on which I can connect more than 7 hubs is an acer laptop with a bluetooth 5 chipseth. HP elite laptops with bluetooth 4 are a no go. However the Acer laptop starts to give problems when I connect 12 hubs. Besides that it is almost impossible to find bluetooth 5 dongles online. Its all 4 or 4.2. Probably because there is no need for people to connect more than a few things to bluetooth.

In the past and on Lego shows people seem to still use 9v tracks. Arduino setups seems interesting to automate stuff beyond the trick of manually hit a control thing. The Arduino Lego Trains youtube channel has nice videos but the author has disappeared already several years. 'AlmightyArjen' does similar things, also 9v. The downside of this technic is that 9v isn't available anymore and there are lots of wires involved. Fx Track promises us a future for 9v, but we have to see if thats gonna fly. Let alone what it will cost for people started with RC track to replace lots of gear.

I've been looking for alternatives for BAP, because of the scaling problem and the fact that the author is hardly around on this forum. 4DBrix has some stuff, but seems to be in problems because of copycats. Shame, as their nControl thing looks like it could be interesting. They have a wifi solution for PF motors according to there site. Wifi would of course be the solution for a wireless solution without the downsides of bluetooth.

How are others handling their automation wishes? Is 9v still the best option for larger layouts? (it tackles the battery problems) I like to operate a handfull of trains on the same layout without having to jump out of my chair every minute to prevent a crash ;-)

 

Share this post


Link to post
Share on other sites

I also found links about DCC/LDCC in combination with Lego Mindstorm RCX gear. Info like this is 15 years old. No references found if anyone is doing DCC-like things with the newer EV3. Hanso in the Mindstorm section of this forum is doing EV3 things for trains. But he doesn't use train motors but technic motors for his trains. (nice project by the way!) I wonder if there are still people doing DCC kind of things with lego trains. Does Fx Bricks have any plans with this once they produce their 9v solution?

Share this post


Link to post
Share on other sites

The problem with the EV3 bricks is that they are much too large to fit into a normal train. I'd say the way to go is either powered up or power functions.

One idea to "safe ports" would be to use the Powered Up distance and color sensor to control power functions trains. It isn't as powerful as a power functions remote so you may be able to make different "track sections" with a total of 8/16 trains or something. But figuring that out so that there are no overlaps might be pretty complicated.

Another option (in the same direction) might be to use SPIKE Prime hubs for switches etc. They can be controlled via USB or run autonomous and have 6 output ports. It can also control 4 Powered Up hubs at once. But they are pretty expensive and the official programming is still limited.

Edited by Tcm0

Share this post


Link to post
Share on other sites

Bluetooth is fine for a few devices.  Depending on the size of your railroad empire, Wifi would be one way to go for control a large number of devices in an TCP/IP network.  Modules like the ESP8266 with a motor driver are inexpensive compared to DCC modules.  I think it is mostly DIY at the moment. 

 

 

 

Share this post


Link to post
Share on other sites
4 hours ago, Tcm0 said:

The problem with the EV3 bricks is that they are much too large to fit into a normal train. I'd say the way to go is either powered up or power functions.

One idea to "safe ports" would be to use the Powered Up distance and color sensor to control power functions trains. It isn't as powerful as a power functions remote so you may be able to make different "track sections" with a total of 8/16 trains or something. But figuring that out so that there are no overlaps might be pretty complicated.

For my automation software (release TBD) I'm looking into a driveby solution; my trains are all PuP with a color sensor looking down for colored plates so the idea is that when the train sees a specific tile it temporarily switches to IR-mode to control a receiver operating the upcoming switch. At least that's the theory, I have a test setup but yet to actually do any tests.

Share this post


Link to post
Share on other sites

It depends how interconnected your automation needs to be.  But I would keep my eye on Pybricks.

It's only available for EV3 at the moment, but they are actively working to bring support to other hardware (including the standard Powered Up train hub).  Once that's available, you will be able to use Python to program some autonomy on the hub itself without being continuously tethered to a bluetooth device -- all on standard LEGO hardware.  I did a test with this to do, as @AlecDGeneric mentioned, colored plates on the tracks to tell the train to speed up/slow down/pause.  I didn't do any IR automation, but that's a fun idea and should be possible!

 

Share this post


Link to post
Share on other sites
19 hours ago, AlecDGeneric said:

For my automation software (release TBD) I'm looking into a driveby solution; my trains are all PuP with a color sensor looking down for colored plates so the idea is that when the train sees a specific tile it temporarily switches to IR-mode to control a receiver operating the upcoming switch. At least that's the theory, I have a test setup but yet to actually do any tests.

While a great idea, it could also be expensive- with one cord per sensor and only two sockets per hub, you would need two hubs on the locomotive. The need to carry two battery boxes also eliminates some locomotive designs, but others will still work fine with that configuration.

Share this post


Link to post
Share on other sites
1 hour ago, zephyr1934 said:

you would need two hubs on the locomotive

Why? With the receiver's dome between the sleepers I just reconfigure the sensor looking for tiles; that is switching it to mode ir_tx(7) when detecting yellow and back to mode color(0) after a second in my test, which actually works well (now did some testing) when the color detection is consistent, though I may have to test more configurations (speed, colors, duration of ir_tx).

Share this post


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

It depends how interconnected your automation needs to be.  But I would keep my eye on Pybricks.

 

Wow. An open source python project to automate lego EV3 and PowerUp hubs. I will certainly follow this one. Thanx!

Share this post


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

Why? With the receiver's dome between the sleepers I just reconfigure the sensor looking for tiles

Ah, okay, it had not occurred to me to broadcast the IR out of the bottom of the locomotive. Not good for a general application where the IR receivers are typically on top of other locomotives or whatnot but if the IR receivers are aligned to have good sight lines that is a different story

Share this post


Link to post
Share on other sites

It depends how comfortable you are with programming, but I have an open source Node.js library I use for controlling Powered Up - https://github.com/nathankellenicki/node-poweredup/

I've used both my MacBook Pro and a Raspberry Pi 3B so far, but I think my MacBook Pro has been able to connect to 11 devices so far, and the Raspberry Pi 7. I don't know if those are the max'es though.

Share this post


Link to post
Share on other sites

Every train MOC I've built in the last 4 years has been controlled by Arduino via Bluetooth. Of all the onboard electronics, only the motors are Lego. It's all rather hackish since my electronics and Android knowledge (for the controller app) only go so far, but I've been happy with what I've been able to achieve. This approach definitely opens up the possibilities, considering sensors and other components are cheap (often only $1 - $2 each) and you've got the flexibility of programming the Arduino however you like.

eg. Recently I reversed the roles taken in automatic level crossing activation - the train tells the crossing to activate as it approaches, instead of the crossing waiting to detect the approaching train. It worked flawlessly over a 2 day exhibition and wasn't impacted by lighting conditions or any of the other issues that can play havoc with train detection.

I'm working on a system where each train on a large loop will know where it is on the track, and announces its position to other trains on the layout. Those trains can then continue at their set speed or slow if they're getting too close. It's only in early development at the moment but I've managed to recruit a few people to the cause and am determined to get it up and running!

Edited by Beej
Typos

Share this post


Link to post
Share on other sites

Amazing, indeed. And wifi controllers from 4DBrix to operate trains! I need one of these, although maybe thats not possible anymore after the 4DBrix news.

 

"Anyway, I am presently changing the whole automation system. So far, I have been using nControl from 4DBrix and enhanced the software by about 1.500 lines of own code. Unfortunately, nControl has a lot of bugs and other drawbacks, so I will move away from it and come up with a better, completely different solution." I'm gonna follow this Mattze

Share this post


Link to post
Share on other sites
On 4/9/2020 at 9:17 PM, TuxTown said:

Wifi would of course be the solution for a wireless solution without the downsides of bluetooth

A thing to take into consideration here is that while WiFi as a protocol will support loads of devices, not all routers do. As I understand it, they support up to a certain number (related to the amount of channels), and then start switching (quickly) between them. You might need to get more professional routers (the enterprisey ones can handle hundreds of devices), and take care to not require super-fast latency. 

What I am using myself is just a wired solution for most devices, except for the trains. The sensors, switch motors and LEDs are all just wired into Arduinos, which are then wired into a PC or Raspberry PI, which will then handle the remote control. This limits the amount of devices controlled over BlueTooth. Right now I am using BlueTooth for the trains, but I just bought some ESP32 chips that support both BlueTooth and WiFi, and are small enough to mount inside of a train (similar to the Wemos D1 in the posted video, which is an ESP8266, the predecessor to the ESP32, I think). I was thinking of trying to write a WiFi<->BlueTooth bridge for them at some point, so they could act as stand-alone controllers. This is a long-term project though, since interfacing with the Lego stuff over BlueTooth proved a bit too difficult / out-of-my-wheelhouse the last time I tried it (I use bricknil, a Python library, right now), as well as working on a better control tool to run on the main PC. 

Share this post


Link to post
Share on other sites

Nice.

what hardware and components are you using? are you using mqtt and node-red to drive it? 

There seem to be a quiet a few home automation platforms like tasmota and esp-easy that allow setting up devices post-install but vary in what hardware is available in stable releases, including which rfid platform is available.

 

Share this post


Link to post
Share on other sites
On 6/28/2020 at 12:49 PM, bricktrain automation said:

Is this what you mean by train automation?

Using RFID's to identify the trains, NRF24L01's for communication. Everything is controlled by Arduino's.

Nice job! @AlmightyArjen it really looks a lot like your setup! If I have time in a week or so I will share some of my ideas including a Attiny1616 for (Dutch style) railroad signals.

@ciphernaut of course MQTT and Node-Red would be perfect. Although I don't like most of the plugins on there so it will require some rewriting. Maybe we should start writing our own nodes?!

Share this post


Link to post
Share on other sites

@JopieK Agreed.

 

I've started a document to scope various use case requirement to get a clearer view as to what platforms out there can be leveraged. Feel free to add your setup / use cases. https://docs.google.com/document/d/1FIe7-u3s2GsN8l3kyhp2Tf9ReoExb7_D5aUxJltgXCI/edit?usp=sharing

Share this post


Link to post
Share on other sites

Very interesting what you are all working on. I thought that the train-automation was more or less dying.

I am using Arduino Nano's for the nodes. For reading the RFID's the nodes use a NFR522. For communication they use a NRF24L01. An Arduino mega is acting as a central control.

The trains have an Arduino as well, combined with a NRF24L01. At this time I still use the infrared receiver on the trains: the Arduino's on the trains have a infrared-LED to forward the commands. The advantage is that the trains can still be controlled with an infrared transmitter. But the drawback is the small amount of steps you can control the motor. And if the LED moves, the train does not get any commands anymore. There are projects in where an Arduino replaces the Lego IR receiver, might be interesting.

It is easy to setup: The first train drives an initialisation round and after that, the layout of the track is known.

I started as a nice small Arduino project, but to get it running, it was a bit more complex than I thought....

Share this post


Link to post
Share on other sites

I don't know where you got the idea that "train-automation was more or less dying"? Microcontrollers are really booming, at least for me... ;) but I teach embedded systems engineering so maybe not a typical observant... But in the industry they also become more and more important, IoT, IIoT, Industry 4.0, all made possible by cheap and fast microcontrollers.

Share this post


Link to post
Share on other sites

My solution is a pure Lego solution, using a Raspberry Pi (or any computer, also my MacBook Pro) as the brains.

* I use a LEGO Dacta Control Lab (Interface B) to control 9v components - Power Functions LED lights (for signals), Power Functions LED motors (for switches), and a 9v track wire to control 9v trains. This is plugged into the Raspberry Pi via a USB-Serial cable.
* I use the Raspberry Pi's onboard Bluetooth to control Powered Up trains.
* I use LEGO Education WeDo 1.0 hubs and the WeDo 1.0 distance sensor to detect trains. The hubs are also plugged into the Raspberry Pi via USB. (I could also use old 9v IR sensors plugged into the Dacta Control Lab, but the WeDo distance sensors are more reliable)

The programming language is Node.js/Typescript.

I made a post here about how to control trains, signals, and switches using a Powered Up Bluetooth controller here. I'm in the middle of moving house, but once I get a chance I'll make another post about automating it using the WeDo sensors. 

 

Edited by Mr Hobbles

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.