Go Down

### Topic: Reading A Frequency (Read 1 time)previous topic - next topic

#### Grumpy_Mike

#30
##### Jan 12, 2016, 12:07 pmLast Edit: Jan 12, 2016, 12:09 pm by Grumpy_Mike
OK I think we have cracked this one. It is a classic case of an X-Y Problem. What you did NOT say was that you wanted to measure the frequency of a complex waveform. I suspect you want to make your own guitar tuner.

I downloaded that app and recorder the note it produces, it is a very complex waveform that will give you a seemingly random number of frequencies. Consider these three pictures of exactly the same note plotted out at different scales. You will see it is composed of all sorts of random frequencies. Your code measures the time between zero crossings to work out the frequency. You will see that this changes almost randomly over the length of the note.

The harmonic mix of the note changes over the duration of the note, the largest harmonic is not always the fundamental. Measuring this is way way way more complex than the software you have. In short you need an FFT to analyse your tone, and even then you are likely to be an octave out.

#### sigilwig444

#31
##### Jan 15, 2016, 12:47 amLast Edit: Jan 15, 2016, 01:31 am by sigilwig444
OK I think we have cracked this one. It is a classic case of an X-Y Problem. What you did NOT say was that you wanted to measure the frequency of a complex waveform. I suspect you want to make your own guitar tuner.

I downloaded that app and recorder the note it produces, it is a very complex waveform that will give you a seemingly random number of frequencies. Consider these three pictures of exactly the same note plotted out at different scales. You will see it is composed of all sorts of random frequencies. Your code measures the time between zero crossings to work out the frequency. You will see that this changes almost randomly over the length of the note.

The harmonic mix of the note changes over the duration of the note, the largest harmonic is not always the fundamental. Measuring this is way way way more complex than the software you have. In short you need an FFT to analyse your tone, and even then you are likely to be an octave out.
Alright, so here's what I did... Instead of using that app, I just switched entirely to using a trumpet (the closest thing I have to a flute). It still seems to give me random readings, it's just sooooo strange... Like initially it'll give
a reading of 0 hz, and appear to be stuck there... Then sometimes it looks like it's doing something, but it'll display frequency readings over 5000 hz, which is an extremely high frequency, and I'm not coming close to anything really above 440 hz on the trumpet... It just doesn't seem to work. I've eliminated most of the variables, I double checked that my microphone worked when plugged into a computer, I finally soldered the connection of the jumper to the audio jack... Right now I have the audio input of the TL082 chip connected to the GND pin of the microphone... If I connect it to Left or Right out that still doesn't help anything... There's only one more thing that could potentially be a problem:

This is a stereo microphone, not a mono one. I wasn't able to find a mono microphone online that suited my needs, so I just bought a stereo one... Could this be the problem?

Also, could the voltage of the 9v battery I'm using affect things? Like if it's dropped too much?

I've started to look into Paul's freqmeaure library again, and if I can't manage to figure this out I'm going to go ahead and order parts for that, it looks pretty solid.

Otherwise is there anything else I can try? I'm almost ready to give up and try the different circuit with Paul's library...

Thanks!

#### Grumpy_Mike

#32
##### Jan 15, 2016, 02:09 pm
Quote
it's just sooooo strange.
No it is to be expected.

Quote
I just switched entirely to using a trumpet
That is even worse than an piano.

Download the app Fourier Synthesizer ( Education ) from KonakaLab, it is free. Just use the fundamental and try and measure that.

Quote
could the voltage of the 9v battery I'm using affect things? Like if it's dropped too much?
Very unlikely.

Quote
I've started to look into Paul's freqmeaure library again, and if I can't manage to figure this out I'm going to go ahead and order parts for that, it looks pretty solid.
You will face exactly the same problems with that. Simple frequency measurements only work with simple periodic wave forms like sine or square waves.

#### Paul Stoffregen

#33
##### Jan 16, 2016, 07:50 amLast Edit: Jan 16, 2016, 07:51 am by Paul Stoffregen
For anyone interested, this conversation is also occurring in parallel over on the PJRC forum.

If anyone later finds this by searching and wants to see whatever solution (might) work, look here too....

#### tmd3

#34
##### Jan 18, 2016, 07:27 am
The hardware isn't yet in a working condition.  No matter what kind of signals this device might see, it will have to get a reasonably accurate reading of the analog input.  I don't see that it can do it with what's shown.

The offset voltage divider, as shown in the last fritzing diagram that's posted, looks like it's made up of two 100 ohm resistors.  That's too low a load resistance for the TL082.

The microphone input shows only one wire connected to the circuit.  It certainly needs two, and it may need more.  We need to know more about the microphone in order to recommend a remedy.

However the signal is to be analyzed, it has to be captured accurately.  I don't see that this circuit can do it.  If the OP still interested in pursuing this, we can at least straighten out the hardware.

#### Grumpy_Mike

#35
##### Jan 18, 2016, 03:17 pmLast Edit: Jan 18, 2016, 03:19 pm by Grumpy_Mike
Quote
The hardware isn't yet in a working condition.
I would beg to differ, because he is getting results being output. The problem is that he was expecting a constant frequency to be indicated when feeding in a sound of an acoustic instrument. That basic miss match of expectations is what fueled this thread.

The OP had no idea that an instrument produced a complex waveform that was never going to get him the results he expected with the simple software he had. This is down to a fundamental lack of knowledge on the part of the OP.

This could have been corrected if only he had done a bit of research. However, sadly, even after he has been told this, he persists on thinking it is something that can be done simply and so asks the same unmodified, and extremity vague, question on another forum. His lack of ability to demonstrate he has actually learned anything from this exchange marks him out as a time waster.

#### tmd3

#36
##### Jan 20, 2016, 05:57 pm
Indeed, the time-between-zero-crossings algorithm will generally give erratic results for complex signals.  Indeed, the OP reports getting erratic results.  But, that doesn't mean his hardware works.  We certainly haven't seen anything that verifies it - something like a listing of analog samples from acquired from a known input signal.

Here's why I think it doesn't work:
- The impedance of the analog offset circuit is so low that the op amp can't develop much voltage into it.
- There appears to be only one connection between the microphone, or other signal source, and the circuit.  I don't see how that can act as a signal source; rather, I'd expect it to act as an antenna for power frequency interference.  I'd expect to see, say, a signal input and a ground connection.
- The OP reports that he has connected the ground wire of the signal source to the op amp's input.

I think that the project, as shown in the last fritzing diagram posted by the OP, won't accurately acquire analog data from the signal source.  That's not to say that the project would work if analog acquisition worked - it's been thoroughly discussed here that it won't.  If the acquisition portion of the project worked perfectly, it's not unlikely that the results would be indistinguishable from what the OP reports.

Go Up

Please enter a valid email to subscribe