Pages: [1]   Go Down
Author Topic: Lego powerfunctions library  (Read 1671 times)
0 Members and 1 Guest are viewing this topic.
The Netherlands
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've made a library to control the lego powerfunctions receivers.
Its using IR so you only need a arduino and a IR led.
A nice extra is you can do PWM control on the motors, the lego RC cant do that.

There is an example included with a program that emulates the RC from lego.

http://www.rjw.speedxs.nl/arduino/LEGOPowerFunctions.rar

Bare in mind, this is my first library so if you have suggestions, better code optimization tell me smiley
Logged

The Netherlands
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have made a update, removing some bugs.
I've also made a joystick from it.

http://www.rjw.speedxs.nl/arduino/front.jpg
http://www.rjw.speedxs.nl/arduino/print.jpg
http://www.rjw.speedxs.nl/arduino/inside.jpg
schema: http://www.rjw.speedxs.nl/arduino/arduino-joystick.bmp

To make the IR pulse i used the function: oscillationWrite from David Cuartielles
with a delay of 13us should make 38khz frequent.
But this is not the case, I've put it on a scope, and its about 28khz.
So i have lowered the timing to 9us.

« Last Edit: April 24, 2009, 06:40:45 am by SuperCow » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Tried your library and it worked on the first run. A few questions though, why didn't you use a timer to generate the signals for the IR-Led?
And could you give some comments on the LEGOPowerFunctions::message_pause, I don't understand where the calculations are for.

Thanks.

Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 74
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is a nice one!!! Thanks a lot, it will be great to control LEGO PF Trains etc.
Logged

Nowhere
Offline Offline
God Member
*****
Karma: 3
Posts: 852
|-\ |\|\
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Cool!  I ordered one of those speed control remotes, but it's backorded till next month.  (just the estimate, probably will come earlier)
Even when I recieve it, I could still use the arduino.


Mindstorms cheap replacement?

Edit:  Just got it working to power remotely my EPD.  (Entirely pointless device)
It is a small device that fits on a desktop.  The powerfunctions battery powers 2 XL motors, which turn cranks, which pump lego pneumatic pumps, which activate lego pneumatic cylinders, which switch their own valves, moving up and down repeadedly.  It's a completely inefficient and convoluted way to get two rotating reciprocating motions from one device!
Now I just have to have the cylinders reverse the direction of the motors, making a huge cycle of pointlessness!
« Last Edit: March 15, 2010, 08:24:47 am by amacmullen14 » Logged

Soundcloud page: http://soundcloud.com/beefinator-2
Youtube channel: http://www.youtube.com/user/beefinator14
Old soundcloud page (ran out o

Pages: [1]   Go Up
Jump to: