Cosmik42 Posted January 20, 2019 Posted January 20, 2019 (edited) Hi everyone, I just released the V0.6 of The Lego Train Project which delivers the ultimate goal I set to myself: build a fully automated driving system for lego trains. First you can watch this 3 minutes video to understand the high-level concept and see it in action: Download V0.6 here: https://www.eurobricks.com/forum/index.php?/forums/topic/169318-automation-control-all-your-powered-up-power-function-sbrick-devices-with-a-single-software/&page=1#1 Map out your section The first thing that you need to do is to define your Sections. Typically you need to define a new section everytime you have a Switch. Here is what I did on this simplified version of my layout: #2 Report your sections to the software. Note this is a one time setup! Note about Switches: - I use a very simple system with a motor like this one to motorize my switches You need to define that a Motor is a Switch for it to show up in the Switch drop-downs. Note about Sensors: - In this scenario I only use WeDo 2.0 distance detectors. They are easy to buy and cheaper than the Boost Color-Distance detector. Note: WeDo 2.0 & Boost Sensor should show up automatically. SBrick Sensor have to be defined manually.# 3 Define Train's Paths Once your network is setup, you need to create the different scenarios your trains will take! #4 Some Important Verifications Before Starting: - Make sure each Train is attached to the section it is physically at. This is the only way for us to know constantly where is a train. A wrong section on start will break the automation. - Select a path which contains the section where this train is. Otherwise the automation won't start. #5 Enjoy! And that's all Folks! Hope you enjoy it. It was an incredible challenge to put it together and I hope it will be used beyond my own layout :) Cheers! Vincent. Edited August 18, 2019 by Cosmik42 Quote
SandraNZ Posted January 21, 2019 Posted January 21, 2019 I love what you have done here. It obviously works well and is easy to use. I am working on something similar but using a PICAXE for the train detection (using Light Dependent Resistor) and for the point control, all reporting back to an Arduino for train control. There is an Arduino library for the infra-red LEGO controller. The Arduino will control the movement of the trains and will command the PICAXE where to set the points, and it will receive location information back from the PICAXE to make decisions on next moves. Do you think it would be possible to port the Bluetooth Hub code into an Arduino library? Then I can use all my trains not just the infra-red ones. What do you think? Quote
Cosmik42 Posted January 21, 2019 Author Posted January 21, 2019 8 hours ago, SandraNZ said: Do you think it would be possible to port the Bluetooth Hub code into an Arduino library? Hi Sandra! It sounds like you are working on some great automation project too. I don't own any Arduino, so I can't help you there, but my own implementation was inspired by the work of Nathan who shared node.js library. Very clean and readable implementation that should help you get the protocol right! Quote
Cosmik42 Posted August 18, 2019 Author Posted August 18, 2019 Just refreshed the images which expired a long time ago. Quote
Giottist Posted August 18, 2019 Posted August 18, 2019 On 1/21/2019 at 2:29 AM, SandraNZ said: I love what you have done here. It obviously works well and is easy to use. I am working on something similar but using a PICAXE for the train detection (using Light Dependent Resistor) and for the point control, all reporting back to an Arduino for train control. There is an Arduino library for the infra-red LEGO controller. The Arduino will control the movement of the trains and will command the PICAXE where to set the points, and it will receive location information back from the PICAXE to make decisions on next moves. Do you think it would be possible to port the Bluetooth Hub code into an Arduino library? Then I can use all my trains not just the infra-red ones. What do you think? Hi Sandra, I'm working at the same topic (ok, ok, occasional ...). Cosmik42 was so nice and enabled the C# COM Port interface in the BAP software. I'm thinking about a comparable problem to retrieve information about which indiviual train occupies which sector or a track sector is free. From time to time I think at RFID identification or barcodes beneth my locos. Arduinos can read out the sector sensors and send the information to the BAP software via the COM interface. I prefer the Arduino Mega due to its large number of IO ports. At the moment I've just tested the communication between Arduino and BAP. And not to forget to mention I got real help from Cosmik42 by PM. Thanks a lot! Quote
Giottist Posted August 18, 2019 Posted August 18, 2019 I've to add the code for the BAP editor: Just write: SerialPort ArduinoPort = new SerialPort( "Com3", 9600, Parity.None, 8, StopBits.One); // COM3 is the COM port for the connected Arduino in my computer, please look up your port ArduinoPort.Open(); // Do some communication like in the following sample: string message = ArduinoPort.ReadLine(); MainBoard.WriteLine(message); // The input will be displayed in the message window in the BAP shell. ArduinoPort.Close(); MainBoard.WriteLine( ""); // to print a line feed Do not declare any interface by yourself in the BAP editor, Cosmik42 did for us in the BAP code. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.