Introduction: ESC Programming on Arduino (Hobbyking ESC)

Hey there,


I'm going to show you how to program and use a Hobbyking ESC. I just found a few information and tutorials which really didn't help me very much. So I decided to program an own sketch, which is very easy to understand.


Good to know:

* ESC stands for Electronic Speed control

* The ESC has a 5 V (not used), GND and Signal pin like a servo

* You control it like a servo with write() http://arduino.cc/de/Reference/ServoWrite or writeMicroseconds http://arduino.cc/de/Reference/ServoWriteMicroseconds

Step 1: Receiving ESC Information

You should pay attention to the ampere value of your ESC. In this tutorial a 20 A ESC is used:

http://www.hobbyking.com/hobbyking/store/__15202__hobby_king_20a_esc_3a_ubec.html


I can't really promise that this is working with any other ESC but i think so, because in the english manual 20 and 30 A ESC's are described. In the German version you find a generalization from 10 to 120 A, that's why I think this could work for every other ESC.


Source:

German: http://tom-620.bplaced.net/rc_modelle/zubehoer/regler/hobby_king/hk_80A_regler_deutsch.pdf

English: http://www.hobbyking.com/hobbyking/store/uploads/811103388X7478X20.pdf

Step 2: Arduino Connection

I tried it with an arduino uno R3. I guess it should also be possible with other arduino models like Duemilanove or Mega.


First you have to connect the ESC to your battery. Next, connect the ESC like so:


* Black to GND

* White/Yellow to PIN 9



The ESC is now on, which is why it is important that you DON'T connect the red wire to your 5V Port, because it could destroy your computer's USB Port.


On this picture you can see the correct connection between ESC and Arduino (Mega).


Picture source: http://1.bp.blogspot.com/-eqDaRgO5FjU/T9U3avwT2-I/AAAAAAAAALE/-8pj4qD12Q0/s1600/Figure2_2_edit.jpg

Step 3: The Sketch

Just copy and paste this Code to your IDE:







/*

Coded by Marjan Olesch

Sketch from Insctructables.com

*/

#include <Servo.h>



int value = 0; // initialize the variables you need


Servo firstESC, secondESC; // you can control 2 or more servos simultaneously


void setup() {


 firstESC.attach(9);   // attached to pin 9

 Serial.begin(9600);   // start serial at 9600 baud


}


void loop() {


//First connect your ESC WITHOUT arming. Then open the serial and follow the instructions.


 firstESC.writeMicroseconds(value);


 if(Serial.available()) 

   value = Serial.parseInt();   // parse an integer from serial


}

Step 4: Understanding and Programming an ESC

ESCs are programmable. You just don't need a language to program them, but simple interactions via the serial. The ESC communicates with sound codes.


To open the menu (which runs infinitely) you just have to do following Steps:


* Connect your ESC

* Adapt the code for all ESCs you need to configure

* You should hear nothing at the beginning, because the Arduino sends a zero

* Open your serial monitor and send '2000'. it's the highest Signal the ESC can receive

* You will hear the sounds described on the picture ( Source: Manual: http://www.hobbyking.com/hobbyking/store/uploads/811103388X7478X20.pdf)



The Hobbyking ESCs can receive a signal between 700 and 2000 us. 700 means 'throttle at lowest position' and 2000 'throttle on the highest position'.


Example:

- Write 2000 us

- Wait for 'D-D-D-D' to chose lipo as battery type

- As soon as the third 'D' appears write a 700 in your serial (delay compensation)

- The ESC will make a sound to confirm that the option is picked




I hope i could help you with this tutorial.