[HN Gopher] Can Lego City Powered Up trains be automated? ___________________________________________________________________ Can Lego City Powered Up trains be automated? Author : jweissman Score : 176 points Date : 2022-12-05 14:46 UTC (8 hours ago) (HTM) web link (bricks.stackexchange.com) (TXT) w3m dump (bricks.stackexchange.com) | blobbers wrote: | TLDR Stall at a dead end to reset the system using pybricks | bcraven wrote: | That was part one, the final solution was to use a colour | sensor to detect plates beneath the train. | leetrout wrote: | Is it weird to post the fake question and your own answer to the | question at the same time? | | I havent had much luck in the overflow communities so I am unsure | how common this is. Is it what most people do? | OwlsParlay wrote: | If you know the answer and it's a valid question (i.e. it's not | trivial or easily googled already), it's fine to do. The point | is less to reputation farm as it is to share knowledge. | megablast wrote: | It is called a faq. | unwind wrote: | No, it's not weird. | | At least on Stack Overflow it's a common way of sharing | knowledge. | | Source: been using SO quite intensely, have many reps. | josephcsible wrote: | There's nothing "fake" about self-answered questions, and Stack | Exchange even includes UI specifically for posting an answer at | the same time as your question. | vanderZwan wrote: | I suppose the part where the writing structure is _" question | written as if by someone who does not know the answer | themselves, answer written as if it's a different person"_, | even when explicitly posting to share knowledge, is what | throws people off. I assume this is part of the SO guidelines | but I can't blame anyone for being confused by that. | rippercushions wrote: | SO allows multiple answers per question. I have on occasion | asked something and given a crappy/hacky self-answer as a | stopgap, with somebody else eventually chiming in with a | much better one later. | quietbritishjim wrote: | There's nothing about the question or answer that suggests | that they're different people. | | FWIW I've done the same, even more like that than the post | here. (Not about Lego though!) I had a problem, was | disappointed not to find the answer on StackOverflow so | when I came to post the solution I put the question in the | way I would have written it _before I figured out the | solution_. Seemed more likely to be found by anyone with a | similar problem. | primitivesuave wrote: | I used to make all kinds of cool projects with lejos | (https://lejos.sourceforge.io/) and am now a bit tempted to get | the new toys and test out the Python interface. Would be nice if | Lego actually invested more time into making a standard | programming interface for advanced users. | dolmen wrote: | It looks like LEGO is investing in bringing together the | popular Raspberry Pi platform and its toys, and abandonning | dedicated apps such as the Robot Inventor (Mindstorms) app. | | https://www.raspberrypi.com/news/raspberry-pi-build-hat-lego... | alexheikel wrote: | Why not? | als0 wrote: | > One of the weaknesses of the City Hub currently is that it | requires a tethered Bluetooth device, such as a phone, tablet or | computer, in order to function. By flashing the custom Pybricks | firmware to the hub, we can overcome this limitation and write | programs directly to the device. | | This is why I come to Hacker News | preinheimer wrote: | As someone who likes lego and programming, I love this answer. | But I hate how hard lego has made it. | | Yes, with some work you can make your train stop and go. But I | don't think there's a good track switching solution that's lego | only and automated. There's an aftermarket motor thing that | connects with USB. The lego only attempts end up unwieldy and | usually lacking in reliability (e.g. | https://rebrickable.com/mocs/MOC-11841/1963maniac/train-trac...) | | The Duplo trains ship with pretty neat functionality out of the | box: lights, whistle, brick reader that activates an action when | it sees a certain brick. You can't recreate this with lego with | just a single power brick, as it's four things: sensor, light, | motor, sound. Lego train can only do two. | esotericimpl wrote: | I remember in middle school doing some programming on the Apple | 2 in the logo language and using a lego motor to essentially | schedule moving the car to the park and then making a motorized | lego swing spin around. | | I think this is the first time i saw the wonder of programming, | sad that its harder to do this now. | mc32 wrote: | So, while this is uhhh, off track, Legolands and such have some | kind of automation, though, presumably, those are bespoke | solutions and are not available to regular consumers. | bombcar wrote: | The Legoland trains are basically model trains wearing a Lego | skin. They're also a different "scale" than the "Lego toy" | trains. | mc32 wrote: | Huh! I never noticed. It makes some sense when you think | about parts-wear. | jacquesm wrote: | Lego motors are designed for about 100 hours of service | life. | drewzero1 wrote: | Wow, that's not much... my kid would probably hit that | within a month. (I just replaced the motor in a Bachmann | Thomas that wore out in about the same amount of time.) | jacquesm wrote: | That's why they're not fussy about replacing the few that | wear out, the average use is frequently after the first | purchase and then it drops off sharply so I guess they | decided it wasn't worth designing around long usage. In | the older trains you could replace the little motor | easily, with the newer ones (starting with the infamous | 'red' motor a long time ago) that practice ended and you | have to replace the entire unit. | bombcar wrote: | The motors for the trains are better than that because | they're designed for continuous use (somewhat) but yeah, | at the end of the day Lego is a toy. | bogeholm wrote: | > Legolands and such have some kind of automation, though, | presumably those are bespoke solutions | | I can vouch for that! I can say - with great confidence - | that the best job I ever had was in Legoland, Billund while I | was in high school. The job: keep the outdoor small models | running from 15:30 when the real engineers left, until park | closes. Then leave a note about the stuff I couldn't fix | myself. | | The electronics were industrial PLCs wired to a control | computer, and the mechanics inside the models were made from | industrial type stuff that you might see on a robot, conveyor | belt or the like. | | Most of the models (trains, cars, cranes etc.) were built on | a metal chassis or skeleton. | | Fond memories of getting paged by the system with "ALARM: | Cars, Norway" to discover that a kid had dropped her soft ice | on the highway ;) | bignevi wrote: | Possible | f4c39012 wrote: | It is a shame that Lego Duplo and Lego trains aren't | compatible. One of my favourite demos of the sheer awesomeness | of Lego is connecting a 2x4 Duplo with a 2x4 Lego block. Any | way round. If you've never tried this, do it now :-) | matheweis wrote: | The PyBricks that the SO questioner self answers with is | actually quite capable of doing this, and runs Python to boot. | | I wish this was the default interface that LEGO provided but | I'm thankful for the PyBricks team creating a solution. | marpstar wrote: | Noticed that the question and answer were authored by the same | person. Skimmed their other answers for fun and they are quite | the expert. Very impressive ability to identify specific LEGO | bricks. | keraf wrote: | I added my Lego Rollercoaster on Home Assistant[0] a little while | back. Nothing fancy, just cut a Power Functions extension wire to | put a relay in-between and an ESP board to control it. On one | side I had the power pack and the other the motor. Would have | loved to switch out the power pack for a constant power source | but never got to it. | | If you're looking to do some Power Functions (PF) hackery, there | are some interesting articles that cover the wiring and working | of PF gadgets more in detail[1][2]. | | [0] https://twitter.com/iamkeraf/status/1274433444446113792 [1] | https://www.hackster.io/Notthemarsian/take-control-over-lego... | [2] https://www.philohome.com/pf/pf.htm | greesil wrote: | Well there goes a weekend. I can't wait to try this out for my | kids. | cactusplant7374 wrote: | Is there any way to use the Flipper with these trains? | lini wrote: | Older Lego trains use IR for control so if you just want to | control motors and lights, you can get one of those and control | it with the IR blaster on the Flipper. If you also want the | sensors/newer programmable hub, then you need the BLE protocol. | bri3d wrote: | I couldn't find an off the shelf Flipper module, but the Lego | Powered Up BLE protocol is fully documented by Lego: | | https://lego.github.io/lego-ble-wireless-protocol-docs/ | | So it shouldn't be too hard to add one. | | Keep in mind that as noted in this article, the default Powered | Up Hub behavior is as a "passthrough pipe" to the host device, | so just using a Flipper might be a bit obnoxious. | cactusplant7374 wrote: | Gotcha. I was hoping there was a primitive subghz protocol. | That would be fun. | post_break wrote: | It's a shame they got rid of metal tracks and went to batteries. | If you're rich you can buy new replacements: | https://shop.fxbricks.com/pages/fx-track | | Or try to buy old stock on ebay etc. | EamonnMR wrote: | You could only run a single engine per layout and switching | could cut off the power. | | Now what I really wish they'd bring back is the Space | Monorail... | incanus77 wrote: | > Now what I really wish they'd bring back is the Space | Monorail... | | Agreed. I still think about that thing. I was about 10 when | it came out and used to go and stare at the box at the toy | store. When the new Futuron LEGO minifigs came out with the | first revamp to the Classic Space suit, it just looked so | damn cool. To this day they always make me think of the | monorail. | vertis wrote: | I had this, and I still miss it and my other lego. | jerrysievert wrote: | you can modify non-metal tracks to work with stained glass | foil, and maybe a jumper or two depending on what you're trying | to modify. i used it successfully for cross-tracks (x's) when | they came out originally. | bombcar wrote: | Metal tracks had some advantages, but plastic have, too. | | The "best" model railroads have electric track at a constant | voltage and DCC or other controlled locomotives, so that you're | not "driving" the train with the voltage on the track. | preinheimer wrote: | On a related note, Lego is cancelling Mindstorms. So if you were | dreaming up an advanced train city with Mindstorms as the brain | you'd better stock up now. | | https://www.theverge.com/2022/10/28/23428766/lego-discontinu... | adolph wrote: | My child is starting Lego robotics courses and I was confused | by the change. As close as I can tell WeDo, PoweredUp/Boost and | Spike all operate similarly. The core is a hub consisting of a | STM32 microprocessor with a BLE module, power management, | options for internal lights and accelerometer, and varying | count of IO to servos, motors and sensors. With certain kits | some of motors are built in. They all use the same new | proprietary connector but the usual folks are making converters | for EV3 and PowerFunctions. | | While Lego promotes use of their proprietary apps, other | bluetooth shims can facilitate connections. I was able to | connect to a Boost hub without issue using MIT's Scratch | website to execute instructions. As far as I can tell, only | Spike can operate untethered by BT with the default firmware. | | I've been integrating some BBC Microbit with Geekservo Lego | compatible microservos and the overall experience is similar. | Lego throughout is easier to integrate but doesn't lend itself | to as much customization/experimentation. Using the MIT Scratch | IDE is similar to MS Makecode used for Microbit. Compose your | blocks, flash your microprocessor. Some things I like about | Makecode are GitHub integration and the ability to seamlessly | move between blocks, JS and Python. | | There isn't enough IO and connectivity for any Mindstorm or new | Lego MCU to make an advanced train city. You'd be better off | with ESP8266 on ESPNow mesh operating glue-your-own or | Geekservo units. | adolph wrote: | I was wrong about the movement from WeDo through Boost to | Spike: ## SPIKE Prime and SPIKE Essential | All SPIKE Prime and SPIKE Essential sensors and motors are | compatible with each other. ## MINDSTORMS(r) EV3 / NXT | and SPIKE Essential MINDSTORMS EV3 and NXT components | aren't compatible with SPIKE Essential because they use | different connection cables and ports. ## WeDo 2.0 and | SPIKE Essential WeDo 2.0 motors, sensors, and hubs | aren't compatible with SPIKE Essential. ## Powered UP / | Control+ and SPIKE Essential The Control+ L and XL | motors can be plugged into the SPIKE Essential hub and | detected by the SPIKE app, but other elements won't be | detected. | | https://www.lego.com/en-in/service/help/spike_prime/spike- | es... | ceejayoz wrote: | To be clear: Mindstorms the coding platform, but not the parts. | You'll still be able to build Lego robots, just using Scratch. | sschueller wrote: | Isn't it being replaced with something newer and better? | dolmen wrote: | I think the real replacement is the Raspberry Pi Build HAT | that allows to connect LEGO Powered Up/Boost/Robot Inventor | sensors and motors to a Raspberry Pi. | | https://www.raspberrypi.com/news/raspberry-pi-build-hat- | lego... | qzio wrote: | Lego spike. | | It is part of their education line. | | https://www.lego.com/en-se/product/lego-education-spike- | prim... | extasia wrote: | I used to love motorised lego stuff. Building marble runs was my | favourite... | preinheimer wrote: | The Great Ball Contraption (GBC) videos are pretty good: | https://www.youtube.com/watch?v=VCmwskpxyCg | | Really interesting ways to move balls around. | jameshart wrote: | The motivation of using a special device to untether from the app | as being 'to reduce screen time' seems tenuous at best. Is using | an app to program in a block language to control real trains in a | customizable city really 'screen time'? And even if it is, is it | automatically _bad_? | Xylakant wrote: | The quote from the answer suggests a slightly different | motivation than reducing screen time. | | > I use a setup similar to the above to allow an automated | train to run around my son's city without the need to have a | screen nearby the whole time. | | It's a criticism that I hear regularly of the requirement to | use an app for various of the motorized Lego kits: Having a | phone in hand often leads to the result that the kids stop | controlling (or even building) the kit and rather start playing | on the phone. It's also a bit an expensive thing to hand to | your six year old so they can control their Lego train. | [deleted] | jpace121 wrote: | I was not planning on buying a train set but now I may be... This | looks way too fun. | Kon-Peki wrote: | Is this the 3rd generation of Lego City trains? | | We have the first (?) generation in which each train uses IR (I | think) and each controller can deal with 2 trains at once, but | are selectable to 4 "channels" - so 8 trains in total. I wanted | to buy another train or two a few years ago but they had switched | to a bluetooth-only system. | | We also have one of the Duplo bluetooth trains and it is pretty | nice as well. | TonyTrapp wrote: | There's at least two generations before that "first (?)" | generation: 12V powered trains from the 80s and 9V powered | trains from the 90s. In both cases, the train tracks were | conductive. No batteries needed. A controller was attached to | the train tracks. Still my favorite system, as it has no parts | that can ever become obsolete (dead batteries, unsupported | phone apps, unsupported bluetooth protocols...) | jacquesm wrote: | And before then the 4.5V 'blue' rails (you could upgrade from | that to the 12V system by swapping out the motor and adding | the middle rail, but that lost you the ability to make | certain tracks because then the two rails would end up being | shorted out, which is why Maerklin long ago decided to use a | center track for one pole and the outside for the other). | incanus77 wrote: | I have train set 182 [1] from 1975, bought at Harrod's in | the UK and brought back to the US for a family friend who | passed it on to me. It's still in the box with styrofoam | liner. | | [1] https://brickset.com/sets/182-1/Train-Set-with-Motor | jacquesm wrote: | If it was never used it is worth a fortune. | [deleted] | mschuster91 wrote: | > 9V powered trains from the 90s | | You could use an RCX to control and power the train motors. | Fun times from a simpler world, the downside was obviously | that you could have only one train running on the grid | because the power was supplied back to the rails! | Kon-Peki wrote: | I do like the version we have, as you can theoretically | have an almost unlimited number of trains running. But | yeah, it was really frustrating to have them cease | production. | | On the other hand, based on the photos in this article, it | looks like the traction motor assembly may be common across | recent generations which would allow tinkerers to make | their own controllers. | TonyTrapp wrote: | To clarify, you could run more than train but they would | all go at the same time! Unless you parked them on a | passing loop, of course... | lode wrote: | Automating my Lego trains was my first introduction to | programming, back in the late 1980s using GW-Basic. (When I was | about 8 years old.) | | I had several stations on a looped track, and controlled the | train position by switching on the power to the motor for a | certain time. | | At first I used a photodiode taped to the CRT monitor (and | controlling the motor by lighting up a square in the corner of | the screen), later I upgraded to controlling a relay via the | parallel port. | blobbers wrote: | And then you wrote DOS as your first program as a whiz kid. We | see you BillG. Don't need to brag. | hyperman1 wrote: | I did more or less the same thing, as did lots of other | people. | | Wiring the serial or parallell port to something wasn't hard. | Instructions for bit banging them where generally found in | the library (paper books). Serial had weird voltages but was | near indestructible. Parallel was TTL just like anything else | digital, so some 74 ICs got you mostly there. | | The era where you basically needed to solder if you wanted a | computer was just over, so electronic knowledge was still | easy to find. | iancmceachern wrote: | I love this photo diode solution, reminds me of duck hunt. | Brilliant! | rrobukef wrote: | In 1999-ish, my two brothers and I got a box of relays and some | reed sensors and solenoids (for track-switches) embedded in | lego blocks. | | We're all engineers now, the box is treasured and still works. | Finding a PC with a parallel port has become challenging | though. | vertis wrote: | One idea is: https://hackaday.com/2017/05/05/converting- | parallel-port-cnc... | | Plus there are a bunch of off the shelf solutions on Amazon | (YMMV). | fnordpiglet wrote: ___________________________________________________________________ (page generated 2022-12-05 23:00 UTC)