Introduction: Ukelele Tuner Using LabView and NI USB-6008

As a problem-based-learning project for my LabVIEW & Instrumentation course at Humber College (Electronics Engineering Technology), I created a ukulele tuner that would take an analog input (ukulele string tone), find the fundamental frequency, decide what note was trying to be tuned, and tell the user if the string needed to be tuned up or down. The device I used to translate the analog input into digital input was the National Instruments USB-6008 DAQ (data acquisition device), and the user interface was implemented with LabVIEW.

Step 1: Standard Ukelele Tuning

The first step was finding out the fundamental frequencies of musical notes, and what range the ukulele strings are typically tuned at. I used these two charts, and decided that I would make my tone range between 262 Hz (C) and 494Hz (High B). Anything less than 252 Hz would be considered too low for the program to decipher what note was trying to be played, and anything greater than 500 Hz would be considered too high. The program, however, still tells the user how many Hz they are away from the closest decipherable note, and if the string should be tuned up (note too low) or down (note too high) to reach an available note.

Additionally, I created ranges for each note, rather than just a single frequency, so that it would be easier for the program to find which note was being played. For example, the program would tell the user that a C is being played if the note had a fundamental frequency between 252 Hz (halfway to B) and 269Hz( halfway to C#), but in order to decide if it needed to be tuned up or down, it would still compare the note being played to the fundamental frequency of C which is 262Hz.

Step 2: Creating a Purely Digital Theoretical Model

Before diving into the analog side of the project, I wanted to see if I could create a LabVIEW program that would at least do the main processing of a sound sample, such as reading an audio .wav sample, finding the fundamental frequency, and making the required comparisons to the frequency chart in order to find if the sound should be tuned up or down.

I used the SoundFileSimpleRead.VI available in LabVIEW to read a .wav file from a path that I designated, put the signal into an indexed array, and fed that signal into the HarmonicDistortionAnalyzer.VI in order to find the fundamental frequency. I also took the signal from the SoundFileSimpleRead.VI and connected it directly into a waveform chart indicator so that the user can see the waveform of the file on the front panel.

I created 2 case structures: one to analyze what note was being played, and the other to determine if the string needed to be turned up or down. For the first case, I created ranges for each note, and if the fundamental frequency signal from the HarmonicDistortionAnalyzer.VI was in that range it would tell the user what note was being played. Once the note was determined, the played note value was subtracted by the note's actual fundamental frequency, and then the result was moved into the second case that determined the following: if the result is above zero, then the string needs to be tuned down; if the result is false (not above zero), then the case checks if the value is equal to zero, and if true, then the program would notify the user that the note is in tune; if the value is not equal to zero, then it means it must be less than zero and that the string needs to be tuned up. I took the absolute value of the result to show the user how many Hz they are away from the true note.

I decided a meter indicator would be the best to visually show the user what needs to be done to make the note in tune.

Step 3: Next, the Analog Circuit

The microphone I used for this project is the CMA-6542PF condenser electret mic. The datasheet for this mic is below. Unlike most condenser microphones of this type, I did not have to worry about polarity. The datasheet shows that the operating voltage for this mic is 4.5 - 10V, but 4.5 V is recommended, and it's current consumption is 0.5mA max so that is something to be careful of when designing a preamp circuit for it. The operating frequency is 20Hz to 20kHz which is perfect for audio.

I implemented a simple preamp circuit design on breadboard and adjusted the input voltage, making sure there was not more than 0.5mA across the mic. The capacitor is used to filter the DC noise that might be coupled along with the electric signals (output), and the capacitor does have polarity so be sure to connect the positive end to the microphone output pin.

After the circuit was complete, I connected the output of the circuit to the first analog input pin (AI0, pin 2) of the USB-6008, and connected the ground of the breadboard to the analog ground pin (GND, pin 1). I connected the USB-6008 to the PC with a USB and it was time to make adjustments to the LabVIEW program to take in an actual analog signal.

Step 4: Reading Analog Signals With DAQ Assistant

Instead of using the SoundFileSimpleRead.VI and the HarmonicDistortionAnalyzer.VI, I used the DAQ Assistant.VI and the ToneMeasurements.VI to deal with the analog input. The DAQ Assistant setup is fairly straight-forward, and the VI itself takes you through the steps. The ToneMeasurements.VI has many outputs to choose from (amplitude, frequency, phase), so I used the frequency output which gives the fundamental frequency of the input tone (from the DAQ Assistant.VI). The output of the ToneMeasurements.VI had to be converted and put into an array before it could be used in the case structures, but the rest of the LabVIEW programming/indicators stayed the same.

Step 5: Conclusion

The project was a success but there were definitely a lot of flaws. When I was operating the tuner in a noisy classroom, it was very hard for the program to determine what was noise and what was the tone being played. This is likely due to the preamp circuit being very basic, and the microphone being very cheap. When it was quiet, however, the program worked with good reliability to determine the note that was trying to be played. Due to time constraints I did not make any additional changes, but if I were to repeat the project I would purchase a better microphone and spend more time on the preamp circuit.