This project entails creating a full-functioning automatic guitar tuner. It is capable of tuning guitar string pegs automatically to tune a guitar to a variety of tunings. This provides a remedy for two types of guitarists: one is for the professional, who may not be able to tune his strings by ear in a loud environment and wants his strings tuned instantly. The other is for the novice, who may not have the trained relative pitch necessary to tune the guitar himself. We also aimed to make this device affordable, so that the potential users would not be intimidated by the price point for being able to tune his guitar conveniently.

The tuner is manually attached to the target guitar peg. The guitarist will use a button to select which string he wants to tune, and then pluck the according string for the tuner to correct the guitar tuning. If the guitar is in tune, a green LED will light up indicating that it is in tune. If it is either sharp (too high) or flat (too low), the tuner will light up the corresponding LED and twist the guitar pegs accordingly until it is in tune.

High-Level Project Block Diagram

Mechanical Engineering

We are using a continuous servo motor to wind the guitar pegs. The DC motor provides enough torque to wind a tuning peg if all the power from the Arduino is used for it. Thus, while the motor is turning, the rest of the circuit is temporarily disabled because the code is only focused on turning the motor in the loop. If we had the entire circuit working simultaneously with the motor turning, the Arduino wouldn’t have enough power to turn the guitar pegs with the appropriate torque as the USB port provides only 5 volts.

A: Hole diameter for original servo piece:

3/8 inches

B: Length of attachment:

11/8 inches

C: Width of space for peg:

7/16 inches

D: Height of attachment inside:

5/8 inches

E: Thickness of attachment:

1/16 inches

Electrical Engineering

We are sending a direct signal from an electric guitar’s sound jack, amplifying it through an op-amp with a signal filter, and sending it to the ATmega128. The microcontroller is connected to a servo motor and will rotate the motor depending on the user selection using a button and 6 LEDs (each LED resembles its corresponding string). As you can see in our op-amp circuit, we have a gain of 57 [1 + (56k/1k)] to bring up the voltage to around 5V for the Arduino to read properly. We also added diodes as a fail-safe for the circuit.

Op-Amp:

Software (Programming)

We are translating the analog signal into a digital signal that will control the rate and direction of each motor using our Arduino board. Within our Arduino code, we are filtering out the overtones of each string using a Butterworth filter to isolate the fundamental frequency of the guitar signal. We count how many times the sinusoidal signal crosses a voltage threshold on the y-axis for a period of time on the x-axis in a function. We call this function with the Atmega’s internal timer to get a consistent period for sampling.

After the string input has been idle (meaning the cross counts have been below threshold for a period of time), we then take the average of a few values for cross counts that were within the boundaries of the string (eliminating further possibility of higher frequencies altering our averages) to check if the string is in tune. We found the “in tune” averages and stored them in the Arduino. The microprocessor compares the computed average from the string input to the “in tune” average for each string to determine if it is in pitch.

If the string is in tune, the Arduino will only light up the corresponding LED. If it is out of tune, the Arduino will not only light up the corresponding LED, it will send a PWM signal to the servo motor to turn it either direction depending on if the string is too high or low.

The code also considers the user input from the button, changing the variables for pitch detection depending on the selected string (and lighting up the corresponding display LED)

int led_high = 13; // this LED will show user if a string's pitch is too high
int led_ok = 12; // this LED will show user if a string's pitch is correct
int led_low = 11; // this LED will show user if a string's pitch is too low

// After the string input has been idle for a while, we take the average of a number of cross counts that were in bound.
if (idle_timer == 10000)
{
Serial.println("AVG AVG LOOK HERE AVG AVG");
average_val = avg_cross / divide_by;
Serial.println(average_val);

// If the tuning is off by a questionably high amount, count it as an error in reading and do not turn the peg.
// Otherwise tune the peg for a period of time. This time depends on how far off the read average is.
if (pitch_diff < 20)
for(long i = 0; i < pitch_diff * 36000; i++)
{
digitalWrite(servoPin, HIGH); // start the pulse
delayMicroseconds(15); // pulse width
digitalWrite(servoPin, LOW); // stop the pulse
}
}

// If the tuning is off by a questionably high amount, count it as an error in reading and do not turn the peg.
// Otherwise tune the peg for a period of time. This time depends on how far off the read average is.
if (pitch_diff < 20)
for(long i = 0; i < pitch_diff * 270000; i++)
{
digitalWrite(servoPin, HIGH); // start the pulse
delayMicroseconds(2); // pulse width
digitalWrite(servoPin, LOW); // stop the pulse
}
}

// If the string crosses it's set threshold, add it to the count. If there are no crossings, the idle timer will begin to run.
if (lasty > threshold and y < threshold)
{
cross_count++;
idle_timer = 0;
}
}

Design Description

(1) Servo Motor - This motor uses the pitch detection code from the Arduino to wind the peg to its proper frequency.

(2) Servo Motor Attachment - This is a plastic piece that attaches to the servo motor by fitting onto a smaller plastic piece already installed on the servo motor and fits on the other side to a guitar peg, so that the servo motor can effectively tune the guitar string.

(3) Op-Amp- The op-amp amplifies the guitar signal to a readable signal (around 5V) for the Arduino to determine the pitch.

(4) Pitch detector (Arduino) - The Arduino reads in the amplified signal from the op-amp circuit, then counts how many times the signal crosses a certain threshold to determine the frequency. Depending on which string is selected, it will send a PWM signal to the servo motor to tune the peg to its proper pitch.

(5) Selector button - This will set the variables for the pitch detector, so that the user can choose which string he wants to tune. Each time the button is pressed, the next string will be chosen, shown in the LED Array.

(6) LED Array - These LED's provides information to the user to show which string is being tuned [6 LEDs], and as to whether it is being tuned up or down by the Arduino [3 LEDs].

Cost

Part

Number of units

Total Cost

Arduino Diecimila

1

$35

Servo Motor (Continuous)

1

$30

Servo Motor Attachment

1

<$1

Operational Amplifier (ECG891N)

1

<$1

LEDs

9

<$1

Pushbutton

1

<$1

USB Oscilloscope

1

$140

Capacitors (3.3uF)

1

<$1

Resistors (56k, 22k, 1k)

4

<$1

Cumulative Total Cost

~$211

Conclusion

By the end of the project, we had created an automatic tuner that was mostly accurate for most strings and could tune a string by itself within one or two windings. We were also pleased to find that our two biggest hurdles (signal amplification and pitch detection) were solved with time to spare to allow us to focus on the other components (LEDs and servo control). We were also able to create the tuner using relatively inexpensive parts, as the tuner itself could be made for only around $70.