So… after BSA class on Tuesday I decided to work on my LEGO train, the red streetcar (60423). Because I’d changed my train tracks from a loop to a “U” shape I needed to find a way for the train to stop at the main train station, pause, roll to the smaller station in front of the Academy, pause, continue forward the the end of the line in front of the New Hashima cube(s), pause and then then repeat all three stops in reverse. My pervious experience with “guessing” where to stop and restart and programming that into the train didn’t work very well when the train tracks were in the original loop configuration. I was thinking that it would work much better if I added a color sensor to the train and then add that to the program. 

LEGO used to sell a light/distance sensor for its Power-Up hub (which is what I’m using to run my train), but it’s been discontinued. I have two light/distance sensors in my inventory. I have a small one (on the right) that I think used to be part of my LEGO WeDo or maybe EV3 robotics kit and a larger one from my Robot Inventor kit. I had to redesign the motor car to accommodate the sensor, so I tried using the smaller sensor first. I set up a small circular set of tracks to test out the sensor. Absolutely no response from the sensor. For whatever reason they weren’t communicating. So I had to tear-down the car and do a second redesign to accommodate the larger 3×3 sensor. 

Because I needed a large hole in the front, facing down for the sensor, that pushed the engine and its four wheels way back. But it didn’t tip forward because of the weight of the battery pack kept it balanced. But then, because the four wheels were so far back, the train had a difficult time clearing some walls where the track makes a 45-degree turn. But the worse part was that the train wouldn’t stop where I’d put the colored bricks. It turns out that I had to reduce the speed the train traveled from 50% to 30% and then it started to detect the color brick. It also only seemed to detect the red brick and light blue color brick. When I tried to use black, I think it saw shadows as black and stopped inconsistently. 

Alas, when I ran the tests on the actual track in the LEGO city, the sensor didn’t pick up any color and the train nearly drove off the end of the track by the New Hashima cube. I hit the manual “off” switch just in time and caught the lead car with my foot, giving it a soft landing. I’m really tempted to give up on the color sensor method and just try to program the correct distances between stops. Also because of its “long nose” do to the need for a 3×3 hole in the floor for the sensor, I’m thinking that I should move the whole motor/battery pack/hub to one of the lead-pointy cars… and switch the former motor-car into a passenger car. Okay, more experimentation is needed… 

ONE DAY LATER…

I successfully moved the motor and battery pack/hub to the lead/engine car, but I couldn’t figure out how to keep the original size to add the color sensor. 

So, I decided to give it a go without the color sensor and see if I could just program the distances between the stops. 

The program started in front of the main train station, stop at smaller station in front of the Academy, then stop at the end of the track in front of the New Hashima cube, then reserve course and do that loop four times. 

So, robot programming is challenging. I ran the program several times, adjusting the “run time” between stops, before recording the above video. But the train never quite stopped where I wanted it to stop. I find it interesting that on the first “lap” the train stopped well short of the end of the track on the New Hashima side of the track. But on the next three “laps” it drove all the way to the bumper-stop with increasing intensity. Why the distance seems to change after the first lap is another one of those inconsistencies with “consumer level” robotics, beginning with “programming” the train on my phone instead of my computer. 

Previous experience with LEGO robotics (EV3, WeDo, NXT, Robot Inventor & Spike), I would program the stops based on distance traveled instead of “time” intervals. Hell, I could program the motor to stop based on the number of turns of the wheels or the number of degrees of a single turn. Maybe I should just switch to one of those kinds of programming apps instead of the simplistic “Powered Up” app. I’m also thinking that, now that I have separate front wheels, I should extend the length of the engine car so that I can try to make space for the color sensor… That’s one of the things that I love with LEGO (and robotics), you’re never quite done. Have a great weekend, y’all. JBB

Sources:

Tags: LEGO, LEGO 60423 Streetcar, LEGO programming, LEGO robotics, LEGO Trains


Creative Commons License

JosephBruceBustillos.com (website) by Joseph Bruce Bustillos is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License