CURRENT ISSUE

Contests

bottom corner

Feature Article



Issue #213 April 2008

Programmable Power
Build a Simple USB DAC
by Yoshiyasu Takefuji

Yoshiyasu describes the step-by-step construction of a simple USB DAC around an ATtiny45 and a MAX517. You can use the system as a programmable power supply.

Start | USB Communications | Firmware | MAX517 (DAC) Programming | Firmware, Software, & LIBUSB | Host Device Driver Installation | Testing | Sources & PDF

In this article, I’ll explain how USB communication can be implemented on an Atmel ATtiny45 eight-pin DIP with open-source software packages (libusb, Cygwin, WinAVR, and AVR-USB). WinAVR compiles the target firmware program under Windows. AVR-USB is an open-source USB protocol stack for firmware, which can be compiled by a GNU C compiler under WinAVR. libusb is also an open-source USB protocol stack for a host PC, which is used under Cygwin on Windows, to compile a USB application program.

With the open-source software packages, the USB 1.1 or USB 2.0 low-speed function can be easily achieved without a USB chip. The size of a USB protocol stack for firmware embedded in the ATtiny45 is about 2 KB. Therefore, more than 2 KB is available on the ATtiny45 for user programming. If you use an ATtiny85, 6 KB of space will be available for programming. The USB connector has four pins: 5 V, GND, D–, and D+. The D– and D+ pins are used on the ATtiny45 for USB communication with another two pins for XTAL1 and XTAL2 with a 12-MHz resonator. Note that 1.5 Mbps of USB streaming data can be decoded by the open-source AVR-USB package’s USB protocol stack. The open-source USB protocol stack gives you a user-friendly API, where usb_control_msg and usbFunctionSetup functions are used for USB communication between a host PC and an ATtiny45.

The circuit is built in a breadboard with a 1.5-kW resistor for the 5-V pullup of D– and two 68-W series resistors directly connected to PD0 and PD2 from D– and D+, respectively. The 3.3-V CMOS voltage regulator is used to feed the ATtiny45. Because six ATtiny45 pins (5 V, GND, D–, D+, XTAL1, and XTAL2) are used, two pins are left for MAX517 two-wire serial programming. The MAX517 is a two-wire, 8-bit DAC. The necessary commands must be supplied from an ATtiny45 for D/A conversion.

Photo 1
Figure 1—This is a circuit diagram of a programmable USB power supply using an Atmel ATtiny45 and a MAX517 8-bit DAC.

Figure 1 shows the circuit diagram of the programmable USB power supply. A female USB connector can be custom-made for a user-friendly breadboard (see Photo 1). Photo 2 shows the complete circuit.

Photo 1
Photo 1—This is a hand-made female USB connector for a breadboard.
Photo 1
Photo 2 —This is a completed programmable USB power supply using an ATtiny45 and a MAX517.

The system features an ATtiny45, a MAX517, a breadboard, a 3.3-V voltage regulator, a 12-MHz ceramic resonator, and a female USB connector. It also includes one 1.5-kW resistor, two 68-W resistors, and two 4.7-kW resistors.

The installed software packages on Windows include Cygwin (gcc-core, gcc++, libusb, and other necessary libraries). Download the setup file and double-click it to install the necessary packages (www.cygwin.com/setup.exe). WinAVR must also be installed. Download the latest WinAVR-xxx-install.exe file and double-click the downloaded installation file (http://winavr.source
forge.net/download.html
).

To install Cygwin first, double-click setup.exe in Windows and select the root install directory (in my case, c:\cygwin is given). Next, pick direct connection, choose the nearest site from the list, and select the necessary packages for your system. You must at least install gcc-core, gcc++, and libusb.

Next

 


bottom corner