Building a brushless motor controller around an ATmega chip

You know when you see something like this it’s just going to be awesome, and we weren’t disappointed by our first impression. [Davide Gironi] built a brushless motor controller from the ground up using an ATmega8 as the brain. If you want to understand every aspect of a subject this is how to do it. Lucky for us he explains what each portion of the prototype does.

Brushless motors have no brushes in them (duh). But what does that really mean? In order to spin the motor a very carefully crafted signal is sent through the motor coils in the stationary portion (called the stator), producing a magnetic field that pushes against permanent magnets in the rotor. A big part of crafting that signal is knowing the position of the rotor. This is often accomplished with Hall Effect sensors, but can also be performed without them by measuring the back EMF in the coils not currently being driven. The AVR-GCC compatible library which [Davide] put together can be tweaked to work with either setup.

Get a good look at the system in action after the break.

[via Dangerous Prototypes]

17 thoughts on “Building a brushless motor controller around an ATmega chip

  1. Surely that isn’t a Floppy drive motor? Looks nothing like a CD-ROM motor.

    Nice build by the way, albeit a bit overkill for such a small motor. Would it be possible to use the motor-driver chip/circuit that originally drove it be controlled with the ATmega intsead? (I know that probably wasn’t the intent of the project though)

    1. Now that you tell me.. i Can’t remember where it comes from, t could also be a floppy drive :)
      Anyway, you have to use a mosfet driver circuit, even for small motors, event if small they usually suck more than the current that ATmega can driver.

      1. Many ESCs uses LPF to process the PWM input. The LPF input is there to protect motors with gears. However on the multicopters ones needs sharp fast response. To workaround this problem you can use 400Hz signal (The data is fortunately processed over certain amount of samples, not over time) but is better having no LPF at all.
        And if you can get to TWI or SPI pins then you can have digital input with custom firmware.

    1. I’ve checked SimonK and other open source projects running on ATmega. Most of those are made for RC stuff. I’ve find it difficult to modify that code, to add a rotation direction and a speed controller, that’s the reason why i’ve developed my code, and even for educational purpose :)
      SimonK code is very optimized, mine not, and it will be the choice if i’ve to run motors with high speed / efficiency requirements.

  2. I have previously struggled with BLDC motor control, having resorted to using some of the DRV range of driver IC’s from TI to eventually make things turn.

    I’ll be giving his code a look, especially if it does a decent job of position sensing through back-EMF detection.

    Once you’ve had a hard drive spindle motor spinning (sans-original controller), you’ll never go back to brushed ;)

  3. can you please post the schematic and code of your circuit?
    and I have a question about hall sensors,if I want to build my own ESC, are the hall sensors already built in bldc motors of quadcopters or I have to get them and place them myself?
    Thanks in advance! =]

    1. It depends on the power stage of the circuit, this one it is built using IRF640, so i suppose it can drive 15A without problems, but i’ve never try with more than 5A @ 24V motors, so you have to investigate it more. Also keep in mind that this firmware does not implement PWM, a better firmware should implement it. As soon as i had spare time, i will build a new one with PWM and analog comparer instead of ADC readings.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.