This will most likely be my last project log, but I'm happy to say that my project actually has results! Here is a video of the tuner tuning the G string. As you can see, its a fully automated process, tuning every six seconds. it works pretty well, and in the future I would recommend using a raspberry pi and python as its a stronger language. If I had more time I would test this on other instruments.
I also laser cut more parts of the box to account for the excess wiring.
Here's a video of how my project works, I'm not using a ukulele since it's harder to record. Also, since I'm using a 9 volt battery, the motor doesn't always have enough torque. I was able to get the entire circuit up inside the box, but my subpar soldering skills proved to be my enemy, and it broke. My goal is to create another circuit that is better quality, as using a breadboard just isn't going to cut it. I'm taking a break to make a better game plan as I went headfirst into this endeavor the last time.
Ok so, its definitely been a while since I last updated this, but never fear! I've been getting so much done lately. I might also reiterate stuff I said in the last post. The FFT works really well, and I was able to code a method in arduino that turns the stepper motor in response to whatever the FFT is spitting out compared to the desired frequency. Here are my results after a bit of tweaking (ignore the 440hz, im using a free trial of an app):
As you can see, the tuner was able to get each string relatively close to what it was supposed to sound like. It works the worst with A since the code has trouble accurately detecting frequencies in that higher range.
After getting the code to work satisfactorily, I decided to start working on the actual product as a whole, and making look like something nice instead of a bunch of wires. I also decided to work on creating an interface, so that people with literally 0 coding or tech experience could use it. This was very hard for me as I am really bad at CAD, but so far, it is looking really nice. Now, I'm figuring out how to get the entire circuit to fit into this cute box!
My FFT code FINALLY WORKS. It is pretty accurate (within 5 Hz usually) and works with my ukulele, and so I've started working on the code that tunes the instrument based on the frequency. I'm using a microphone that doesn't have automatic gain, so that definitely helps. So far, it's working pretty well (it tunes G especially nicely), but the unsteadiness of the output is messing things up. I can attribute that to the fact that the voltage doesn't vary that much, so the signal isn't the easiest to work with. To combat this I have to take the average of the output, which slows things down a bit but definitely makes it more accurate. If I can't fix this even more via my code I'll have to try and mess with the gain to amplify the signal some more.
Now, I am tweaking my code and microphone since the results are not as constant as I'd like.
I received a lot of guidance from a fellow classmate about using FFT for my project, and in an hour so I received a lot of information and realized that I was actually on the right track for my project. I was playing around with Amanda Ghassaei's code, since that made the most sense to me, and it turned out he was able to successfully reproduce her results in the past. The first problem he helped me tackle was the fact that the FFT code wasn't printing anything readable on my arduino. We used an oscillator and a wave signal generator to test the code that he used for a similar project and it worked perfectly, crossing off the possibility that my arduino was not functional.
After looking at the electret microphone, we realized that automatic gain and voltage range (0-2.5 instead of 0-5) was the reason why the code didn't read anything from it. Since the code calculates the frequency using the amplitude and midpoint, we halved all of the values from 128 to 63, and then we got legible data. However, since the equipment I was using had automatic gain (which increased when no sound was detected and vice versa) we realized it would be better to use a piezo, which was my original plan, so the signal could be clean.
The main reason why I was testing FFT with a microphone in the first place was because I didn't have a simple way to boost the signal from the piezo sensors I was using. My friend also led me to some resources that i can look at to easily create an op amp circuit, but I will most likely also look into ordering one in the future to make the overall device more compact. For now, I will get used to using the oscillator (i don't really need the wave signal generator since I know the code works) to test out my eventual op amp circuit that I will begin working on in January. If everything goes to plan, I should be able to strum my ukulele and get an accurate frequency reading very soon.
Last month, I was able to 3D print a shaft that fits both onto the nema motor and the ukulele. The slot design was much easier to design and implement. I also verified that the motor has enough torque to turn the strings. Once getting the more hardware-y components out of the way I started testing out different sensors to see which one would work the best for detecting frequency of my ukulele.
I started out with a large piezo vibration sensor from adafruit, but the output I was getting was weak and not very detailed, even when I tried changing the circuit by using different combinations of resistors. I was however, able to write some code that made the motor rotate 360 degrees in both directions when a vibration was detected, which is the most basic version of what I want my project to end up being. These sensors are better for absolute thresholds or detecting knocks rather than a specific vibration of an object.
My teacher suggested another type of sensor to use, an electret microphone. (specifically the Max 9814) At first, I was against the idea, as I wanted my input to be solely vibrations. But since I was having so much trouble getting usable data from vibration sensors, I decided to give it a try. The microphone actually had quite a lot of perks. For one, it dims sounds that come from further away and amplifies closer sounds, which helps with my initial worries of surrounding sounds interfering with data collection. The signal from this sensor is also stronger due to a built in op-amp, so I didn't need to create my own circuit since it was all built in.
Now that I have a sensor that gives good output (still debating on buying another version that's simpler and easier to use), I am now working on the most difficult aspect of this project: the code. Specifically, the FFT (Fast Fourier Transform) code that does all the work of determining the frequency of incoming raw data from sound/vibration waves. It's much easier to run FFT on something like Python or MATLAB, since arduino is more limited than those languages. However, libraries for FFT on arduino exist, and I'm currently trying to figure it all out or maybe write my own. It's very complicated, but I'm sure I'll figure it out.
So far, I have decided to use a standard NEMA 17 stepper motor, and have tested it out to confirm that it has enough torque to turn the pegs on my ukulele. I used a L298 motor module with an arduino uno, using code i found that comes with the arduino program. Now, I'm splitting my time between using peizo vibration sensors and designing the overall product with CAD. I am working on an initial design that will connect the motor to the peg better the than very ratchet set up I have shown. The first design has too much space so my next attempt will just be a slot that the peg can be inserted into. Once I get that sorted out, I will focus on getting readable and accurate vibration data from the piezo sensor/accelerometer that I've ordered.