How Can I Read Sound Frequencies with a Controller?

Click For Summary

Discussion Overview

The discussion revolves around the methods and components needed to read sound frequencies using a controller, specifically focusing on the use of a microphone, signal processing, and the challenges faced in achieving accurate readings. The scope includes technical explanations, experimental setups, and some conceptual clarifications related to audio signal processing.

Discussion Character

  • Technical explanation
  • Experimental/applied
  • Debate/contested

Main Points Raised

  • One participant suggests using a microphone, a pre-amp, and an ADC input for reading sound frequencies, emphasizing the need to bias the audio signal.
  • Another participant describes their setup with an op-amp and variable resistor, noting issues with noise and the limited range of signal values when playing notes.
  • Concerns are raised about the noisy baseline affecting zero-crossing detection, with a suggestion for a low pass filter to mitigate this issue.
  • It is proposed that increasing the gain on the pre-amp could improve the signal range, but this may also exacerbate noise issues.
  • Participants discuss the importance of grounding unused inputs on the Arduino to reduce background noise and unexpected circuit behavior.
  • There is a mention of the potential differences in noise levels when using different sound sources, such as a guitar versus whistling.
  • One participant inquires about the effects of defining unused pins as outputs and whether this could help with noise reduction.
  • Another participant suggests using a method to retrieve ADC values for analysis, which could provide insights into the signal quality.

Areas of Agreement / Disagreement

Participants express various viewpoints on the best methods to improve signal quality and address noise issues, indicating that multiple competing approaches exist. The discussion remains unresolved regarding the optimal setup and configurations for reading sound frequencies accurately.

Contextual Notes

There are limitations related to the assumptions about signal processing techniques, the definitions of terms like "range" and "amplitude," and the specific characteristics of the sound sources being used. The discussion also highlights unresolved mathematical steps in the signal processing methods proposed.

Who May Find This Useful

This discussion may be useful for individuals interested in audio signal processing, electronics, and those working with microcontrollers in experimental setups involving sound frequency analysis.

UR_Correct
Messages
36
Reaction score
0
Hi all,

I was wondering how I would go about reading sound frequencies with a controller. Would I need like a microphone and some secondary chip to convert the signal?

Any help would be greatly appreciated.

EDIT: I probably need a low frequency one, between 50-500 Hz
 
Last edited:
Engineering news on Phys.org
By "with a controller" I'm guessing that you want to use a PIC chip or something like that...

In that case you need a microphone, a pre-amp -- which could just be a single op-amp with a gain of maybe 100, and an ADC input of the controller. The ADC will only handle 0-Vcc volts, so you need to bias the audio signal up such that the quiet-no-signal baseline is at 1/2 the Vcc voltage. Then you need to sample the ADC at at least twice the frequency of the highest pitch you want to recognize. The simplest thing to do with the samples is count zero crossings (at that 1/2 Vcc value), but with noisy or non-harmonic sounds that may not be very accurate. The step after that is Digital Signal Processing...
 
Thank you! Here is what I have so far. My Vcc is 5V, and I used an op amp and a variable resistor to get the baseline at 2.5V (quiet). I'm using arduino's UNO, so they have nice 10-bit resolution (1024) analog inputs, so I'm getting around 500 as a digital value for quiet. It does jump around a bit, maybe between 480 and 520, which is due to noise, I'm sure.

The problem is that when I play any note (like whistle or something), the signal only really goes from maybe 400 - 600. How can I make it so the range is higher (i.e. 200-800)? Is the range the amplitude? Shouldn't I see discrete values that would make up a sine wave?
 
It's also hard to get zero crossings because my baseline is too noisy. Would this call for a filter? Maybe a low pass filter? I've had only the most basic DSP education. The class was mainly doing math (fourier, s-domain, z-domain transforms)
 
Ok, good. You've made it past the worst...

Yes, the wiggly baseline will most likely be noise, both on the input and in the ADC itself.
You could look more carefully at it to see if it has any, say 60Hz, regularities which might lead to areas of improvement. To do zero-crossing detection you should have a window around your putative zero. You need hysteresis.

Then range==amplitude so you need more gain on your pre-amp. This will probably exacerbate the noise issue, so you may need a better opamp, or a real audio preamp.
You should see fairy nice up/dn ramping values if you have a clean and simple input. I don't know off hand what a whistle signal should look like -- oh wait is it a police whistle with a little ball in it? That has a lot of garbage... Do you have a flute or recorder or something? Maybe start out with an electronic signal generator or even a (very) little power supply hum...

A low pass filter will help with complicated signals. If you have a constrained range that you are trying to detect it might be enough. If you can FFTs implement on your controller that might give you a leg up on detecting base frequency in complicated signals. It'll be slower though...
 
Also make sure any unused inputs of the arduino UNO are tied to ground else if they are left floating they will add to your background noise.

you hinted that it has multi channel inputs

Dave
 
@Schip: Thank you again! Yes, it was a little trouble getting there, but I'm glad I didn't quit like I wanted to. I've actually just been using a guitar to get signals, but when I don't feel like grabbing it, I just whistle with my mouth. Will there be any excess noise with a guitar note? I'm unsure if tone will affect it.

@davenn: Could you elaborate on tying other inputs to ground? There are 6 analog pins and 14 digital pins, then a 3.3V, GND, 5V, Vin, and AREF pins on the UNO. I'm only using the 5V, GND, and the first analog pin (A0). In my code, no other pin is defined to be input or out except for analog 0 (which is input, of course). Does that affect anything? Should I define everything as output?

Thanks again, guys!
 
@davenn: Could you elaborate on tying other inputs to ground? There are 6 analog pins and 14 digital pins, then a 3.3V, GND, 5V, Vin, and AREF pins on the UNO. I'm only using the 5V, GND, and the first analog pin (A0). In my code, no other pin is defined to be input or out except for analog 0 (which is input, of course). Does that affect anything? Should I define everything as output?

Thanks again, guys!

Hi UR

when doing anything that involves digital circuitry, it is essential that all unused inputs are grounded. If you don't you can get noise coming from those floating inputs (analog or digital) and that can cause all sorts of unexpected mis-operations of the circuit.

as far as defining the other pins as outputs not sure not familiar enough with the UNO
but that would be worthwhile to try. some one else here my be able to be a bit more specific.
My comment was more of a general warning when playing with multi input digital devices :)

Dave
 
A guitar note, during the decay portion, should be a pretty-good sine. Lips whistling should also be fairly sine-ish, but might have some excess wind noise. Your mic may pickup background sound from the room, and of course the amplifier could be noisy too.

Do you have a way to get the ADC values back out of your controller? Send them over a serial/USB, or set an output port and use a logic analyzer... That should show you what you're dealing with.
 

Similar threads

Replies
10
Views
3K
  • · Replies 46 ·
2
Replies
46
Views
6K
Replies
5
Views
3K
Replies
2
Views
3K
Replies
9
Views
2K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 11 ·
Replies
11
Views
6K
Replies
5
Views
2K
Replies
20
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K