Electronic Speed Controller

When considering the idea of building a Quad Copter, I decided that I would like to build as much of the thing as possible. That would give opportunity for learning, and I've always wanted to design and make a PCB. Great!

This speed controller is going to drive a Dong Yang Servo D3536-11 brushless DC motor (as pictured) as I managed to source four with propellers for a decent price on eBay.

I did a lot of reading, and came across a few interesting articles, and stories. This document (authored by Ward Brown from Microchip) however takes the prize as the most useful thing I've found so far. Don't expect to understand it immediately if you're coming in fresh - I certainly didn't.

Having read around, and after a good long think about this, I decided to start working out the design of my circuit. I took a lot of 'inspiration' from the circuit on pages 29 and 30 of the Microchip document, my design isn't identical, but certainly bears some resemblance. Then again - how many ways can you wire up a set of push-pull MOSFETs?

Simulating the Circuit

Whilst designing the circuit, I kept a simulator close at hand. I found this simulator by Paul Falstad to be really great and very helpful.

Designing the Circuit

Requirements

My speed controller has some key requirements:

  • Small, Simple & lightweight
    This is partly a 'wait and see' requirement... But to keep weight down I can remove as many components as possible.
  • Have a familiar microcontroller
    Over the years I have become very familiar with Atmel's line of 8-bit AVRs, so I'll probably use one of them.
  • Will eventually be driven by a 7.4v battery
    This raises an interesting question. My microcontroller will probably be running on 3.3v, which won't be enough to switch the MOSFETs correctly...
  • The motor's product page (that's all the documentation I have!) recommends a 50A ESC.
    The parts used by Mr. Microchip are rated for over 100A pulsed, which should be enough.

The Microcontroller

My familiarity with AVRs, and bad experience with PICs leads me directly to Atmel's site. I have used talent from the MSP430 range in the past, but found some things frustrating while developing for them. As I have everything I need to develop for an AVR processor, I think I will.

Key concerns are:

"What voltage does it run at?"
"Does it have an analog comparator?"
"Does it have a timer?"
"Does it have an interface? (e.g: SPI)"
"Does avr-gcc support the micro?"
"Does avrdude support it?"
"Can it be programmed with my buspirate?"
"Does EAGLE PCB have a part for it?"

The 'go-to' AVR is the ATMega328p. It's good, but it's also bit large, and does more than I need. I've used the ATTiny85 in the past, but its slim 8-pin figure doesn't give enough for this project. I have a small stash of ATTiny2313s laying around, but after careful consideration, I decided on the ATTiny26L.

The reason for this decision is partly... Because EAGLE PCB has the part. But partly because it has a far broader range on the timer's prescaler, and it also appears to have superior analog components which may well be important when measuring the back EMF.

Switching the MOSFETs

For MOSFETs to operate in a switching fashion, you must give a gate voltage close to the Drain, or Source. In very broad terms, a voltage in-between will cause the MOSFET to have an intermediate resistance, and will cause it to heat up. This is not what we want, and as the output of the microcontroller will likely be about 3.3v (compared to the battery's 7.4v), it is exactly what we are going to get - unless we do something about it.

What we can do, is use a transistor as a switch. Consider the following circuit, or have a play, use this and import this

So, the power rail is at 7.4v, and the 'In' is either 0v or 3.3v. When the input is 0v, the output will be 7.4v, and when the input is 3.3v, the output will be 0v (or close to it - 21.75mV in that simulation). We can get it closer to 0v by increasing the pullup resistor's value, or decreasing the gate resistor's value.