# How to convert a TowerPro 18A MAG8 (HH30A_V1.1) Electronic Speed Control (ESC) from PWM to I2C?

A while ago, I purchased four of these ESCs to use them for the control of brushless motors.

Now I need to know how to convert them from PWM to I2C.

I'm not a electrical engineer, so I don't know how to do this. I already searched the web, but I didn't find anything helpful. I usually get displayed confusing Forums or the versions of the controllers were different.

Any ideas how to modify them?

• What is an ESC? – AngryEE May 1 '12 at 19:20
• ESC – Marc May 1 '12 at 19:22
• Data sheet link, please. – Brian Carlton May 1 '12 at 19:52
• The only thing I can give you is this link. It's a really small "manual" of the 30a version. – Marc May 1 '12 at 20:06
• It's on this this list, but the things change so often that you'd have to do some reverse engineering to make sure your prospective firmware matches your hardware. Like Fake Name says, this is a tricky process unless you have good instructions for your exact model of controller. You might try asking on this forum thread though. – mng May 1 '12 at 20:07

The way I would approach this is not to modify the ESCs at all. That way leads to frustration.

You'll have much more luck by making an I2C -> PWM module. This is easier than is sounds. Firstly, a little about RC servo PWM

An RC servo expects to see a pulse about every 20 milliseconds (50 times per second). The length of this pulse tells it what angle to rotate to. A pulse of 0.9ms means +90º, while a pulse of 2.4ms means -90º.

The ESC input will expect the same type of input, but will interpret the pulses to mean something about motor power, rather than angle. Many ESCs allow you to calibrate them I.E. Explain to them which length pulses correspond to what motor power. Often you hold down a button to switch them into calibration mode, then move the joystick through a sequence of, pressing the button again after each movement.

All you need to find is a chip which can produce such a PWM signal, at the behest of I2C commands.

Well fancy that, such a chip exists: PCA9685. What's more, it actually has 16 output channels, so you can drive 16 of those ESCs! It can produce frequencies from 40Hz to 1000Hz, with a 12-bit resolution. That means you'll get at more than 8-bit resolution on the 0.9ms - 2.4ms range. With this chip, you'll be able to plug in servos, ESC, whatever into you 16 ports.

If you need help to get this working, just ask specific answerable questions on this forum, and we'll be happy to help.

Kevin mentioned that you could also do this with a microcontroller. Probably the easiest way to do this is with a PSoC3 from Cypress Semicondctor. The reason to choose these over most other microcontrollers out there are:

• You can easily have 4 PWM outputs. There aren't many MCUs with that many. In fact, I think you can have more than 50 PWM outputs if you want.
• Configuring it is insanely easy. Considerably easier than a PIC for example.
• The actual code would also be pretty simple.

Unlike most MCUs, you can basically choose whatever and however many peripherals you want from a huge list. You drag them into a schematic page, and wire them up however you want. In this case, the wiring is pretty simple:

Here I have created 8 PWM outputs. Configuring them is a breeze:

Here I am configuring one of them as follows:

• 16 bit resolution (this will give you more than 12-bits res for your application)
• Time period of 20ms
• An initial pulse width of 1.65ms

This setup means that as soon as the PSoC is powered on and the PWM modules are started, they will immediately produce the 0º signal.

• The PCA9685 is an LED controller optimized for LCD Red/Green/Blue/Amber (RGBA) color backlighting applications - It can probably do this, but it will need its own controller. This chip just transfers the programming need from the TowerPro controller to whatever's controlling the TowerPro. A more flexible solution would be a custom microntroller with I2C and PWM modules that could then emulate whatever I2C ESC you wanted. – Kevin Vermeer May 1 '12 at 21:44
• @KevinVermeer - Obviously it will need an I2C Master. That much was obvious from the question. – Rocketmagnet May 1 '12 at 21:51
• @KevinVermeer - OK, I've added some description of an easy MCU solution. – Rocketmagnet May 1 '12 at 22:13

Unless someone else out there has done this fir this specific ESC, or the spec-sheet for this ESC specifically mentions I2C compatibility, you're out of luck.

Basically, an ESC like this is composed of a microprocessor, together with a bunch of power MOSFETs and some assorted other devices.

In the cases where this has been done, it involves reprogramming the microprocessor with a firmware image that supports I2C communication.
In most cases, this involves writing a firmware version that supports I2C. (Unless the manufacturer has released the source-code for their firmware). It may also be possible to do this by porting a copy of the firmware from another similar ESC. Both options require considerable familiarity with embedded MCU programming, and motor control.

If there are I2C versions for a similar product, you will need to reverse-engineer the ESC enough that you can determine what was changed, and make the corresponding modifications to the firmware sources. Then, you need a programmer for whatever microprocessor this uses to get the firmware onto the IC.

Realistically, from your question, I think this may be a bit beyond your current capabilities.

I2C and the PWM modulation scheme used in common RC devices are very different beasts.

This is kind of one of those situations where you can say "If you don't know enough about working with MCUs that you have to ask the question, you don't really know enough to accomplish what you want to do."

If you want to learn, I would recommended starting out with a simple MCU, like an Arduino or similar. Once you are at the point where you are not using the Arduino IDE to write code for the Arduino, you could take another look at this project.

I think your best option would be to try to make something that outputs a Servo PWM pulse-train, and is controlled over I2C. There may be things like this on the market, but I don't know the RC market that well.

• There are i2c and firmware modifications of this ESC, but the PCBs are different and the names are the same. (one example, but in german, sorry!) – Marc May 1 '12 at 20:03
• @Marc - If there are I2C versions for a similar product, you will need to reverse-engineer the ESC enough that you can determine what was changed, and make the corresponding modifications to the firmware sources. Then, you need a programmer for whatever microprocessor this uses to get the firmware onto the IC. – Connor Wolf May 1 '12 at 20:13
• Furthermore, from the forum you link (and google translate) there is a note: Update 1 (03/03/2009): The latest TowerPro 25A "Mag8" controller from Hobby City have no crystal-on-board, a completely different circuit than any previous, and therefore no existing firmware: At the moment, not recommended!. Considering I don't see a "crystal" on your ESC (it's actually a resonator, I blame the machine translation), I think you're SOL. – Connor Wolf May 1 '12 at 20:23
• @Marc, I think Fake Name's last suggestion is the best option. You can make your own device that sits in between and accepts I2C slave commands from a master controller to produce particular PWM duty cycles going to the ESC. – Jon L May 1 '12 at 21:30

Arduinos have built in PWM modes for many of the connector ports, and the basics are pretty easy to learn. Start here: arduino.cc

Whatever you have that's sending this I2C, can be received at your Arduino based PWM driver.

You can also send a PWM train to these ESCs using the Ardupilot shield with code from Github or ardupilot.com and a couple of different Arduinos 328, 2560 (that is if building a drone, car, or RCairplane is your objective). If this is your idea for 4 ESCs, then going with off the shelf goodies is a lot easier than learning to code Man-In-The-Loop control functions in C code.

Best of luck!