--- S Webster wrote: A.K.A. Paul > Nikolai Golovchenko wrote: > > > Is this the same as phase accumulators? > > I beg to differ from Tracy. I think it is. Phase > accumulators are > based on the principle of - as the name suggests - > adding up little > pieces of the cycle and "rolling over" when the sum > of these amounts to > or in fact exceeds, a full cycle. True, but that's not what Nikolai described (I thought). OTOH, I'm hardly the Phase Accumulator expert. My understanding of the phase accumulator is: You start off with a single cycle of something you wish to generate. This may be a square wave, sine wave, or a hyperbolic paraboloid wave (what in the hell is that?). The phase accumulator simply determines which portion of the cycle you wish to access. In its simplest form, the single cycle of the wave form is in an array and the phase accumulator is the index. The array is accessed at a constant rate, however the index is advanced according to the frequency of the wave form. Here's a simple C example: #define TABLE_SIZE 256 char wave_table[TABLE_SIZE]; float phase,delta_phase; void phase_accumulator(void) { int i; while(1) { phase += delta_phase; if(phase > TABLE_SIZE) phase -= TABLE_SIZE i = phase; output(wave_table[i]); routine_that_updates_delta_phase(&delta_phase); } } void main(void) { delta_phase = .... init_wave_table(wave_table); } I'd definite do this in assembly instead of C (but that's another thread). In each application, there are always ways to optimize this approach. For example, for square waves you don't need a table at all nor do you need floating point arithmetic for the phase accumulator. Fixed point arithmetic works fine and the most significant bit of the phase accumulator is the output. For most pics, you're forced to optimize because 256 element arrays (in ram aren't possible). 256 element arrays in code are possible, but are always a pain in the ass (because of page boundaries). Who knows, perhaps it's only semantic and S. and I are on the same page. But like I said, I'm not the expert... > I would think that even a 3-bit (six resistor) ADC > would considerably > improve performance, and perhaps allow output of > both tones via the one > channel (though Dave Van Horn's "twist" would still > be a difficulty). Borrowing a little from the best of both worlds is often the best solution. .lo ===== __________________________________________________ Do You Yahoo!? Bid and sell for free at http://auctions.yahoo.com