Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
08/09/12 23:24
Read: 639 times

#188032 - 5 sinewaves
Responding to: Per Westermark's previous message
Good question. Very good.
I think you are exactly right and I need to calculate the 5 sinewave values internally with the MAC and use the onboard dac to output that waveform. A 256 byte lookup table gives a very good sinewave, I've tested that with the 89S52 and it looks perfect.
Honestly, I don't know how to figure out a 5th or 3rd. The 2nd and 4th harmonics are simply 2 or 4 times the fundamental freq.
A 5th would be having C as a bass note and G above it as the 5th. E would be a 3rd. Those actual frequencies for example (with a Lo C bass note):
C 32.70 Hz
G 49.00 Hz this is a fifth
C 65.41 Hz 2nd harmonic is up one octave
E 82.41 Hz This might be labeled as 2 2/3
G 98.00 Hz
C 130.81 Hz 4th harmonic, up 2 octaves.

So a solution might be:
Use the one onboard dac of the AT89LP6440 to output all 5 harmonics from the one dac.
We use only one timer. It is set for the bass note being played (X 256)
Another timer reads the A/D inputs for the gain sliders.
The main timer interrupt routine finds the values of all 5 harmonics. It multiplies each by it's associated gain slider, then adds these values internally using the MAC capabilities, and then outputs one calculated byte per interrupt.
I like this one but figuring out the 5ths and 3rds will be a bit of trial and error I think. The 2nd harmonic is simply 2 X the fundamental frequency. The 4th is 4 X the freq. So outputting every other byte in the lookup table gives us the 2nd harmonic which is up one octave, outputting every 4th byte takes us up an octave above that.
So the MAC routine calcs and outputs one accumulated byte of all 5 sinewaves. 256 of these interrupts produce one waveform. The bass note outputs this waveform at the freq of the note being played.
looks like I might need 6 sinewaves.

List of 7 messages in thread
Faking an interrupt      Garry Motter      07/23/12 15:28      
   or use a better part      Jim Granville      07/23/12 19:40      
   More Interrupts      Michael Karas      07/23/12 21:59      
      timer expansion      Rick Gebhardt      08/09/12 16:18      
         5 timers?      Per Westermark      08/09/12 16:25      
            5 sinewaves      Rick Gebhardt      08/09/12 23:24      
               Phases      Per Westermark      08/10/12 00:54      

Back to Subject List