8. Using the USB Communication Port

The Orangutan SVP’s USB Connection provides a virtual serial port called the Pololu Orangutan SVP USB Communication Port which allows two-way communication between a personal computer and the Orangutan SVP’s AVR at a rate of over 20 kilobytes per second.

The bytes sent from the computer will be transmitted to the Orangutan SVP’s auxiliary processor and made available to the AVR. Bytes sent by the AVR will be sent to the computer. In addition to this two-way data communication, you can use the RTS and DTR handshaking lines. The state of these lines (either 0 or 1) is controlled by the computer and can be read by the AVR. Several standard terminal programs set the DTR line to 1 when they connect to a serial port, and then set it to 0 when they disconnect. Therefore the DTR line can be used to determine whether a terminal program is connected to the Orangutan, and make the Orangutan’s behavior dependent on that.

On the PC side, the Orangutan SVP’s USB drivers make the USB Communication port look like a standard serial port to the operating system, allowing you to use existing terminal programs and software designed to use serial ports. On the AVR side, the Pololu AVR C/C++ Library provides serial communication functions for using the port.

Communication on the PC side

To use the USB Communication Port, 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 Orangutan SVP USB Communication Port entry. The port name will be at the end of this line in parentheses (e.g. “COM3”). In Windows, a given device will always be associated with the same port unless you manually change its port assignment in the Device Manager (see Section 5.a).

Windows 8 device manager showing the Pololu Orangutan SVP.

To determine the port name in Linux, type ls /dev/ttyACM*. The port name will be one of the devices listed there. If there are only three ports, then the USB Communication Port will be /dev/ttyACM1 (the programmer will be /dev/ttyACM0 and the TTL serial port will be /dev/ttyACM2). If you see more than three ports, then you should look at the output from dmesg when you plug in the Orangutan SVP to see which three ports are created; the second port is the USB Communication Port. In Linux, the port name depends on how many other devices are using the USB CDC ACM driver to create virtual serial ports at the time the Orangutan SVP is plugged in.

To determine the port name in Mac OS X, type ls /dev/tty.usb*. There should be three entries for the Orangutan SVP, and the USB Communication Port should be the second one.

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). To use any of these terminal programs, you must specify the port name determined above.

PuTTY is a free Windows terminal program that can send and receive bytes on a serial port.

If you need to send and receive non-ASCII bytes, you can use the Pololu Serial Transmitter Utility for Windows.

Advanced users developing scripted applications may prefer the free terminal program kermit (Windows or Linux).

You can also write a computer program to use the serial port. The freely available Microsoft .NET framework for Windows 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 the USB Communication Port:

// Choose the port name and baud rate.
//   Port Name must be determined from the Device Manager.
//   Baud rate is irrelevant for the USB Communication Port.
System.IO.Ports.SerialPort port = new System.IO.Ports.SerialPort("COM4", 115200);

// Connect to the port.
port.Open();

// Set the DTR line to 1.
port.DtrEnable = true;

// Transmit two bytes to the AVR: 0x61, 0x62
port.Write(new byte[]{0x61, 0x62}, 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);

// Set the DTR line to 0.
port.DtrEnable = false;

// Disconnect from the port so that other programs can use it.
port.Close();

Communication on the AVR side

Writing programs for the USB Communications port on the AVR side is supported by two different sections of the Pololu AVR C/C++ Library.

The SVP-specific functions section of the library provides the rts_enabled() and dtr_enabled() functions which return the states of those control lines. Complete documentation of the SVP-specific functions can be found in Section 13 of the Pololu AVR Library Command Reference. A high level overview can be found in Section 3.j of the Pololu AVR C/C++ Library User’s Guide.

The Serial Port Communication section of the library provides many functions for serial communication, all of which will work for the USB Communications port. Complete documentation of serial communication functions can be found in Section 10 of the Pololu AVR Library Command Reference. A high level overview can be found in Section 3.h of the Pololu AVR C/C++ Library User’s Guide.

Related Products

Orangutan SVP-324 Robot Controller (assembled)
Orangutan SVP-324 Robot Controller (partial kit)
Orangutan SVP-1284 Robot Controller (assembled)
Orangutan SVP-1284 Robot Controller (partial kit)
Log In
Pololu Robotics & Electronics
Shopping cart
(702) 262-6648
Same-day shipping, worldwide
Menu
Shop Blog Forum Support
My account Comments or questions? About Pololu Contact Ordering information Distributors