Understanding the concept
First things first, before we even get started building this Guitar Tuner we need to understand the concepts behind it! To do that there are a few basic ideas that you need to know about. To start out we need to know about Frequency. Frequency is defined as the number of occurrences of a repeating event per unit time. For our purpose we will be looking at a sound wave, so the frequency will be defined similarly to the picture depicted below:
We will be using the measurement of Hertz to describe our frequency. We define this to be:
1 Hertz = 1 Vibration/Second
The next concept that you should understand when working with a guitar is Pitch. The pitch of a sound is directly related to the frequency of the sound wave. A high pitched sound will be a sound wave that has a higher frequency. Similarly a low pitched sound will come from a lower frequency sound wave. When using a guitar as an example, when you pluck a lighter thinner string it will vibrate quickly. These quick vibrations send out a high frequency sound wave, with a high pitch sound. If you were to pluck a string on the opposite end, a heavier and thicker string, it will vibrate more slowly. This will have a lower frequency sound wave and thus a lower pitch sound. The image below accurately depicts this:
Another useful concept to know about is Tone. For our purposes we will be considering a musical tone, such as the one a guitar makes! There are many different parts that make up a musical tone. It consists of the duration, pitch, intensity, and timbre. The duration of a tone is how long it lasts for. We spoke of the pitch of a sound wave above. Intensity is how loud or quiet the sound is. As for timbre, this signifies the quality of the sound. Timbre is what allows us to differentiate between slightly different sounds. There are multiple types of tones. For example a simple tone will only have one frequency, but can vary in intensity. If you are looking at a complex tone then it will be made up of two or more simple tones and thus can vary in more than one category.
The last thing you need to know is how a guitar makes a sound. When you pluck the strings of a guitar they begin to vibrate back and forth. This vibration sends off sound waves through the air that humans can pick up on. There are generally 6 strings on a guitar, all with varying thickness and weight. Depending on the string that is plucked, you will get a sound wave with either high or low frequency. Humans can detect frequencies in the range of 20 to around 20,000 Hz and can differentiate between small differences in these. Our goal for this project is to be able to build a device that can detect these different strings.
We compiled two separate parts lists. One for building our design and one for testing it. You could use various tools and software to test the circuit but we took advantage of what we already had at our disposal.
Parts List for Building
- Elegoo Uno R3 board
- LCD Screen (1602 Module)
- 10K Potentiometer
- ADTL082 JFET Op-amp(TL082)
- 4 resistors (3 100kΩ and 1 4.7kΩ)
- 2 capacitors (1 10μF and 1 100nF)
- ¼” Audio jack
- Power source (board is powered by USB from the computer, op-amp is powered from +/-5V of the Analog Discovery, everything else is powered by the 5V off the Elegoo)
Parts List for Testing with Perfect Signal and Guitar
- Waveforms Software
- Analog Discovery
- Electric Guitar(make sure volume is all the way turned up)
Circuit Schematic and Code
This is the final schematic of our guitar tuner. What this circuit does is take a ~50 mV peak to peak signal and amplify it to ~2.5V peak to peak, then give it a ~2.5V DC offset so that the signal is centered around 2.5V. This signal is then fed into an Elegoo Uno, which finds the frequency of the signal and associates it with a string. Once it has associated a string with the frequency of the signal, it outputs the name of the string to an LCD string.
In a previous iteration of the circuit, we attempted to have a microphone with built in adjustable gain as our input. This proved to be difficult, as there was too much noise in the signal for the code to be able to differentiate a frequency from it. What we decided to do instead was use a non-inverting amplifying circuit that took its input from a ¼” guitar jack.
Our next iteration of our circuit had a 22kΩ as the far left resistor value. When we tried strumming the guitar, we found that the circuit wasn’t amplifying the signal as much as we wanted. We wanted our signal to be amplified to about 5V peak to peak, but it was only being amplified to 250mV. The code was unable to discern a frequency from a signal with such a small amplitude, so we changed the 22kΩ resistor to a 4.7kΩ resistor. The change in resistance amplified our signal to 2V peak to peak. Although this is not what we wanted ideally, we found that this amplification was enough for the code to get a frequency from the signal. Here is what our amplified (blue) signal looks like in comparison to our clean wave (yellow).
Here is a picture of our final circuit:
Our final code can be found at this link http://docdro.id/JaNlx7r. We based our code from the code found in this instructable. The main changes we made were to remove the sharp/flat functionality, and to change the method of displaying the note.
Testing Setup – Clean Wave
Once the circuit is assembled and you’ve loaded the code onto the Arduino we recommend testing it using a function generator and oscilloscope to make sure each part is performing as expected and to give some insight as to what each part is doing to the signal. Our group made use of the Digilent Analog Discovery.
First we wanted to ensure that if our Arduino was given a good clean sine wave that it would be able to determine its frequency. Set your function generator to produce a sine wave with 2.5V DC bias, max amplitude of 5V and frequency of one of the guitar strings (Note that the analog in port can only handle voltages between 0 and 5 Volts. Going below or above these limits can damage your Arduino). Plug it directly into the A0 port of the Arduino and check the LCD screen to see if it’s displaying the proper note.
Next, you want to see if the amplifier circuit is giving you the amplification that you need. The input coming from the guitar should have max amplitude of 50-200mV centered at 0V and the output should have max amplitude 5V centered at 2.5V. Use the function generator and oscilloscope to test the output against a known input.
If all of these parts work individually, hook it all together and feed in a 50-200mV centered at 0V with frequency of one of guitar strings. Check the LCD screen for the correct note.
Testing Setup – Actual Guitar
Once you’ve verified that your circuit is amplifying your signal correctly, the last thing to do is plug the guitar into the audio jack. We had the WaveForms scope measure the original input signal (the signal coming off the guitar) and the amplified signal to make sure that the signal was being amplified correctly. We also monitored the frequency that the Elegoo measured from the signal to make sure it was getting the correct frequency from the correct string.
We strummed the D string and got the following signal and frequency output.
The circuit amplified the signal to ~2V and read a frequency in the D string range. We tested the low E string as well and got the following signal and frequency output.
The circuit once again amplified the circuit correctly and read a frequency in the E range. Here is a video of us going through each string on the guitar. We hope our project serves as a stepping stone for those learning about signals and systems and encourages them to try and make something of their own.