Upload firmware to the Radio Controlled Stepper

From CunningWiki
Jump to: navigation, search

This tutorial will show you how to load firmware on to the Radio Controlled stepper.


There a couple settings you can change on the RC Stepper. For example, when you are controlling a stepper motor using the RC stepper and you move the joystick on your remote control from left to the right the stepper motor will turn exactly 360 degrees. But what if you want to it turn 720 degrees instead. By tweaking and uploading the firmware you can do that. In this tutorial I'll walk you through doing just that.

There are a few assumptions I make on this page: First, I assume you are using a computer that is running windows. Second, you want to spend as little money as possible and not have to buy additional tools. And lastly, you have an Arduino laying around.


For this tutorial, you'll need:

  • Arduino Uno or Duemilanove (w/ an ATmega328, not an older board with an ATmega168)
  • a 10 uF capacitor (e.g. from Sparkfun or from Digi-Key)
  • jumper wires


[Step 1] Install winavr

Here is the direct download link: http://sourceforge.net/projects/winavr/files/latest/download When you are installing it, make sure the install path you specify doesn't have any spaces in it. That means don't install it in into your "Program Files" folder. The programs that come with WinAVR have trouble running when install in a directory that has spaces in it. A good place to put it in is "C:\WinAVR"


[Step 2] Download the Radio Controlled Stepper source code

Link to the source code. After you download it, unzip it someplace you can keep track of. For this tutorial I'm going to place my source code into the folder "C:\rcStepper\".


[Step 3] Make your changes to the config file

Once you unzip the source code, look for the file named "config.h". This file will have the settings you can configure. Open it up and poke around inside. Even though the extension of this file is ".h" you can still open it in plain ol' notepad. Each setting in the file has a short description next to it that explains what it does. For this example I scroll down until I see "#define ABSOLUTE_POSITION_RANGE_IN_DEGREES" and I change the number from 360 to 720. This will get me double the rotational range. Once I make my change I save the file.

Config.h opened in notepad.png


[Step 4] Programming the Arduino to act as a Programmer

Now we need to make the Arduino board into a programmer so that it will be able to program other microcontrollers. This is very simple; with the Arduino IDE open, open the ArduinoISP sketch by going to File->Examples->ArduinoISP. This sketch will make the Arduino act as an ISP programmer. Select your board in the Tools menu, and make sure the correct COM port is selected (also, copy down or make a mental note of the COM port. It will be needed in step 6). Then just upload the sketch to the Arduino.

ArduinoIspSketch.png


[Step 5] Connect the Arduino to the RC stepper

Connect the Arduino board to the RC stepper as shown in the following diagram. Also connect a 10 uF capacitor between reset and ground on the Arduino board as shown in the diagram (the stripe on the capacitor that’s marked with a negative sign (-) should go to ground). The capacitor prevents the Arduino board from resetting (which starts the bootloader), thus ensuring that the Arduino IDE talks to the ArduinoISP (not the bootloader) during the upload of sketches. (The capacitor is needed if you’re using an Arduino Uno, and might also be necessary for an Arduino Duemilanove.)

Program rc stepper with arduino.png


[Step 6] Compile and program the firmware

Open up the folder with the RC stepper firmware and locate the file called "CompileAndProgram.bat". Be careful not to double click on this file just yet, we have to edit it first. Open up notepad and drag this file into it. Even though the file ends in ".bat" it is really just a text file. Inside it find where it says "COM1" and change it to the COM port from step 4. Save the file once you make your change. Now double click on the file to run it. This file is a script that will compile the firmware and program it on to the RC stepper.

CompileAndProgram.bat opened in notepad.png


[Optional Step 7] Burn the fuses

You need to do this step if you are building your own RC stepper from scratch. If you purchased your RC Stepper from us then the fuses are already burned in for you and you should skip this step.

To burn the fuses, look in the RC stepper firmware folder and open the file called "burnFuses.bat". Just like in the previous step you need to edit this file. Find where it says "COM1" and replace it with the COM port from step 4. Once you save your change double click on the file and it will burn the fuses for you.



Acknowledgements

Parts of this tutorial are adapted from High-low tech's excellent tutorial on how to use the Arduino board as an ATtiny programmer. As well as Sparkfun's tutorial on Using an Arduino to Program an AVR.