Hacking Lego Motors

Lego Technic Power Function motors are nice and easy to hack for robotics projects – in large part because they come with a built in gearbox so you get nice amounts of torque at low speeds right out of the box.

Here’s a quick breakdown of what you need to know. The tl;dr is that you apply a 9V PWM signal to the two inner cores of the ribbon cable. The outer two cores are not connected.

I’m using the M Series 8883 motor but there are plenty of alternative choices available. I’ve not tried them but I would assume they all use the same pin-outs.

The motor is supplied attached by a four-way ribbon cable to a lego electrical connector:

Motor and Connector Combinaton
Motor and Connector Combinaton

You can either snip this cable in the middle and solder the individual cores or you can sacrifice a simple lego PF extension cable instead and leave your motor assembly intact.

The Lego PF system uses a standard pin-out system across all the products but note that for our purposes here we only need the C1 and C2 lines (the 0V and 9V lines are not connected inside the motor).

Here’s a photo of the motor end showing the pin-outs:

Motor End Pin Assignments
Motor End Pin Assignments

And here’s the pin-outs for the connector end. Which you might need if you’ve just cut your motor cable in half without making a note of the cable orientation…

Connector End Pin Assignments
Connector End Pin Assignments

If you’re interested in the internals, undo the small crosshead screw

Underside showing housing retention screw
Underside showing housing retention screw

then prise off the housing using a small flat-bladed screwdriver trying not to stab your fingers and thumbs in the process

Housing retention tabs
Housing retention tabs

Once that’s off you can pull off the gearbox (which itself comes apart very easily to reveal a set of three planetary gears):

Gearbox removal
Gearbox removal

Finally you can slide off the inner housing to reveal the motor itself and the small smoothing capacitor.

Internals
Internals

You can then see that the outer two cores (0V and 9V) are not connected to the motor internally. So, you control the motor by putting 9v on C1 and 0v on C2 to spin the motor anti-clockwise as seen from the outside, or alternatively put 0v on C1 and 9v on C2 to spin it clockwise as seen from the outside. To control the speed, apply a 0 to 9V PWM signal of the required duty cycle on the logic high control line. In terms of current draw, my M series motor pulls about 70mA when free running and up to about 500mA when I really load it hard. Bottom line – you need a controller circuit to run this, you can’t just hook it up to a micro-controller’s digital out lines.

Pre-assembled Test LEDs

Here’s a nice little idea I saw somewhere a while ago and have just got round to making. It’s just an LED in series with a 470Ω resistor connected to a pair of 0.1″ pitch posts. Whenever you need to quickly check a signal on a breadboard you can just plug one of these babies in and you’re done.20160220_065025

Baby’s First Scope

Much as I’d love to have a proper oscilloscope I’m wise enough to know that spending a couple of hundred quid on a cheapo version is probably a bad idea. This is a tool that warrants some significant investment. Or alternatively pretty much none.

I’ve just bought and built a little Jyetech DSO138 kit oscilloscope and whilst the specs are pretty pitiful, for £20 it’s a pretty good piece of kit.

Assembled Scope

The main features are as follows:

  • Analog bandwidth: 0 – 200KHz
  • Sampling rate: 1Msps max
  • Sensitivity: 10mV/Div – 5V/Div
  • Sensitivity error: < 5%
  • Vertical resolution: 12-bit
  • Timebase: 10us/Div – 500s/Div
  • Record length: 1024 points
  • Built-in 1KHz/3.3V test signal
  • Waveform frozen (HOLD) function available
  • Save/recall waveform

So, this thing is not going to cut it for high performance professional applications but if you’re learning electronics and playing with RC circuits and 555 timers then it’ll definitely get the job done for you.

Building the kit requires just basic soldering techniques but some of the parts are quite small, and there’s a lot of them, so it’s not a kit for a first time soldering experiment. It also comes in two flavours, one with the surface mount components already done and one where you need to solder them yourself. Surface mount soldering is a challenge so avoid this version if you’ve never done it before.

The Parts

While I could go into great detail about calibration and how well it responds and all that jazz, it frankly doesn’t matter. If you’re buying this kit, and you have any kind of common sense, you’re not looking for or expecting that level of sophistication. At the end of the day it lets you see reasonably robust, reasonably slow signals in reasonable situations. Job’s a good ‘un.