Author Topic: Tuner  (Read 15180 times)

0 Members and 1 Guest are viewing this topic.

Offline adeptTopic starter

  • Regular Contributor
  • *
  • Posts: 65
Tuner
« on: September 18, 2010, 02:20:18 am »
I guess another name for this would be a frequency generator. Anyway, I have gone through several ideas with my dad (Electronics Engineer). The first was to use a 555 timer chip with resistors. I want a specific value of frequency though, and was lectured about the standard resistor values and the inefficiencies of the design. So he made on involving a PLL chip. You know, the ones for touch tone dialing? So That involved binary counters and a PLL, and a quartz crystal. But that isn't the best way to do it, because the binary counters would require button, and I want it so you can just play a tone, and a comparator can determine which value is greater and light up an indicator LED to show whether sharp or flat. So, is there any easy and practical way to do this without the purchase or making of a programmer (as my budget is too small for such a thing)? The people at Cemetech aren't familiar enought with PLL's to help me. I need to get the design solid before I waste money on parts. An IC is not my first choice. I want to make that clear. I have a SIMPLE AVR programmer that I made for the robot I designed. It only programs using the 6 pin programming method. Size is also a factor. I would greatly prefer something pocket sized over something desktop sized. I'm already familiar with surface mount soldering and PCB design. Any designs made in ExpressPCB, Eagle, or some other free PCB software are acceptable as help. THIS IS NOT COMMERCIAL! It's for my girlfriend, a musician like me. It's for her birthday. I want it to actually be accurate. So those are the criteria in the Engineering Design Process. The Constraints are pocket sized, and under $50 for parts (not resistors, capacitors, or other common stuff. I have plenty of those). So you professional design engineers that are here, help my design come into fruition. Thanks!
 

Offline JohnS_AZ

  • Frequent Contributor
  • **
  • Posts: 499
  • Country: us
    • About.me
Re: Tuner
« Reply #1 on: September 18, 2010, 04:12:21 am »
Off the top of my head, why not use a frequency to voltage converter (LM2917 I think). Feed the analog V out to the micro. You could then do math to figure out what note the input is closest to, then display how far off it is on an LED bargraph.

HEY!  That could be a design idea!  *chuckle*
I'm either at my bench, here, or on PokerStars.
 

Offline adeptTopic starter

  • Regular Contributor
  • *
  • Posts: 65
Re: Tuner
« Reply #2 on: September 18, 2010, 05:07:09 am »
OMG!! You just solved a problem I've been working for 2 weeks to think of how to use it! At times I wish I had a college education, but that's years in the future... :D So thanks John for the answer. If I need help on using it, I'll post again.
 

Offline JohnS_AZ

  • Frequent Contributor
  • **
  • Posts: 499
  • Country: us
    • About.me
Re: Tuner
« Reply #3 on: September 18, 2010, 05:16:07 am »
Well, it may not be the answer, as I said it was just off the top of my head (and without rereading the datasheet).

Unless she plays a flute I imagine some input filtering is going to be required. Input gain could be tricky, and AGC circuit trickier. But ... I think it could be made to work.
I'm either at my bench, here, or on PokerStars.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19514
  • Country: gb
  • 0999
Re: Tuner
« Reply #4 on: September 18, 2010, 04:57:00 pm »
I'm a bit confused as to what you want.

If it's just an audio frequency generator, that's easy.

If you want to know the exact frequency of a tone, that's easy too.

You say you don't want any programmable devices but you already have an AVR programmer and a microcontroller is just what you need, even if it's just a simple tone generator. You can use a crystal for accurate frequency control so it never needs adjusting and it's easy to generate a squarewave with a known frequency out of an I/O port which can directly drive a piezo sounder.

To find the frequency of a tone is a little more tricky but it's still pretty simple. It should be pretty easy to convert the audio signal to a squarewave to monitor the fundamental frequency, decide on a tolerance and display the not being played. I'd  use the timer, for low frequencies you count the MCU's clock (or a division of it) over the period of the signal being monitored, for higher frequencies you count the periods within a clock interval.
 

Online Simon

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Tuner
« Reply #5 on: September 18, 2010, 05:20:46 pm »
I think your trying to make some sort of frequency measuring machine ? like a guitar tuner ? would comparing the measured frequency and a known reference be what your after ?perhaps pass the two through a low pass filter and then see when they are equal or if your measured frequency is over or under ?

of course if your trying to make a guitar tuner why not I might part with mine that I was given to me by Ozzy Osbourne  8) for an extortionate amount of money. (only joking - about selling it)
 

Offline adeptTopic starter

  • Regular Contributor
  • *
  • Posts: 65
Re: Tuner
« Reply #6 on: September 18, 2010, 09:30:06 pm »
Like a guitar tuner yes. But not one, because it measures chromatically. All the notes, not a portion. She plays the clarinet, not the flute, so high fundamental pitches aren't an issue. BUT the note isn't as pure. Filtering is something I've thought of. I was thinking yesterday that the frequency to voltage regulator could be put through a capacitor. That would filter the voltage to a more stable one. If I'm wrong, correct me. I was thinking of using a guitar pickup as a microphone device. I would like as little knowledge to be required in order to use it. i.e., not excessive dials, buttons, and switches. Minimalistic so to speak. My programmer is for only 6 pin programmable devices. It was barely functional for my robot. It's not really a frequency generator, I'm using a comparator to compare the voltages made by the microphone and the constant (the part I'm having trouble with...). Using the frequency to voltage converter, the tuner should be able to use a pickup, and compare to a constant voltage instead of a reference frequency. So the whole frequency generator idea is junk now. I need help with the constant voltage though. A simple variable regulator like the LM317 will work. So, does anybody have the equations to the LM317? As I change the resistor value, what happens to the voltage? I'll ask around to see if anybody I know has an AVR programmer too. I could type up a quick C program for the AVR that makes a frequency that goes through one of those Frequency to Voltage Converters into the comparator.
BTW, I'm very impressed at how quickly my questions are answered on this forum! I LOVE IT!
 

Online Simon

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Tuner
« Reply #7 on: September 18, 2010, 09:39:28 pm »
you will need to get your measured frequency to a known Vpp value in oder to make a valid measurement, or measure the Vpp and add that to the equation
 

Offline adeptTopic starter

  • Regular Contributor
  • *
  • Posts: 65
Re: Tuner
« Reply #8 on: September 19, 2010, 01:04:11 am »
No, I need the equation. I don't really want to buy the part and measure myself to see if it will work properly for my application. Someone surely has the formula that shows the relationships between the Resistor and the Voltage.
 

Online Simon

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Tuner
« Reply #9 on: September 19, 2010, 07:25:44 am »
you can calculate the impedance (resistance) of a capacitor at a given frequency with: 1/(2 X pi X f) it's impedance will vary with frequency, as we are not making this project we have no idea of the final formula's need, that's where you come in handy  ;)
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19514
  • Country: gb
  • 0999
Re: Tuner
« Reply #10 on: September 19, 2010, 08:30:09 am »
The fact that the tone is not pure is not your problem, the LM2917 includes a comparator with Schmitt trigger inputs which will only trigger when the signal passes through zero, which means that the strongest frequency component will be measured.

You problem is that the LM2917 is not designed to do what you want, it's designed for a tachometer over speed alarm, it's possible to use it for what you want but it won't be easy, see the following quote from the data sheet and note the text highlighted in bold.

Quote
The LM2907, LM2917 series are monolithic frequency to voltage converters with a high gain op amp/comparator designed to operate a relay, lamp, or other load when the input frequency reaches or exceeds a selected rate.

You want to trigger an output when the frequency is approximately equal to a certain rate, not much above or below but nearly equal. The problem with using a F/V circuit like the LM2917 is that you need to detect more than one note and for every note, you need a window comparator which requires two comparators, so for eight notes that's 16 in total which a lot of ICs: four LM339s.

By the time you've purchased the LM2917, four LM339s and the necessary passive components, you might as well have bought a microcontroller, which is: smaller, cheaper and will enable you to do cool things, such as display the note being played on a 7 segment display.

For example, just looking in my local supplie, RS Components:

The cheapest through hole AVR with enough pins I could find on RS is the ATMEGA48PA-PU, for £1.80
http://uk.rs-online.com/web/search/searchBrowseAction.html?method=getProduct&R=6962298

The 8 pin version of the LM2917 is £1.086 but there's a minimum order quantity of 5.
http://uk.rs-online.com/web/search/searchBrowseAction.html?method=getProduct&R=0460944

The cheapest though hole quad comparator on RS is the LM2901 which is similar to the LM339 costs £0.19 each (£0.76 for 4) but the minimum order is 10.
http://uk.rs-online.com/web/search/searchBrowseAction.html?method=getProduct&R=6612781

The cost of the comparators plus the LM2917 comes to £1.846, more than the AVR and that's not even including the extra passive components.
 

Offline Zad

  • Super Contributor
  • ***
  • Posts: 1013
  • Country: gb
    • Digital Wizardry, Analogue Alchemy, Software Sorcery
Re: Tuner
« Reply #11 on: September 19, 2010, 03:44:06 pm »
Or plug a microphone into your PC and use a tuning / frequency measurement program? I realise that's not a hardware solution but it is a heck of a lot easier. If you want to know absolutely all the frequency components of the signal, then you need to sample it and perform a Fourier transform on the data. http://en.wikipedia.org/wiki/Fourier_transform

The PLL method isn't a bad one either. It needn't be a complex circuit, the CD4046 chip has the voltage controlled oscillator and phase comparator onboard, and costs peanuts. 

Offline adeptTopic starter

  • Regular Contributor
  • *
  • Posts: 65
Re: Tuner
« Reply #12 on: September 19, 2010, 11:37:50 pm »
I'm going to ask my teacher's and friends at school tomorrow about a chip programmer. I might find one that works better than mine(The main issue with mine is the unreliability and difficulty to use...). Then it's just the code, which Kerm could help me with. He has a degree in C programming, and experience with things like this.

At Hero:
Thanks a lot for the parts! So why do I need so many inputs and outputs? Is each one of them being used for a different note? If so, how would I be able to measure with different octaves, where the fundamental (loudest tone) is lower, and only the harmonics (the ones that are octaves to the fundamental, and go off in both directions, as far as you can hear.) are at the octave being observed. When you tune, you don't measure the harmonics, just the fundamentals. Then, could you explain to me exactly how the 7 segment could indicate flat or sharp, and the note name (including whether it's flat or sharp) correctly. Maybe to display what name of note it is... A LED graph would perhaps function better in this application. Plus, the lower power and minimalistic style I'm looking for are met better with a LED graph. Could I use a simple board design like the one I made for my robot? (http://www.librocritosis.com/nerdnirvana/projects/robot.html) I think the pinout is different on your chip is different, but the concept is the same. Sorry this was so much to read! :P

At Simon:
The frequency range I want to measure is 55hz to 3.5khz. But again, I want the mathematical relationship of the resistor to the voltage output of the lm317.
 

Offline DJPhil

  • Frequent Contributor
  • **
  • Posts: 511
  • Country: 00
Re: Tuner
« Reply #13 on: September 20, 2010, 01:25:42 am »
But again, I want the mathematical relationship of the resistor to the voltage output of the lm317.
I may not be understanding what you're after, but isn't what you're looking for on the datasheet? There's several manufacturers of the LM317, in National's datasheet I think what you're looking for is lower left on the first page.
If you haven't worked with datasheets much, I'd recommend bookmarking www.datasheetcatalog.org, very useful.

Hope that helps. :)
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19514
  • Country: gb
  • 0999
Re: Tuner
« Reply #14 on: September 20, 2010, 08:15:36 am »
I'm going to ask my teacher's and friends at school tomorrow about a chip programmer. I might find one that works better than mine(The main issue with mine is the unreliability and difficulty to use...). Then it's just the code, which Kerm could help me with. He has a degree in C programming, and experience with things like this.
Buy one, they're not expensive.

I'd recommend a PIC but that's just me.

Here's a link to the ebay store where I bought mine from:
http://stores.ebay.co.uk/PICcircuit

If your budge is minimal and you only want to program in circuit or on a piece of breadboard, just get the USB programmer:
http://cgi.ebay.co.uk/iCP01-USB-Microchip-PIC-Programmer-Tiny-Low-Price-/270636883929?pt=LH_DefaultDomain_0&hash=item3f03371fd9

If you don't mind spending a little more, get a programmer which comes with a nice ZIF socket, which is what I recommend.
http://cgi.ebay.co.uk/iCA01-USB-Microchip-PIC-Programmer-Set-ICSP-Adapter-/280564217522?pt=LH_DefaultDomain_0&hash=item4152ee36b2

Quote
Thanks a lot for the parts! So why do I need so many inputs and outputs? Is each one of them being used for a different note?
There's only one input for the tone.

You'll probably need some amplification, if it's from a microphone.

You don't need as many outputs as the MCU I linked to has. I just chose the cheapest AVR which is through hole and has enough outputs to drive a 7-segment display, plus a few LEDs, if there had been one in a 14-pin package for the same price or cheaper, I would've chosen it. I don't want to start a PIC vs AVR flame war but I would've chosen a PIC because you probably could've got one with enough pins and is powerful enough for the same price or less.


Quote
If so, how would I be able to measure with different octaves, where the fundamental (loudest tone) is lower, and only the harmonics (the ones that are octaves to the fundamental, and go off in both directions, as far as you can hear.) are at the octave being observed. When you tune, you don't measure the harmonics, just the fundamentals.
That shouldn't be too difficult, as long as the harmonics aren't to strong and you just play one note at a time, no chords which will confuse a frequency counter, for that, you need something more complicated: a spectrum analyser and it isn't worth it for a simple tuner.

Quote
Then, could you explain to me exactly how the 7 segment could indicate flat or sharp, and the note name (including whether it's flat or sharp) correctly. Maybe to display what name of note it is...
I was thinking a couple of LEDs could be used to indicate sharp or flat.

Quote
A LED graph would perhaps function better in this application.  Plus, the lower power and minimalistic style I'm looking for are met better with a LED graph.
How would that work?

Would you need an LED for each note? That doesn't sound very minimalistic.

Whatever you think looks best, just as long as you MCU has enough outputs.

If you want something cool, you can buy a phone colour display quite cheaply but the project is probably already complicated enough for a first MCU project.
http://www.sparkfun.com/commerce/product_info.php?products_id=569

Here's a link to some display driver code:
http://www.sparkfun.com/tutorial/Nokia%206100%20LCD%20Display%20Driver.pdf

Quote
Could I use a simple board design like the one I made for my robot? (http://www.librocritosis.com/nerdnirvana/projects/robot.html) I think the pinout is different on your chip is different, but the concept is the same. Sorry this was so much to read! :P
Yes but make it neater this time.

Quote
The frequency range I want to measure is 55hz to 3.5khz.
That should be no problem, as the frequency is low you might want to have a high frequency oscillator/timer and count the number of pulses per period otherwise measuring 55Hz with a decent level of accuracy will be slow.
 

Offline adeptTopic starter

  • Regular Contributor
  • *
  • Posts: 65
Re: Tuner
« Reply #15 on: September 21, 2010, 04:40:36 am »
Maybe a real programmer would be a good investment in my electronics future, but the way my parents pay me for work (as a job is out of the question in my state until your 16, which I'm not), is 1 USD for each "difficult chore", which is all defined out. Anyway, to get the 50 dollars I budgeted for, you realize it took my 50 "difficult chores" to get that much. If I blow it by too much, that would really stink! But if my buddies have one, that's better. So far, I haven't turned up one :(. Of course, that USB one is really cheap. I couldn't find anything that said how much circuitry is required on board though. It's just like the one I made, but neater. I'm guessing that it will require 2 capacitors, a crystal, and a header to plug it in. All that effort would pay for the fancier USB one, with the other stuff inside. I'll have to look for US links though...
PIC chips are indeed just as handy, universal, not to mention about half the price as an AVR. I've never worked with one, but is there a simple to use IDE for programming it? (Sorry I'm too fat and lazy to google it myself :P Plus I don't wanna try to set up 30 different IDE's, and learn them to find one I like.) The AVR one I use was SUPER easy to use. It didn't take half my knowledge of C programming to use it! BTW Hero, I love the really detailed help. You sure can help an experienced noob like me!
 

Offline JohnS_AZ

  • Frequent Contributor
  • **
  • Posts: 499
  • Country: us
    • About.me
Re: Tuner
« Reply #16 on: September 21, 2010, 04:53:10 am »
Where abouts do you live?
I'm either at my bench, here, or on PokerStars.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19514
  • Country: gb
  • 0999
Re: Tuner
« Reply #17 on: September 21, 2010, 08:35:13 am »
Maybe a real programmer would be a good investment in my electronics future, but the way my parents pay me for work (as a job is out of the question in my state until your 16, which I'm not), is 1 USD for each "difficult chore", which is all defined out. Anyway, to get the 50 dollars I budgeted for, you realize it took my 50 "difficult chores" to get that much. If I blow it by too much, that would really stink!
Your parents should be grateful that you want to spend your money on something educational, rather than CDs, DVDs going out or worse drink and drugs.

I think you should try to persuade them to buy you the programmer, preferably the one with the ZIF socket, otherwise just the USB part without the socket will do. They should see it as an investment in your education, enabling you to get a better job when you're older. Failing that, if you don't mind waiting, put it on your Christmas list or see if you can have it as an early Christmas present.

Quote
But if my buddies have one, that's better. So far, I haven't turned up one :(. Of course, that USB one is really cheap. I couldn't find anything that said how much circuitry is required on board though. It's just like the one I made, but neater. I'm guessing that it will require 2 capacitors, a crystal, and a header to plug it in. All that effort would pay for the fancier USB one, with the other stuff inside. I'll have to look for US links though...

The programmer is the yellow thing with the USB connector poking out of one end of it and contains all the circuitry required to program the PIC. The board is purely passive, it's just a ZIF socket, a capacitor (just to smooth the power; not essential) and a switch to change the internal connections so it can program either 8 to 20 pin or 28 to 40 pin devices.

You don't need the board, it just makes things slightly easier. The programmer has five connections: 0V, 5V, Vpp (programming voltage, around 12V to 13V), clock and a serial port which sends the program to the PIC. All you need to do is connect the five pins to the PIC (see programmer and PIC data sheets) and you can program it. If you design your circuit carefully, you can program the PIC whilst it's in your project (see PIC data sheet).

Quote
PIC chips are indeed just as handy, universal, not to mention about half the price as an AVR. I've never worked with one, but is there a simple to use IDE for programming it? (Sorry I'm too fat and lazy to google it myself :P Plus I don't wanna try to set up 30 different IDE's, and learn them to find one I like.) The AVR one I use was SUPER easy to use. It didn't take half my knowledge of C programming to use it!
Microchip (the company who makes PICs) supply their own IDE and programming tools for free: Google MPLAB - it's easy you use.

I've not used C yet, just assembler which is supposed to be more difficult but one learns more because they have no choice but to learn the hardware,

Quote
BTW Hero, I love the really detailed help. You sure can help an experienced noob like me!

I'm a total MCU noob too, I've only written one simple program before so I won't be able to help you much with the code. I would have to do some learning before I can make a project as complicated as what you're intending to build.

Here's a few links to some tutorials:
http://www.gooligum.com.au/tutorials.html - very good, I've used this myself. It covers the baseline MCUs (the cheapest and simplest chips) to midrange PICs and both assembly and C programming.
http://www.winpicprog.co.uk/pic_tutorial.htm - iIve not actually used this one yet but it got good reviews on another forum I used to visit. It covers midrange PICs and assembly, IR, RS232 and I2R.
 

Offline scrat

  • Frequent Contributor
  • **
  • Posts: 608
  • Country: it
Re: Tuner
« Reply #18 on: September 21, 2010, 11:21:28 am »
I suggest making your own programmer/debugger (which is far better than a simple programmer).
For example, for PICs: http://www.icd2clone.com/wiki/Main_Page. You need to program the PICs inside it the first time, but it can be easily done with a simple RS-232 programmer (few diodes, BJTs and resistors).

On the software side, besides quoting the suggestion of using a PC soundcard first (http://www.tech-systems-labs.com/test-software.htm), I think that you could also perform a simple Fourier transform (at least a Fourier series decomposition) inside a PIC (consider that you don't have strict real-time contraints). The trouble could be the RAM memory quantity, since precision in frequency is proportional to the number of samples... Algorithms are not hard to implement, that's why microcontrollers are are now used for many analogue functions.
Once you decide which way you want to go (CD4046, PIC, AVR, PC, ... ), let me know, and if you need help, just ask.

One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. - Elbert Hubbard
 

Offline adeptTopic starter

  • Regular Contributor
  • *
  • Posts: 65
Re: Tuner
« Reply #19 on: September 23, 2010, 04:37:23 am »
At John:
I live so far away from just about all life and civilization. Las Cruces, NM to be exact. That's in the US for you foreigners! ;)
At Scrat:
I don't really understand what you meant. Could you maybe explain it in more detail?
At Hero:
My parents are borderline insane! i.e. a few weeks ago, my mom donated all my clothes that didn't have church or band logos on them. What the hell was that about?! Now I'm the subject of jokes at school, cuz of my lameness. They aren't interested in anything I am. Anyway, no monies from them for me! And Christmas is past my girlfriend's birthday (November 10th). That's the time I need it done.
So this week, I think I can scrounge around for some cash. Work my butt off and get some money, because my nerd friends at school, and every teacher I asked had no idea what I was talking about, or didn't have one. I'll update on all that later though.
As for the programming part, I'm big on C and Assembly both, as an avid calculator hacker. It's a nerdy thing that involves making the graphing calculator do what it was never designed to do. It's working with nothing, to make games, utilities, OS's, etc. Kerm is the best assembly programmer ever. He knows all about Z80 assembly (the dialect we both know), and the in's and out's of C, C#, Java, and other languages used by a professional programmer. But the dialect of PIC's is surely different, so I'll look at the page to find the names of the registers, and see if in the program they call it ld or load if you know what I mean. :D
 

Offline scrat

  • Frequent Contributor
  • **
  • Posts: 608
  • Country: it
Re: Tuner
« Reply #20 on: September 23, 2010, 09:11:44 am »
At Scrat:
I don't really understand what you meant. Could you maybe explain it in more detail?

I'll go a step back... One way to test if a signal contains a specified frequency is to perform a Fourier analysis on it. The concept is quite simple: you try to decompose your signal into a sum of many sinusoids, each will have its amplitude and phase. It is similar to when you get the 3 x,y,z elements from a vector, since you are projecting your vector into three orthogonal directions, while in the Fourier case you project your signal into a number of "orthogonal" sine waves.
For doing that, you just make an average of the (instant) product between your signal and the specified sine wave. In practice, you're looking at how much these two signals are similar. If you're searching for a certain frequency, it is sufficient to calculate the product at each instant and then accumulate (sum over and over) the result.
If you apply this algorithm on the input audio signal for sine waves at several frequency values around the right (tuned) value, then you will find if the input frequency is lower or higher than the right one.
I think that this can be done on a PIC18.

Of course it needs to be tested before implementation, and you could do it by feeding a C program on a PC with a .wav file of the musical instrument playing and then considering the results (an off-line simulation, indeed).

I don't know if I was clear enough, behind Fourier analysis there is some math theory, but I think the concepts are really not that complex, if one (much better than me) explains them.
One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. - Elbert Hubbard
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19514
  • Country: gb
  • 0999
Re: Tuner
« Reply #21 on: September 23, 2010, 09:55:19 am »
adept,
You're probably already more equipped to learn MCUs than me and are probably also more clever than me too.

scrat,
Is there really a need for Fourier?

If it's just a single note then it should be easy to get the fundamental using a simple frequency counter. If a chord then yes you need Fourier but surely not for single notes.
 

Offline scrat

  • Frequent Contributor
  • **
  • Posts: 608
  • Country: it
Re: Tuner
« Reply #22 on: September 23, 2010, 10:38:07 am »
scrat,
Is there really a need for Fourier?

If it's just a single note then it should be easy to get the fundamental using a simple frequency counter. If a chord then yes you need Fourier but surely not for single notes.

If I understand right, this is the case. Of course, no need for fourier for a single note, although it could be more precise (an adjusting averaging is implicit into Fourier analysis). Also a PLL or only part of it (phase comparator and filter) could work well for a single tone (reference clock driven for example by a PWM peripheral, sweeping for the various frequencies). But PLL costs al little more, firmware is more flexible since signal remains at low frequencies.
One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. - Elbert Hubbard
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19514
  • Country: gb
  • 0999
Re: Tuner
« Reply #23 on: September 23, 2010, 03:10:16 pm »
Why not do the whole thing on the MCU? Like you say firmware is more flexible and cheaper.

The easy way would be to use a counter to count the signal which is squared using a comparator and reset it every second but you might want a faster response time than 1s but resetting more often would reduce the accuracy at lower frequencies.

A better way is to use reciprocal counting, configure the counter to count a fixed 2MHz signal and reset the counter every audio cycle so a 56Hz signal gives a count of  35714 and a 3.5kHz signal 571.
 

Offline scrat

  • Frequent Contributor
  • **
  • Posts: 608
  • Country: it
Re: Tuner
« Reply #24 on: September 23, 2010, 03:59:28 pm »
You're right, perhaps it is simpler than I imagined: if the sound is a chord, and if squared signal follows an harmonic, you will still be able to detect it, since you already know in which range you're looking for the frequency. At least you will know the note, not the octave.
One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. - Elbert Hubbard
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf