RC Remote Control to Lego® Power Functions™
by fulda in Circuits > Remote Control
3710 Views, 12 Favorites, 0 Comments
RC Remote Control to Lego® Power Functions™
Long time ago Lego created simple system of motors and servo for powering sets called Power Functions™. The system was very simple and powerful, with one significant issue. It use infrared communication from controller to motors. It mean, it is not possible to control devices outside during sunny days. As well distance is not very big.
From the other hand China bazaars offer lot of various, cheap and working remote controllers for RC toys. Usually operate at 2.4GHz radio frequency, very suitable for RC cars and similar toys.
Power Functions™ battery boxes and motors are still available on market, it is easy and logical step to convert RC radio signal to Power Functions.
Supplies
,Supplies:
- PCB Board (not sponsored, order where you like)
- Power function extension cable(s) (I'm using China bazaars like aliexpress)
- Electric parts
- PIC16F15313-I/SN
- TB6612FNG
- 78M05 SMD/TO252
- capacitors SMD 0805
- diode 1N4007 SMD minimelf
- some 2,45mm/0.1" pin headers (optional, you can solder wires directly)
Tools:
- Soldering iron
- Soldering tin
- Microchip PIC programmer (PicKit, Microchip Snap, etc)
Schematic Description
Schematic is very simple. It use small microcontroller (MCU) Microchip PIC16F15313 as main processing unit. Benefit of this controller is, that it is equipped by two CCP (Capture & Compare) units suitable for pulse measurement and four PWM (Pulse Width Modulation) units.
CCP units are configured for measure RC servo signal pulse width. (I assume everyone understand RC Servo Pulse. If not, search the web please.) Use of CCP unit make software much easier.
PWM units are used to create motor output signal. As per design of Power Functions, PWM signal can be presented on pin C1 or pin C2 of connector. It is easiest to utilize two PWM modules per motor, than switch one between pins.
Signal from MCU is amplified by motor driver TB6612FNG. That driver allow use of model power packs instead of Lego 9V batteries.
Energy from batteries can be used for powering RC radio receiver. To enable this functionality, PCB switch JP5 is present on board. Once closed (soldered together), energy from battery (stabilized by 78M05) is delivered back to receiver. Only one converter can power RC receiver at same time.
Downloads
Soldering PCB
First of all you need printed circuit board (PCB). As this instructable is not sponsored by any PCB manufacturer and I do not want to navigate you to any, because did bad experience with few of them, chose your own. (You can try to utilize PCBshopper to find your best).
Usual PCB manufacturer will ask you for gerber file. Standard gerber file is delivered as .ZIP file. Instructables page does not allow me to upload file with this extension. I can add only link to my page, where you can DOWNLOAD GERBER file. Board dimensions are 36,2 mm x 21,3mm (1.425" x 0.8375").
PCB is very simple with small amount of components. Component names are printed on board or can be seen on attached image. For some of you can be little complicated to solder motor driver TB6612FNG. It is more easy when you have PCB with good soldering mask. Normally I'm soldering this IC as first.
Device is designed that all components can be soldered before MCU is programed. MCU program can be uploaded later by using pin header X1. I'm normally not populating any pins to X1, just using pins from my programmer.
Lego Power Functions Plugs
As stated already, very good source for Lego Power Functions plugs are extension wires. In ideal case you need 2 of them, that you will cut by half. It mean, you will get 4 plugs on wires. You need 3 of them only. In case you will not use Lego battery box, you will need 2 of them only.
On the PCB are mark first pin by square soldering pad. This pin is positive voltage pin. If you are not sure, simply connect connector to battery and measure where positive voltage is present. Positive voltage is first pin, negative is fourth (last) pin.
Microcontroller Programming
For device programming use your preferred programming tools. I'm using PicKit3. That is easy and powerful tools. You have to connect power source (battery) to device and keep rest of connectors unplugged. Then connect programming device and upload program.
In attachment you can see few program versions. Version with source and compiled version. Source version is *.asm.txt as instructables does not support asm extension. Compiled version is *.hex.
Default program rc2lego is for two motors or for motor and lego power functions servo. When two motors are used, one is for drive and second for steering.
Version rc2lego_t is for "tank". It mean one motor for left and second for right. this version automatically mix channels for steering and for drive.
Version rc2lego_s is for "lights". It assume it is used for 3rd or upper channel and is used for turn on/off lego power functions lights.
Speed table is stored in SAF memory. You can modify speed curve during programming if neded.
Videos
Some videos for having more fun.