This page has technical information on how the guitar tuner worked. If you have more questions, please feel free to contact me.
The electric guitar rests in a stand that has servos positioned to reach the tuning pegs and the strings. The servos that are connected to the tuning pegs (one per peg, 6 total)are continuous-rotation servos that receive a square wave (PWM) to control the speed and direction of rotation. The servos that are connected to the strings (one per string, 6 total) are finite-rotation servos that receive a square wave (PWM) to control the angle of the servo. These servos have guitar picks attached to their horns to strum the strings. All programming was done in LabVIEW. My main contribution to this project was the majority of the myRIO programming (Data Acquisition, Signal Processing, Controller, and Actuation signals).
The electric guitar was connected from it’s audio out (1/4″ audio jack) directly to the myRIO’s “Audio In” port. The audio that we were focusing on was up to 330 Hz (high e of the guitar), so we had to sample our data at above 660 Hz. To be safe, we picked a sampling rate of 2000-3000 Hz. The sampling was done via the myRIO FPGA (Field Programmable Gate Array). The data was stored in a FIFO (First In First Out) and used DMA (Direct Memory Access) to make the data accessible from the myRIO’s main processor.
On the myRIO’s main processor, the signal was filtered using a band-pass filter from 5 Hz (to remove any DC component) to 400 Hz. This reduced our data to just the range of audio around the standard tuning of a guitar. We waited for the FIFO to accumulate 2000-3000 samples (number of samples equal to the sampling rate) in order to get a frequency resolution of 1 Hz when we put the signal through the FFT (Fast Fourier Transform). The FFT told us the frequency-amplitude breakdown of the sound signal coming in.
With the frequency information of the audio wave, we could begin our controller operations. Knowing that the harmonics of a single string being played would be scalar multiples of the root frequency (the frequency that your ears respond to most out of the harmonics, also the lowest frequency), we could take the frequency with the highest magnitude from the FFT and find the modulus of that frequency and our target frequency to find the offset of the actual frequency from the target frequency. From there we used a simple proportional controller to determine the speed input to our tuning servos. While monitoring the frequency information of the signal, we had a simple logic trigger to re-strum a string when the maximum amplitude (volume) of the signal was below a pre-set threshold, the strumming servo associated with that string would strum the string. This process ran continuously during all tuning functions to make sure that the proper audio signal was being acquired.
Once the proper PWM signal was determined by the controller, we used a control reference from the main processor to the FPGA. The controls that we referenced on the FPGA created the PWM signal that was then sent to the servos via the myRIO’s digital IO ports. The myRIO digital IO ports will only supply a 0-3V PWM signal, but the servos used for strumming required a 0-5V PWM signal. To get the proper signal, we used transistors gated across a 5V potential difference (source to drain) with the gate controlled by the 0-3V PWM signal from the myRIO. This gave us the proper 0-5V PWM signal for the strumming motors.