HobbyKing.com New Products Flash Sale
Reply
Thread Tools
Old Sep 28, 2011, 04:23 PM
Nek
DIY O.G.
Nek's Avatar
French Polynesia, Windward Islands, Faaa
Joined Nov 2002
313 Posts
Mini-HowTo
RCTimer/Turnigy/Hobbywing ESC DIY Firmware Flashing


Thanks to the help of timecop (yes he can be nice as long as he is interested ) I managed to flash my RCTimer 10A and 30A ESC. The procedure should be the exact same for the 18A and 20A versions. I will have some of these ESC in a few days and will test. Only difference can be the programming pads order, we will get into that.

Also note that the procedure is most likely the same for the Turnigy Plush if they have the same chip and pads. Check it all with a multimeter before hand! More and more ESC have their pinouts posted in this topic and I will update the initial post with them.

Another note. timecop and I also had some RCT 10A that went poof after the reflash. Problem is discussed in the thread, don't really know if it has been fixed...

1- Required stuff:

- RCTimer or other Atmel chip compatible ESC stripped of it's shrink tube.

Check this list made by TomSn0w of all compatible ESCs with their specs and appropriate firmware file. Thanks a lot for this!

- An AVR USB programmer. I am using USBASP from Protostack. It is the exact same kind of programmer used when flashing a Turnigy 9X.
- A way to connect temporarily the programming pads of the ESC to the AVR programmer.

- The hex file for the firmware (.hex is the compiled firmware, you can compile your own if you want to as well):
1- Go there: https://github.com/sim-/tgy
2- Hit the download button on the top right
3- Right click and save as the tgy.hex file from the bottom on the popup. There are newer versions posted from time to time. I used the tgy.hex one, but newer ones could be better! [EDIT: tgy.hex is good for the rctimer ESC and other very classic hw copies with no external oscillator. Depending on your ESC you might want to ask in this thread if you are better off using another compiled .hex. nfet and bfet stuff is getting too technical for me still ^^]
- AVRDUDE or AVRStudio or what ever software you want to use to actually flash the firmware.

-ALTERNATE: Use the tool posted in this thread coded by catch15117, thanks a lot for this! (not really up to date)

-ALTERNATE2: Another tool posted in this thread by LazyZero, thanks a lot!

2- Step by Step:

- Identify the pads:

This is what my RCTimer 10A ESC looks like, the 30A one is pretty much the same, just bigger.



You can see the 6 programming pads on the bottom of the board in the flash of light

They are in this order, from left to right: RESET, VCC, GND, SCLK, MISO, MOSI

Looking at the RCTimer 30A ESC from the top you will see the same 6 pads, but the order is reversed it is from left to right: MOSI, MISO, SCLK, GND, VCC, RESET

ALWAYS double check with a multimeter in continuity check mode that each pad goes to the right "leg" of the Atmega8. You can look in the datasheet at the MLF top view on page 2 to know what pin is what. Note the round mark for chip orientation. Thanks to timecop, here is one all marked up!



If you post a new ESC picture with pins marked, please attach it to your post so that by looking at attachments in the thread I can find them faster and keep it updated. Thanks everyone!

Turnigy/Hobbywing 6A:



Turnigy 12A plush (tested by JussiH and works on tgy.hex) Thanks JussiH for the picture.



Turnigy/Hobbywing 25A:



Turnigy Red Brick 25A:



Thanks to pia32.

Mystery FM30A:



Thanks to flashervn for this one.

Mystery/HK blue series 12A:



Thanks to tomk7 for this one!

Mystery/HK blue series 20A:





Mystery/HK blue series 30A:



Thanks to bas10an for those! Second HK Blue series 20A is thanks to larsm!

HK blue series 40A:



eRC 45A:



Thanks to SeismicWave for these ones!

Red Brick 25A, thanks to pia32 for the picture. Flashed with tgy.hex



HobbyKing F-20A:





Thanks to adlerbak!

HobbyKing F-30A:



Thanks to finkbuilt!

HobbyKing F-60A:



Thanks to SeismicWave

DYS 30A:



Thanks to Dolby for these pics!

RCTimer 40A:



Thanks to adlerbak

HobbyKing SS non programable 30A:



Thanks to capt

- Connecting to the AVR programmer:

Here is how I did mine:



Simple headers for the connections to the AVR programmer. I used single strain wires from Radio Shack, but any kind of wires will do, just solder the metal part of a male header pin at the end so you have something stiff. A nice solder blob on twisted wires could do as well, but may make lining up very tricky, just find your way!

To hold the wires in place together I just used a big blob of hotglue. Also note that you WILL WANT to make those wires much longer than I did, no big deal but more length would have helped. Close up of my artistic work:



You can always solder the wires to the pads, but when you have 4+ ESC to do it is a pain!

This is how jonnyc67 did it:



You can find more info on this setup with pogo pins in his post in this topic.

Simonk also has a similar method using long board to board headers. More info and info in this post

- Getting the right software:

I got this link from timecop, never heard of that project but it is supposed to be the most up to date one: https://github.com/sim-/tgy. So hit download on the top right, and right click save as the tgy.hex file. This is the new firmware file. Thanks a lot to simonk for writing this! There could be newer versions of the compiled firmware (.hex files). [EDIT: tgy.hex is good for the rctimer ESC and other very classic hw copies with no external oscillator. Depending on your ESC you might want to ask in this thread if you are better off using another compiled .hex. nfet and bfet stuff is getting too technical for me still ^^]

I am using a command line software to program AVR stuff but I heard AVR Studio is a really nice GUI. I am on Mac OS X but AVRDUDE is multi platform, so I will base this howto on it.

Just looking it up on google I found this link: http://sourceforge.net/projects/winavr/ which should install AVRDUDE. This link has a tutorial on how to run it in command line.

For OS X go here: http://www.ladyada.net/learn/avr/setup-mac.html Option 1 for install is supposed to be easy and works.

Linux peeps, well you know what to do, go get the AVRDUDE sources and compile them This is how I installed it on OS X btw.

- Flashing:

The meat of things! Open up your terminal/cmd line client and navigate to the folder where you downloaded tgy.hex

Plug in your AVR Programmer into USB and now be VERY careful and press the stiff end of your wires onto the pins and keep em pressed down. This is where you will need a steady helping hand or some sort of plastic grips, vice, whatever, just find a way to keep those pins lined up and contacting the pads. If you are lined up right you will hear the initial beeps and then continuous beeping.

Now here are the AVRDUDE commands that need to be issued in the terminal while everything is connected. Quick rundown on the arguments. "-p m8" says that my chip is an Atmega8, "-c usbasp" is the programmer name, type "avrdude -c asdf" to have the list of the compatible programmers.

Code:
avrdude -c usbasp -p m8 -U flash:w:tgy.hex
You should get this readout in the terminal, disregard the sck warning, no idea what that is lol

Code:
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9307
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: current erase-rewrite cycle count is -50462977 (if being tracked)
avrdude: erasing chip
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file "tgy.hex"
avrdude: input file tgy.hex auto detected as Intel Hex
avrdude: writing flash (1482 bytes):

Writing | ################################################## | 100% 1.08s



avrdude: 1482 bytes of flash written
avrdude: verifying flash memory against tgy.hex:
avrdude: load data flash data from input file tgy.hex:
avrdude: input file tgy.hex auto detected as Intel Hex
avrdude: input file tgy.hex contains 1482 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.72s



avrdude: verifying ...
avrdude: 1482 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.
ESC will beep while it happens if the motors are still connected. ESC will be silent otherwise.


EDIT: Fuses don't need to be changed on the newer versions of the firmware, which is what you should be using.

The following is left for reference only, not needed anymore.

Quote:
These are the arguments to revert to stock fuses -U lfuse:w:0x2e:m -U hfuse:w:0xcf:m

I am leaving the following for information, not needed anymore.

Then you need to set the fuses, high and low:

Code:
avrdude -c usbasp -p m8 -U lfuse:w:0x84:m
Output:

Code:
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9307
avrdude: reading input file "0x84"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0x84:
avrdude: load data lfuse data from input file 0x84:
avrdude: input file 0x84 contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.
High Fuse:

Code:
avrdude -c usbasp -p m8 -U hfuse:w:0xd9:m
Output:

Code:
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9307
avrdude: reading input file "0xd9"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xd9:
avrdude: load data hfuse data from input file 0xd9:
avrdude: input file 0xd9 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.
Lift the pins up, you are done!

3- Quick Recap:

- Identify the right pins
- Make a connector to the AVR Programmer
- Install AVRDUDE and use this command for reflashing:

Code:
avrdude -c usbasp -p m8 -U flash:w:tgy.hex
Just did a quick test fly on my tri after the flash, and so far am loving it. Much more precise response it seems and the noise is 100% times softer.
Nek is offline Find More Posts by Nek
Last edited by Nek; May 02, 2012 at 02:00 AM.
Reply With Quote
Sign up now
to remove ads between posts
Old Sep 28, 2011, 04:31 PM
Registered User
jonnyc67's Avatar
Joined Jan 2008
235 Posts
Nice one Nek I may just have to give this a go - I've got 6 30A rctimer esc's, 6 20A esc's & 6 18A esc's to do for current projects - guess I'm going to make up something with pogo pins as I'll have a few to do..
jonnyc67 is offline Find More Posts by jonnyc67
Reply With Quote
Old Sep 28, 2011, 04:43 PM
Nek
DIY O.G.
Nek's Avatar
French Polynesia, Windward Islands, Faaa
Joined Nov 2002
313 Posts
Quote:
Originally Posted by jonnyc67 View Post
Nice one Nek I may just have to give this a go - I've got 6 30A rctimer esc's, 6 20A esc's & 6 18A esc's to do for current projects - guess I'm going to make up something with pogo pins as I'll have a few to do..
Good stuff!!! Try it on just enough to have a flying machine and see how you like it first. I haven't flown the firmware enough to have everyone commit, there is NO turning back

Also please post your pogo pin setup if you get to doing it that way
Nek is offline Find More Posts by Nek
Reply With Quote
Old Sep 28, 2011, 04:55 PM
Registered User
Joined Jun 2011
216 Posts
Care to tell us noobs what difference it'll make? I just re-flashed a Turnigy 9X and found it somewhat fun so perhaps...
Saneless is offline Find More Posts by Saneless
Reply With Quote
Old Sep 28, 2011, 05:28 PM
UAV Pilot
UndCon's Avatar
sweden
Joined May 2007
1,006 Posts
Good write-up. I have been thinking of this for a long time...but I changed timing instead. I do have a spare USBASP programmer (and 1 installed in my 9X radio)

I mainly use 18A's.

//UndCon
UndCon is offline Find More Posts by UndCon
Reply With Quote
Old Sep 28, 2011, 06:26 PM
Registered User
jonnyc67's Avatar
Joined Jan 2008
235 Posts
If it's similar to quax's old firmware, it seems to give fast pwm/better throttle response (as it cuts out some software filtering)than the standard firmware, provides better step resolution & removes any low battery cut off functionality. removes any card programmability though. I think it also hard sets the pwm response from 1000-2000 so you can't program for individual tx throttle endpoints... I'm sure TC will chip in at some pint to confirm/deny this
jonnyc67 is offline Find More Posts by jonnyc67
Reply With Quote
Old Sep 28, 2011, 07:20 PM
Registered User
jonnyc67's Avatar
Joined Jan 2008
235 Posts
P.s. I've got some pogo pins ordered - thought you might like the link...
http://www.ebay.co.uk/itm/10pc-P100-...ht_2256wt_1185
jonnyc67 is offline Find More Posts by jonnyc67
Reply With Quote
Old Sep 28, 2011, 08:06 PM
hacker
Canada, BC, North Vancouver
Joined Dec 2010
936 Posts
This tree is my attempt to simplify and improve quax' original code, and make it support multiple boards. There are some feature improvements now, and I've been hacking on it fairly heavily over the last month. See the commit history and README and stuff on github at https://github.com/sim-/tgy and https://github.com/sim-/tgy/commits/master/ . Some people have sent me motors and boards to test/fix weird corner cases, so hopefully it will turn into something that works well for everybody.

The main thing that pissed me off enough to start hacking on it was the 8kHz PWM frequency that Turnigy Plush boards were stuck with (causing the annoying audible whine), the clicking with lower kV motors, the screaming instead of proper restart if the motor is stopped while running, and the averaged throttle response instead of immediate input->output (with some timing-based limiting to avoid overcurrent, only at low speeds). All of these should be fixed or improved over the OEM firmware and quax' tree.

Keep in mind, this means it will totally break a helicopter that requires slow start and there is no battery protection or thermal shutdown; however, this is usually better than any other option on a multicopter. Actually, I thought maybe pulsing high/low PWM rate might be a useful audible indicator of one of these bad conditions, but haven't done that yet. Feedback, patches, pull requests (and free hardware) definitely welcome!

Oh, and for programming plush boards, I just use a long-pin 2x3 header (like about 1.5 inches long) that I bent to line up all to pins in a row, quite similar to how Nek did it with wires. It's springy yet strong enough to stand up to many uses. I started with wires first, but they were hard to keep straight enough. The header method is good enough that I have done it hundreds of times for testing, and the board looks untouched after, which is nicer than solder blobs and wires all over the place. pogo pins would certainly work, too!

Nek, did you make a new pinout for the RCtimer boards, then? If so, I can merge it into the tree as a new include file. Cheers!
simonk is offline Find More Posts by simonk
Reply With Quote
Old Sep 28, 2011, 08:28 PM
Suspended Account
Joined Dec 2010
11,763 Posts
RCTimer pinout is exactly same as tgy, as he just recommends downloading the precompiled .hex file - which I assume uses tgy.inc as-is. So it should be all good.
timecop is offline Find More Posts by timecop
Reply With Quote  (Disabled)
Old Sep 29, 2011, 02:25 AM
Nek
DIY O.G.
Nek's Avatar
French Polynesia, Windward Islands, Faaa
Joined Nov 2002
313 Posts
Quote:
Originally Posted by Saneless View Post
Care to tell us noobs what difference it'll make? I just re-flashed a Turnigy 9X and found it somewhat fun so perhaps...
From one noob to another all I know is that it doubles the speed of updates from the ESC to the motors and allows 8X faster communication with the flight controller.

Now I had a day of flying on them and man do they rock now! simonk thank you so much for that firmware! I added a good minute of flight, motors are cooler and the tricopter much more stable! Still have to tweak my PIDs more but am very very pleased with the results.

As timecop said I did not change the pinout. I checked most of them and they were spot on so I just went with the default compiled hex file.
Nek is offline Find More Posts by Nek
Reply With Quote
Old Sep 29, 2011, 03:58 AM
Droner
SebastianJ's Avatar
Denmark, Capital Region of Denmark, CPH
Joined Mar 2006
2,410 Posts
Very nice how-to, thanks.

However:

The photo of the ESC is missing.

You wrote "They are in this order, from right to left: MOSI, MISO, SCLK, GND, VCC, RESET"

SCLK? Looking at the Atmega8 datasheet there is SCL, SDA and SCK, do you mean SCL?

I urge everyone to post their findings regarding the order of these connections on various ESC's.

Nek, perhaps you'd like to update post #1 with the photos and connection order that we post here?




Sebastian
SebastianJ is offline Find More Posts by SebastianJ
Reply With Quote
Old Sep 29, 2011, 04:03 AM
Suspended Account
Joined Dec 2010
11,763 Posts
It's SCK. Also called SCLK. SCL is unrelated.

I hereby donate this diagram for the 1st post of the thread.
timecop is offline Find More Posts by timecop
Last edited by timecop; Sep 29, 2011 at 04:09 AM.
Reply With Quote  (Disabled)
Old Sep 29, 2011, 04:04 AM
Nek
DIY O.G.
Nek's Avatar
French Polynesia, Windward Islands, Faaa
Joined Nov 2002
313 Posts
Quote:
Originally Posted by bas10an View Post
Very nice how-to, thanks.

However:

The photo of the ESC is missing.

You wrote "They are in this order, from right to left: MOSI, MISO, SCLK, GND, VCC, RESET"

SCLK? Looking at the Atmega8 datasheet there is SCL, SDA and SCK, do you mean SCL?

I urge everyone to post their findings regarding the order of these connections on various ESC's.

Nek, perhaps you'd like to update post #1 with the photos and connection order that we post here?




Sebastian
Will sure do Sebastian. But unless my eyes are very tired I don't see any SCL or SDA pins on that diagram. SCLK is referring to SCK sorry if that was confusing. I don't know what is wrong with the ESC pictures, will re upload them!
Nek is offline Find More Posts by Nek
Last edited by Nek; Sep 29, 2011 at 04:06 AM. Reason: pictures should be fixed
Reply With Quote
Old Sep 29, 2011, 02:08 PM
hacker
Canada, BC, North Vancouver
Joined Dec 2010
936 Posts
The current tgy.hex is a build of 95471bfd from September 6th, which still used WGM20 phase-correct hardware PWM mode at intrc/510 Hz, which is just about 16kHz PWM. Not much has really changed since then that will affect flight. The only major bug fix was the all_pFET_off macro being screwed up, but it's probably OK for now. I won't upload a new tgy.hex until I've had a chance to test and make sure there are no timing issues with any of the newer commits; I haven't been tagging versions or anything yet, but just uploading mostly stable hex files after I test that they work and fly properly on my tricopter.

Cheers!
simonk is offline Find More Posts by simonk
Reply With Quote
Old Sep 30, 2011, 05:39 PM
Droner
SebastianJ's Avatar
Denmark, Capital Region of Denmark, CPH
Joined Mar 2006
2,410 Posts
Simon, consider doing a 200-1200ms (UltraPWM) version of the code and gain popularity with the Xaircraft users (poor guys).
SebastianJ is offline Find More Posts by SebastianJ
Reply With Quote
Reply


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Discussion Rctimer 30A esc cutting out with KK board Efliernz Multirotor Talk 2 May 26, 2011 03:20 PM
Sold FS: Tricopter Parts- HK401b, Pentium 30A ESC, rctimer 750kv motors pwu_1 Aircraft - General - Miscellaneous (FS/W) 2 Jan 18, 2011 10:58 PM
Sold RCTimer 2826-6 + ESC 30A New in packaging will trade as well Pics Added! planebldr Aircraft - Electric - Power Systems (FS/W) 4 May 25, 2010 10:54 PM
Discussion RCTimer 30A Programmable ESC hunter7193 Power Systems 8 Jan 02, 2010 03:27 PM
For Sale Several New ESC's - 10a, 20a, 30a - Reduced Callen9345 Aircraft - Electric - Power Systems (FS/W) 0 Apr 20, 2009 03:31 PM