Oops. This lookup table should actually be .. "439.91",59853 "439.99",59854 "440.06",59855 .. (with adjustments for getting into the ISR, etc) if you want to load the value directly to TMR1. > Then you can make the TMR1 preload value a variable which is changed when > the user makes an appropriate input to the device. One cycle difference > changes the frequency by .0774 Hz at 440Hz - (this function is of the form y > = 1/x and so is not linear). So you could just precalculate a lookup table > as in > > .. > "439.91",5683 > "439.99",5682 > "440.06",5681 > .. > etc. > > and use this to feed the LCD and the TMR1 preload based upon a position > determined by the user's selected frequency. > > With this setup it would be very easy to tweak the frequency to say ~442Hz > or you could even make an EADGBE guitar tuner or a chromatic tuner if you > were so inclined by precalculating the TMR1 values and including them in > your lookup table. Combining these two features would be more work though > since you can't just offset the A440 referenced TMR values by the same > amount across the scale. (You need less adjustment at low frequencies and > more at higher frequencies so you'd either need another lookup table or some > division routines, etc.) For a variable A4 alone though it should be pretty > easy. > > Once you have your ~440Hz square wave, remember that an ideal square wave > only carries energy at multiples of the fundamental. So you need a filter > that passes 440 (and a little cushion for frequency adjustment and component > tolerances of course) and cuts 880,1320,1760, etc. If you could make a > perfect filter that was a brick wall at say 500Hz then you would be left > with a perfect 440Hz sine wave. Perfect, perfect, perfect. Yeah right. In > reality though I think if you had a good steep filter you could get pretty > close. Maxim makes various filter IC's that I have not actually used but I > think they just require a few external components and the IC to make 8th > order filters and the like. Try: > > http://para.maxim-ic.com/ss.asp?FAM=Filt&TREE=Filters&HP=Filters.cfm&LN=&SORD=125+122+1052+124&FT_125=202&FT_122=194&FT_1052=12374&FT_124=198&Dest=Search+%26+Update > > For example look at the MAX7400/MAX7404 (8th order elliptic, switched cap > filter - http://pdfserv.maxim-ic.com/en/ds/MAX7400-MAX7407.pdf). In the > datasheet it is spec'ed that at 1.5 * Fcorner the output is down at least > 75dB (typically 82). If your corner is 500Hz then at 750Hz (before the 2nd > harmonic) you are down ~80dB. Should make a pretty decent representation of > a sine wave. > > I would definitely filter the output. It is definitely harder to tune a > guitar accurately with distortion on (basically morphs the guitar signal to > be more like a square wave) and I wouldn't doubt that the effect would be > similar to trying to tune to a square wave. > > Good luck - sounds like a fun project. > > Nick > > > > > ----- Original Message ----- > From: "Koen van Leeuwen" > To: > Sent: Wednesday, January 07, 2004 10:47 AM > Subject: Re: [PICLIST] [PIC:] Frequency dividing to 440 Hz > > > > I haven't heard of other "standards" before other than the A4=440 Hz. > > I have read somewhere that in Mozart's time a typical A4 was 450 Hz, but > it > > has been standardized in 1939 as 440 Hz (Source: > > http://www.boulder.nist.gov/timefreq/general/glossary.htm > > ). > > That page also states that the smallest noticable difference is 0.28%, so > that > > gives at least some headroom :o) > > > > So I should make my tuner tunable for other scales too :o) > > > > -- > > http://www.piclist.com hint: PICList Posts must start with ONE topic: > > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads > > > > -- > http://www.piclist.com hint: PICList Posts must start with ONE topic: > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads > -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads