← Back

Guitar Tuner with DC Motors

2020

This was a class project in Mechatronics at Boğaziçi University, taught by Sinan Öncü, and built with Abdullah Gedük, Ediz Ferit Kula, Alp Uysal, Elif Hacıhasanoğlu, and Kevser Didar İskender.

We built a device that tunes a guitar automatically by turning its tuning pegs with DC motors.

The user experience was:

  1. The user selects a target tuning (E standard, etc.) using the buttons and LCD.
  2. Then, for each string:
    1. The tuner prompts the user to play it.
    2. The user plays, and the tuner measures the string’s fundamental frequency.
    3. The tuner rotates that string’s motor until the string is perfectly in tune.

Frequency measurement

To measure the frequency, the microcontroller first needs to receive the guitar’s sound. There are two ways to do that: use a microphone, or connect an electric guitar directly, since its pickups already output the sound as an electrical signal. We chose the latter. An electric guitar’s output signal is very weak, though, so we built an amplifier to boost it before feeding it into an analog input of our Teensy 3.2 microcontroller.

electric guitaramplifiermicrocontroller.\text{electric guitar} \longrightarrow \text{amplifier} \longrightarrow \text{microcontroller}.

The Teensy sampled the analog audio signal, and we used a discrete Fourier transform to compute its fundamental frequency.

Motor control

Once you know the target frequency and the measured frequency, you can compute the tuning error:

e=ftargetf^.e = f_\text{target} - \hat f.

The sign of that error tells you which way to turn the peg: tighten the string to raise its pitch, or loosen it to lower it. The remaining question is how long the motor should rotate. If it rotates for too long, the string overshoots the target.

To answer that, we calibrated the motor duration experimentally. The relationship between motor-on time and frequency change turned out to be linear, so the tuner simply ran each motor for a duration proportional to the frequency error: longer for a large error, shorter for a small one.

The tuner repeated this measure-and-rotate loop until the frequency error fell below our tuning tolerance, and then moved on to the next string.

Electronics

The electronics were divided into five parts: power, signal conditioning, control, user interface, and motor actuation.

A 12 V, 3 A adapter supplied power to the motors and fed a breadboard power supply that generated the 5 V and 3.3 V rails used by the control electronics. The guitar jack fed the custom amplifier circuit, which boosted the audio signal to a level that the Teensy 3.2 could sample through its analog input. The Teensy computed the string frequency, read the tuning-selection buttons, and displayed the selected tuning and instructions on the 16×2 LCD.

For actuation, the Teensy generated the logic signals for six motor channels. A hex inverter produced the complementary signals required by the motor-control stage. Three L293D dual H-bridge drivers converted these logic signals into bidirectional current for six DC motors, one attached to each tuning key.

The complete circuit of the guitar tuner.

Prototype demonstration. Watch on YouTube.

Read the complete project report: PDF

I’m always interested in discussing business and technology. I also have plenty of ambitious project ideas in mind if you’re looking for one.

Feel free to reach out at dev@atalay.biz.

Follow me at: LinkedIn, X, GitHub, YouTube, Reddit