Sign in to follow this  
Hanso

[EV3]Train controlled by Mindstorms EV3 for large, fully automated train layout

Recommended Posts

again.. well done.. a clever way of staying 100% pure lego!  I have to admit, I enjoy the challenge too!

 

another option might be to orient the power pack vertically, so the dial aligns a lot more directly with the EV3 motor (or a gearing down from it)... maybe the whole front cabin could be modular, and detach?

Not sure if it would stick out too much, or get in the way of your stylish 80's roofline! :)

Share this post


Link to post
Share on other sites

The train is now finalized (i.e. if you ever can speak of a final version with Lego ;-).

36171317745_d9e30315f6_c.jpg

Building the train was one challenge, programming it was the second. One of the challenged we faced, was how to stop the train as exact as possible at a specific location. This functionality is needed for loading and unloading the train.

As you can see on the picture below, the train can be start/stopped by turning the control dial of the battery.

33865368060_1eb792db42_c.jpg

By means of the white gear, the EV3 motor can just make some rotations until the control dial reaches the end stops. This gives us a either speed 0 (stop) or speed 3 (normal). In principle, this would be enough. However, if you want to stop the train at an exact position, the train should run at speed 1.

And here comes the difficulty: how do you know when the dial is in the correct position? I guess, you think (like I did): just turn the dial a fixed number of degrees and you should have it. And yes, that works. Most of the times.... sometimes, the number of degrees doesn't result in getting the train to run at speed 1 (probably due to the slip gear). If results in either in speed 0 (stopped) or speed 2 (still too fast). We have tried two possibilities to get to speed 1: either from speed 3 and then a fixed number of degrees towards speed 1 or go to speed 0 first, and then upwards to speed 1. In both cases: most of the times it goes well, but now always. So we needed a fail-safe mechanism.

35780092820_a8ec6b9be7_c.jpg

The solution is as follows:

  1. The train arrives at the station (coming from the left).
  2. When the color sensor reads 'white', it goes to speed 1 (hopefully).
  3. In the happy flow, it slowly continues to drive until it reads 'green' and the train stops.

Two problems can occur:

  1. Either, going to speed 1 results in the train stopping (way too early). This is solved by a time-out. If the color sensor doesn't read green or red after 5 seconds, it slowly turns the control dial. This process is (in principle) repeated infinite. By this means, at a certain point the train will start driving at speed 1 and therefore the timeout will not occur anymore.
  2. Or, it goes to speed 2. At this speed, the train doesn't stop at the green section but in the red section. If that is the case, the speed is set back to '3' making the train do another round and have another try.

In any case, the train will always stop at the green section. Ok, you're right. In theory, it could happen that the train will not stop at the green section because at every retry, the train needs to do another round. But as said earlier, in most cases (9 out of 10), the train stops at the green section in one try. In the other cases, either it needed to rely on the time out or on the do-another-run. For a non-critical system, this is good enough ;-)

You can see the first demo of this at Youtube:

 

Enjoy, Hans

Share this post


Link to post
Share on other sites

And this is (a part) of the program written in the EV3 programming environment to stop the train at the green spot or to do another try when it doesn't stop at the right spot (click to enlarge):

36234091585_549717ac36_c.jpg

Enjoy, Hans

Edited by Hanso

Share this post


Link to post
Share on other sites

For Lego World 2018, we are planning to have two trains running on the layout. The trains will drive in oppossite directions.

38459023356_6107136651_c.jpg

One train will - like the other years - deliver the candy to the visitor, the second train will return the empty containers. This new functionality needs to be designed, other members of the team are busy with that.

The trains drive in opposite directions. We could have made two train ovals, that would a very easy solution to prevent the trains running into eachother. By making a part of the layout a single track only, we add additional complexity.

A testrun of two trains on a single track can be viewed on Youtube:

 

In the test setup, I didn't use a PC for controlling the two trains. A third EV3 brick (visible in the middle of the track) was programmed as controller and the two train EV3 bricks were connected by bluetooth as the two slaves. By sending messages to the trains back and forth, the trains were prevented to run into eachother.

The controller program was quite simple: it sends a start command to train #1 and waits until it receives a message back that train #1 is at the waiting point and gives the start command to train #2. It then waits again until it receives from train #2 the message that it has arrived at the waiting point. This sequence is repeated. The train itself starts driving when it receives the start message. It continues driving until the color sensor 'reads' the red tiles that are built-in in the track. It stops the train and sends a message to the controller brick that it has arrived at the waiting point. Both trains run exactly the same software.

Easy as that ;-)

 

Enjoy,
Hans

Edited by Hanso

Share this post


Link to post
Share on other sites

48005511038_44f63f36c2_b.jpg

This is a rendered image of the train (made by Stud.io 2.0).

You also see that we will cover up most of the rails. The reason is because we got too many 'false' readings by the color sensor. Especially when the underground of the table is white, we got this problem. By putting 'dark bluish gray' between the rails, we prevent these false readings. Another improvement to decrease the false readings: we now do multiple sensor readings (100x). For example, the train should slow down at the moment the colour sensor reads 'white'. But instead of responding to the first reading of the color white, it now counts the number of white readings until it reads a different color. Only if the number of white readings is more than 100, it was "highly probably" white. This way of determining the color, decreases the risk on false positives.

Enjoy,
Hans

Edited by Hanso

Share this post


Link to post
Share on other sites

48071788378_0f98f9a8e8_b.jpg

Added a button at the end of the train to shutdown the power of the train in case of an "emergency". In a situation where we needed to stop the train fast, most of the time we pushed the 'back' button on the EV3. This stopped the programme to run, but not the train ... the train is powered by a PF battery and that was still switched on. I changed the programme already that when you hit the 'Select' button, that the EV3 shutdown the power. But hitting this power was nog logical, although we are raised by Microsoft technology "Press start to shutdown this PC" ... ;-)

So, now the train has a big button at the end of the train that is now our emergency stop. At first, I made it red but that didn't look nice.

 

Edited by Hanso

Share this post


Link to post
Share on other sites

I have drawn the container loader in LDD and then rendered by Studio.io.

This is the result:

Lego Mindstorms EV3 Train Layout - Container Loader

Click on the picture to see it in full resolution (4096 x 2304), more pictures available here: https://flic.kr/s/aHsmMhW4fq.

 

Enjoy, Hans

Share this post


Link to post
Share on other sites
On 5/8/2020 at 4:08 PM, Coder Shah said:

Love the way you integrated the huge EV3 brick in the train model! Well done!

 

On 5/29/2020 at 12:23 PM, mic8per said:

Brilliant...

Thanks @Coder Shah and @mic8per

Share this post


Link to post
Share on other sites

Instead of a color sensor, I have now integrated two touch sensors. This should make the reading of the 'slow down' and 'stop' beacons more reliable.

In the video below, you can see a first test run.

 

 

Outside view (click on the picture to see the full size image);

51787222636_7ac64e65f4_c_d.jpg

Inside view (click on the picture to see the full size image);

51786403767_4135fda73e_c_d.jpg

Edited by Hanso

Share this post


Link to post
Share on other sites

Nicely done! I like the compact looking model, hope I will be able to see some of your creations at some event if it's allowed again. Color sensors can be hard to deal with sometimes, I used 4 touch sensors for homing my 6DoF and 1 color, guess which one gives the most problems.

Share this post


Link to post
Share on other sites
14 minutes ago, Mr Jos said:

Nicely done! I like the compact looking model, hope I will be able to see some of your creations at some event if it's allowed again.

Thanks. Hope that we can show our layout at Lego World 2022.

14 minutes ago, Mr Jos said:

Color sensors can be hard to deal with sometimes, I used 4 touch sensors for homing my 6DoF and 1 color, guess which one gives the most problems.

Uhm, the third touch sensor ...?

Share this post


Link to post
Share on other sites
6 hours ago, Hanso said:

Thanks. Hope that we can show our layout at Lego World 2022.

Uhm, the third touch sensor ...?

Almost correct! It was the IR.

Awesome, hope we can get to Utrecht in 2022, don't know if I should go there with some of my machines, if they are still assembled next year autumn.

Do you run your layout with lego rechargeables in the EV3's? I have 5x EV3 with rechargeable running one of my machines, 6th brick now in a 2nd machine is without yet and using one of those 5 during programming now. But as I look to get some more EV3's I can only find retail versions 2nd handed (no battery). So wondered if you use an alternative power source for bricks that are stationary (not running around in a train). I had been thinking about making dummy battery boxes and hooking them up to a constant power source running from the 230V.

Share this post


Link to post
Share on other sites
2 hours ago, Mr Jos said:

Almost correct! It was the IR.

Hahaha ;-).

 

2 hours ago, Mr Jos said:

Do you run your layout with lego rechargeables in the EV3's? I have 5x EV3 with rechargeable running one of my machines, 6th brick now in a 2nd machine is without yet and using one of those 5 during programming now. But as I look to get some more EV3's I can only find retail versions 2nd handed (no battery). So wondered if you use an alternative power source for bricks that are stationary (not running around in a train). I had been thinking about making dummy battery boxes and hooking them up to a constant power source running from the 230V. 

We have all EV3 bricks (total of 18 now) running on the official Lego rechargeable battery (we always bought the EV3 Education set, the battery was then included). And the EV3 is always connected to a transformer, so it won't get out of juice. The only exception is the train, but because the EV3 is not doing that much (only controlling the speed dial), it runs for a long time. And we have enough spares for switching the PF battery.

Share this post


Link to post
Share on other sites

The replacement in the train of the color sensor by two touch sensors is finished. In this video, you can see the train stopping exactly at the red bump. The difficulty is the rotation of the speed control on the battery box 8878. The zero speed and maximum speed (= 'speed 3') are easy, this is done mechanically. To prevent the construction breaking down by the powerful EV3 motor, we need white clutch gears (76244). But due to this gears, the rotation of the power knob fluctuates a bit.

The maximum speed is too high to have the train stopped at an exact position. We need this exact position (with a tolerance 4 studs) for loading and unloading the train. So we need a speed in between ('speed 1'). As said, rotating the power knob to this exact 'slow' position, is not accurate enough. You end up with a speed of zero (not ok), the desired speed ('speed 1', ok) or still too much ('speed 2, not ok'). Driving always on speed 1 (as maximum speed, mechanically topped) could have been a solution, but it doesn't look nice to see a train at such a slow speed and the train doesn't make it through the curves due to the friction (especially when the juice is getting low).

So how did we solve it? As you can see in the video, when the train detects the white bumps, it will make a full stop. Then we rotate the speed knob every 5 seconds with 10 degrees. At a certain point, the power knob reaches the point that the train starts driving at speed 1. It will then detect the red bump within 5 seconds. Destination reached! The 5 seconds delay is enough to reach the red bump before the speed knob is rotated again.

  • Advantage: it will always find the red stop, even with a tolerance of only 1 stud.
  • Disadvantage: it takes around 15 - 20 seconds to find the red stop after it hits the white bump.

Because we need the train to stop at an exact point, we take the disadvantage for granted. Certainty over speed.

 

Edited by Hanso

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.