Automatic Guitar Tuner







A Brief Description

Required Equipments

How it works?

Block Diagram

Algorithm

Detailed Pin Diagram

Problems Faced

Group Members Information

Course Teacher






A Brief Description


In this project, we designed and built an automatic guitar tuner. When using the tuner, the user plucks and tunes the strings one by one. The user tells the tuner which string to tune using mechanical switches. A green LED will be lit to indicate the selected string is tuned. The prototype is shown below in Figure 1.



pin diagram

                                                                                                                              fig.1 Guitar tuner system overview






Required Equipments







How it works?


The complete system can be divided into four sub-systems: microphone input, filter, analog frequency counter, microcontroller, and DC servo with guitar peg attachment.

Microphone input

We used an electret microphone to transduce guitar audio signals into electrical signals. The output of the microphone is connected to a 1uF capacitor. The pull-up resistor and the capacitor filter out frequency components lower than the lowest frequency of the guitar strings (here we chose 30Hz as the lowest string frequency is about 80Hz). The signal is then further amplified by an inverting amplification circuit built using an LTC1056 op-amp. The schematic is shown below in Figure 2. The signal needs amplification because the signal directly from the microphone is not large enough for the subsequent signal processing circuits. The values of R1 and R2 are 1k and 4.7M ohm, respectively.



pin diagram

                                                                                                                       fig.2 Schematic of microphone input circuit



Filter

The amplified guitar signal is then filtered with a switched-capacitor (SC) low-pass filter (LPF). We used an 8th-order Butterworth SC LPF IC chip, the LTC1064-2. The cutoff frequency of the switched-capacitor filter depends on which string is being tuned. The filter cutoff frequency is determined by the input frequency to the LTC1064 chip, which is generated by a voltage-to-frequency converter, the AD654. The circuit schematic is shown below in Figure 4. To be able to vary the output frequency of the AD654 (and thus also the LTC1064 cutoff frequency), we did the following:

  1. Fixed input voltage and timing capacitor values: We set the input voltage Vin to be 0.5V, which is obtained through a resistor divider from the 5V power supply. We chose 1nF for the timing capacitor (CT). We chose values that would allow us to use readily-available resistor values, and that would limit the charging current going into the timing capacitor to be within the range specified on the datasheet of the AD654.

  2. Calculated the value of the timing resistor (RT) for each guitar string: The values can be found in the table below. We calculated the resistor values based on fclk:fc = 100:1 for the switched-capacitor chip (set by tying Pin 10 of LTC1064 -5V).





pin diagram

                                                                                                      fig.3 Schematic of low pass filter built with LTC1064-2 and AD654







pin diagram

                                                                                                              Table 1. Timing resistor values for the six guitar strings





The output from the switched-capacitor filter chip is a sine wave because the second and higher harmonics of the guitar signals are attenuated significantly by the 8th-order Butterworth filter.



Analog frequency counter

The analog frequency counter converts the sine wave output from the filter to a square wave and shifts the DC offset of the wave into the range readable by the Arduino. The schematic of the analog frequency counter is shown in Figure 5 below. It consists of a Schmitt trigger and a DC level shifter. The two triggering voltages are (R1 / R2) * Vz, which are determined by the Zener diode voltage (Vz) and the resistor values. We want the triggering voltages to be about +/- 0.5V because the output from the filter is about +/- 0.8V for the lowest-frequency string (and becoming larger when string frequency increases). We used 3.3V Zener diodes. To get +/- 0.5V triggering voltages, we chose R1 = 1k and R2 = 6.1k. The level shifter is based on an op-amp. We want the input to the Arduino to be within the range 0 - 5 V, but the output of the Schmitt trigger is -5V to 5V. For an inverting op-amp, (Vin - VREF) / R3 = - (Vout - VREF) / R4 And given the conditions that Vin = -5V ? Vout = 5V and Vin = 5V ? Vout = 0V We can get that VREF = 1.4V and R4 / R3 = 0.75. We chose R3= 3.9k, R4 = 3k. VREF is obtained by a voltage divider from 5V, the two resistors are 5.1k and 1.5k



pin diagram

                                                                                                              fig.4 Schematic of analog frequency counter circuit





Microcontroller

We used an Arduino Uno as the microcontroller. The Arduino code is included in the Appendix. There are two main components in the code: 1) count the frequency of the input square wave, and 2) output a PWM signal to the servo based on the difference between the read-in frequency and the desired frequency. The frequency is counted using an analog comparator interrupt. We compare the input square wave with 1.1V (done by setting the 6th bit of the ACSR register for the analog comparator to 1). Every time there is a rising edge, the interrupt request routine is executed and the count is incremented. This continues until 50 cycles are counted, at which point the Arduino calculates the average frequency over these 50 cycles by dividing the total time elapsed by the number of cycles. This average frequency can be affected by startup jitter, noise, etc. So frequencies more than 30Hz away from the target frequency are rejected. The servo is driven by PWM output from the Arduino. The Arduino will only attempt to tune the string when the parsed frequency value is within the 30Hz range of the desired frequency. The Arduino will continue to sample to frequency and turn the servo until it detects a frequency that is +/- 1 Hz away from the desired frequency. Once the Arduino detects that the string is in tune, the Arduino turns a green LED on and stops all movement of the servo. The LED will remain on and the servo will not turn until the Arduino receives a new string input to tune.



DC Servo and Guitar Peg Attachment

The DC servo drives a mechanical device made of plastic, which is attached to one of the guitar pegs. When the servo rotates according to the PWM output from Arduino, it turns the peg and drives it to the desired position. The microphone is listening to the guitar note continuously, and when the system detects that the string has been tuned (i.e., the peg is turned into the correct position), the Arduino will stop the DC servo and light up the green LED.






Block Diagram




                                                                       pin diagram

                                                                                                                                               fig.5 Block Diagram






Algorithm




  1. Taking amplitude as voltage input from microphone by strobing guiter strings.

  2. Fitwering noise and filtering frequency with band pass filter.

  3. Amplifying the input with op-amp.

  4. Level shifting the input to a particular level to avoid the negetive values.

  5. Converting the input (sign wave) to square wave with schematic trigger.

  6. Taking the square wave to arduino uno's ADC pin.

  7. Data sampling and analyzing with arduino code to detect the current frequency.

  8. Calculating motor rotation to reach to the standard frequency from current frequency.

  9. Rotating the motor according to calculated rotation which is connected with a rotating robotic hand and the robotic hand rotates the nob of a certain string acording to the rotation of motor to reach the the string to proper frequency.






Detailed Pin Diagram




                                                                       pin diagram

                                                                                                                                   fig.6 Pin Diagram(Arduino Uno)










Problems Faced


  1. Guiter sound input, taken from microphone was the first difficulty as it outputs too much noise along with inconsistent data too often.

  2. The oscilloscope that was granted for us for this project lagged too much while obseving waves from guiter string and too often it showed unpredictable behviour while showing sound input.

  3. Rotating the nobs of guiter with dc servo was a challange because often it was needed to rotate the motor more than 180 degree so we had to change dc servo and use servo motor with continuous rotation.






Group Members Information


Section A1: Group 5






Course Teachers


  1. Md. Aashikur Rahman Azim

  2. Md. Iftekharul Islam Sakib

  3. Md. Tarikul Islam Papon





Back to top