Skip to main content
Tweeted twitter.com/StackSignals/status/1265795032260530176
replaced http://dsp.stackexchange.com/ with https://dsp.stackexchange.com/
Source Link

If I want to simulate a digital oscillator (or phasor) to modulate an arbitrarily length signal: $$y(t) = \cos(2\pi f_ct)\quad\text{where}\quad t = \frac{n}{f_s}\quad\text{for sample}\quad n$$

What is the advantage of using a numerically controlled oscillator (Answered hereAnswered here) versus simply incrementing $n$ over the length of the input?

main(): 
  n = 0                 # total samples processed
  N = len(input)        # num samples in input
  blksz = N / 16        # don't create phasor all in one call
  # calculate phasor over multiple passes
  while ( n < N ) 
      update_phasor(blksz)
# calculate phasor
update_phasor(blksz):
  for (i = 0; i < blksz; i++)
      y[i] = exp(j*2*pi*fc*n/fs) 
      n++

The NCO referenced above and the pseudocode implementations give different results and I am trying to understand which makes more sense.

Also, what is the best way to synthesize the phasor if the desired frequency needs to change on the fly?

If I want to simulate a digital oscillator (or phasor) to modulate an arbitrarily length signal: $$y(t) = \cos(2\pi f_ct)\quad\text{where}\quad t = \frac{n}{f_s}\quad\text{for sample}\quad n$$

What is the advantage of using a numerically controlled oscillator (Answered here) versus simply incrementing $n$ over the length of the input?

main(): 
  n = 0                 # total samples processed
  N = len(input)        # num samples in input
  blksz = N / 16        # don't create phasor all in one call
  # calculate phasor over multiple passes
  while ( n < N ) 
      update_phasor(blksz)
# calculate phasor
update_phasor(blksz):
  for (i = 0; i < blksz; i++)
      y[i] = exp(j*2*pi*fc*n/fs) 
      n++

The NCO referenced above and the pseudocode implementations give different results and I am trying to understand which makes more sense.

Also, what is the best way to synthesize the phasor if the desired frequency needs to change on the fly?

If I want to simulate a digital oscillator (or phasor) to modulate an arbitrarily length signal: $$y(t) = \cos(2\pi f_ct)\quad\text{where}\quad t = \frac{n}{f_s}\quad\text{for sample}\quad n$$

What is the advantage of using a numerically controlled oscillator (Answered here) versus simply incrementing $n$ over the length of the input?

main(): 
  n = 0                 # total samples processed
  N = len(input)        # num samples in input
  blksz = N / 16        # don't create phasor all in one call
  # calculate phasor over multiple passes
  while ( n < N ) 
      update_phasor(blksz)
# calculate phasor
update_phasor(blksz):
  for (i = 0; i < blksz; i++)
      y[i] = exp(j*2*pi*fc*n/fs) 
      n++

The NCO referenced above and the pseudocode implementations give different results and I am trying to understand which makes more sense.

Also, what is the best way to synthesize the phasor if the desired frequency needs to change on the fly?

Made title clearer to include users searching for NCO details.
Link

Trying to understand Numerically Controlled Oscillator (NCO) for phasor implementation details?

If I want to simulate a digital oscillator (or phasor) to modulate an arbitrarily length signal:

$y(t) = cos(2\pi f_ct)$

where $t = n / f_s $ for sample n $$y(t) = \cos(2\pi f_ct)\quad\text{where}\quad t = \frac{n}{f_s}\quad\text{for sample}\quad n$$

What is the advantage of using a numerically controlled oscillator (Answered here) versus simply incrementing $n$ over the length of the input?

main(): 
  n = 0                 # total samples processed
  N = len(input)        # num samples in input
  blksz = N / 16        # don't create phasor all in one call
  # calculate phasor over multiple passes
  while ( n < N ) 
      update_phasor(blksz)
# calculate phasor
update_phasor(blksz):
  for (i = 0; i < blksz; i++)
      y[i] = exp(j*2*pi*fc*n/fs) 
      n++

The NCO referenced above and the pseudocode implementations give different results and I am trying to understand which makes more sense.

Also, what is the best way to synthesize the phasor if the desired frequency needs to change on the fly?

If I want to simulate a digital oscillator (or phasor) to modulate an arbitrarily length signal:

$y(t) = cos(2\pi f_ct)$

where $t = n / f_s $ for sample n

What is the advantage of using a numerically controlled oscillator (Answered here) versus simply incrementing $n$ over the length of the input?

main(): 
  n = 0                 # total samples processed
  N = len(input)        # num samples in input
  blksz = N / 16        # don't create phasor all in one call
  # calculate phasor over multiple passes
  while ( n < N ) 
      update_phasor(blksz)
# calculate phasor
update_phasor(blksz):
  for (i = 0; i < blksz; i++)
      y[i] = exp(j*2*pi*fc*n/fs) 
      n++

The NCO referenced above and the pseudocode implementations give different results and I am trying to understand which makes more sense.

Also, what is the best way to synthesize the phasor if the desired frequency needs to change on the fly?

If I want to simulate a digital oscillator (or phasor) to modulate an arbitrarily length signal: $$y(t) = \cos(2\pi f_ct)\quad\text{where}\quad t = \frac{n}{f_s}\quad\text{for sample}\quad n$$

What is the advantage of using a numerically controlled oscillator (Answered here) versus simply incrementing $n$ over the length of the input?

main(): 
  n = 0                 # total samples processed
  N = len(input)        # num samples in input
  blksz = N / 16        # don't create phasor all in one call
  # calculate phasor over multiple passes
  while ( n < N ) 
      update_phasor(blksz)
# calculate phasor
update_phasor(blksz):
  for (i = 0; i < blksz; i++)
      y[i] = exp(j*2*pi*fc*n/fs) 
      n++

The NCO referenced above and the pseudocode implementations give different results and I am trying to understand which makes more sense.

Also, what is the best way to synthesize the phasor if the desired frequency needs to change on the fly?

deleted 7 characters in body
Source Link
Loading
Source Link
Loading