News: 1634626808

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

A Raspberry Pi HAT for the Lego Technic fan

(2021/10/19)


There is good news for the intersection of Lego and Raspberry Pi fans today, as a new HAT (the delightfully named Hardware Attached on Top) will be unveiled for the diminutive computer to control Technic motors and sensors.

[1]

In the belly of the beast: Pi Build HAT next to your correspondent's Lego (click to enlarge)

Using a Pi to process sensor readings and manage motors has been a thing since the inception of the computer, and users (including ourselves) have long made use of the General Purpose Input / Output (GPIO) pins that have been a feature of the hardware for all manner of projects.

However, not all users are entirely happy with breadboards and jumpers. Lego, familiar to many a builder thanks to lines such as its Mindstorms range, recently [2]introduced the Education SPIKE Prime set, aimed at the classroom.

The set contains a wide variety of components, including motors and sensors, controllable via a rechargeable hub and tablet application. It is the latter elements that a Build HAT-equipped Pi can replace: simply plug those motor and sensor components into the Pi hardware instead.

Effectively, this is a HAT device that connects to Lego devices that use a LPF2 connector. An onboard RP2040 microcontroller takes care of the low-level control of the Technic devices while an external power supply is needed to provide power. At the top level, developers can make use of Python to query sensors and run motors.

[3]

A Raspberry Pi Build HAT in use ... Click to enlarge

It's entertaining stuff, and we can imagine it coming in handy in a classroom setting – sensors include devices to check distance, report colour and force, while motors can both be queried with regard to their position (if supported) and spun as required. The Pi team reckon the kit will also find fans outside of the education sector.

[4]The Register speaks to one of the designers behind the latest Lego Ideas marvel: A clockwork solar system

[5]The Register recreates Apollo 15 through the medium of plastic bricks, 50 years on

[6]What to do with our leftover Saturn V Lego? Why, build another rocket, of course

[7]BOFH : But soft! What light through yonder filing cabinet breaks?

It's also a stepping stone to bigger and more exciting things, in our opinion. After all, once a curious mind has created a bit of code to operate machinery in the real world via the rapid prototyping made possible by the kit, making the transition to more advanced applications is not such a major leap.

As for the Build HAT itself, there are only four LPF2 connectors (adding more was apparently tricky due to space constraints) as well as a power connector and a helpful slot for feeding through the ribbon from the Pi's camera (should one be fitted.) The Raspberry Pi team reckons it should work on all models of the computer that have a 40 pin GPIO header, although Pi-400 users will need an extension cable and won't be able to use the external power supply to power the Pi.

Give it a go

We tried it out with a Pi 4 Model B and found no significant issues – there was enough juice to keep the Pi running and the Python libraries are well documented with helpful examples.

Not so great was the fact that the HAT fouled the fan we'd fitted to our Pi 4 and, of course, the stock case would no longer fit. To be fair, this is pretty much par for the course when it comes to augmenting one's Pi, but worth keeping in mind. Then again, one could regard it as an opportunity to get creative with the plastic bricks.

[8]

Compared to the cost of the Lego involved (the complete SPIKE Prime set retails [9]for a whopping £361.99 to consumers so it might be worth picking and choosing the required components), the HAT is a relative snip at $25, although you will need a power supply capable of pumping out 7.5v into a 2.1mm centre-positive barrel jack. If you've not got one to hand, the Pi team expects the branded version to go for $15. Pre-orders start today, although resellers won't have it in stock until 25 October, meaning a few more days wait for end users.

[10]

If you've gone down the Technic route, with motors and sensors armed with LPF2 connectors, the Build HAT is a fun interface. We're still pondering how to make our [11]definitely-not-official-plastic-brick NASA crawler move without sending the Saturn V and Umbilical Tower on top tumbling.

A headless Pi running things from within the heart of the beast and slowly spinning up motors a degree at a time does have a certain appeal. ®

Get our [12]Tech Resources



[1] https://regmedia.co.uk/2021/10/19/build_hat_lego2.jpg

[2] https://education.lego.com/en-au/products/lego-education-spike-prime-set/45678#lego-learning-system

[3] https://regmedia.co.uk/2021/10/18/build_hat_in_use.jpg

[4] https://www.theregister.com/2021/09/15/lego_solar_system/

[5] https://www.theregister.com/2021/08/27/lego_csm/

[6] https://www.theregister.com/2021/07/30/lego_saturn_1b/

[7] https://www.theregister.com/2021/07/16/bofh_2021_episode_12/

[8] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_onprem/personaltech&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=2&c=2YW6XTja6al6w-Dc40Jr5pAAAAJc&t=ct%3Dns%26unitnum%3D2%26raptor%3Dcondor%26pos%3Dtop%26test%3D0

[9] https://www.lego.com/en-gb/product/lego-education-spike-prime-set-45678

[10] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_onprem/personaltech&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44YW6XTja6al6w-Dc40Jr5pAAAAJc&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0

[11] https://www.theregister.com/2021/01/05/saturn_v_crawler/

[12] https://whitepapers.theregister.com/



Doomed! You're all doomed!

ShadowSystems

My Evil Plans can commence at last! Muh Hahahahahahahahahahahahahahahhhahhahaha...

Actually, a huge leap

Mike 137

" ... once a curious mind has created a bit of code to operate machinery in the real world via the rapid prototyping made possible by the kit, making the transition to more advanced applications is not such a major leap "

The actual leap is from blindly tweaking something you don't understand the internals of - to obtaining a holistic views of how the entire system works.

It's a leap of approach as much as a leap of information. It's fundamentally a change of thought process, and that's not all that easy to make.

I see the lack of it all the time, manifested by systems with poor performance, poor ergonomics and poor reliability, so we should be teaching the more effective thought process from the start, rather than trying to tack it on after teaching the less effective one. The problem is typified by software development degree courses, where secure development is left until the final year and is often an optional module. As a result, insecure practices are so strongly engrained by the time the module is taken that it doesn't make a lot of difference.

I'll probably get down votes for saying anything at all negative in the context of the Pi. but this is not specifically about the Pi - it's a matter of principle about the way we teach. For example, on a visit to the BETT expo before the pandemic, on over 200 stalls I couldn't find a single electronics related teaching material that exposed the actual mechanisms of the item to view. Everything was packaged opaquely, on the basis of "just plug it together and follow these instructions and it will work as expected".

Re: Actually, a huge leap

Joe W

I agree - to some extent. I don't really see the sense in teaching "proper security" from the beginning on (and I'm talking about kids aged 6 and up[*], not university level courses). Feeding their curiosity about how to make the machine do their bidding is the aim. What they will be taught is checking input, and making sure the motors are not fried by running into the limits of motion of the model (and this is something they will figure out, probably by themselves). I think it is a good start. Should we prioritise security by design? Yes, more than we do it now[**]. The question is really when and how, and how high of a priority we want to make it as a function of time. Not a top one from the very beginning, as this will discourage kids from pursuing the subject.

However, I fear the ship has long sailed, as we all know the classic problem of people just using example code or going on stackoverflow and copying "solutions" without understanding them or their implications. Unless we manage to clean up ze interwebs at the same time we stand no chance.

What I really like about MindStorms is the inclusion of LabVIEW (even if it has been rebranded). This is a good introduction to the mindset of programming a control flow (and it can be extended by writing libraries in C/C++ or Fortran). This is sadly absent from the Pi offerings, as far as I can tell - if somebody has a good alternative to LabVIEW on the Pi (or Arduino, or ESP) I'd be happy to read about it!

[*] No, MindStorms is not aimed at that group. Nor is the PiHAT in the article. I know that.

[**] I'm totally guilty of that, e.g. not sanitising input if I feel I can get away with it...

FORTUNE DISCUSSES THE OBSCURE FILMS: #3

MIRACLE ON 42ND STREET:
Santa Claus, in the off season, follows his heart's desire and
tries to make it big on Broadway. Santa sings and dances his way
into your heart.