Resources »Pololu USB AVR Programmer User's Guide
View document on multiple pages.
1. OverviewThe Pololu USB AVR programmer is a programmer for Atmel’s AVR microcontrollers and controller boards based on these MCUs, such as Pololu Orangutan robot controllers and the 3pi robot. The programmer emulates an STK500 on a virtual serial port, making it compatible with standard AVR programming software. Two additional features help with building and debugging projects: a TTL-level serial port for general-purpose communication and a SLO-scope for monitoring signals and voltage levels. Please note that this guide applies to Pololu’s second-generation AVR programmer (pictured to the left below), not the original, similar-looking Orangutan USB programmer (pictured to the right).
If you have the original Orangutan USB programmer, you can find it’s user’s guide here. Important Safety Warning and Handling ProceduresThe USB AVR programmer is not intended for young children! Younger users should use this product only under adult supervision. By using this product, you agree not to hold Pololu liable for any injury or damage related to the use or to the performance of this product. This product is not designed for, and should not be used in, applications where the malfunction of the product could cause injury or damage. Please take note of these additional precautions:
1.a. Module Pinout and Components
The Pololu USB AVR programmer connects to a computer’s USB port via an included USB A to mini-B cable, and it connects to the target device via an included 6-pin ISP programming cable (the older, 10-pin ISP connections are not directly supported, but it is easy to create or purchase a 6-pin-to-10-pin ISP adapter). The USB AVR programmer has three indicator LEDs:
The VBUS line provides direct access to the 5V VBUS line on the USB cable and can be used to power additional devices. The line can provide up to 100 mA, so the current draw of your programmer plus any additional devices should not exceed this amount. If you attempt to draw more than this limit, your computer might disconnect the USB port temporarily or take other actions to limit the use of USB power. The GND line provides direct access to the grounded line on the USB cable (and ground on the programmer). The TX and RX lines are the TTL serial port for the USB-to-TTL-serial adapter. They are labeled from the computer’s perspective: TX is an output that connects to your target’s serial receive pin and RX is an input that connects to your target’s serial transmit pin. Section 6 describes how to use these lines to communicate with your devices from the computer. The A and B lines can be used as serial control/handshaking lines for the USB-to-TTL-serial adapter (see Section 6.a) or as analog voltage inputs for the SLO-scope (see Section 7).
The USB AVR programmer has a standard 6-pin AVR ISP connector for programming AVRs, and the pins are labeled on the silkscreen on the bottom side of the board. The pins on the connector are:
1.b. Supported MicrocontrollersThe programmer should work with all AVRs that can be programmed with the AVR ISP interface, but it has not been tested on all devices. It has been tested with all Orangutan robot controllers and the 3pi Robot. The programmer features upgradable firmware, allowing updates for future devices. It does not currently work with Atmel’s XMega line of microcontrollers. The programmer is powered by the 5V USB power bus, and it is intended for programming AVRs that are running at close to 5 V (note that the programmer does not deliver power to the target device). 1.c. Supported Operating SystemsThe Pololu USB AVR programmer has been tested under Microsoft Windows XP (Service Pack 3), Windows Vista, Windows 7, Windows 8, and Linux. See Section 5 for limited Mac OS X support. The programmer’s configuration utility works only in Windows, but this should not be a big problem for Linux users because all the options that can be set in the configuration utility are stored in persistent memory, so you would only have to use Windows when you want to change those parameters, which should be rarely (if ever). The programmer does not require the configuration to program AVRs or to use the TX and RX USB-to-TTL-serial adapter pins. The SLO-scope application works only in Windows. The programmer is compatible with a variety of AVR programming utilities for Windows, Linux and Mac OS, including AVRDUDE, AVR Studio 4, AVR Studio 5, and Atmel Studio 6. 2. Contacting Pololu
You can check the Pololu USB AVR programmer page for additional information. We would be delighted to hear from you about any of your projects and about your experience with the Pololu USB AVR Programmer. You can contact us directly or post on our forum. Tell us what we did well, what we could improve, what you would like to see in the future, or anything else you would like to say! 3. Getting Started in WindowsThe Pololu USB AVR programmer works in Windows XP, Windows Vista, and Windows 7. 3.a. Installing Windows Drivers and SoftwareIf you use Windows XP, you will need to have either Service Pack 3 or Hotfix KB918365 installed before installing the drivers for the Pololu USB AVR programmer. Some users who installed the hotfix have reported problems using the programmer which were solved by upgrading to Service Pack 3, so we recommend Service Pack 3 over the hotfix. Please note that these drivers will only work for the USB AVR programmer; if you have Pololu’s original Orangutan USB programmer, you will need to install the drivers specific to that device. Before you connect your Pololu USB AVR programmer to a computer running Microsoft Windows, you must install its drivers:
Windows 8, Windows 7, and Windows Vista users: After the installation has finished, your computer should automatically install the necessary drivers when you connect a Pololu USB AVR programmer, in which case no further action from you is required. Windows XP users: After the installation has finished, follow steps 3-7 for each new Pololu USB AVR programmer you connect to your computer.
If you use Windows XP and experience problems installing the serial port drivers, the cause of your problems might be a bug in older versions of Microsoft’s usb-to-serial driver usbser.sys. Versions of this driver prior to version 5.1.2600.2930 will not work with the USB AVR programmer. You can check what version of this driver you have by looking in the “Details” tab of the “Properties” window for C:\Windows\System32\drivers\usbser.sys. To get the fixed version of the driver, you will need to either install Service Pack 3 or Hotfix KB918365. Some users who installed the hotfix have reported problems using the programmer which were solved by upgrading to Service Pack 3, so we recommend Service Pack 3 over the hotfix. After installing the drivers, if you go to your computer’s Device Manager and expand the “Ports (COM & LPT)” list, you should see two COM ports: “Pololu USB AVR Programmer Programming Port” and “Pololu USB AVR Programmer TTL Serial Port”. In parentheses after these names, you will see the name of the port (e.g. “COM3” or “COM4”). If you expand the “Pololu USB Devices” list you should see an entry for the Pololu USB AVR programmer.
Some software will not allow connection to higher COM port numbers. In particular, AVR Studio and Atmel Studio can not connect to ports higher than COM9. If you need to change the COM port number assigned to your USB device, you can do so using the Device Manager. Bring up the properties dialog for the COM port and click the “Advanced…” button in the “Port Settings” tab. From this dialog you can change the COM port assigned do your device. Once your have successfully installed the device drivers and software, you can run the Pololu USB AVR Programmer Configuration Utility, which is available in the Start menu in the Pololu folder. This application allows you to change many of the settings of your programmer and can help troubleshoot problems. Please see Section 3.e for more information. This software package also contains the installation files for the Pololu SLO-scope application for Windows. Please see Section 7 for installation and usage instructions. 3.b. Programming AVRs Using Atmel Studio 6If you have an Orangutan or 3pi Robot or wish to use the Pololu AVR C/C++ Library for some other reason, we recommend following the Pololu AVR Programming Quick Start Guide instead of this tutorial. The following tutorial covers the steps needed to program AVRs in Windows using Atmel Studio 6 and a Pololu USB AVR Programmer. Atmel Studio 6 is a free integrated development environment (IDE) provided by Atmel. In this tutorial, we will write a simple program to blink an LED connected to pin PD1 of an AVR. If you want to program an AVR that does not have an LED connected to pin PD1, the code in this tutorial can be modified. You will need to:
After you have completed these prerequisites, you can create a new Atmel Studio 6 project:
#define F_CPU 20000000 // AVR clock frequency in Hz, used by util/delay.h
#include <avr/io.h>
#include <util/delay.h>
int main() {
DDRD |= (1<<DDD1); // set LED pin PD1 to output
while (1) {
PORTD |= (1<<PORTD1); // drive PD1 high
_delay_ms(100); // delay 100 ms
PORTD &= ~(1<<PORTD1); // drive PD1 low
_delay_ms(900); // delay 900 ms
}
}
Note: The value of F_CPU should be the clock frequency of your AVR in units of Hz, so if your AVR is not running at 20 MHz you will need to change that line. If you do not make this change, the timing of
If you got an error that says “Unable to connect to tool STK500” and you see an error message in the Output pane in the main window that says “The signature of the attached tool is AVRISP_2, which is unexpected.” then you need to upgrade your programmer’s firmware to version 1.07 or later (see Section 9). If you get a different error, see Troubleshooting (Section 8) for help identifying and fixing the problem.
As your USB AVR Programmer programs the AVR, you should see all three LEDs flicker and you should see the following text appear at the bottom of the window: Erasing device... OK Programming Flash...OK Verifying Flash...OK If there were no problems, the LED connected to PD1 of your AVR should now be flashing! Note that if you are trying this on a 3pi robot and you have not yet soldered in the optional through-hole LEDs, the flashing LED will be on the bottom of the robot. If there was a problem, please see Troubleshooting (Section 8) for help identifying and fixing it. 3.b.1. Adding Devices to Atmel Studio 6
While the older AVR Studio 4 supports programming a large number of different AVRs with STK500-compatible programmers such as the Pololu USB AVR Programmer, Atmel Studio 6 only supports programming a small selection of devices by default. If you would like to program a device that is not supported by default using Atmel Studio, you will need to add an XML file to one of Atmel Studio’s directories.
3.b.2. Using Advanced Features of Atmel Studio 6This section provides a brief overview of the features of Atmel Studio 6’s Device Programming dialog that were not covered in Section 3.b. You will not typically need to use these advanced features, but it is good to know about them for the rare occasions when you will need them. Please see the Atmel Studio 6 documentation for more detailed descriptions of these features. ISP Clock FrequencyIn the Device Programming dialog, under Interface settings, you can set the frequency of the clock used when programming the target device. The higher the ISP frequency, the faster the target AVR will be programmed, but this frequency must be less than a quarter of the target AVR’s clock frequency. Click Read to read the frequency from the programmer and click Write to write the selected frequency to the programmer. It is important to note that the actual frequency values displayed in Atmel Studio are not correct when you are using the Pololu USB AVR programmer. See Section 3.e for a list of the actual frequencies and more information about selecting the ISP frequency.
Fuses (proceed with caution!)Selecting Fuses in the Device Programming dialog automatically causes the programmer to read the fuse settings of the target AVR. If the programmer is not connected to the target AVR when you select this tab, Atmel Studio displays an error message. Fuses allow you to configure certain persistent, fundamental aspects of your AVR such as boot flash size, brown-out detection level, and the clock off of which it should run (e.g. external crystal or internal oscillator). To learn more about the fuses and what they do, see the datasheet for your specific AVR. Warning: You can permanently disable your AVR by setting the fuses incorrectly. Only advanced users who know precisely what they are doing should change the fuse settings! Lock BitsSelecting Lock bits in the Device Programming dialog automatically causes the programmer to read the lock bits of the target AVR. If the programmer is not connected to the target AVR when you select this tab, Atmel Studio displays an error message. Lock bits allow you to secure your AVR by preventing further flash writing or reading. The lock bits can be reset to a fully unlocked state by performing a chip erase (i.e. by clicking the Erase Device button in the Memories section). Lock bits are usually only important if you wish to release a product to other people without giving them access to the program it is running, or if you wish to make it more difficult to accidentally overwrite a programmed chip. 3.b.3. Faster programming with F5 in Atmel Studio 6The Device Programming dialog in Atmel Studio 6 is modal, which means you must close it after you are done programming in order to go back to editing your source code. It takes 4 clicks to open up the dialog and initiate the programming process again. This section describes a different method for programming that will allow you to compile and program simply by pressing F5. First, in the View menu, select “Available Atmel Tools”. This will bring up the “Available Tools” window. Make sure that there is one and only one STK500 in the list and make sure that the COM port number matches the COM port number of the Pololu USB AVR Programmer Programming Port, which is displayed in the Device Manager. If there are multiple STK500 entries, right click on them and select “Remove” to remove the extra entries. You will only have to do this once.
Next, open the project properties window by opening the Project menu and selecting “Properties…”. In the Tool tab, select STK500 as the debugger/programmer, and select ISP as the interface. You will only have to do this once per project. You can also set the ISP Clock speed here but please note that the frequencies displayed in Atmel Studio are not correct when you are using the Pololu USB AVR programmer (see Section 3.e for the correspondence). It is a good idea to set the frequency to something between 80 and 90 kHz (which will result in 200 kHz on the Pololu AVR Programmer) at first and to try increasing it later once F5 programming is working.
Finally, you should be able to press F5 to build your project and program the resulting HEX file onto your AVR! Alternatively you can program by selecting either “Continue” or “Start Without Debugging” from the Debug menu. 3.c. Programming AVRs Using AVR Studio 4This tutorial covers the older AVR Studio 4, which is no longer supported by Atmel. For a tutorial on the newer Atmel Studio 6 see Section 3.b. For a tutorial on AVR Studio 4 for Orangutan and 3pi robot users, see the Programming Orangutans and the 3pi Robot from AVR Studio 4 guide. The following tutorial covers the steps needed to program AVRs in Windows using AVR Studio 4 and a Pololu USB AVR programmer. Specifically, we will write a simple program to blink an LED connected to pin PD1 of an AVR. If you want to program an AVR that does not have an LED connected to pin PD1, the code in this tutorial may need to be modified. You will need to download and install several pieces of software:
If you have an Orangutan or 3pi and want to jump straight in to using your USB AVR programmer, you can skip steps 1–3 by downloading the AVR Studio project these steps would create. Determine the microcontroller on your device, download the corresponding file below, extract all the files to a directory, open the AVR Studio project file (BlinkLED.aps), and proceed to step 4.
3.c.1. Using Advanced Features of AVR Studio 4This section provides a brief overview of the programming features of AVR Studio 4 that were not covered in Section 3.c. You will not typically need to use these advanced features, but it is good to know about them for the rare occasions when you will need them. Please see the Atmel’s AVR Studio 4 documentation for more detailed descriptions of these features. ISP FrequencyIn the ISP window, under the Main tab, the Programming Mode and Target Settings section lets you set the frequency of the clock used when programming the target device. The higher the ISP frequency, the faster the target AVR will be programmed, but this frequency must be less than a quarter of the target AVR’s clock frequency. Click Read to read the frequency from the programmer and click Write to write the selected frequency to the programmer. It is important to note that the frequencies in the ISP Freq list are not correct when you are using the Pololu USB AVR programmer. See Section 3.e for a list of the actual frequencies and more information about selecting the ISP frequency.
Fuses (proceed with caution!)Clicking on the Fuses tab automatically causes the programmer to read the fuse settings of the target AVR. If the programmer is not connected to the target AVR when you select this tab, AVR Studio displays an error message. Fuses allow you to configure certain persistent, fundamental aspects of your AVR such as boot flash size, brown-out detection level, and the clock off of which it should run (e.g. external crystal or internal oscillator). To learn more about the fuses and what they do, see the datasheet for your specific AVR. Warning: You can permanently disable your AVR by setting the fuses incorrectly. Only advanced users who know precisely what they are doing should change the fuse settings! Lock BitsClicking on the Lock Bits tab automatically causes the programmer to read the lock bits of the target AVR. If the programmer is not connected to the target AVR when you select this tab, AVR Studio displays an error message. Lock bits allow you to secure your AVR by preventing further flash writing or reading. The lock bits can be reset to a fully unlocked state by performing a chip erase (i.e. by clicking the Erase Device button in the Main tab). Lock bits are usually only important if you wish to release a product to other people without giving them access to the program it is running, or if you wish to make it more difficult to accidentally overwrite a programmed chip. 3.d. Programming AVRs Using AVRDUDEIt is possible to program AVRs in Windows using AVRDUDE. AVRDUDE is free and included in the WinAVR package. To program a hex file onto your AVR, you would type something similar to the following into a command prompt:
Please see the AVRDUDE documentation for more detailed information. AVRDUDE’s terminal mode (the -t option) is not compatible with the programmer because the programmer will exit programming mode and release the target AVR from reset if it receives no programming commands for 1400 ms. 3.e. Configuring the ProgrammerThe Pololu USB AVR programmer can be configured using the Pololu USB AVR Programmer Configuration Utility for Windows. The utility comes with the Windows drivers (Section 3.a). You can run it from your Start Menu, or by just double clicking on the executable pgm03a_config.exe. This section describes all the available settings and what they do.
Target VDD MonitorThe USB AVR programmer monitors the voltage of the target AVR while it is being programmed to ensure that ISP commands are only sent when the AVR’s VDD is at a safe level, since attempting to program an underpowered AVR can permanently disable it. There are two parameters that control this feature:
Measurements From Last ProgrammingThis section displays the minimum and range of the target VDD measurements from the last time the programmer was in programming mode or tried to enter programming mode. This can help determine whether programming problems are due to the target’s power supply. Error From Last ProgrammingWhen an error or unexpected condition causes the programmer to leave programming mode, or fail to enter programming mode, then the programmer turns on the red LED and records the error code. A description of the error can be found here. See Troubleshooting (Section 8) for details on specific error messages. ISP FrequencyThe higher the ISP frequency, the faster you can program the target AVR, but the ISP frequency must be less than a quarter of the target AVR’s clock frequency. The ISP frequency can be set in Atmel Studio (see Section 3.b.2) as well as in the Configuration Utility, but the frequencies listed in the Atmel Studio user interface do not match the actual frequencies used by the Pololu USB AVR programmer. The correspondence is shown below:
An AVR running at 20 MHz or higher (e.g. the Orangutan SV-xx8, Orangutan LV-168, Baby Orangutan, and 3pi robot) can be programmed at 2000 kHz (1.845 MHz in Atmel Studio), which is the fastest setting. An AVR running at 8 MHz or higher (e.g. the original Orangutan) can be programmed at 1500 kHz (460.8 kHz in AVR Studio). An AVR running at 1 MHz, such as one clocked off of the internal RC oscillator with the divide-by-8 fuse bit programmed, can be programmed at an ISP frequency as high as 200 kHz (57.6 kHz in Atmel Studio). This is the USB AVR programmer’s default ISP frequency. The two lowest frequencies support AVRs with a clock frequency under 1 MHz. The 1.5 kHz setting is too slow to actually program the flash or EEPROM on your target device using Atmel Studio (it will timeout while attempting to program the flash/EEPROM pages), but it will still let you set the fuses. Be aware that if you attempt to program flash or EEPROM at 4.0 kHz, it might take five minutes or longer to program a 16KB of flash, so we only recommend this ISP frequency for putting small programs on very low-frequency AVRs. Serial NumberThis is a unique identifier assigned to this programmer by Pololu. This number can not be changed. TTL Serial PortThis section is used to identify pins A and B with serial handshaking lines so that they can be used as general purpose user I/O lines. See Section 6.a. AVR ISP EmulationThis section is used to change the hardware and software version numbers of the programmer. These numbers are read by Atmel Studio when it connects to the programmer and are expressed in hex. If these numbers do not match the numbers that Atmel Studio expects, then it might bring up a dialog asking if you want to upgrade (or downgrade) your programmer’s firmware; the Pololu AVR USB programmer does not support this method of firmware upgrading, so this dialog is nothing more than a nuisance to those not using an Atmel programmer. You should click Cancel to ignore the message and proceed to the AVRISP programming dialog. To prevent this firmware-upgrade dialog from appearing in the future, set the numbers here to the numbers that AVR Studio says it expects. 4. Getting Started in LinuxThe Pololu USB AVR programmer can be used in Linux to program AVRs and to send and receive bytes on the USB-to-TTL-serial adapter. The configuration utility is written for Windows; there is no Linux version. All of the parameters that can be set in the configuration utility are stored in persistent memory, so Linux users only have to use Windows when they want to change those parameters, which should not be too often. The SLO-scope client is written for Windows, and there is no Linux version; Linux users are unable to use the SLO-scope at this time. If you would like to write a configuration utility or SLO-scope application for Linux, you can contact us for information. 4.a. Linux DriverNo driver installation is necessary to use the Pololu USB AVR Programmer in Linux. The Linux Kernel comes with a USB-to-serial driver (the cdc_acm module) that automatically works with the programmer. (The source code for this driver is in the kernel source under drivers/usb/class/cdc-acm.c.) When you plug your programmer into a Linux computer, the CDC ACM driver should automatically detect it and create two serial port devices. Unless you have other devices plugged in that use the CDC ACM driver, the names of these two serial port devices should be /dev/ttyACM0 for the programming port and /dev/ttyACM1 for the USB-to-TTL-serial adapter. If the programmer is plugged in, but you do not see these devices, please see Troubleshooting (Section 8) for help identifying and fixing the problem. 4.b. Programming AVRs in LinuxIf you have an Orangutan or 3pi Robot or wish to use the Pololu AVR C/C++ Library for some other reason, we recommend following the Pololu AVR Programming Quick Start Guide instead of this tutorial. To program AVRs in Linux using the Pololu USB AVR Programmer, you will need to install four software packages, which can be downloaded from their respective websites. In Ubuntu Linux, these packages are provided in the “Universe” repository.
Once these packages are installed, you will be able to compile C programs for the AVR with gcc to produce hex files. These hex files can be loaded on to your AVR using avrdude and a programmer. We will not go into the details of writing C programs for the AVR here, but, as an example, we will show you how to use your Linux computer and the USB AVR Programmer to make an LED connected to PD1 of an AVR blink. On any of the Orangutan robot controllers and the 3pi Robot, this program will blink the red user LED. If you want to program an AVR that does not have an LED connected to pin PD1, the LED-blinker code in this tutorial will have no visible effect. If your device is an ATmega48, ATmega168, or ATmega328P, download the corresponding archive below:
If your device is not one of the above, you will need to download one of the above archives and modify the makefile to use your particular device. Unpack the archive on your Linux computer. Copy the file Note: You will probably want to edit BlinkLED.c slightly if the clock frequency of your AVR is not 20 MHz. F_CPU should be defined as the clock frequency of your AVR in units of Hz. If you do not make this change, the timing of delayms() will be off, but the LED will still blink. At this point, you should be ready to compile the example program and load it on to the AVR. Plug in the programmer and type make. You should see output like this:
This output indicates the AVR was successfully programmed. The LED connected to PD1 of your AVR should now be flashing! Note that if you are trying this on a 3pi robot and you have not yet soldered in the optional through-hole LEDs, the flashing LED will be on the bottom of the robot. If there was a problem, please see Troubleshooting (Section 8) for help identifying and fixing it. 5. Getting Started in Mac OS XThe Pololu USB AVR Programmer can be used to program AVR microcontrollers, using Mac OS X as the development environment. 5.a. Firmware Support for Mac OS XMac OS X compatibility: we have confirmed that the programmer works on Mac OS X and we can assist with advanced technical issues, but most of our tech support staff does not use Macs, so basic support for Mac OS X is limited. Changing the firmware (if necessary)The standard USB AVR Programmer firmware works with Mac OS X 10.7 (Lion) and later. There is a special, modified version of the firmware that should work on all versions of Mac OS X. To install the modified firmware you will need to use a Windows or Linux computer, but after that all further work can be done on the Mac.
Note: If you have OS X 10.7 (Lion) or later, you don’t need to change your programmer’s firmware. The modified firmware only allows programming of AVRs; it does not support the bonus features of the programmer (the TTL-level serial port and the SLO-scope). Checking the installationTo check the installation, plug the Pololu USB AVR Programmer into a USB port on your Mac. Click “Cancel” if you see the following dialog:
In a Terminal window, type
If you are using Mac OS X 10.7 or later and have not changed the programmer’s firmware, there should be two new If you are using an older version of Mac OS X, you will need to install the modified firmware as described above, and you should only see one new 5.b. Programming AVRs in Mac OS XIf you have an Orangutan or 3pi Robot or wish to use the Pololu AVR C/C++ Library for some other reason, we recommend following the Pololu AVR Programming Quick Start Guide instead of this tutorial. Installing CrossPackTo program AVRs in Mac OS X, you will need the free avr-gcc compiler, avr-libc, AVRDUDE, and other associated tools.
Using AVRDUDEOnce an AVR program has been compiled to a .hex file, it is ready to be flashed to the AVR. The AVRDUDE program (which was installed as part of the CrossPack package) may be used for this purpose. To see the full command-line syntax for AVRDUDE, type
For example:
If all goes well, the output should look something like this:
6. Communicating via the USB-to-TTL-Serial AdapterOne bonus feature of the Pololu USB AVR programmer is the USB-to-TTL-serial adapter, which can be used for connecting microcontroller projects to a personal computer. The programmer’s drivers make the USB-to-TTL-serial adapter look like a standard serial port to the operating system, allowing you to use existing terminal programs and software that are designed to use serial ports. This feature is similar to the Pololu USB-to-serial adapter product, except the programmer has fewer control lines available and transmits at 5 V. The TX and RX lines of the programmer are used to send asynchronous serial communication. When the programmer receives a byte from the computer via USB, it will transmit that byte on the TX line. When the programmer receives a byte on the RX input line, it will send that byte back to the computer via USB. The bytes are sent and received eight bits at a time, with no parity and one stop bit. This coding is sometimes abbreviated 8N1. The bits must be non-inverted, meaning that a zero is sent as low voltage, and a one is sent as high voltage. All devices involved in asynchronous serial communication need to agree ahead of time on the duration of one bit (the baud rate), so all devices must be independently configured to run at the same baud rate before they will be able to communicate with each other. The USB AVR programmer supports all integer baud rates from 110 to 115200 bits per second. The following figure is an example of an 8N1 TTL serial byte:
To use the USB-to-TTL-serial adapter, you must first determine what port name the operating system has assigned it. To determine the port name in Microsoft Windows, open the Device Manager, expand the “Ports (COM & LPT)” list, and look for the “Pololu USB AVR Programmer TTL Serial Port” entry. The port name will be at the end of this line in parentheses (e.g. “COM4”). In Windows, a given device will always be associated with the same port unless you manually change its port assignment (see Section 3.a).
To determine the port name in Linux, type
After determining the port name, you can use any serial port software to communicate on that port. There are many free terminal programs available, including PuTTY (Windows or Linux), Tera Term (Windows), and Br@y Terminal (Windows). Advanced users developing scripted applications may prefer the free terminal program kermit. To use any of these terminal programs with the USB-to-TTL-serial adapter, you must specify the port name determined above and your desired baud rate. The characters you type will be transmitted on the programmer’s TX line. Bytes received by the programmer on the RX line will be displayed on the screen by the terminal program.
If you need to send and receive non-ASCII bytes, you can use the Pololu Serial Transmitter Utility for Windows. You can also write a computer program to use the serial port. The freely available Microsoft .NET framework contains a SerialPort class that makes it easy to read and write bytes from a serial port. Here is some example C# .NET code that uses a serial port:
// Choose the port name and the baud rate.
System.IO.Ports.SerialPort port = new System.IO.Ports.SerialPort("COM4", 115200);
// Connect to the port.
port.Open();
// Transmit two bytes on the TX line: 1, 2
port.Write(new byte[]{1, 2}, 0, 2);
// Wait for a byte to be received on the RX line.
int response = port.ReadByte();
// Show the user what byte was received.
MessageBox.Show("Received byte: " + response);
// Disconnect from the port so that other programs can use it.
port.Close();
6.a. Communicating via the Serial Control LinesFirmware version 1.04 (released on April 29th, 2011) fixes a problem with the RTS and DTR control signal outputs. If you want to use those outputs, you should upgrade your firmware to version 1.04. Please see Section 9 for information about upgrading your firmware. Firmware version 1.03 (released on December 22nd, 2010) inverts the TTL serial port’s control signals so that 0 V corresponds to 1 and 5 V corresponds to 0, making it consistent with other USB-to-TTL-serial adapters. Prior to version 1.03, the opposite convention was used. In addition to transmitting bytes on the TX line and receiving bytes on the RX line, the USB-to-TTL-serial adapter can use programmer pins A and B as serial handshaking lines of your choosing. Each pin can be configured as an input or an output by identifying it with a serial handshaking line. The table below shows which handshaking lines are available (CTS is not available because there is no provision for it in the USB CDC ACM subclass).
By default, pins A and B are high-impedance inputs that are not identified with any handshaking line. To use pins A and/or B, you must configure them to be serial handshaking lines using the Pololu USB AVR Programmer Configuration Utility (see Section 3.e). The programmer stores the configuration in persistent memory.
After your have associated pins A and/or B with serial handshaking lines, you can take advantage of the I/O capabilities of A and B. For input lines, this means you can get a digital reading of the voltage on the line over USB. For output lines, this means you can set the voltage on the line over USB. A voltage of 0 V corresponds to a logical 1, while a voltage of 1 V corresponds to a logical 0. For example, if you wanted to connect your Pololu USB AVR Programmer to an AVR running the Arduino bootloader, you could configure pin A to be DTR and then connect pin A to the AVR’s reset line. When the Arduino software sets DTR to 1, the programmer will drive the line A low, which puts the AVR in reset mode. You can read input lines and/or set output lines by either using a terminal program that supports control signals (such as Br@y Terminal) or by writing a computer program. The Microsoft .NET framework is free to use and it contains a SerialPort class that makes it easy to read and write bytes from a serial port as well as set and read the control signals. Here is some example C# .NET code that uses a serial port in this way:
// Choose the port name and the baud rate.
System.IO.Ports.SerialPort port = new System.IO.Ports.SerialPort("COM4", 115200);
// Connect to the port.
port.Open();
// Assuming that line A is identified with RTS, and your firmware version is 1.04
// or greater, this drives line A low (0 V).
port.RtsEnable = true;
// Assuming that line B is identified with DSR, and your firmware version is 1.03
// or greater, this takes an inverted digital reading of line B.
if (port.DsrHolding)
{
MessageBox.Show("Line B is low.");
}
else
{
MessageBox.Show("Line B is high.");
}
// Disconnect from the port so that other programs can use it.
port.Close();
When the SLO-scope feature is enabled, it assumes control of pins A and B and uses them as analog inputs (or digital outputs controlled by the SLO-scope application). Pins A and B temporarily lose their serial handshaking line associations while the SLO-scope is active, but these associations are restored once the SLO-scope is disabled. You can disable the SLO-scope via the SLO-scope application or by unplugging the programmer and plugging it back in. 7. Measuring Voltages Using the SLO-scopeA second bonus feature of the Pololu USB AVR programmer is the severely limited oscilloscope (SLO-scope), which uses lines A and B as inputs to measure TTL-level voltages at a sample rate of up to 20 kHz. The SLO-scope has two operating modes:
The SLO-scope can measure voltages between ground and approximately 5 V (depending on your computer’s USB bus voltage); you can measure higher voltages by passing them through an external voltage divider before connecting them to the programmer. The following schematic shows a general voltage divider circuit that can be used to scale down an input signal to the SLO-scope’s required 0 – 5 V range:
The total resistance of R1+R2 should be as large as possible to minimize the divider’s effect on your signal, but it should not exceed 100 kΩ or so. Installing and Runing the Pololu SLO-scope ApplicationThe SLO-scope application for Windows comes with the Windows drivers (Section 3.a) and can be installed by running the installation batch file sloscope_installer.bat. Windows Vista: right click on sloscope_installer.bat and select “Run as administrator”. At this time, the SLO-scope can only be used under the Windows operating system. Once installation is complete, the application should begin running automatically. Note that the application will give you an error message and close if a programmer is not connected to your computer. To start the SLO-scope application yourself, open the Start menu and navigate to:
The SLO-scope application was written as a Visual C# 2008 project: SLO-scope client C# source code (56k zip) Using the Pololu SLO-scope ApplicationThis application connects to the programmer, streams data from the SLO-scope, and provides the basic functionality of a 10 or 20 kHz oscilloscope.
Controls are available for setting the SLO-scope operating mode, adjusting the horizontal and vertical scales, and configuring lines A and B as digital outputs. To start capturing data, click the Run button in the upper right corner. If the horizontal scale is such that it takes more than 200 ms of data to fill the lower SLO-scope pane, the data will continuously stream across the pane. If the lower pane displays 200 ms of data or less, the pane will draw all of its data at once when it has enough new data to warrant an update (or, if triggering is enabled, when the trigger event is satisfied). In this latter time domain, you can enable the persistence feature (check the Persistence checkbox) to cause the data on the screen to fade out over time when the next update occurs. The Length parameter determines how long it takes for the data to fade. The upper SLO-scope pane shows a summary of all of the data currently stored in memory. This is approximately 10 seconds of data when running at 10 kHz and 5 seconds of data when running at 20 kHz. To review the captured data in detail, click the Stop button (in the same place that the Run previously occupied). When the SLO-scope is stopped, you can scroll through the data stored in memory by clicking on the portion of the upper pane that you want to inspect or by clicking and dragging the cursor in the lower pane to pan through the data more finely. You can zoom in and out by changing the horizontal scale, and you can inspect the data in the lower pane by hovering over it with your cursor. A purple rectangle highlights the portion of the upper pane is visible in the lower pane. You can adjust the vertical scaling of a channel’s data by changing its volts-per-division parameter, and you can adjust the amount of data that is shown in the lower pane by changing the SLO-scope’s milliseconds-per-division (horizontal scale) parameter. Triggering can be used when horizontal scaling is 20 ms/div or less. You can trigger on rising or falling edges of either channel A or channel B, and you can adjust the trigger level by directly setting the value in millivolts or by dragging the trigger level scrollbar on the right side of the lower pane to the desired position. When triggering is enabled, the data in the lower pane will update whenever a trigger event occurs. Triggering can help you to better identify and analyze periodic signals (such as motor noise, PWMs, etc.) while the SLO-scope is running. To change the color used to draw a channel’s data, double click on the colored square in either the Channel A or Channel B box. To change the vertical position of the 0V level of a channel, click and drag that channel’s corresponding 0V-indicator triangle on the left side of the lower pane. While the SLO-scope is running, lines A and B do not function as serial handshaking lines as discussed in Section 6.a. Rather, the SLO-scope can control the I/O states of A and B. The SLO-scope application lets you configure these pins as inputs (their default settings when you first enable the SLO-scope) or as digital outputs driven high or low. 8. TroubleshootingThis section helps solve problems you might have using the Pololu USB AVR programmer. If the computer fails to connect to the programmer:
If the programmer has problems connecting to the target AVR:
If /dev/ttyACM0 or /dev/ttyACM1 do not exist in Linux:
Still need help?If none of the above troubleshooting suggestions help, please contact us for support. 9. Upgrading FirmwareThe program that runs on the USB AVR Programmer (the firmware) can be upgraded with bug fixes or new features. Firmware Versions
Special Modified Firmware VersionsThese special modified versions of the firmware make the programmer appear as a single virtual COM port instead of a composite device with two virtual COM ports and a native USB interface. These versions of the firmware do not support the TTL serial port, the SLO-scope, or the configuration utility. These versions are provided to support Mac OS X.
Determining your firmware versionYou can determine the firmware version by following the steps below. To determine the programmer’s revision code in Windows: If you only see one entry for the programmer in your Device Manager, then you have a special modified firmware version. If you see multiple entries for the programmer, then you have one of the standard firmware versions and you can determine the exact version number by following these steps:
To determine the programmer’s revision code in Linux:
If you only see only one device with a name matching
Upgrading FirmwareTo upgrade your programmer’s firmware, follow these steps:
If you run into problems during or after the firmware upgrade, then it is possible that you accidentally corrupted the firmware on your programmer. The solution to this problem is to retry the firmware upgrade procedure. Even if your programmer is not recognized at all by your computer and you see no sign of life from it, you can get it back into bootloader mode by following the instructions in step 3. |
|
Log In
|
Wish Lists
|
BIG Order Form
|
Shopping Cart
US toll free: 1-877-7-POLOLU ~
(702) 262-6648 |
|||||||||||||
| Catalog | Forum | Resources | Distributors | Ordering | About | Contact | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|