Wednesday, April 2, 2014

Flashing HobbyKing 20A ESC with SimonK Firmware

Standard ESCs are designed for cars and aircraft for which it is undesirable for the speed of the motors to change rapidly.  As such, the firmware running on the ESC accounts for this by ramping motor speeds up or down smoothly regardless of how rapid the change in inputs from the transmitter.  It achieves this by averaging the input signal with the n previous input signals before acting upon it; such filtering necessarily introduces latency in the response of the vehicle.  This latency can, under certain conditions, cause the control system to become unstable.  For the case of a multicopter, we'd like the change in rotor speeds (and thus thrust) to be as fast as possible which will improve the responsiveness of the vehicle. 

Additionally, the standard firmware incorporates other functions which are useful for fixed wing aircraft and cars but could very well be detrimental to multicopters (like a low voltage cutoff - designed to protect your LiPo battery from damage - clearly we don't want the multicopter's motors to shut off mid-flight.)

In a process known as RapidESC, the standard ESC is converted, at no cost, into a high performance, highly responsive ESC suitable for multirotor applications.  Specifically,  we will use open source firmware designed for this process by the legendary Simon Kirby who is well-known throughout the RC multirotor community simply as SimonK.  In the case of the SimonK firmware, the ESC is reprogrammed to run at 400Hz rather than its original speed of 8Hz.  It does, however, continue to average the current input signal with the last n values (which will eliminate spikes in the input), but because the ESC is sampling the input signal 400 times a second instead of 8 times a second, any change in the throttle input will result in an almost immediate change in the RPMs and thus the thrust of the motors.  The video below demonstrates the difference in responsiveness of the control system between an ESC running the standard firmware versus one running SimonK.



So, in short, the idea here is that we'd like to replace the existing firmware on the ESC with the SimonK firmware using a process called "flashing".  It should be noted that this firmware is, in many cases, both brand-specific and model-specific so be sure to select the correct one.  Here is a database containing containing flashing information for various ESC's including which firmware version to use for a particular ESC.  Before beginning it is necessary to identify the RapidESC firmware version that is suitable for the particular ESC being flashed.

Here's what I used...

Hardware

  1. HobbyKing Blue Series 20A ESC
  2. USBasp Programming Device for ATMEL Processors
  3. ATMEL Atmega Socket Firmware Flashing Tool
  4. Exacto Knife 
Note that (2) and (3) are made specifically for ATMEL processors.  In order to flash ESCs that use a different processor (like Silabs) will require a different (but similar) programming tool and socket connector.

Software

  1. KKmulticopter Flash Tool
 This software was, in fact, developed to flash the KK2 flight controller with the latest firmware.  It, however, also allows one to quickly and simply flash one's ESC with the latest version of SimonK firmware which is a .hex file and which can be downloaded automatically from an online repository.  Additionally, this software tool will run on Windows, Mac or Linux (although Windows might first require the installation of a driver for the USB programming device).

Preparing the ESC for flashing

Before the ESC can be flashed, we need to to be able to access the ATMEL processor on the ESC so that an electrical connection can be made.  For this purpose, the shrink wrap covering must be removed.  Rather than removing the entire shrink wrap from the ESC and then having to re-wrap the ESC afterwards it is easier to simply cut an access window/flap.  Use the Exacto knife to cut the shrink wrap around the ATMEL processor, as shown in the picture, on three sides to create a flap that can be folded back.  This now provides direct access to the ATMEL's electrical terminals for the socket tool.

NOTE:  There are two ways to get the correct orientation of the ATMEL processor (which is square in shape).  The first way is to look at the writing on the ATMEL.  If the writing is correctly oriented, then so is the chip.  The second way is to look for the dot on the ATMEL (ie a  small round impression on the ATMEL's plastic casing).  This indicates the top left corner and the chip should be oriented accordingly. 


The socket tool generally has a red dot on one of the corners and the socket tool should be connected to the ATMEL so that the red dot is in the TOP LEFT CORNER - ie the same corner of the ATMEL that contains the circular dot - so we match the dot on the socket tool with the dot on the ATMEL.  If the socket tool does not contain a dot (or if it has since been erased) then look at the pin configuration on the socket tool and you will notice that 4 of the 6 electrical connections are concentrated near one of the corners.  This concentration of pins connects to the LOWER RIGHT HAND corner of the AMTEL chip.

Flashing the ESC with SimonK firmware in 5 simple steps (on my Mac)

  1. Download and install the KKmulticopter flash software (just use the latest stable version).
  2. Plug the USBasp programmer into the USB port and connect the socket tool to the programmer.
  3. Launch the KKmulticopter software set the following:
    1. For the programmer, select "Any usbasp clone with correct VID/PID".
    2. For the controller, select "atmega 8 based brushless ESC + enable Bootloader (8kb flash)".  NOTE:  Make sure to select the "enable bootloader" option.
    3. For the firmware (which will be downloaded from an online repository) select "BS N-FET V2014-03-06 by Simon Kirby" or whatever the most recent update is.  If you are unsure of which version of the firmware to use then take a look at this list.
  4. Connect the socket tool to the ATMEL IN THE CORRECT ORIENTATION and hold it in place with one hand.  The pins in the tool are spring-loaded so it is easy to keep the ATMEL connected by applying a bit of downward pressure on the socket tool.
  5. With the other hand, click "Flash Firmware".  Whole process takes about 10 seconds.  You are done when you see "Flashing of firmware was successful".
DO NOT DISCONNECT THE FLASHING TOOL TOO SOON OR YOU RUN THE RISK OF PERMANENTLY DAMAGING YOUR ESC.  If you happen to disconnect or are otherwise confronted with red writing (an error) then just repeat steps 4 and 5.

Now close the flap of shrink wrap so that it covers the ATMEL again and add a small piece of tape to keep it in place and you're done.  

Voila.

No comments:

Post a Comment