Controling Lego DC motors


7 posts
by salimfadhley » Tue Jun 26, 2012 12:41 pm
Is there any hardware (either planned or currently for-sale) that will help me control regular lego technic motors from a Raspberry Pi?

Lego has a system called Mindstorms which uses very expensive 8bit microcontrollers which lack many features of a modern computer (e.g. networking, display). There's at least one mindstorms compatible shield for Arduino but that's almost as expensive as a Lego microcontroller.

Any suggestions?
Posts: 1
Joined: Tue Jun 26, 2012 12:37 pm
by specsdude » Sat Jun 30, 2012 9:36 pm
hi salim-

I'm also interested in this, because I have a large mindstorms collection which I'd like to incorporate into a Pi project. My approach would be to cut off the Lego connectors and hook up the leads to the GPIO - maybe not directly but through something like the Gertboard which would protect the Pi.

I have RCX motors, I think NXT motors may be a little more complicated...?

I actually have a Pi but haven't tried out the GPIO yet.
Arise! Arise, riders of Théoden! Spears shall be shaken, shields shall be splintered - a sword day, a red day, ere the sun rises! Ride now! Ride now! Ride! Ride to ruin, and the world's ending! Forth Éorlingas!
Posts: 52
Joined: Sat Jan 21, 2012 2:15 pm
Location: In a small English village, far from the eyes of Mordor
by SlyFox » Sun Jul 01, 2012 11:08 pm
This would be a great idea however they'res 2 versions of mindstorms that are non compatible with each other.

http://upload.wikimedia.org/wikipedia/commons/thumb/9/95/LegoMindstormsRCX.jpg/220px-LegoMindstormsRCX.jpg

http://cache.lego.com/upload/contentTemplating/Mindstorms2History/images/picB2F61C4781F076001DA7E229CE695D81.jpg

i guess the same principle follows them both, but im not sure on how they worked for sure seen as i was a kid when i had it but ive always thought it was to do with the direction of current on them causing the motors to go the direction.

is the pi even strong enough to do that on top of running the os? the older version (yellow) took 8 AA batteries which suggests to run all the motors might cause it to be power hungry
Posts: 2
Joined: Sun Jul 01, 2012 7:17 pm
by specsdude » Tue Jul 03, 2012 9:05 pm
This would be a great idea however they'res 2 versions of mindstorms that are non compatible with each other.


Yes, they're most likely not compatible with each other, but I'm sure you could use them both together on the Pi, just using different connections/protocols.

is the pi even strong enough to do that on top of running the os? the older version (yellow) took 8 AA batteries which suggests to run all the motors might cause it to be power hungry


The way to do it would be to use a GPIO expansion board, which is has its own power supply. All the Pi has to do is control.

Tomorrow I'll start testing the Rpi.GPIO Python module with some LEDs.
Arise! Arise, riders of Théoden! Spears shall be shaken, shields shall be splintered - a sword day, a red day, ere the sun rises! Ride now! Ride now! Ride! Ride to ruin, and the world's ending! Forth Éorlingas!
Posts: 52
Joined: Sat Jan 21, 2012 2:15 pm
Location: In a small English village, far from the eyes of Mordor
by exartemarte » Tue Jul 03, 2012 10:02 pm
I don't know anything about NXT, except that I think the motors have encoders built in.

The older RCX-style motors are straightforward 9V geared dc motors which will need a motor driver, such as the L293D or equivalent, and a suitable supply. I wouldn't advise connecting a motor driver to the Pi gpio, though, unless you're very sure about what you're doing - a wrong connection could feed 9V to the Pi with possibly disastrous results. Better to wait for a buffer board that will protect the Pi if you make a mistake.

I'm fairly sure the contact sensors are just microswitches - so that will be the same as connecting push-buttons, as in the online tutorials.

The powered RCX sensors, such as the light sensors, are more complicated. They use a two-wire connection and the controller has to alternate between feeding power to them and taking readings from them, and presumably there will be timing issues. You can't just connect them up to an analogue port.
User avatar
Posts: 308
Joined: Sat Mar 03, 2012 3:51 pm
Location: Middle England
by dexterindustries » Wed Apr 10, 2013 1:39 am
This is a project we started working on with LEGO motors and sensors. It's not totally complete, but the hardware and firmware is complete (we could use some more work cleaning up our python code). This connects the LEGO motors and sensors to the Raspberry Pi.

http://www.dexterindustries.com/BrickPi/introduction/

We've got a repository up on Github for this project, including the hardware designs in Eagle. These should give pointers on how to hook up the motors and sensors to the Raspberry Pi.
John Cole
Dexter Industries
Code: Select all
www.dexterindustries.com
User avatar
Posts: 23
Joined: Thu Mar 07, 2013 3:51 am
Location: Somwhere
by dexterindustries » Sat May 11, 2013 7:23 am
And the most recent update: we've launched a Kickstarter campaign for our project here:

http://www.kickstarter.com/projects/john-cole/brickpi-lego-bricks-with-a-raspberry-pi-brain/

Image
John Cole
Dexter Industries
Code: Select all
www.dexterindustries.com
User avatar
Posts: 23
Joined: Thu Mar 07, 2013 3:51 am
Location: Somwhere