Thread Tools
Aug 02, 2013, 06:02 AM
Registered User
Thread OP
Mini-HowTo

Putting Arduino on an ESC to play with BLDCs


So because a lot of the cheap ESCs use the ATmega8 chip, I thought I'd try loading the Arduino bootloader onto it. The bootloader basically allows you to use the familiar Arduino programming environment and upload using a programmer.

I used a Hobbyking 20A BlueSeries ESC - the schematic for that can be found here: (although be warned a lot of the resistor values aren't correct)
Hobbyking 20A BlueSeries Schematic

Cross reference the names with the "Arduino" numbered pins to program them in Arduino:
ATmega8 pin mapping for Arduino

First - we need the drivers for the programmer. I used the AVR ISP mkii and the drivers windows installed do not work with Arduino. I had to force the device manager to update to the drivers found here:
AVR driver for Win7 with Arduino
unzip them and update drivers and browse to where you unzipped the drivers. they are unsigned but install anyway.

Now we need to tell Arduino how to talk to this board. Go to your Arduino install directory (...Program Files/Arduino/hardware/arduino) and open boards.txt with a text editor (wordpad worked for me). Add this to the bottom of the file:
Code:
##############################################################

atmega8.name=Hobbyking ESC with ATmega8 @16MHz

atmega8.upload.protocol=arduino
atmega8.upload.maximum_size=7168
atmega8.upload.speed=19200

atmega8.bootloader.low_fuses=0x3f
atmega8.bootloader.high_fuses=0xd7
atmega8.bootloader.path=atmega8
atmega8.bootloader.file=ATmegaBOOT-prod-firmware-2009-11-07.hex
atmega8.bootloader.unlock_bits=0x3F
atmega8.bootloader.lock_bits=0x0F

atmega8.build.mcu=atmega8
atmega8.build.f_cpu=16000000L
atmega8.build.core=arduino
atmega8.build.variant=standard
**If you're using a different ESC you can name it whatever you want in the first line but you may need different fuse settings (the fuse values you put here get set with the bootloader). Check simonk's github files for fuse settings on different ESCs

Now next time you open Arduino you'll be able to go to Tools->Board-> and select this new board (I named it Hobbyking ESC with ATmega8 @16MHz).

Now we need to hook up the programming pins for the programmer. Use these two images to do that:
AVR Pinout
Hobbyking 20A blueseries programming pins
Other ATmega8 programming pinouts found here

In Arduino, You can then select the board from Tools->Board->Hobbyking ESC.....
And select the programmer from Tools->Programmer->(AVRISP mkII for me)

Now write the bootloader!
Tools->Burn Bootloader
After a few seconds it will be done.
**Keep in mind the AVRISP mkII does not power the chip, you need to have the ESC plugged into a supply or 3s or 4s battery while programming and the onboard regulator will do its thing.

Once the bootloader is on the chip you can't go back. But you can always load the simonk firmware later. But now you're ready to write Arduino programs!

To test, File->Examples->Basics->Blink and change the led pin from 13 to 2 (this is the signal pin on the servo lead for the hobbyking ESC. Other ESCs have different pinouts so be careful here
The line:
Code:
int led pin = 2;
You can find other pins using the

Then File->Upload Using Programmer
Plug in a resistor and LED into the servo lead and ground and see if it's working:


Be very careful when writing programs and making pins high and low. You need to understand BLDC operation and control. If you drive both FETs on one motor phase high at the same time you will short them and they will blow up. Use a bench power supply with limited current to prevent from destroying FETs

I'm playing with position control and microstepping BLDCs so this provides a nice, easy and cheap MCU and power stage to mess with. But you can also use this to understand BLDC speed or position control better because they are really cool! This is a very good guide on BLDC theory (make sure you read part 2 and 3 too!) :
http://elabz.com/brushless-dc-motor-with-arduino/
Sign up now
to remove ads between posts


Quick Reply
Message:


Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Discussion Arduino BLDC ESC enygmatronics Electric Power Systems 0 Jun 21, 2013 01:49 PM
Discussion How do I attach an ESC to a receiver with an ESC already on it? taudronis RC Flight Events 1 Apr 07, 2013 09:46 PM
Help! Noob question with esc and bldc motor monti73 Multirotor Drone Electronics 7 Jan 10, 2013 08:05 PM
Wanted Small cheap camera to put on an RC Car and possibly plane. TheBeastTamer FPV Equipment (FS/W) 1 Jan 04, 2013 06:48 PM
Mini-HowTo Connecting an ESC to an Arduino Skriptkid Multirotor Drone Talk 0 Jun 13, 2012 07:54 AM