[HN Gopher] Raspberry Pi Build HAT - Controls Lego Technic motor...
       ___________________________________________________________________
        
       Raspberry Pi Build HAT - Controls Lego Technic motors and sensors
        
       Author : MarcScott
       Score  : 235 points
       Date   : 2021-10-19 07:01 UTC (16 hours ago)
        
 (HTM) web link (www.raspberrypi.com)
 (TXT) w3m dump (www.raspberrypi.com)
        
       | rheide wrote:
       | I've been playing around with the Lego and Raspberry pi
       | combination on and off through the years [1], with the goal of
       | building a standalone tracked vehicle (pi on board) that can move
       | around my apartment. There were various ways to do this already,
       | mainly by using off the shelf motor controller boards and later
       | the third party Bluetooth motor bricks. This was all for the old
       | "power functions" system though, Lego has since revamped their
       | lineup with a lot of new parts that all use a different
       | connector. I'm really looking forward to getting one of these.
       | 
       | [1] https://www.colorfulwolf.com/blog/tag/raspberry-pi/
        
         | jacquesm wrote:
         | Lego has the bad habit of not extending their 'systems'
         | thinking to their electrical and electronic components. New
         | connectors are introduced rather willy-nilly and supply
         | voltages and communications protocols change with potentially
         | every model year.
         | 
         | This allows them to quickly follow trends but it is totally
         | contrary to the mechanical interface which is backwards
         | compatible for over 60 years.
         | 
         | The same goes for the train sets, the track width is more or
         | less the same for ever but the track interconnects and the way
         | the trains are powered have changed often.
         | 
         | Fortunately for the trains there is a solution (subset of
         | track, only use the old 12V system for the track it will also
         | support battery powered trains giving a reasonably broad
         | coverage), but for the electronics and the various motors the
         | situation is quite a bit more complex. Note how the article
         | essentially limits compatibility to a single one of the 10 or
         | so systems that Lego has over the years used to connect
         | electrical components.
         | 
         | Anybody remember the very old style electrical interconnect
         | plates?
         | 
         | Someone ought to cook up a compatibility kit that allows you to
         | connect older and newer stuff at will.
        
       | pqs wrote:
       | What would be the ideal age to start introducing my son to these
       | kinds of projects? At what time can they start programming? I
       | don't want to start too early.
        
         | bobsmooth wrote:
         | Give him normal LEGO now if you haven't already.
        
           | pqs wrote:
           | He loves LEGO.
        
             | mcshicks wrote:
             | Legos are great. My son was lego fanatic and he did learn
             | some programming on mindstorm (rcx) and did some c like
             | programming on it as well (not quite c it was called). He
             | also learned basic from books and old tandy computers. I
             | taught (volunteer) arduino, rpi and occasionally scratch
             | classes at my local library pre-covid and I would say lots
             | of kids can program at 8, and quite a few a bit younger but
             | even with scratch being able to use a keyboard and mouse as
             | opposed to touch screen is really important. An of course
             | being able to read/write. I think just having fun computer
             | things around the house that are not video games is good.
             | Scratch is actually pretty awesome I think for learning
             | programming, and then stuff that actually moves is really
             | cool. I was also lucky in that my father in law actually
             | had a robot company (ibm pc, basic programming, lots of
             | cables) and he sent us one to play with when he as maybe 8
             | or 9? But there are so many choices today. Good Luck!
        
       | bobsmooth wrote:
       | I'm surprised a 3rd-party HAT hasn't been developed before now.
        
         | burstmode wrote:
         | There used to be one for the beagleboard, but it's not
         | available anymore...
         | 
         | https://makezine.com/2013/04/23/beaglebone-lego-motor-contro...
        
       | meibo wrote:
       | Sadly, LEGO keeps discontinuing great and simple systems like
       | this and replacing them with "smart" versions that you _have_ to
       | use a phone with, since they don 't want to ship remotes anymore.
       | Giving an 8 year old a phone to play with their LEGO sets kinda
       | defeats the point(they'll want to play Minecraft instead, from
       | personal experience).
       | 
       | There's not even any features like Mindstorms that offer
       | customization/programming, it's literally just a clunky
       | touchscreen remote that doesn't pair with the model half of the
       | time. I guess phones on the box sell better.
        
         | makeitdouble wrote:
         | The Raspberry Pu side stearing the project gives me hope it
         | will come out better than the past initiatives.
         | 
         | The real ugly part with the smartphone requirements is it
         | targets pretty recent OS versions (too old hand me downs are
         | out of the picture), and outside of the top end education hubs
         | ($200+) there is no obvious way export/import/backup the
         | programs.
         | 
         | Having a kid invest time to make anything a bit complex on them
         | is a recipe for disaster.
        
         | oaiey wrote:
         | It is not the simple system which everyone misses ... because
         | that has no roadmap to a STEM usage ... it is the lack of
         | generic purpose (brickable :) ) remote control to work without
         | smart phone which is the key problem.
         | 
         | For example, a simple remote is super easy to do. A complex
         | behavior config (like steering boxes) or calibration modules
         | could be small plugins into a remote so you keep it with your
         | instruction/set. They could be also remotely programmed and
         | injected there.
         | 
         | SO many ideas how to do this correctly with the original LEGO
         | mindset.
        
         | [deleted]
        
       | MarcScott wrote:
       | Here are the projects we have launched to support the release of
       | the new hardware.
       | 
       | https://projects.raspberrypi.org/en/pathways/lego-intro
       | 
       | Feedback would be very gratefully received.
        
         | Fiahil wrote:
         | Does it work with PoweredUp hubs and motors ?
         | (https://www.lego.com/en-fr/product/technic-hub-88012)
        
           | josephg wrote:
           | You should already be able to drive poweredup hubs from the
           | r.pi via bluetooth. There's a few libraries out there and
           | incomplete but official documentation on the protocol[1]
           | 
           | I assume this will work with the poweredup motors. The
           | poweredup motors and sensors all use the same pinout, cable
           | and serial protocol.
           | 
           | [1] https://lego.github.io/lego-ble-wireless-protocol-
           | docs/index...
        
       | rsre wrote:
       | When I was young I always enjoyed playing with Mindstorms. It was
       | my first experience programming. For me it was amusing that I
       | could build some robot with Lego and make it retrieve a ball from
       | our living room.
       | 
       | Sadly jumping from the block oriented programming to "real"
       | programming of the Hitachi H8 microcontroller was not very
       | straight forward, so I kind of hit a wall in that regard. Maybe
       | this collaboration will act as a better gateway to "real"
       | programming.
        
         | hdjjhhvvhga wrote:
         | I have somewhat mixed feelings about this. On the one hand,
         | block-based "programming" does allow children/newbies to
         | construct something that works. On the other hand, almost
         | nothing usable is being programmed this way. So I'd say it's
         | more or less fine as a kind of introduction to general rules of
         | programming, but the sooner you get to the actual code, the
         | better.
         | 
         | That said, microcontroller programming is something very
         | specific in the sense that the same thing might (and often is)
         | programmed in a completely different way on another device, so
         | basically a large part is just getting to know your hardware.
         | Fortunately, these days several abstraction layers are
         | available for people who need them, from MicroPython to
         | FreeRTOS.
        
           | cbhl wrote:
           | If memory serves, a decade ago LabView was fairly involved in
           | the robotics-education space, as a "real" block-based
           | language that industry actually used and that kids could
           | theoretically graduate from teaching languages into. Only
           | kids I saw using it were those whose parents used LabView at
           | the day job from an industrial background though.
        
           | MarcScott wrote:
           | I think you should have a look at the projects we have
           | written that support this launch.
           | 
           | https://projects.raspberrypi.org/en/pathways/lego-intro
           | 
           | They're exclusively written in Python, some of them using
           | Bluetooth for remote control, some using pollution APIs to
           | display data and also TensorFlow for image recognition.
        
           | jacquesm wrote:
           | Block based programming allows people to make working
           | applications these days. See: Mendix, Labview, Betty Blocks
           | and many many others besides.
           | 
           | PLCs have historically used ladder diagrams, which are also
           | not 'code'. I've seen Excel spreadsheets that you would have
           | been hard pressed to replicate using code.
           | 
           | Programming in its very essence is telling a machine what to
           | do, what form that comes in isn't all that relevant, and code
           | is just one of those forms.
           | 
           | 'actual code' is not a requirement for programming.
        
           | spoonjim wrote:
           | Depends what you mean by "usable." Are you going to ship it
           | in military hardware? No. But I built a block based program
           | connected to a motor that gave kids a candy if they guessed
           | the number that the computer was thinking of in less than 6
           | guesses. A 4 year old invented binary search within 10
           | minutes.
        
           | yon1237 wrote:
           | I think it's more about teaching kids/newbies to think in a
           | programming way. That can be language agnostic. You're
           | essentially trying to achieve something "complex" using
           | simple instructions. At a basic level that's a great way to
           | learn programming. As the problems get more complex it
           | becomes obvious why paradigms & architectures exist, and your
           | programming skills can improve.
        
             | cbhl wrote:
             | I think that's the thing? Block programming languages come
             | from folks who write "CS education" literature as opposed
             | to the "new programming languages" literature. They're
             | turing complete, because curriculums require teaching the
             | use of if statements and for loops, but that's about it.
             | 
             | If I actually wanted to use a block language at my day job
             | I'd want affordances for larger, more complex programs.
             | Compiler or JIT, copy/paste, zooming in and out of parts of
             | programs (ala Prezi or something), integration with source
             | control diff tools, C extensions / integration with
             | existing code, console output, file I/O, etc.
        
               | shakna wrote:
               | Whilst it was never completed, as funding for the program
               | was diverted elsewhere, I worked on a team at a
               | university using Blockly [0] compiling it to Lua, and
               | parsing from Lua back into our specific runtime set of
               | Blockly functions.
               | 
               | It could do absolutely everything that Lua could do. We
               | also added a kind of multifile support, using tabbed
               | views to reimplement libraries on the browser side of
               | things (compiling into separate Lua files).
               | 
               | The idea was that educators at both ends of the spectrum
               | could convert to and from the same visual
               | representations. The primary school classes the uni were
               | running could use blocks, and slowly move to normal Lua,
               | one feature at a time, all the way up to the first and
               | second year ICT programs for higher ed.
               | 
               | Because it could compile to Lua, we could use git and a
               | whole bunch of other tools that already exist. There was
               | an experimental C/asm.js branch to add in FFI support,
               | but that was deemed too time-costly whilst the rest still
               | had a bunch of edge-cases.
               | 
               | And then, unfortunately, the whole program got yanked.
               | But about that time it was close approaching what I would
               | consider "useable" for actual real work.
               | 
               | [0] https://github.com/google/blockly
        
               | ManBlanket wrote:
               | Sounds like a wonderful tool for fundamental CS courses
               | and projects. I remember assignments like creating a
               | Cesar Cipher using Java, being distracted by tangential
               | stuff like what the static keyword means and importing
               | libraries. That language was a lot to take in, just
               | tuning-out the noise from what I needed to learn.
               | Something like half the class did not take the second
               | course. Most of the thrash had little to do with the
               | assignments themselves. Being able to toggle between a
               | visual representation of the program and the code helps
               | students' comprehension of the core concepts immensely.
               | That much is obvious when you work with kids on Lego
               | robotics projects. I could imagine a tool set like that,
               | with the flexibility to build something like a console
               | blackjack game. It would quickly become a standard for
               | teaching secondary school programming courses. Hopefully
               | someone else will take up that torch before my own kids
               | are looking at learning how to program.
        
           | jonathankoren wrote:
           | This is true to a certain extent. Certainly, large problems
           | get awkward pretty quickly using the Scratch model. However,
           | I found this Code.org version of Minecraft[0] interesting.
           | You primarily use the Scratch like interface, but then you
           | can click a button, and see how your legos translated into
           | Javascript.
           | 
           | [0] https://studio.code.org/s/aquatic/lessons/1/levels/1
        
         | mschuster91 wrote:
         | > Sadly jumping from the block oriented programming
         | 
         | Jesus, _that_ is what I call a trip down memory lane! I wonder
         | what happened to my RCX.
        
         | maherbeg wrote:
         | I started programming in normal languages before I did a
         | mindstorms based project for a robotics lab at university.
         | Going in the other direction is just as jarring because of how
         | limited the block based system felt. It's also just a clunky
         | IDE compared to a text editor...
        
         | lnsru wrote:
         | Luckily now we have Arduino that hides all the nasty stuff from
         | users. There are 2 basic blocks: unit and loop. Adding
         | repeating code blocks into loop block isn't that hard. Jumping
         | from Mindstorms to Arduino shouldn't be a big difference.
        
           | jacquesm wrote:
           | My 9 year old son gets this so for any adult it shouldn't be
           | a huge hurdle. Arduino is a very nice little platform.
        
             | swiley wrote:
             | IMO: It's slightly easier for small children to learn to
             | program than adults. I'd imagine anyone here shouldn't have
             | an issue but saying a kid gets it isn't quite right.
        
         | Teknoman117 wrote:
         | The leJOS alternate firmware for the RCX was my first
         | introduction to Java. It was amazing how complete the support
         | was given the small footprint. It even implemented Java's
         | threads system.
        
       | Fred27 wrote:
       | Does anyone know if these work with the sensors and motor in LEGO
       | Boost and WeDo 2.0? They're not included in the compatability
       | list, but do have the LPF2 connector. I'm guessing they'll work,
       | bu tnot sure.
        
         | deng wrote:
         | The color/distance sensor 88007 is in the compatibility list,
         | so it'll work. However, the move hub 88006 is not in the list,
         | which is unsurprising since I think it's bluetooth-only. There
         | are already several libraries which you can use here, like
         | https://github.com/undera/pylgbst or
         | https://github.com/virantha/bricknil.
        
       | karmicthreat wrote:
       | This would be great, if you could buy a Pi.
        
         | glenneroo wrote:
         | Why can't you buy a Pi?
        
       | makeitdouble wrote:
       | Wow. This is a pretty big deal.
       | 
       | There have been third party hubs to pilot Lego Technic motors for
       | a while now, but this HAT is a lot cheaper than any of them (TBF
       | it doesn't work the same either, with no battery, button or
       | physical casing etc.), works with the latest batch of motors, has
       | official blessing, and the RPi is also a lot more extensible and
       | flexible on every aspect.
       | 
       | This is a no brainer purchase for anyone trying to do more things
       | with Lego Technic in my opinion.
        
       | amelius wrote:
       | Cute, but the Legos are crazy expensive. What you save by using a
       | Pi, you lose by buying Legos.
        
         | kingosticks wrote:
         | The "Prime" set they reference in the article looks awesome but
         | it's over PS300! A motor alone seems to be about PS50.For
         | schools maybe this is reasonable, not so much for individuals.
        
           | amelius wrote:
           | Yes, the quality is great, but with limited budget you can
           | learn so much more from buying cheap robotic components from
           | AliExpress.
        
       | sillyquiet wrote:
       | I played around with the second generation Mindstorms in college,
       | it was pretty fun even for 20 year old me.
       | 
       | I still have the bricks, motors and sensors! (I even still have
       | the RCX and the weird infrared thing you use to program it). This
       | is going to be a fun project for my daughter and me, especially
       | since the Pi is way more flexible than the RCX.
        
       | _joel wrote:
       | Ok, time to hook this baby up to Prometheus :)
       | https://projects.raspberrypi.org/en/projects/lego-data-dash
        
       | amelius wrote:
       | What kind of motors do they use? Stepper motors, DC motors, ...?
        
         | ralphhughes wrote:
         | The motors that connect to the Build HAT are servo motors with
         | integral absolute encoders. Encoder resolution is one degree.
         | Power is 7V DC ish.
        
       | vs2 wrote:
       | The Build HAT is not compatible with LEGO Mindstorms (EV3)
       | because the plug system is different. The Build HAT/SPIKE(tm)
       | Prime system uses LPF2 plugs whereas the Mindstorms system uses
       | RJ12 plugs.
        
         | _trampeltier wrote:
         | It can't be long, until Lego start to change the brick size.
        
           | makeitdouble wrote:
           | What if I told you there is another plug type, that might
           | still be sold with some old sets somewhere, and is still
           | supported by a bunch of third party hubs (that for a long
           | time were more advanced in many ways than Lego's own system
           | ...)
           | 
           | Lego's stewardship of all this was a mess, and I'm super glad
           | they open the system to officially blessed third parties.
        
             | bombcar wrote:
             | There's also all the various rail/train systems, some of
             | which are compatible with some variants ...
        
           | jacquesm wrote:
           | That's already happened, twice even.
           | 
           | There is 'duplo' and there is 'Modulex':
           | 
           | https://www.newelementary.com/2017/11/old-bricks-what-are-
           | mo...
        
             | thanatos519 wrote:
             | Duplo is Lego-compatible. A 2x4 Lego brick fits exactly
             | onto 1x2 Duplo studs. A Duplo brick is 2x the height of a
             | Lego brick, and a Duplo plate is 1x the height of a Lego
             | brick.
             | 
             | It's fun to build large structures quickly with Duplo then
             | detail them with Lego!
        
               | jacquesm wrote:
               | There are even ways to connect Modulex bricks to regular
               | Lego, some people have figured out some interesting
               | tricks.
               | 
               | Which allows you to take that strategy to the next level.
        
             | AlanYx wrote:
             | There was also Lego "Quatro", double the size of Duplo, for
             | very young toddlers.
             | 
             | Only sold from 2004-2006, but still in high demand on the
             | used market. Interlocks with Duplo and regular Lego.
        
               | jacquesm wrote:
               | Oh cool, never knew about that one. I do have one more to
               | add but it's mostly technics warmed over, which is
               | 'Znap', clearly aimed at the same market as 'Knex', which
               | Lego at some point saw as a competitor. Since then
               | they've come their senses, the Znap line was ugly and
               | highly impopular, leading to being discontinued after
               | only a year.
        
       | moritonal wrote:
       | First time I've seen the STEAM acronym (Science, Technology,
       | Engineering, Arts and Math). Described as:
       | 
       | "While these initiatives are a wonderful start into the
       | exploration of these four areas of study, the critical process of
       | creativity and innovation is missing. Students in STEM programs
       | may have more experiential learning opportunities, but they are
       | limited to only science, technology, engineering and math. Our
       | economy requires so much more than an understanding of these
       | areas - it requires application, creation and ingenuity. STEM
       | alone does not foster these essential nutrients."[1]
       | 
       | It reads weirdly for me, because the people I know in STEM are
       | some of the most creative people I know. Very much my own biased
       | opinion, but adding Arts into STEM seems to ironically exclude
       | art from the other subjects, and gives a space for all those art-
       | focused people (I sometimes avoid at hack-a-thons because they
       | don't like coding things) to feel included rather than
       | encouraging them to learn STEM?
       | 
       | 1. https://artsintegration.com/what-is-steam-education-
       | in-k-12-...
        
         | whywhywhywhy wrote:
         | I don't mind STEAM, but I am biased as a designer who knows how
         | to code and I think it leans into things a lot of kids are
         | interested in making like videogames that have an art element
         | to them.
         | 
         | There is also "STEAMS" STEAM + Sport, which makes no sense to
         | me.
        
           | wccrawford wrote:
           | IMO, it's an attempt for people to not feel like they're
           | being left out. It happens any time a group of people self-
           | select and self-promote. Other people who aren't in that
           | group change the group and claim they were ostracized and
           | they're essential.
           | 
           | Eventually, it includes literally everyone and means nothing
           | at all.
        
         | asoneth wrote:
         | The first I recall seeing the STEAM acronym was John Maeda's
         | efforts to popularize it in the early 2010s e.g.
         | https://scholarship.claremont.edu/steam/vol1/iss1/34/
         | 
         | His focus at the MIT Media Lab was teaching artists and
         | designers to program, and my understanding is that he continued
         | that as the president of RISD, so it definitely was not
         | intended as an acronym to convince art/design folks they didn't
         | need to learn STEM.
         | 
         | I also never personally interpreted the attempted inclusion of
         | Art as implying a lack of creativity in the other domains any
         | more than the inclusion of Math implied a lack of mathematical
         | aptitude in the other domains.
        
         | stavros wrote:
         | I agree that adding arts in there is kind of assuming that
         | otherwise all these boring STEM people wouldn't have any way to
         | create things. Which seems backwards. There's a huge creation
         | component in STEM, especially in engineering, as if you aren't
         | creating something, you aren't doing engineering.
         | 
         | I don't know if I agree with the second point about excluding
         | arts people, it sounds like you want them to be _forced_ to
         | learn STEM, which I don 't agree with. Let people let what they
         | want to learn, but STEM by definition could not exist without
         | creativity.
        
       | nicolas_t wrote:
       | I would have loved this as a kid... And when my son grows up I
       | think we will have a lot of fun building things with this.
        
       | pauljurczak wrote:
       | Does it provide PID speed control for the motors? Or any other
       | form of closed loop speed control.
        
       | bhouston wrote:
       | Can you attach move than one of these? It only has 4 ports.
        
       ___________________________________________________________________
       (page generated 2021-10-19 23:02 UTC)