Open Power Functions Receiver

Open Source Lego Receiver 8884

Open Source Lego Power Functions Receiver

Building the mini receiver-Lego PF Measurements

Open source LEGO Power Functions Receiver

This page is the home of the open source power functions receiver for LEGO Power Functions. Originally, I started out just wanting to make a receiver for the LEGO power functions remote, and thought it could be done in a month, and that I’d be happy ending up with a simple prototype. In the end, the protocol holds some nasty coding challenges, and I made my life very difficult by cramming a receiver with 4 outputs (2x PWM, 2x servo) in a 2x4x1 brick whereas the original receiver is 4x4x3 and features 2 outputs. Although I made this receiver VERY small, the code runs fine on a DIP microcontroller as well. You might even consider porting this code to another microcontroller, or change the code and read out the messages with an Arduino, or… or…. it’s open source!

Presentation Open Power Functions Receiver from Tinkerer on Vimeo.

 

Source Code

The source code is available here at bitbucket. If you want the hex file for the receiver, you’ll find it here. Do remember to program the fuse in the Attiny44a to disable the CLK/8 scaler.

*NOTE* Due to changing of the motor driver, the schematics are no longer up to date. I’ll update them soon.

The Gerber files and board / schematic (Eagle) for the receiver can be found here. If anyone is interested in a through-hole version drop me a line and I’ll see what I can do for you.
Schematic: PDF
Layout: PDF
Partlist:: See below

 LEGO Receiver – 6 times smaller, twice the outputs

Original 8884 receiver (right) with miniaturized open source receiver on the left

Jump to ‘build log’ for latest news

The purpose of this project is to add Lego Power Functions to more DIY Lego building products. When I saw the specification was published openly by LEGO, I felt the urge to do something with that info. I also found the ‘default’ LEGO receiver (8884) to be too bulky to build nice minifig scale projects. From my background as electronics engineer I felt the receiver could be made smaller. The ultimate goal would be to jam all necessary electronics in THE Lego Brick, being the 2×4 default brick. One of the sacrifices to reach this goal was to remove all connectors, and connect motors, power supply etcetera with soldered wires to the LEGO brick. For now, that is the status quo. The schematics and PCB files are open source and downloadable, so if you wish to create a new, larger form factor go ahead and please publish the results, if needed contact me and I’ll place the files on my site.

Open Lego Power Functions receiver features

  • Support of v1.2 Power Functions protocol
  • Channel selection by using tactile switch on side of brick; last channel used is remembered between power offs.
  • simultaneous servo and PWM output
  • 1000mA 5V regulator to provide power to servos (NXP NX1117C50)
  • Size: standard 2×4 LEGO brick
  • connections for external power supply, 4.5 to 16V
  • 2x 1400mA PWM output @ 14kHz (DRV8835 driver)
  • NO power down mode! (bug or feature?)

Will this be the end of the commercial LEGO receiver?

No way! This project is a hack in the sense that it shrinks the existing receiver by a factor 4 while adding functionality. The very nice LEGO connectors are not provided though, you’ll have to buy LEGO cables (8871 or 8886), cut, strip and solder them to use LEGO motors. I might think of a larger form factor in future to make this more convenient. In pricing, this is not a ‘cheaper’ alternative. Although part pricing is about half of the unit cost of  ’the’ LEGO receiver, you’ll still have to make a housing, buy the PCB and solder the components to the PCB.

So why is this still a good alternative? At first, you’ll be able to add LEGO power functions in a more aesthetically pleasing way. At second, you’ll get servo control (using micro servos, not the big LEGO servos). That way, you could use micro servos in your LEGO to get better steering options for boats, cars, maybe even planes? And although some VERY cool builds excists with RC LEGO on minifig scale, none of those can use a LEGO RC handheld unit. I can’t wait to see the first minifig scale car steered by a LEGO remote control. But that might just be me ;)

Schematic and Layout

*NOTE* updated schematic and layout will be published!

Schematic: PDF
Layout: PDF

Partlist

RefDes Value Pkg Farnell no.
IC1 Attiny44A SOIC14 1699397
IC3 NX1117CE50 SOT223 2057286
U$1 LB1948MC-AH MSOP10 2137871
U$2 TSOP4136 TO-92? 4913164
U$3 Sideswitch ? 1437640
C3,C4 100n 0805 1740665
C1,C2 4u7/16V Case A 1754083

 

Tested Remote Controls

8879 (dual jog) and 8885 (dual joystick) were tested and received OK. See ‘measurements’ section on description of protocols used by each transmitter.

Background info on internals

Note: this section is not interesting to you if you’re not interested in the hardware design. If you’re a non-ElectricalEngineer LEGO builder, please read on if you’re interested, but do not feel obliged to understand this.

  • The receiver uses a TSOP4136 infrared receiver. This is one of few receivers easily commercially available that has a minimum burst length of 6 cycles
  • The microcontroller is an AVR attiny44A. This device is small enough, and packs enough peripherals to program the protocol. The program is too large to fit in its smaller brother the attiny24A, but should be able to run in the attiny84A (not tested). Peripherals used: external interrupt, timer0, timer1, pin change interrupt, EEPROM. The servo connections are also used for programming through SPI. If DebugWire is used (requires AVR Dragon of JTAGICE), servos can remain connected, as this leaves the servo pins unused during programming / debugging. pins were mapped for convenience in layout, and minimum external connections while maintaining a full feature set
  • The motor driver is the DRV8835, a dual motor controller in an incredibly small housing. Earlier, I tried using another motor driver which crapped out on me each time the motor should start. This one performs better.

26 thoughts on “Open Power Functions Receiver

  1. Terje Akselsen says:

    Hi there :)
    Exciting project you have started with here.
    I’m an entusiast for trains, and especially Lego. My kid’s are now at an age that they also shows an intrests in this as well.
    We have now bought a few trains and a few tracks. For shifters I’ll use a computer to controll at the time 7 of them.
    I’m now also looking into a way to control the trains as well with the PC.
    Then I’ll need assebmle a way to communicate with the trains via IR.
    I was thinking of using USB IrDA to control the trains.
    Do you have any ideas for this ?

    Best Regards
    Terje Akselsen

    • admin says:

      Hey Terje,
      Nice to see someone enthousiastic already, I’m still building on this website, so please check back later. I do not have a remote control for LEGO trains myself, but a friend of mine used a PC with remote control box. He’s using the TIRA-2 from http://www.home-electro.com. Of course building something yourself with an Arduino or microcontroller could also be possible, you’ll probably only need a very limited set of commands.
      Have fun!

      • Cody says:

        That is exactly what I’m trying to do. I am trying to figure out if I can use my Arduino to control my LEGO Manas motors. I’ve found out that the Manas’ IR sensor is likely 76kHz. Do you have any suggestions for how I might figure out what the pulse width is and the timing?

        • admin says:

          Hello Cody,
          Interesting! I didn’t know the Manas sets existed at all. The easiest way is to open the transmitter and measure the pulses on the LED. You’d need an oscilloscope to do that. I’ll send you an e-mail to talk about the details!

  2. Thijs says:

    very nice! interesting demo video

  3. Tristan says:

    Very interesting.

    Would you be able to provide a PDF of the schematic, for those that don’t want the hassle of getting Eagle.

    With a bit extra work, I reckon you could fit that inside a battery box with a Li-Ion battery and the plug connector O/Ps.

    • admin says:

      Hello Tristan,
      I added a PDF of schematic and layout. I reckon I could fit that in a Li-Ion box, but that might also be done by someone else, since I’ve been spending many a free hour of the past half year ;) connecting the LEGO connectors might be done by cutting a LEGO extension cable in halves.

  4. suggestion for you says:

    Woah, great!
    I would like to buy a complete (assembled/tested) unit (I’m not into electronics).

    You may consider a “kickstarter.com” project funding or working for “hitechnic” or “mindsensors”.

    • admin says:

      Hello ‘suggestion for you’,
      I thought about commercializing this, but I guess the disclaimer in the PowerFunctions document kind of prevents this. Thanks for the tip of looking at hitechnic or mindsensors, I’ll contact them :)

  5. fabio says:

    Hi, this project is really great, I really like.
    I’m making a proportional radio control at 8 ch + two on-off.
    My problem is the size ………
    But we are moving with a radio system does not tie this to have no problems in public events and have infinite MODELS running simultaneously …

    https://www.youtube.com/watch?v=RtHb6GdubIY&feature=player_embedded

    Fabione

    • admin says:

      Hello Fabio,
      Thanks for your comment. I’ve been thinking about making a Infrared< ->RF converter tailored to power functions. That way you could maintain your current hardware. By the way, the Power Functions spec, and therefore my receiver, supports an extra address bit, therefore enabling 8 channels in total…

      • fabio says:

        Thanks for the fast response ..
        The big problem is that the transmitters lego there are only 4 channels …
        If we have to move several models simultaneously is impossible …
        I can send you my project, so tell me what you think??

        If you give me your email I will attach as soon as possible.

        FAbione

        • admin says:

          Hey Fabio,
          The extra receiver channels on PF are only available when you send a special command. I’ll be happy to take a look at you project, don’t know when exactly… info at hackvandedam . nl

  6. Saike says:

    Hi there! What do you think, is it possible to control the servo Lego set 9398 of the conventional receiver, such as this: http://www.hobbyking.com/hobbyking/store/__24899__Turnigy_4X_FHSS_2_4ghz_Transmitter_and_Reciever_Mode_1_.html ??? Lego servo has a four connectors, but this receiver has only three.

    • admin says:

      Hey Saike!
      Unfortunately, LEGO servo signals are not compatible with RC servos; your receiver generates servo signals as output (see http://www.seattlerobotics.org/guide/servos.html for a bit of explanation; the connector has ground, power, position signal), whereas LEGO receivers give power (9V, not 5V as servos need!), gnd, and 2 outputs with PWM signal. The output is a so-called full-bridge. Basically, the LEGO receiver drives the motor at a certain power (0-100% PWM control), and your receiver sets a position with a small power digital signal while providing power for the motor with 5V and GND.
      The new LEGO servos use the motor power signal to set the position. My receiver can drive ‘normal’ RC servos directly AND has a motor power output.
      If you’d still like to try this you’d need to convert the servo signals to PWM signals, and drive an H-bridge at 9V…

  7. Kai says:

    Hi,

    I would like to use you PCB with 2 of the original pf motors instead of others or servos. Is this sitll possible? I think so, but I’m not sure. And did you updated the schematics or is it still on your todo list? :-)
    Please contact me via email. Thanks

    Kai

    • admin says:

      Hello Kai,
      Yes, of course that’s possible! I’ve updated schematics and code, I’ll mail you for the details.

  8. John says:

    Hi,

    can you send me all necessary files so that I can order the PCB.

    Thanks

  9. Nuno Cardoso says:

    Hi,

    I need to teach my Raspberry Pi how to speak “Legolese”, that is, o emit IR messages so I can control my car. This makes it easier for me, no wire cutting, no risk on killing my pi, etc.

    Are you interested in creating an open source RC controller API ?

    • admin says:

      Sure!
      At this moment my ‘ip’ is concentrated around the receiving side, but I can help you; I’ll contact you by email

  10. Joel Finch says:

    I’ve always had problems fitting the standard power functions receiver into MOCs because it has the requirement of being visible, line-of-sight, to the controller.

    Have you considered a split system, where the channel selector and standard power connectors are on one unit, and the IR receiver is connected via a cable to a separate much smaller brick (or no brick at all)?

    • admin says:

      Hello Joel,
      Nope, never considered, but it’s a good point. You could very easily extend wires from the IR receiver and the switch to some kind of front panel.

  11. Samuel says:

    hello i cannot seem to find a schematic on the v1.0 reciever. i have(from motorized excavator)2 IR receivers (im hoping theyre v1.2 theyre date code is 34k1 and 35k1, though it doesnt matter much) im looking to modify them to a 1.8A ish circuit to handle a 11.1v LiPo with 2 PF XL motors. i believe if i can get a schematic i can reverse engineer it and give it a lil more substantial voltage and Amp capability. i have little skill when it comes to designing my own PCB and i am desiring help. this mod would eliminate all other PF errors like the XL cutoff and 2M motor whine. seeing as how PF v2 is amazing, there is no reason to hang on to these anymore. intending to make open source and fit in original package. thanks for help.

    • admin says:

      Sorry for the late answer; I’ll update somewhere the next months. Drop me an email at info at , and I’ll give you a preview ;)

  12. Rman_nl says:

    He Great job!. Ik wil met arduino over IR de lego PF motors bedienen. Welke Ir zender(led) kan ik gebruiken (ontvanger TSOP4136)? Weet jij ook waar de code daarvan is? Op Youtube staat een clip van iemand die dit al gedaan heeft maar helaas geen reactie.

    http://www.youtube.com/watch?v=hjmaHYJ3NY0

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>