Hi All , I am new to DSP and trying to get my fundamentals right. I am currently investigation various efficient ways of generation a single look up table(and parsing it) from which generating sinusoids for a QPSK modulator (cos , sin , -cos , -sin). I got a lot of hits from google , but none explain the fundamentals properly. Can any one point me in the right direction - links , slap on the wrist etc. BR Rate
Sine wave look up table
Started by ●October 10, 2007
Reply by ●October 10, 20072007-10-10
On Oct 10, 12:16 pm, ratemonotonic <niladri1...@gmail.com> wrote:> Hi All , > > I am new to DSP and trying to get my fundamentals right. I am > currently investigation various efficient ways of generation a single > look up table(and parsing it) from which generating sinusoids for a > QPSK modulator (cos , sin , -cos , -sin). > > I got a lot of hits from google , but none explain the fundamentals > properly. Can any one point me in the right direction - links , slap > on the wrist etc. > > BR > RateA very simple table driven oscillator is easy to implement. First, fill an array with a full cycle of a sine wave. Set the array size to a power of two, say 256. Second, define 16-bit signed integer variables to hold the phase and phase increment. Set the phase increment to 2^16*Ftone/Fs, where Ftone is the desired tone frequency and Fs is the sample rate. For each sample, use the top 8 bits of the phase as an index into the table. Output the corresponding sample and then add the phase increment to the current phase. Repeat. To get cos, add 64 to the phase increment before getting an index. To get -sin, -cos, invert the table values. Does that help? John
Reply by ●October 10, 20072007-10-10
On 10 Oct, 20:43, John <sampson...@gmail.com> wrote:> On Oct 10, 12:16 pm, ratemonotonic <niladri1...@gmail.com> wrote: > > > Hi All , > > > I am new to DSP and trying to get my fundamentals right. I am > > currently investigation various efficient ways of generation a single > > look up table(and parsing it) from which generating sinusoids for a > > QPSK modulator (cos , sin , -cos , -sin). > > > I got a lot of hits from google , but none explain the fundamentals > > properly. Can any one point me in the right direction - links , slap > > on the wrist etc. > > > BR > > Rate > > A very simple table driven oscillator is easy to implement. First, > fill an array with a full cycle of a sine wave. Set the array size to > a power of two, say 256. Second, define 16-bit signed integer > variables to hold the phase and phase increment. Set the phase > increment to 2^16*Ftone/Fs, where Ftone is the desired tone frequency > and Fs is the sample rate. > > For each sample, use the top 8 bits of the phase as an index into the > table. Output the corresponding sample and then add the phase > increment to the current phase. Repeat. > > To get cos, add 64 to the phase increment before getting an index. To > get -sin, -cos, invert the table values. > > Does that help? > > JohnWhy 64 to get cos , is it related to me selecting 256 samples of sinwave? is it to do with 90 degree phase difference? thanks in advance Rate
Reply by ●October 10, 20072007-10-10
John <sampson164@gmail.com> wrote in news:1192045401.199051.8570@ 50g2000hsm.googlegroups.com:> On Oct 10, 12:16 pm, ratemonotonic <niladri1...@gmail.com> wrote: >> Hi All , >> >> I am new to DSP and trying to get my fundamentals right. I am >> currently investigation various efficient ways of generation a single >> look up table(and parsing it) from which generating sinusoids for a >> QPSK modulator (cos , sin , -cos , -sin). >> >> I got a lot of hits from google , but none explain the fundamentals >> properly. Can any one point me in the right direction - links , slap >> on the wrist etc. >> >> BR >> Rate > > > A very simple table driven oscillator is easy to implement. First, > fill an array with a full cycle of a sine wave. Set the array size to > a power of two, say 256. Second, define 16-bit signed integer > variables to hold the phase and phase increment. Set the phase > increment to 2^16*Ftone/Fs, where Ftone is the desired tone frequency > and Fs is the sample rate. > > For each sample, use the top 8 bits of the phase as an index into the > table. Output the corresponding sample and then add the phase > increment to the current phase. Repeat. > > To get cos, add 64 to the phase increment before getting an index. To > get -sin, -cos, invert the table values. > > Does that help? > > John >The method described by John is discussed in an article I wrote many years ago for an Analog Devives publication. You can find it here: http://www.danvillesignal.com/signal- generation/signal-generation.html Al Clark Danville Signal Processing, Inc.
Reply by ●October 10, 20072007-10-10
On Oct 10, 5:58 pm, ratemonotonic <niladri1...@gmail.com> wrote:> On 10 Oct, 20:43, John <sampson...@gmail.com> wrote: > > > > > On Oct 10, 12:16 pm, ratemonotonic <niladri1...@gmail.com> wrote: > > > > Hi All , > > > > I am new to DSP and trying to get my fundamentals right. I am > > > currently investigation various efficient ways of generation a single > > > look up table(and parsing it) from which generating sinusoids for a > > > QPSK modulator (cos , sin , -cos , -sin). > > > > I got a lot of hits from google , but none explain the fundamentals > > > properly. Can any one point me in the right direction - links , slap > > > on the wrist etc. > > > > BR > > > Rate > > > A very simple table driven oscillator is easy to implement. First, > > fill an array with a full cycle of a sine wave. Set the array size to > > a power of two, say 256. Second, define 16-bit signed integer > > variables to hold the phase and phase increment. Set the phase > > increment to 2^16*Ftone/Fs, where Ftone is the desired tone frequency > > and Fs is the sample rate. > > > For each sample, use the top 8 bits of the phase as an index into the > > table. Output the corresponding sample and then add the phase > > increment to the current phase. Repeat. > > > To get cos, add 64 to the phase increment before getting an index. To > > get -sin, -cos, invert the table values....> > Why 64 to get cos , is it related to me selecting 256 samples of > sinwave? is it to do with 90 degree phase difference? > > thanks in advanceyou can thank yourself, because it looks to me that you answered you own question(s). r b-j
Reply by ●October 11, 20072007-10-11
Al Clark wrote:> John <sampson164@gmail.com> wrote in news:1192045401.199051.8570@ > 50g2000hsm.googlegroups.com: > >> On Oct 10, 12:16 pm, ratemonotonic <niladri1...@gmail.com> wrote: >>> Hi All , >>> >>> I am new to DSP and trying to get my fundamentals right. I am >>> currently investigation various efficient ways of generation a single >>> look up table(and parsing it) from which generating sinusoids for a >>> QPSK modulator (cos , sin , -cos , -sin). >>> >>> I got a lot of hits from google , but none explain the fundamentals >>> properly. Can any one point me in the right direction - links , slap >>> on the wrist etc. >>> >>> BR >>> Rate >> >> A very simple table driven oscillator is easy to implement. First, >> fill an array with a full cycle of a sine wave. Set the array size to >> a power of two, say 256. Second, define 16-bit signed integer >> variables to hold the phase and phase increment. Set the phase >> increment to 2^16*Ftone/Fs, where Ftone is the desired tone frequency >> and Fs is the sample rate. >> >> For each sample, use the top 8 bits of the phase as an index into the >> table. Output the corresponding sample and then add the phase >> increment to the current phase. Repeat. >> >> To get cos, add 64 to the phase increment before getting an index. To >> get -sin, -cos, invert the table values. >> >> Does that help? >> >> John >> > > The method described by John is discussed in an article I wrote many > years ago for an Analog Devives publication. > > You can find it here: http://www.danvillesignal.com/signal- > generation/signal-generation.html > > Al Clark > Danville Signal Processing, Inc.I think some caveman probably has prior art for carving this on a cave wall somewhere. :-) Steve
Reply by ●October 11, 20072007-10-11
On Oct 10, 10:59 pm, Al Clark <acl...@danvillesignal.com> wrote:> John <sampson...@gmail.com> wrote in news:1192045401.199051.8570@ > 50g2000hsm.googlegroups.com: > > > > > > > On Oct 10, 12:16 pm, ratemonotonic <niladri1...@gmail.com> wrote: > >> Hi All , > > >> I am new to DSP and trying to get my fundamentals right. I am > >> currently investigation various efficient ways of generation a single > >> look up table(and parsing it) from which generating sinusoids for a > >> QPSK modulator (cos , sin , -cos , -sin). > > >> I got a lot of hits from google , but none explain the fundamentals > >> properly. Can any one point me in the right direction - links , slap > >> on the wrist etc. > > >> BR > >> Rate > > > A very simple table driven oscillator is easy to implement. First, > > fill an array with a full cycle of a sine wave. Set the array size to > > a power of two, say 256. Second, define 16-bit signed integer > > variables to hold the phase and phase increment. Set the phase > > increment to 2^16*Ftone/Fs, where Ftone is the desired tone frequency > > and Fs is the sample rate. > > > For each sample, use the top 8 bits of the phase as an index into the > > table. Output the corresponding sample and then add the phase > > increment to the current phase. Repeat. > > > To get cos, add 64 to the phase increment before getting an index. To > > get -sin, -cos, invert the table values. > > > Does that help? > > > John > > The method described by John is discussed in an article I wrote many > years ago for an Analog Devives publication. > > You can find it here:http://www.danvillesignal.com/signal- > generation/signal-generation.html > > Al Clark > Danville Signal Processing, Inc.- Hide quoted text - > > - Show quoted text -Hi Al , Thanks for the fantastic paper ! I have some clue now on whats involved. The thing that I dont understand is the 2^16 in the phase increment steps - 2^16 * Ftone/Fs? BR Rate
Reply by ●October 11, 20072007-10-11
On Oct 11, 6:15 am, ratemonotonic <niladri1...@gmail.com> wrote:> The thing that I dont understand is the 2^16 in the phase increment > steps - 2^16 * Ftone/Fs?Think about what's involved in outputting a 1 hz sine wave
Reply by ●October 11, 20072007-10-11
On Oct 11, 6:15 am, ratemonotonic <niladri1...@gmail.com> wrote:> On Oct 10, 10:59 pm, Al Clark <acl...@danvillesignal.com> wrote: > > > > > John <sampson...@gmail.com> wrote in news:1192045401.199051.8570@ > > 50g2000hsm.googlegroups.com: > > > > On Oct 10, 12:16 pm, ratemonotonic <niladri1...@gmail.com> wrote: > > >> Hi All , > > > >> I am new to DSP and trying to get my fundamentals right. I am > > >> currently investigation various efficient ways of generation a single > > >> look up table(and parsing it) from which generating sinusoids for a > > >> QPSK modulator (cos , sin , -cos , -sin). > > > >> I got a lot of hits from google , but none explain the fundamentals > > >> properly. Can any one point me in the right direction - links , slap > > >> on the wrist etc. > > > >> BR > > >> Rate > > > > A very simple table driven oscillator is easy to implement. First, > > > fill an array with a full cycle of a sine wave. Set the array size to > > > a power of two, say 256. Second, define 16-bit signed integer > > > variables to hold the phase and phase increment. Set the phase > > > increment to 2^16*Ftone/Fs, where Ftone is the desired tone frequency > > > and Fs is the sample rate. > > > > For each sample, use the top 8 bits of the phase as an index into the > > > table. Output the corresponding sample and then add the phase > > > increment to the current phase. Repeat. > > > > To get cos, add 64 to the phase increment before getting an index. To > > > get -sin, -cos, invert the table values. > > > > Does that help? > > > > John > > > The method described by John is discussed in an article I wrote many > > years ago for an Analog Devives publication. > > > You can find it here:http://www.danvillesignal.com/signal- > > generation/signal-generation.html > > > Al Clark > > Danville Signal Processing, Inc.- Hide quoted text - > > > - Show quoted text - > > Hi Al , > > Thanks for the fantastic paper ! I have some clue now on whats > involved. > The thing that I dont understand is the 2^16 in the phase increment > steps - 2^16 * Ftone/Fs? > > BR > RateThe 2^16 is in there because John suggested that you use a 16-bit phase accumulator. Think of the value of the accumulator as a measure of "where you are" in the period of the sinusoid. 0 corresponds to zero phase, and 2^16-1 corresponds to very nearly 2*pi in phase. Jason
Reply by ●October 11, 20072007-10-11
Steve Underwood wrote: ..>> The method described by John is discussed in an article I wrote many >> years ago for an Analog Devives publication. >> >> You can find it here: http://www.danvillesignal.com/signal- >> generation/signal-generation.html >> >> Al Clark >> Danville Signal Processing, Inc. > > > I think some caveman probably has prior art for carving this on a cave > wall somewhere. :-) >Not a caveman as such, but (somewhat elaborated - uses 32bit ints rather than 16bit, and an extra "guard point" beyond the pow-of-2-table for interpolation purposes)) it is the original table lookup method for Csound; and hence probably for its ancestor Music11, and hence maybe even earlier than that. Richard Dobson






