comparing autio tone

I am fairly sure this can be done, but I don't know how.

Think radar antenna....

I have a device that outputs a audible tone and varies the tone in pitch (frequency) as the a input it detects get stronger. What I would like to do is take the headphone output and feed the Arduino the audio.

Using a rotary encoder on the antenna I will get a value for the antenna position (important in another part of the project) The value for the input signal (audio tone) to the antenna position, a value between 0 - 359. Then a peak value will need to be determined every revolution. (This is will send to a data base) and repeat....

Question is two pat; 1. how do I feed speaker level audio into the Arduino with out killing it? 2. will need code help, with the paring of reading the pin and putting it into an array so I can find the max value?

I was radar crew in the military long ago.

We used pulse radar to detect presence. That is the type usually seen in movies.

Principle: Pulse goes out and how long echo takes to return gives range. It is the most simple.

If you are using sound then be aware that sound travels slower in cold air and that humidity affects the speed too.

We used doppler radar to detect motion.

Principle: The frequency going out was steady and whatever moved would return a different frequency.

The incoming frequency is subtracted from the outgoing frequency and the result is sound when something moves, quiet when not. Many pulses and returns per second are done this way, the sound is steady in the earphones. The antenna points steady when observing, not swinging around.

I have to say that listening to things move is a blast. Motor vehicles vibrate. The heavier the vehicle the lower the sound so car from truck from APC from tank, you know them. Wheels turning is different from tracks. People walking from running from crawling are all different. A person wearing pants sounds different than a person wearing a skirt. And yes, leaves on trees blowing in the wind have their own voice. You can tell from most sounds what is going on. It's one thing I miss, being able to hear movement.

I'm not entirely sure what you are trying to acheive. But anyway:

'Speaker level sound' is unlikely to be greater than 5V, but what you do have to watch is that is will swing negative relative to ground, which your Arduino will not like at all.

So, if you want to get the volume level from a signal amplified up to a couple of volts, then use a diode to just take the positive half of the signal (as long as its over 0.5V and then a resistor and capacitor as a simple low-pass filter.

Thanks Si, that will take care of the audio in part.

To clarify I am not building a radar unit, but a direction finder that has a lot of similarity to how one works. The Arduinos job will be to interpret the data from the direction finding unit and pair a heading with it

I need the Arduino to find the strongest signal for each revolution. The reviver will handle the RF side of things. My thought was to pair the value of the input signal to a heading every few degrees and once the antenna rotates 360 deg find the high and start over. But I have no idea if that is a good way to do it.

Sounds fun.

So what does the transmitter send? The danger is that as the signal decreases, it is replaced by noise, so the amplitude of the sound may not be largest when in line with the transmitter.

Are you using AM? Have you verified the loudness behaviour with your ears? If that works then you are in with a chance.

You may need to play a sound at a particular frequency and then notch filter it at the receiver.

I am automating this to work with a PC application.

A radio direction finder. The audio tone changes with the number displayed. It is like tachometer + gear = speed. Can't go by tone alone.

GoForSmoke: The audio tone changes with the number displayed. It is like tachometer + gear = speed. Can't go by tone alone.

Well actually you can in the application I will be using it for. The number only represents the attenuator value. In the video it is set to auto, I will be using it is a manual range. I dont care about the number just the tone.

I will be using it mobile (in a truck) not on foot.

okay, so you are just taking the signal from the speaker on one of these units and want to know the frequency not the amplitude?

From the video, it sounds like you have a square wave at a pitch determined by the direction, that sometimes is a continuous tone and sometimes is modulated at about two Hz. You dont care about the 2Hz bit, you just want the overall pitch.

It is hard to tell, but it does sound like the tone is always the same amplitude, and is probably a square wave, clipping up to the supply that is then fed to an audio amp. Do you have a scope you can attach to the speaker to see what the signal actually looks like?

Assuming that you do have a nice clean-ish square wave. You could just rectify it, feed it into an analog input.

Then in your code, you can measure the period of the wave by taking analog readings and when it goes over a threshold, assigning a long var to the current millis() then timing how long it takes to come back below that threshold.

All a lot easier if you can see the waveform.