ECE 477 Digital Systems Senior Design Project Spring 2009

Homework 3: Design Constraint Analysis and Component Selection Rationale Due: Friday, February 6, at NOON

Team Code Name: ______das Autotünr______Group No. ___4__ Team Member Completing This Homework: __Joe Blubaugh______E-mail Address of Team Member: cblubaug @ purdue.edu

Evaluation:

SCORE DESCRIPTION Excellent – among the best papers submitted for this assignment. Very few 10 corrections needed for version submitted in Final Report. Very good – all requirements aptly met. Minor additions/corrections needed for 9 version submitted in Final Report. Good – all requirements considered and addressed. Several noteworthy 8 additions/corrections needed for version submitted in Final Report. Average – all requirements basically met, but some revisions in content should be 7 made for the version submitted in the Final Report. Marginal – all requirements met at a nominal level. Significant revisions in 6 content should be made for the version submitted in the Final Report. Below the passing threshold – major revisions required to meet report * requirements at a nominal level. Revise and resubmit. * Resubmissions are due within one week of the date of return, and will be awarded a score of “6” provided all report requirements have been met at a nominal level.

Comments: Comments from the grader will be inserted here. ECE 477 Digital Systems Senior Design Project Spring 2009

1.0 Introduction das Autotünr is an automatic guitar tuning and music transcription system. It simultaneously tunes a guitar using an array of sixmotors and allows music to be recorded as MIDI files to an external USB storage device. Because of its musical nature, the product must have real-time responsiveness in transcription mode and a fast response in tuning mode as well. The tasks of tuning and transcription are fundamentally sound analysis problems; therefore the device will need the power to perform signal processing techniques quickly and at a high resolution. The device must also interface to consumer USB storage products and will require enough power to drive six small motors.

2.0 Design Constraint Analysis

There are a number of design constraints acting on the project that must be considered. The computational requirements of signal processing algorithms will require a powerful digital signal processor (DSP). General purpose input/output (GPIO) will be used to power a user interface. Numerous on-chip peripherals, including analog to digital converters (ADCs) and pulse-width modulators (PWMs) will be required. An external USB controller will also be needed to connect to storage devices. The power requirements created by driving motors will be addressed, as will the packaging constraints derived from the need to connect the device to a guitar. Finally, cost constraints will also be considered by comparing das Autotünr to other tuning devices that are both simpler and more complicated than it.

2.1 Computation Requirements

In order to tune a guitar, the product will need to be able to sample analog audio and determine frequency characteristics of the sound very accurately. When it comes to musical notes, the human ear can distinguish between frequencies as fine as 2 Hz apart [1]. In addition, small imperfections in tuning can lead to an interference phenomenon called 'beating.' For these reasons, it is essential to have a fine frequency resolution in tuning mode. This requires a large number of samples: in the Discrete Fourier Transform (DFT), the frequency resolution of samples is the sampling frequency divided by the number of samples computed [2]. While zero- padding can be used to reduce the number of samples that actually need to be taken, memory space for these zeros must still be reserved in order for most available DFT libraries to compute correctly.

In transcription mode, absolute accuracy becomes less important, as long as notes in a musical scale can be distinguished. Real-time performance, on the other hand, becomes imperative so that accurate timing information can be captured. Taking these two requirements together, it becomes apparent that both a large amount of data memory (for fine-resolution spectrum analysis) and a fast processor core (for real-time performance) are necessary to successfully execute the functions of the device. For this reason, it is useful to separate the DSP functions from the 'device management' functions.

2.2 Interface Requirements

-2- ECE 477 Digital Systems Senior Design Project Spring 2009

The device will interface with a character-mode LCD to provide feedback to the user and will accept pushbutton inputs to allow the user to control device function. Interfacing to the LCD will require one GPIO pin and a software routine to control the issuing of commands. It may also be possible to use a built-in serial communication peripheral to handle this. At least four pushbuttons will be needed to allow the user to navigate a nested menu structure, so at least four GPIO pins will be needed to handle inputs from these. Because these are simply switches, a high-value resistor will be used to keep sink current on these pins to a negligible value. In addition, three GPIO pins will be used to control an RGB LED. These will essentially be software PWMs utilizing one of our microcontroller's on-board timers. Most RGB LEDs require 2.5 Vf to operate correctly, so the remaining voltage will be dissipated by a resistive element on each line. Since each line will be driving only one LED, amplification circuitry will not be necessary.

2.3 On-Chip Peripheral Requirements

In order to sample audio one channel of ADC is required. In order to have fine-grained amplitude numbers, a 10-bit or greater ADC is desired. To simultaneously drive the servo motors that will tune the strings, six channels of PWM output are necessary. A pair of matching serial interfaces will be needed on the DSP and microcontroller in order to create a communication channel. In addition, two more serial interfaces will be needed to interface with the USB host controller and the user interface LCD. Several on-chip timers will be needed on both the DSP and the microcontroller in order to maintain real-time communications and accurately control motors.

2.4 Off-Chip Peripheral Requirements

One off-chip peripheral will be required: a USB host controller to manage loading MIDI files to an external USB storage device. The controller will communicate with the microcontroller through a serial communication interface.

2.5 Power Constraints

Because the device will include motors who will consume much more power than the electronic components, the project will be A.C. Powered without a battery backup. The motors required for the project can run on unregulated DC voltage but have a maximum 6VDC source voltage. The supply will need to be able to provide several amperes of current in order to drive the motors, supply power to the electronics, and supply the USB specified 500 mA of supply current.

2.6 Packaging Constraints

The device will include a piece that can be attached to the headstock of an acoustic guitar, as well as a second piece containing the user interface, microphone, and USB port. The cabling connecting these pieces will include both power and control lines for the tuning motors. The

-3- ECE 477 Digital Systems Senior Design Project Spring 2009 control lines will need to be adequately shielded to prevent cross-talk. The project could be packaged as a single unit that the guitar is laid on or a multi-piece unit connected by cables.

2.7 Cost Constraints das Autotünr fills the void between two commercially available products: electronic chromatic tuners like the Korg ABCDERF that can be found for $14.99 at jr.com and integrated automatic tuning systems like the Gibson Robot guitar. These integrated solutions are very expensive, adding about $800 in the Gibson guitars. das Autotünr is intended to work with any guitar without modification and should cost less than $400 in order to make it a compelling tool for guitar enthusiasts and technicians.

3.0 Component Selection Rationale

There are four major electronic components in this design. A microcontroller will direct the motors, send data to a USB controller, and control the user interface. A DSP will sample analog audio, perform a spectral analysis and communicate tuning and note information to the microcontroller through a serial interface. A USB controller will take MIDI data sent to it by the microcontroller and write it to a USB storage device. An audio amplifier will be needed to bring the low level signals from a microphone or phono cable to a higher-voltage signal that is better for AD conversion.

3.1 Microcontroller

Since the microcontroller will be responsible for simultaneously controlling six separate motors, the number of PWM outputs is very important. Timer channels were also at a premium. Serial devices for interprocessor communication were another key feature guiding microprocessor selection. Two microcontrollers that fit within the essential design constraints are Microchip's PIC24HJ128GP306 and Freescale's MC9S12DT256. Each microcontroller has eight PWM channels, at least eight timers, and at least two serial communication channels. Each also has a number of peripherals we will not be using: ADCs and CAN interfaces are available on both processors [3], [4]. In most categories, the PIC processor is superior. It is available with 16 kilobytes (KB) of data memory as opposed to the MC9S12's 12 KB. It has 64 pins compared to the MC9S12's 112 [3], [4], making it easier to solder to the board. The PIC's unit price of $5 is very favorable compared to the MC9S12's price of $13 [5],[6]. Microprocessor and DSP selection also influenced each other. PIC offers DSP chips that have a very similar programming model to their microprocessors. This shared environment will help speed software development, so the PIC24 was selected for this design.

3.2 Digital Signal Processor

The decision to include a separate DSP was made because of the computationally intensive DFT, which will be needed in order to analyze the frequency spectrum of the guitar signal. Completing this computation quickly is essential to the responsiveness of the system. Two families of DSP

-4- ECE 477 Digital Systems Senior Design Project Spring 2009 were evaluated: Analog Device's ADSP-21XX DSPs and Microchip's dsPIC family. Candidates included the ADSP-21992 and the dsPIC33FJ64GP306. In terms of raw performance, the ADSP-21992 is a superior chip. It has more available RAM, at 64 KB than the dsPIC's 16 KB. The ADSP is also capable of operating at 160 MHz, much greater than the dsPIC's 7.5 MHz. However, the ADSP has a number of disadvantages for this project: it has 176 leads, requires an external clock circuit, and costs $30 per chip [7]. The dsPIC, which still meets our computational needs, is a 64 lead device with an internal oscillator [8] and a unit price of $3.81 [9]. It also shares a development environment with the PIC24 microprocessor discussed above. This combination of factors led to the choice of the dsPIC as the project's DSP. 3.3 USB Interface Component While there are microprocessors available with USB functionality built-in as a peripheral device, most USB interfaces are currently handled by a specialized microprocessor or other device. Two different solutions were considered for this component: FTDI's Vinculum USB Host Controller VDIP1 and the Cypress Technology SL811HS. The SL811HS operates at 3.3V, the same supply voltage as our other major components [10], while the VDIP1 requires a 5V input [11]. Both take 3.3V logic inputs, so no translation will be required. The most compelling difference between the two is that the VDIP1 has free firmware available that implements a FAT filesystem interface while the SL811HS does not. Because this will reduce the software workload, the VDIP1 was selected. 3.4 Audio Amplifier Signals from microphones and electric guitar cables are very low voltage, so an amplifier is needed in order to bring the device to a level that is compatible with our DSP's ADC. An audio amplifier is required because their circuitry is designed to have a flat frequency response in the audible frequencies of 20 Hz – 30 KHz and they produce very clean signals. Two candidate devices are the LM386 (available from National Semiconductor, Contek, and FCI) and the NJW1105 from New Japan Radio Company. Both are designed to operate on supply voltages of 4 to 12 volts and do not require bipolar power supplies [12], [13]. The NJW1105's primary advantage is its unification of two amplifiers in one package. It also costs more than twice as much as an LM386 and does not provide an externally settable gain. Because of these facts, the LM386 is more suitable, even though two of them will need to be populated and routed.

4.0 Summary das Autotünr is subject to a number of design constraints including a high computational load and a number of required communication channels. The device will have a high power requirement due to its simultaneous use of motors, so supplying enough power will be a key concern in the design. Based on the constraints the project is subject to, a microcontroller and DSP chip were chosen, along with an external USB interface controller and an audio amplifier.

-5- ECE 477 Digital Systems Senior Design Project Spring 2009

List of References

[1] Shera, et. al. “Revised estimates of human cochlear tuning from otoacoustic and behavioral measurements”. PNAS vol. 99 no. 5 3318-3323 March 5, 2002. [2] “Discrete Fourier Transform.” Internet: http://www.diracdelta.co.uk/science/source/d/i/discrete%20fourier %20transform/source.html, [February 2, 2009]. [3] Microchip, Inc, “High Performance, 16-bit Microcontrollers,” PIC24HJXXXGPX06/X08/X10 Data Sheet, June 2007. [4] Freescale, “MC9S12DT256 User Guide,” MC9S12DT256 datasheet, March 2003 [Revised January 2006]. [5] Microchip. “PIC24HJ128GP306.” Internet: http://www.microchip.com/wwwproducts/Devices.aspx? dDocName=en024689#2, [February 3, 2009]. [6] Freescale. “MC9S12DT256 Product Summary Page.” Internet: http://www.freescale.com/webapp/sps/site/prod_summary.jsp? code=MC9S12DT256&nodeId=null&tab=Buy_Parametric_Tab&fromSe arch=false, [February 4, 2009]. [7] Analog Devices. “Mixed-Signal DSP Controller with CAN.” ADSP-21992 datasheet, Aug 2007. [8] Microchip, Inc, “High Performance, 16-bit Digital Signal Controllers,” dsPIC33FJXXXGPX06/X08/X10 datasheet, Dec. 2006. [9] Microchip. “dsPIC33FJ64GP306.” Internet: http://www.microchip.com/wwwproducts/Devices.aspx? dDocName=en024665, [February 3, 2009] [10] Cypress Semiconductor, “Embedded USB Host/Slave Controller,” SL811HS datasheet, Mar 2002. [11] FTDI, “Vinculum VNC1L Prototyping Module,” VDIP1 datasheet, Aug. 2006 [Revised March 2007] [12] New Japan Radio, “Dual Audio Power Amplifier,” NJW1105 datasheet, Feb. 2005. [13] National Semiconductor, “Low Voltage Audio Power Amplifier,” LM386 datasheet, August 2000.

-6- ECE 477 Digital Systems Senior Design Project Fall2008

Appendix A: Parts List Spreadsheet Vendor Manufacturer Part No. Description Unit Cost Qty Total Cost Microchip Direct Microchip PIC24HJ128GP306 16-bit microcontroller $5.28 1 $5.28 Microchip Direct Microchip dsPIC33FJ64GP306 16-bit DSP with ADC $5.24 1 $5.24 FTDI Chip Shop FTDI VDIP1 USB Host controller board $26.93 1 $26.93 Digikey National LM386-1-ND Low Voltage Audio Power Amplifier $1.09 2 $2.18 Semiconductor Digikey Diodes, Inc AP1117T33L-U 3.3 V Linear Regulator $1.05 1 $1.05 Mouser ST Microelectronics L4941BV 5.0 V LDO Linear Regulator $1.17 1 $1.05 Parallax Parallax 900-00008 Continuous Rotation Servo $12.99 6 $77.94 Digikey CUI Inc EMT060350-P5P-KH AC/DC converter, 6VDC, 3.5A $16.80 1 $16.80

TOTAL $136.47

-7- ECE 477 Digital Systems Senior Design Project Fall2008

Appendix B: Updated Block Diagram

-8-