Skip to content

ufnalski/lego_spike_medium_motor_u545re

Repository files navigation

LEGO Education SPIKE or MINDSTORMS Robot Inventor medium motor reverse engineering [STM32U545RE]

The part number is 45603. It's kind of a sentimental journey. I still use SPIKE/Robot Inventor from time to time to engage with younger audience. My favorite robot is Swinging Monkey. It is then high time we reverse engineered the SPIKE medium motor. The motor is equipped with an absolute encoder and a microcontroller. The connector gives direct access to the DC motor terminals. There is no direct access to the encoder chip. The encoder is managed by the microcontroller (STM8S103). My guess is that this is to enable zero position calibration (motor homing) that is then stored in the STM8's EEPROM. The hub negotiates 115200 Bd with the motor. After such a handshake, the STM8 starts sending position readings over UART. This repo copycats the handshake and the heartbeat to let you use the motor in your projects with any microcontroller.

LEGO Education SPIKE medium motor with SPIKE hub in action LEGO Education SPIKE medium motor with STM32U5 in action LEGO Education SPIKE medium motor absolute encoder readings (serial plotter)

Sniffing the original SPIKE hub: LEGO Education SPIKE medium motor with SPIKE hub under investigation LEGO Education SPIKE medium motor with SPIKE hub under investigation LEGO Education SPIKE medium motor with SPIKE hub under investigation LEGO Education SPIKE medium motor with SPIKE hub under investigation LEGO Education SPIKE medium motor with SPIKE hub under investigation LEGO Education SPIKE medium motor with SPIKE hub under investigation LEGO Education SPIKE medium motor with SPIKE hub under investigation LEGO Education SPIKE medium motor with SPIKE hub under investigation

Mimicking with the Nucleo board: LEGO Education SPIKE medium motor with STM32U5 LEGO Education SPIKE medium motor with STM32U5 LEGO Education SPIKE medium motor with STM32U5

Note

The motor module sends some data (@2400 Bd) when powered up. The line periodically (around every 3200 ms) goes low for about 500 ms. The handshake should start there. I use bit banging to mimic the sequence sniffed in the original setup. The sequence of twenty 2 ms LOWs plus 18 ms HIGHs could probably be generated by reconfiguring the UART peripheral on the fly. I leave implementing that elegant solution to you 😎 After successful handshake the motor switches to 115200 Bd and starts sending frames that contain speed, single-turn encoder position and accumulated angular distance.

Pinout

Pin Signal/Power
1 DC motor terminal A1 (PWM, LiPo 2S)
2 DC motor terminal A2 (PWM, LiPo 2S)
3 GND
4 VCC (3V3)
5 UART (hub/STM32U5 to device)
6 UART (device to hub/STM32U5)

LEGO Education SPIKE socket

Missing files?

Don't worry 🙂 Just log in to MyST and hit Alt-K to generate /Drivers/CMCIS/ and /Drivers/STM32U5xx_HAL_Driver/ based on the .ioc file. After a couple of seconds your project will be ready for building.

Readings

What next?

Copycat the speed control loop and add a proportional (P) position control loop.

Call to action

Create your own home laboratory/workshop/garage! Get inspired by ControllersTech, DroneBot Workshop, Andreas Spiess, GreatScott!, bitluni's lab, ElectroBOOM, Phil's Lab, atomic14, That Project, Paul McWhorter, Max Imagination, Nikodem Bartnik, Stuff Made Here, Mario's Ideas, Aaed Musa, Haase Industries, and many other professional hobbyists sharing their awesome projects and tutorials! Shout-out/kudos to all of them! Promote README-driven learning 😎

Warning

LEGO Education SPIKE / MINDSTORMS Robot Inventor medium motors - do try them with DIY control hardware and software ❕

220+ challenges to start from: Control Engineering for Hobbyists at the Warsaw University of Technology.

Stay tuned!

Releases

No releases published

Packages

 
 
 

Contributors