3D Robotics

How to program the Attiny on ArduPilot

To load the failsafe firmware on ArduPilot's Attiny chip, you need to do the following. 1) You'll need an ICSP AVR programmer. We recommend AVRSIP2. Connect the cable to the correct ICSP port on your board, as shown above. The red stripe on the cable should be on the same side of the connector as the square solder pad on the back of the board. (On our boards that means that the red strip is on the side closest to the processor) 2) Now you'll need to change (turn off) one of the default "fuse" settings in the Attiny45, which divides the internal clock by 8 so it only runs at 1 Mhz. (Explanation of all that and more about fuses are in the excellent Sparkfun tutorial here). Run the AVR Studio program that came with the AVRSIP2 programmer. Ensure that the board is powered on by connecting it to an ESC or other power source! The red LED on the board should be on. 3) To change the fuse with AVR Studio, connect the programmer and go to Tools/Program AVR/Connect. Choose AVRISP mkII. You may get an error (choose cancel). On the "Main" tab of the dialog, click the "Settings" button and pick 125khz and click "Write". Then make sure "Device" is Attiny45 and "Read signature". At the bottom it should say that all's okay. If so, switch to "Fuses" tab and uncheck CKDIV8. Press "Progam", then "Verify" to make sure it's woking. [Note for those who are curious: the AVR programmer can only work at 1/4 of the clock speed of the chip. The Attiny ships with a 8Mhz internal clock, but when that DIV8 fuse is set it's only running at 1Mhz, so the programmer must be running at less than 250khz. Once you clear that fuse and the chip is running at full speed, the programmer can run at 2Mhz, which is 1/4 of 8Mhz]. Your processor is working fine and ready to program. 4) Now you'll need to burn the firmware. Still in the AVR Studio dialog box you used above, go to the Program tab. Where it says "Flash", input our firmware hex file. If you've already downloaded it in some folder, you can select that here. If not, switch to your browser and download this file. Click "Program". All should go well and you'll see the OKs below. If you want to make sure it's working, you can click "Verify". Now you can go back to the "Main" tab and change the Settings to 2Mhz. That's it! The failsafe should be working now. Connect the CTRL lead to channel 5 or 6 of your RC receiver and power on the ArduPilot board. When you toggle that channel a red LED should go on and off on the ArduPilot board, indicating that control of the output channels is being switched from the RC receiver to the autopilot or vice versa. For extra fun, toggle it back and forth fast five times. That should reset the autopilot (for in-air recovery).
E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • Amoisonic: So the MUX light does not switch with the channel from the Rx? If so most likely you do indeed have the CKDIV8 fuse set. On mine it sets the MUX mode sometimes if I leave it powered on, or turn it off and on a few times.
    I've yet to program the ATTiny45 fuse but I assume that is the issue, will report back once I have the AVRISP cable made and tried it.
  • I have just received the board today and the date of shipment is 11th Feb 2009,but it looks like that the Attiny firmware problem still exists with the new stock.Red LED steady "ON",blue and yellow LEDs are flashing with pattern,but MUX LED is only flashed once when powered up.The MUX Control input has no effect to external PWM input.
  • @ Chris
    The LOCK LED worked when the board first arrived on first power up. After ardupilot code loaded, attiny45 fuse fixed, LOCK LED never restored itself. Either the LED is blown or the ardupilot is registering the GPS LOCK and therefore the code is hanging.I'm in the process of learning the program so i can debug. When I try to force pin 12 (LOCK LED) to go high on the GPS parser check sum conditional statement, I get no response, pointing to the LED. with the success of others, I'm sure I either got a bad board or did something to it. Get back to you if I have issues with the new board.
  • 3D Robotics
    bGatti. Perhaps you're right. It's not the path we took, but it's an open source hardware project, so you're very welcome to design a version that works the way you describe. If it proves superior in the field, we'll happily consider it.
  • One more link Also let me rather ask if it would be advisable to do this, as it seem to get a AVRISP programmer means importing one. And why buy more equipment if the harware you got can do the job.
  • Hi I wondered if Arduino could be used as a AVRISP programmer? There is a Arduino forum discussing this here
  • 3D Robotics
    bGatti: the MUX does more than just detect and switch between two PWM widths. It also detects a "middle position" and when the toggle is switched five times quickly, reboots ArduPilot. It's also programmable for different toggle switch throws. Although the first could perhaps be done with analog electronics, I doubt the others could.
  • John, Did you having a problem with your LOCK LED on the ArduPilot board?
  • 3D Robotics
    John: sounds like a bum LED. Has it ever come on with this board?
  • So I just changed the the if GPS checksum statement so that no matter what the GPS returns in fix_position the LED, pin 12 should go high. And the with the MUX LED on and the GPS connected and flashing, the lock LED on ardupilot is still unlit.
This reply was deleted.