Go Down

Topic: Controlling an ESC (Read 52894 times) previous topic - next topic

ankur6ue

Oct 02, 2014, 06:44 pm Last Edit: Oct 02, 2014, 11:14 pm by ankur6ue Reason: 1
Like many Arduino users here , I've jumped on the quadcopter bandwagon and working on making one of my own. I got myself an Arduino Uno, Neewer A2212, 1000KV motors and HW30 ESC. I spent a couple of months learning how to program on the Arduino and made a self-balancing robot as my first project (blog on that coming soon).

I started working on building the quadcopter last week. The trickiest part so far has been learning how to use the ESC. I spent the whole day on this yesterday and finally figured it out. It's amazing how much misleading information there is out there about using ESCs. There is two page user manual available, and while it contains accurate information, it can be a bit hard to understand. So hopefully this article would be useful for you.

First off, a quick intro about what ESCs are and why they are needed. ESC stands for Electronic Speed Control. I'm using them to drive my brushless motors. Motors work due to the interaction of the magnetic field created by the current passing through the armature and the magnetic field of the permanent magnets mounted on the motor chassis. Regular motors have brushes that touch the contact points of a motors armature and feed current to the armature. These contacts points are laid out in such a way that as soon as the armature rotates to line up with the magnetic field of the permanent magnets, the contacts switch and the polarity of the current being fed to the armature coil reverses. This recreates the imbalance in the alignment of the magnetic fields leading to a continuous rotatory movement.  

Since there is physical contact involved between the brushes and the armature, regular motors are subject to electrical noise and wear over time. In a brushless motor, the moving parts are switched. The chassis is the rotor and armature the stator. Current is fed directly to the armature instead of through brushes. This architecture eliminates physical parts rubbing against each other leading to better durability, efficiency and precision. However these benefits don't come for free. In order to generate the rotating magnetic field necessary to create the rotation, brushless motors need to be fed a rotating electrical current. You can't just connect them to a battery and expect the rotor to start spinning. This is where ESCs come in.

The role of ESC is to act as electronic brushes. The ESC takes a DC input voltage and converts that into a rotating (cyclical) electric current. The cycle frequency depends upon the PWM input sent to the ESC from the controlling microprocessor. The min and max cycle frequency can be set by the user, and this process is called "arming" the ESC. For a beginner, all this terminology can be a bit daunting, so good to understand the basic concepts.

Note that I'm using the servo library to send inputs to the ESC, so when I say PWM, I mean the output from Servo.write().

Now the question is how to arm the ESC and this is the confusing part. At this point, everything I say will refer to the ESC I'm using - HW30, so while the general concepts might apply to other ESCs as well, the details might not. So be careful.

Before we learn how to arm an ESC, there is another concept called "throttle" to be familiar with. I suppose this originated from the use of ESCs in remote controlled small planes which used a radio controller "throttle" to adjust the speed of the propeller. For an Arduino user, this just means the pulse width of the PWM signal sent to the ESC. Setting the low and high throttle translates to setting the min/max RPM of your brushless motor.

Connecting the ESC to the motor and Arduino

Connecting the ESC to the motor and Arduino is already well covered in numerous article, so just refer to any of those. An important point to note that the communication between Arduino and the ESC is one directional. The Arduino sends PWM signals to the ESC, however the ESC has no way of send data back to the Arduino. There is no display device on the ESC either, so the only way left for the ESC to communicate back to the user is through beeps. These beeps can have different lengths and different time intervals between them. So knowing what different beeps mean is important for understanding which state the ESC is in.

Using ESCs

There are three main things you can do with the HW30 ESC
1.   Program it - this means settings such as low voltage protection, startup mode etc. For a complete list, see the attached user manual. I found the defaults ok for my purpose.
2.   Set the throttle range. You would likely have to do this once. Once the throttles are set, the values are persistent.
3.   Use the ESC


Setting the Throttle Range

The key steps are:
1.   Set the initial throttle position to high.

2.   Turn on the ESC. It is very important that ESC is getting a high signal on the PWM pin when it is turned on. In your code, you should send a high signal and the wait for user input so you have time to turn the ESC on. On turn on, the ESC will emit a 1-2-3 (3 tones of different frequencies in rapid succession).

3.   The ESC will emit a beep-beep tone, indicating that the high throttle range has been set

4.   As soon as your hear the beep-beep, send the low throttle signal. The ESC will respond by emitting several beeps (the number depends on the input voltage of the power supply connected to the ESC). These beeps will be followed by a long beep, indicating that the low point has been correctly set.

The key is to ensure that the Arduino is powered on and sending a high signal to the PWM pin connected to the ESC before the ESC is powered on. Otherwise the ESC will get a random signal as input and there is no telling what will happen. If you don't hear the beeps in the sequence mentioned here, figure out what's wrong before proceeding. Some common sources of error are:

-   Input voltage is not in the acceptable range (ESC will emit beep-beep with a time interval of about 1 sec)

-   PWM signal is abnormal (ESC will emit beeps with a time interval of about 2 sec)

For a full list of errors, see the manual.

Programming the ESC

If you need to change the default ESC settings, keep sending the high signal for about 5 seconds after you hear the two beeps corresponding to the ESC registering the high throttle signal. You'll hear a special tone indicating the ESC has entered the program mode. Upon entering the program mode, the ESC will emit different beeps corresponding to different settings. When you hear the beep corresponding to the setting you want to change, send a low PWM signal right away. The ESC will emit beeps corresponding to the options for that particular setting. As soon as you hear the option you want to set, send a high PWM signal. The ESC will emit a particular beep tone indicating that the new value for the setting has been registered. See the manual for details about different settings.

Using the ESC once the throttle range has been set

Just start the Arduino with a low PWM signal. Now turn the ESC on, so it sees a low PWM signal as the input. As you change the PWM signal to high, the motor should rotate faster.

Important Note: keep in mind that the load you put on the motor will have an impact on the max RPM that can be achieved. So for example when you connect the propeller to the brushless motor, the max RPM the motor can spin the propeller (for a given power being fed from your power supply) will be less than what the motor can achieve when not under load. So, the motor might top out before you move the throttle to the top position. Once the motor has topped out, moving the throttle higher will cause the motor to behave unpredictably. This is fundamentally because the ESC is sending a rotating electric current with a frequency dependent on the PWM input. However the capacity of the motor to respond to this rotating current is dependent on the input power and the load applied. So, a good practice is to set the high throttle to a position that the motor can achieve when subjected to the expected operating load. Otherwise, you'll be wasting part of your throttle range that the motor can't achieve.



Robin2

That looks useful.

When you use the term "PWM" I presume you are referring to the output produced by Servo.write().

If so it would be useful to say so to avoid confusion with the Arduino analogWrite() function which produces PWM for driving regular DC motors, for controlling the brightness of LEDs etc.

I know that, technically a servo is controlled with a PWM signal but it is unfortunate that there is not a different word to distinguish it from the output of analogWrite().

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

ankur6ue

Yes, that's correct. I mean the output produced by Servo.write() when I say PWM.

Robin2


Yes, that's correct. I mean the output produced by Servo.write() when I say PWM.


May I suggest that you modify your post to explain that on the first occasion where you use the term. All that would be needed would be ....... PWM (the output from Servo.write()) .....

...R
Two or three hours spent thinking and reading documentation solves most programming problems.


tylernt

Thanks for taking the time to write all that up. :)

To be more accurate though, Servos (and ESCs) use PPM, Pulse Position Modulation, not PWM.

MarkT


Thanks for taking the time to write all that up. :)

To be more accurate though, Servos (and ESCs) use PPM, Pulse Position Modulation, not PWM.

To be completely _untrue_ you mean.

Pulse width modulation encodes a signal as the width of a pulse, which is _exactly_
what servos and ESCs require.  850us to 2400us wide is the normal range of
pulse widths used.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

tylernt

Very well, let me rephrase my original statement: "Servos accept a de-multiplexed PPM signal, which is PWM of a very specific frequency and duty cycle".

ankur6ue

Please note that there is sample code attached. Feel free to download and let me know if you have any issues with it.

MarkT

You were confusing an RC link encoding with a servo control signal.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

RealSingh

when i connect power to esc it don't beep ??  should it beeps when power deliver to it or not ?
(without connect signal wire of esc to arduino)

some posts suggest that don't connect red signal (5V) wire of esc to arduino.

what should i do now ??

Robin2

some posts suggest that don't connect red signal (5V) wire of esc to arduino.

what should i do now ??
Without more information it is impossible to help.

Post a diagram showing how you have everything connected - especially your power supplies. A photo of a pencil sketch will be fine.

Post a link to the datasheet for the ESC you are using.

"red       (5v)" suggests to me that you are referring to a power wire, and not a signal wire.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

RealSingh

#12
Nov 06, 2014, 05:53 am Last Edit: Nov 06, 2014, 10:26 am by RealSingh
i order esc from this link

http://www.rcbazaar.com/products/806-avionic-20amp.aspx

esc manual link they provide

https://docs.google.com/a/rcbazaar.com/file/d/0B0zolo4QEjsHM0tSV3VpTUhBWU0/edit?pli=1

am asking about that red wire which is in red circle in photo

and my question above mention should esc emit beeps when connect to battery or not ??

(just connect to battery only , no controller circuit no receiver).

battery link......   http://www.rcbazaar.com/products/1266-wolfpack-2200mah-25c-111v.aspx
bldc motor.......   http://www.rcbazaar.com/products/1942-avionic-m182631-kv1800-micro-brushless-motor.aspx

Robin2

am asking about that red wire which is in red circle in photo

and my question above mention should esc emit beeps when connect to battery or not ??
The instruction manual says it should beep - who am I to say different?
Are you following the proper arming sequence?

And (as I thought) the photo clearly shows that the red wire is 5v and the signal wire is white.
Connect the white wire to the appropriate Arduino servo pin and the black wire to GND. Ignore the red wire.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

FlyingQuestionMark

Strange,  all the beeps and sounds have always come from my brushless motor.  I have never heard my speed controller beep.

Go Up