{"id":855,"date":"2013-04-23T00:23:36","date_gmt":"2013-04-22T22:23:36","guid":{"rendered":"http:\/\/majek.mamy.to\/?p=855"},"modified":"2018-03-18T00:15:45","modified_gmt":"2018-03-17T23:15:45","slug":"hobbyking-supersimple-hk-18a-and-simonk-firmware","status":"publish","type":"post","link":"https:\/\/majek.sh\/en\/hobbyking-supersimple-hk-18a-and-simonk-firmware\/","title":{"rendered":"HobbyKing SuperSimple HK-18A and SimonK firmware"},"content":{"rendered":"<p><\/p>\n<h1>Cheap and good ESC for Tricopter<\/h1>\n<p>ESCs are needed for every multirotor. Some are cheap, but dedicated to planes (slower response), some have extra features in firmware, but costs a little more.<\/p>\n<p>But thanks to <a href=\"https:\/\/github.com\/sim-\/tgy\" target=\"_blank\">SimonK and his firmware<\/a>, there is possibility to reprogram many of them. So, to build my <a href=\"https:\/\/majek.sh\/en\/tricopter\/\" title=\"Tricopter\">Tricopter<\/a> I decided to buy cheapest one available and reprogram it:<br \/>\n<a href=\"http:\/\/www.hobbyking.com\/hobbyking\/store\/uh_viewitem.asp?idproduct=6456&#038;aff=78124\" target=\"_blank\">HobbyKing SS Series 15-18A ESC<\/a><br \/>\n<a href=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-esc.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-esc-640x261.jpg\" alt=\"SuperSimple HK-18A ESC\" width=\"640\" height=\"261\" class=\"alignnone size-medium wp-image-864\" srcset=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-esc-640x261.jpg 640w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-esc-150x61.jpg 150w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-esc.jpg 1024w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>So, let&#8217;s modify it \ud83d\ude42<\/p>\n<h1>Hardware<\/h1>\n<p>In order to download new firmware you need some Atmel programmer (I use <a href=\"http:\/\/www.hobbyking.com\/hobbyking\/store\/uh_viewitem.asp?idproduct=21321&#038;aff=78124\" target=\"_blank\">USBasp from HobbyKing<\/a> but on eBay you should get better and cheaper version supporing both 3.3V and 5V logic levels). Also you need some real soldering skills, steady hand and possibly magnifying glass \ud83d\ude42<\/p>\n<p>At start: remove shrink-wrap from ESC. The best and safest place to cut it is on one side.<br \/>\n<a href=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-cut-shrink-wrap.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-cut-shrink-wrap-640x435.jpg\" alt=\"hk-18a cut shrink-wrap\" width=\"640\" height=\"435\" class=\"alignnone size-medium wp-image-868\" srcset=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-cut-shrink-wrap-640x435.jpg 640w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-cut-shrink-wrap-150x101.jpg 150w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-cut-shrink-wrap.jpg 1024w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>After getting shrink-wrap off, first surprise: I have probably new version of pcb because it looks a little different than on pictures from <a href=\"https:\/\/docs.google.com\/spreadsheet\/ccc?key=0AhR02IDNb7_MdEhfVjk3MkRHVzhKdjU1YzdBQkZZRlE#gid=0\" target=\"_blank\">list of supported ESCs<\/a>. But luckily it&#8217;s almost the same but with added programming pads:<br \/>\n<a href=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-programming-pads.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-programming-pads-350x480.jpg\" alt=\"hk-18a programming pads\" width=\"350\" height=\"480\" class=\"alignnone size-medium wp-image-870\" srcset=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-programming-pads-350x480.jpg 350w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-programming-pads-109x150.jpg 109w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-programming-pads.jpg 747w\" sizes=\"(max-width: 350px) 100vw, 350px\" \/><\/a><\/p>\n<p>As you can see on above picture there are 6 pads. But bad news is that some are clean and flat, and other one are with &#8216;balls&#8217; of tin (and on each ESC there were different combination of these). This makes difficult to make some programming connector to touch reliable to these pads.<br \/>\nSo, only soldering left for me.<br \/>\nTo solder without problems to such small pads I made &#8216;balls&#8217; of tin on all pads:<br \/>\n<a href=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-programming-pads-with-balls.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-programming-pads-with-balls-640x452.jpg\" alt=\"hk-18a programming pads with balls and pin description\" width=\"640\" height=\"452\" class=\"alignnone size-medium wp-image-872\" srcset=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-programming-pads-with-balls-640x452.jpg 640w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-programming-pads-with-balls-150x106.jpg 150w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-programming-pads-with-balls.jpg 772w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>Then I soldered header pin connector with very thin wires (Kynar wires, diameter 0.2mm\/AWG32). If you first tin end of this wire, then soldering it to the &#8216;balls&#8217; on pcb is easy (with magnifying glass \ud83d\ude42 ).<br \/>\n<a href=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-header.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-header-640x421.jpg\" alt=\"hk-18a with isp header\" width=\"640\" height=\"421\" class=\"alignnone size-medium wp-image-874\" srcset=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-header-640x421.jpg 640w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-header-150x98.jpg 150w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-header.jpg 1024w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>And just connect it to USBasp and program it!<br \/>\n<a href=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-and-usbasp.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-and-usbasp-572x480.jpg\" alt=\"hk-18a connected to USBasp\" width=\"572\" height=\"480\" class=\"alignnone size-medium wp-image-876\" srcset=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-and-usbasp-572x480.jpg 572w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-and-usbasp-150x125.jpg 150w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-and-usbasp.jpg 1024w\" sizes=\"(max-width: 572px) 100vw, 572px\" \/><\/a><\/p>\n<h1>Software<\/h1>\n<p>Of course you need software to flash it into ESC \ud83d\ude42<\/p>\n<h2>Getting it<\/h2>\n<p>I got it directly using:<\/p>\n<div class=\"codecolorer-container text railscasts\" style=\"overflow:auto;white-space:nowrap;width:550px;\"><div class=\"text codecolorer\">git clone https:\/\/github.com\/sim-\/tgy.git<\/div><\/div>\n<p>Then I modified <strong>tgy.asm<\/strong> to disable runtime calibration:<\/p>\n<div class=\"codecolorer-container text railscasts\" style=\"overflow:auto;white-space:nowrap;width:550px;\"><div class=\"text codecolorer\">.equ &nbsp; &nbsp;RC_CALIBRATION &nbsp;= 0 &nbsp; &nbsp; ; Support run-time calibration of min\/max pulse lengths<\/div><\/div>\n<p>In my opinion this is not needed for this ESC as it has quartz oscilator and will be controlled by MultiWii board instead of receiver.<\/p>\n<h2>Code compilation<\/h2>\n<div class=\"codecolorer-container text railscasts\" style=\"overflow:auto;white-space:nowrap;width:550px;height:300px;\"><div class=\"text codecolorer\">tgy$ make tp_8khz.hex<br \/>\navra -fI -o tp_8khz.hex -D tp_8khz_esc -e tp_8khz.eeprom -d tp_8khz.obj tp_8khz.asm<br \/>\nAVRA: advanced AVR macro assembler Version 1.3.0 Build 1 (8 May 2010)<br \/>\nCopyright (C) 1998-2010. Check out README file for more info<br \/>\n&amp;nbsp;<br \/>\n&nbsp; &nbsp;AVRA is an open source assembler for Atmel AVR microcontroller family<br \/>\n&nbsp; &nbsp;It can be used as a replacement of 'AVRASM32.EXE' the original assembler<br \/>\n&nbsp; &nbsp;shipped with AVR Studio. We do not guarantee full compatibility for avra.<br \/>\n&amp;nbsp; <br \/>\n&nbsp; &nbsp;AVRA comes with NO WARRANTY, to the extent permitted by law.<br \/>\n&nbsp; &nbsp;You may redistribute copies of avra under the terms<br \/>\n&nbsp; &nbsp;of the GNU General Public License.<br \/>\n&nbsp; &nbsp;For more information about these matters, see the files named COPYING.<br \/>\n&amp;nbsp;<br \/>\nPass 1...<br \/>\nPass 2...<br \/>\ndone<br \/>\n&amp;nbsp;<br \/>\nUsed memory blocks:<br \/>\n&nbsp; &nbsp;Data &nbsp; &nbsp; &nbsp;: &nbsp;Start = 0x0060, End = 0x008C, Length = 0x002D<br \/>\n&nbsp; &nbsp;Code &nbsp; &nbsp; &nbsp;: &nbsp;Start = 0x0000, End = 0x03ED, Length = 0x03EE<br \/>\n&nbsp; &nbsp;Code &nbsp; &nbsp; &nbsp;: &nbsp;Start = 0x0E00, End = 0x0FDF, Length = 0x01E0<br \/>\n&nbsp; &nbsp;Code &nbsp; &nbsp; &nbsp;: &nbsp;Start = 0x0FE0, End = 0x0FFF, Length = 0x0020<br \/>\n&amp;nbsp;<br \/>\nAssembly complete with no errors.<br \/>\nSegment usage:<br \/>\n&nbsp; &nbsp;Code &nbsp; &nbsp; &nbsp;: &nbsp; &nbsp; &nbsp;1518 words (3036 bytes)<br \/>\n&nbsp; &nbsp;Data &nbsp; &nbsp; &nbsp;: &nbsp; &nbsp; &nbsp; &nbsp;45 bytes<br \/>\n&nbsp; &nbsp;EEPROM &nbsp; &nbsp;: &nbsp; &nbsp; &nbsp; &nbsp; 0 bytes<\/div><\/div>\n<p>If you don&#8217;t want or you are unable to compile this code, firmware compiled by me is <a href=\"https:\/\/majek.sh\/modele\/tp_8khz.hex\">here<\/a>.<\/p>\n<h2>Programming firmware<\/h2>\n<p>In this step you need Avrdude or other AVR programming software which allows to flash ready firmware in Intel Hex format.<\/p>\n<div class=\"codecolorer-container text railscasts\" style=\"overflow:auto;white-space:nowrap;width:550px;height:300px;\"><div class=\"text codecolorer\">tgy$ make program_usbasp_tp_8khz<br \/>\navrdude -c usbasp -B.5 -p m8 -U flash:w:tp_8khz.hex:i<br \/>\n&amp;nbsp; <br \/>\navrdude: set SCK frequency to 1500000 Hz<br \/>\navrdude: warning: cannot set sck period. please check for usbasp firmware update.<br \/>\navrdude: AVR device initialized and ready to accept instructions<br \/>\n&amp;nbsp;<br \/>\nReading | ################################################## | 100% 0.01s<br \/>\n&amp;nbsp;<br \/>\navrdude: Device signature = 0x1e9307<br \/>\navrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;To disable this feature, specify the -D option.<br \/>\navrdude: erasing chip<br \/>\navrdude: set SCK frequency to 1500000 Hz<br \/>\navrdude: warning: cannot set sck period. please check for usbasp firmware update.<br \/>\navrdude: reading input file &quot;tp_8khz.hex&quot;<br \/>\navrdude: writing flash (8192 bytes):<br \/>\n&amp;nbsp;<br \/>\nWriting | ################################################## | 100% 5.02s<br \/>\n&amp;nbsp;<br \/>\n&amp;nbsp;<br \/>\n&amp;nbsp;<br \/>\navrdude: 8192 bytes of flash written<br \/>\navrdude: verifying flash memory against tp_8khz.hex:<br \/>\navrdude: load data flash data from input file tp_8khz.hex:<br \/>\navrdude: input file tp_8khz.hex contains 8192 bytes<br \/>\navrdude: reading on-chip flash data:<br \/>\n&amp;nbsp;<br \/>\nReading | ################################################## | 100% 4.38s<br \/>\n&amp;nbsp;<br \/>\n&amp;nbsp;<br \/>\n&amp;nbsp;<br \/>\navrdude: verifying ...<br \/>\navrdude: 8192 bytes of flash verified<br \/>\n&amp;nbsp;<br \/>\navrdude: safemode: Fuses OK<br \/>\n&amp;nbsp;<br \/>\navrdude done. &nbsp;Thank you.<\/div><\/div>\n<h2>Bootloader<\/h2>\n<p>Above code contains a bootloader, so further reprogramming could be very easy and could be done using only BEC\/PPM connector. But for such programming you will need another device: <a href=\"http:\/\/www.hobbyking.com\/hobbyking\/store\/uh_viewitem.asp?idproduct=10628&#038;aff=78124\" target=\"_blank\">Turnigy USB Linker<\/a> or you could do it yourself using Arduino board and <a href=\"https:\/\/github.com\/c---\/ArduinoUSBLinker\" target=\"_blank\">ArduinoUSBLinker<\/a> software.<\/p>\n<p>In order to bootloader works, it&#8217;s needed to change  BOOTSZ and BOOTRST bits, so new value of hfuse should be 0xca (or 0xc2 if eeprom should survive chip erase).<\/p>\n<div class=\"codecolorer-container text railscasts\" style=\"overflow:auto;white-space:nowrap;width:550px;height:300px;\"><div class=\"text codecolorer\">tgy$ avrdude -c usbasp -u -p m8 -U hfuse:w:0xca:m<br \/>\n&amp;nbsp;<br \/>\navrdude: warning: cannot set sck period. please check for usbasp firmware update.<br \/>\navrdude: AVR device initialized and ready to accept instructions<br \/>\n&amp;nbsp;<br \/>\nReading | ################################################## | 100% 0.01s<br \/>\n&amp;nbsp;<br \/>\navrdude: Device signature = 0x1e9307<br \/>\navrdude: reading input file &quot;0xca&quot;<br \/>\navrdude: writing hfuse (1 bytes):<br \/>\n&amp;nbsp;<br \/>\nWriting | ################################################## | 100% 0.00s<br \/>\n&amp;nbsp;<br \/>\navrdude: 1 bytes of hfuse written<br \/>\navrdude: verifying hfuse memory against 0xca:<br \/>\navrdude: load data hfuse data from input file 0xca:<br \/>\navrdude: input file 0xca contains 1 bytes<br \/>\navrdude: reading on-chip hfuse data:<br \/>\n&amp;nbsp;<br \/>\nReading | ################################################## | 100% 0.00s<br \/>\n&amp;nbsp;<br \/>\navrdude: verifying ...<br \/>\navrdude: 1 bytes of hfuse verified<br \/>\n&amp;nbsp;<br \/>\navrdude done. &nbsp;Thank you.<\/div><\/div>\n<h1>Testing<\/h1>\n<p>I recommend to connect ESC to battery first time using 10 Ohm resistor (few Watts recommended). It&#8217;s value is small enough to allow motor start and run, but it&#8217;s also large enough that any software or hardware malfunction couldn&#8217;t burn your ESC.<br \/>\n<a href=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-testing.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-testing-640x291.jpg\" alt=\"modified hk-18a - testing via resistor\" width=\"640\" height=\"291\" class=\"alignnone size-medium wp-image-886\" srcset=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-testing-640x291.jpg 640w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-testing-150x68.jpg 150w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/04\/hk-18a-testing-1024x466.jpg 1024w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>And on the end &#8211; small video with original and flashed ESCs with motors:<br \/>\n<iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/DHZ7Cb4SMUc\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Cheap and good ESC for Tricopter ESCs are needed for every multirotor. Some are cheap, but dedicated to planes (slower response), some have extra features in firmware, but costs a little more. But thanks to SimonK and his firmware, there <span class=\"excerpt-dots\">&hellip;<\/span> <a class=\"more-link\" href=\"https:\/\/majek.sh\/en\/hobbyking-supersimple-hk-18a-and-simonk-firmware\/\"><span class=\"more-msg\">Continue reading &rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[50,13,53,42,32],"_links":{"self":[{"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/posts\/855"}],"collection":[{"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/comments?post=855"}],"version-history":[{"count":47,"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/posts\/855\/revisions"}],"predecessor-version":[{"id":1740,"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/posts\/855\/revisions\/1740"}],"wp:attachment":[{"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/media?parent=855"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/categories?post=855"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/tags?post=855"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}