MQTT RC Controller


Having bought a cool second hand RC Monster truck which was missing the radio controller, I was left with two options: Pay for a new Controller and hope the rest of the radio gear still works, or replace the existing radio gear with a new DIY digital controller opening up the possibility for MQTT computer controlled RC toys. I'd like to think the answer is pretty obvious.

Controlling Servos

An ordinary RC Receiver consists of an interchangable crystal to set frequencies, an antenna, and some sockets to connect any Pulse-Width-Modulation (PWM) controlled devices. This might be to control motor speed, or, more commonly to control servos. In this context, we refer to Pulse-Position-Modulation (PPM), which is when a PPM signal is used to control position.

I found a useful article at rc-cam which talks about the kinda signal a servo is expecting to see.

DIY Controller

The original RC controller supported up to three channels, but there is no reason why a digital controller shouldn't support a whole load more. The PIC that I'm using actually supports on-board PWM, but with only up to two channels. If we want a general RC controller, this isn't enough (especially since long-term I hope to persuade my friend to let me connect this up to his 6-channel helicopter)!

Commercial RC Controllers are pretty small, so if we want to make something compatible with most RC Toys, we need something that will also fit in a pretty small space. For the moment though, we'll be working on breadboard, but we certainly want to minimise the components used.

For the comms, I bought a cheap AM transmitter / receiver pair from Maplin (Easy Radio AM433). These take TTL level Serial upto about 4800 baud. I could have used the bluetooth module that I have used on various other projects, but I decided a RC receiver would work better without the overhead of maintaining a connection oriented channel. Never-the-less, the bluetooth chip, or direct Serial cable could replace the AM transceiver.

The controller has a resolution of 255 steps, using a single byte payload.

Download the Source

The code below is a quite straight-forward interrupt based PWM controller written for Microchip PIC16F87X series microcontrollers.

ASM Source Code for PIC16F87X

Control application

As is traditional in my post-IBM days, the RC controller plugs into my MQTT microbroker, enabling many different control mechanisms to be plugged in very easily.

The first controller to be hooked up was the one which originally controlled Rusty. Using just the keyboard, this didn't give much resolution, but enabled control of the monster truck, also providing a feed for the wireless camera mounted.

I then wrote an MQTT Direct Input application, enabling me to use my Playstation Controller to Parrellel port hardware, and Psxpad software to controll the servos.


by Steven Lovegrove Jump to top