How Can I Read Sound Frequencies with a Controller?

In summary, the conversation discussed using a controller to read sound frequencies. It was suggested to use a microphone, pre-amp, and ADC input for the controller. The issue of noise and zero-crossing detection was brought up, and it was recommended to use a low pass filter and increase gain on the pre-amp. The discussion also touched on tying unused inputs to ground and setting other pins as outputs. It was suggested to use an electronic signal generator or power supply hum to test the system, and to analyze the ADC values to see the signals being received.
  • #1
UR_Correct
37
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
  • #2
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...
 
  • #3
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?
 
  • #4
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)
 
  • #5
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...
 
  • #6
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
 
  • #7
@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!
 
  • #8
@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
 
  • #9
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.
 

What is a sound frequency transducer?

A sound frequency transducer, also known as a transducer or acoustic transducer, is a device that converts sound waves into an electrical signal or vice versa. It is commonly used in various applications such as microphones, speakers, and sonar systems.

How does a sound frequency transducer work?

A sound frequency transducer works by converting sound waves into electrical signals through a process called transduction. This is achieved by using a diaphragm or element that vibrates in response to sound waves and converts this mechanical energy into electrical signals.

What factors affect the performance of a sound frequency transducer?

The performance of a sound frequency transducer can be affected by various factors such as the design and materials used, the frequency range it is designed to work with, the sensitivity and impedance of the transducer, and external factors such as temperature and humidity.

What are the different types of sound frequency transducers?

There are several types of sound frequency transducers, including dynamic transducers, condenser transducers, piezoelectric transducers, and electromagnetic transducers. Each type has different designs and mechanisms for converting sound waves into electrical signals.

What are some common applications of sound frequency transducers?

Sound frequency transducers are used in a wide range of applications, including audio recording and playback, communication devices such as telephones and radios, medical equipment such as ultrasound machines, and industrial equipment for measuring and monitoring sound levels.

Similar threads

Replies
10
Views
472
Replies
46
Views
3K
Replies
5
Views
1K
Replies
9
Views
1K
Replies
2
Views
1K
Replies
20
Views
1K
Replies
5
Views
930
Replies
9
Views
1K
  • Electrical Engineering
Replies
4
Views
2K
Replies
14
Views
2K
Back
Top