Friday, September 16, 2011

Using your arduino to program a Turnigy 9X transmitter

I recently purchased a Turnigy 9x transmitter from Hobby King, with the full intention of upgrading the firmware. I had know (or thought) that it was possible to program AVR's using an arduino as the programmer, and being a cheapskate, I didn't bother to purchase one of the recommended programmers. I figured many people must have already done this and there would be some good guides out there. Well, I was wrong. There are some excellent guides on programming the radio with standard hardware, but none using the arduino. That's where this guide comes in. It's meant as a supplement to other guides.

Turn your arduino into an AVRISP programmer
This one is pretty simple. Go to the arduino software, and find the example “arduinoISP”. Open the sketch and upload it to your arduino. See the arduino page for more info.

Attach cable to TX
Open your transmitter, and identify the solder points. There are six of them, and you can refer to other guides if you are unsure. I used a 5S1P lipo connector because it has 6 conductors and I had one lying around. It works pretty slick. I didn't bother to label anything at this point. Just soldered one wire to each point.





Attach test leads
On the other end of the cable, plug in the male portion of the plug with bare pins on the back side. Cut 3 test leads in half and soldered all six pieces to each of the six bare posts. Now with a multimeter, match-up and label each test lead with its corresponding point on the PCB. Label them according to this picture.




Prepare arduino
Connect all the test leads to the arduino using the pin assignments from the sketch. It should be as follows:

// 10: slave reset
// 11: MOSI
// 12: MISO
// 13: SCK

Connect the gnd and +5V to the power block on the arduino, and tripe check that you have the polarity correct.



Disable auto reset
Some arduinos (including my Duemilanove) have an auto reset function that needs to be disabled. To do this, place a 120 Ohm resistor between +5 and reset. The instructions are here.

Prepare eePe
In the eePe software, burn->configure and select the AVRISP programmer from the list. Assuming your radio is like mine, set the processor to m64, and set your port to whatever your arduino uses. In the extra arguments line, put “-b 19200”

Program the radio
You should be good to go. Follow the other guides for programming from here. I suggest you back-up your flash memory first, and all that.

17 comments:

  1. Hi
    thanks for posting this info
    what do you think, will it work with ArduinoMini
    http://www.arduino.cc/en/Main/ArduinoBoardProMini

    Regards
    Victor

    ReplyDelete
  2. I'm wondering the same thing. I would think it would, but that's just a guess.

    ReplyDelete
  3. I haven't tried it, but there is no reason why it shouldn't work the same.

    ReplyDelete
  4. Thank a lot for posting this info,
    I also tried with my arduino nano
    and it is working. Now I have new firmware on my TX. But sometimes you have to press reset on the board to write a new flash, and also I failed to write eeprom...

    ReplyDelete
  5. I'm also unable to program the EEPROM. I never did get that working.

    ReplyDelete
  6. I need help. I'm trying to use my arduino Uno, but I always get "programmer is out of sync" when I try to write the firmware. I can read fine.

    ReplyDelete
    Replies
    1. It could be an number of problems. If you've already triple-checked all the connections, just make sure you have disabled auto reset and changed the communication speed (-b 19200).

      Delete
    2. I got it working in the end. Turns out that the new version of Arduino IDE (version 1.0) is seriously bugged. When I compiled/uploaded the ArduinoISP sketch with version 0022, it worked perfectly.

      Delete
  7. I was using arduino nano with sw v101 . I have flashed two TX with er 9x. But I couldn't read or write the memory. The answer was find by Greebo.
    www.9xforums.com/forum/viewtopic.php?f=10&t=1057&start=30

    You will have to modify the isp sketch a little bit.

    Start Arduino IDE 1.01 and load up the Examples -> ArduinoISP sketch, search for the two places (one in the eeprom_write and the other in the eeprom_read) which look like:

    // here is a word address, get the byte address
    int start = here * 2;


    Change it to


    // here is a word address, get the byte address
    int start = here ;

    I have tested and out works perfect.

    ReplyDelete
  8. I was trying to do the same thing but ArduinoISP was failing to either read or write flash, everything else seemed to work. I found your post and and followed the auto-reset disabling instructions but that didn't change anything, so it seems like with some Arduino Duemilanove models this doesn't make any difference. I was still getting a "avrdude: stk500_getsync(): not in sync: resp=0x15" at the moment it was starting to write to flash.

    I ended up using my $4.30 Launchpad board with the "Launchprog" programmer (similar to ArduinoISP but uses the avr910 protocol instead of avrisp) and managed to write to flash. Only it's a million times slower than ArduinoISP, crashes and you have to replug the usb cable after every programming.

    ReplyDelete
  9. Thankyou worked perfect on my arduino nano v3 168

    ReplyDelete
  10. Is the TX supposed to turn off when being programmed? Mine beeps like crazy and the screen changes like the buttons are being mashed. Does this indicate a solder bridge somewhere? I also get Device signature = 0x000000 when using avrdude, am I not connected to the avr programmer or the TX? I verified the solder connections using a multimeter between the wires and the Atmel chip's legs.

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
  11. It works for me Arduino UNO - IDE 1.01
    Doesn't work with IDE 1.05

    ReplyDelete
  12. It works for me Arduino Duemillenove - IDE 1.5.5 ("int start = here * 2;" patch applied), Capacitor 330uf/16V between reset and ground. Certainly no battery on 9x (v2) . Companion9x settings: avirisp programmer, -P com11 (or whatever port arduino is connected) -b 19200.

    ReplyDelete
  13. Yes, it is works with arduino nano and 1.0.5 without problem!!! Thanks!!!!

    ReplyDelete