<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Signal generator using Arduino and DDS</title>
	<atom:link href="http://mouro.info/signal-generator-using-arduino-and-dds/feed/" rel="self" type="application/rss+xml" />
	<link>http://mouro.info/signal-generator-using-arduino-and-dds/</link>
	<description>s. m. Indivíduo árabe ou berbere habitante do Norte de África. Eu sou do Cacém!</description>
	<lastBuildDate>Mon, 09 Jan 2012 23:25:31 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
	<item>
		<title>By: mouro</title>
		<link>http://mouro.info/signal-generator-using-arduino-and-dds/comment-page-1/#comment-435</link>
		<dc:creator>mouro</dc:creator>
		<pubDate>Mon, 09 Jan 2012 23:25:31 +0000</pubDate>
		<guid isPermaLink="false">http://mouro.info/?p=631#comment-435</guid>
		<description>hey wings, thanks for bringing that up. When I first posted it was correct but I guess the code plugin changed it. 
cheers</description>
		<content:encoded><![CDATA[<p>hey wings, thanks for bringing that up. When I first posted it was correct but I guess the code plugin changed it.<br />
cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wings</title>
		<link>http://mouro.info/signal-generator-using-arduino-and-dds/comment-page-1/#comment-434</link>
		<dc:creator>wings</dc:creator>
		<pubDate>Sun, 11 Dec 2011 17:50:47 +0000</pubDate>
		<guid isPermaLink="false">http://mouro.info/?p=631#comment-434</guid>
		<description>Looks like the comment cannot be posted correctly, so here goes again a little differently: On line 107, remove the ampersand, the text &quot;amp&quot;, and the semicolon in order to compile on an Arduino Uno.

wings</description>
		<content:encoded><![CDATA[<p>Looks like the comment cannot be posted correctly, so here goes again a little differently: On line 107, remove the ampersand, the text &#8220;amp&#8221;, and the semicolon in order to compile on an Arduino Uno.</p>
<p>wings</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wings</title>
		<link>http://mouro.info/signal-generator-using-arduino-and-dds/comment-page-1/#comment-433</link>
		<dc:creator>wings</dc:creator>
		<pubDate>Sun, 11 Dec 2011 17:48:24 +0000</pubDate>
		<guid isPermaLink="false">http://mouro.info/?p=631#comment-433</guid>
		<description>Odd, my comment was posted incorrectly.  Should read:
Removed &quot;&amp;&quot; from line 107...

wings</description>
		<content:encoded><![CDATA[<p>Odd, my comment was posted incorrectly.  Should read:<br />
Removed &#8220;&amp;&#8221; from line 107&#8230;</p>
<p>wings</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wings</title>
		<link>http://mouro.info/signal-generator-using-arduino-and-dds/comment-page-1/#comment-432</link>
		<dc:creator>wings</dc:creator>
		<pubDate>Sun, 11 Dec 2011 17:46:17 +0000</pubDate>
		<guid isPermaLink="false">http://mouro.info/?p=631#comment-432</guid>
		<description>This sketch would not compile without errors (Arduino Uno).

Removed &amp; from line 107 and program compiles and runs ok.

Regards,
wings</description>
		<content:encoded><![CDATA[<p>This sketch would not compile without errors (Arduino Uno).</p>
<p>Removed &amp; from line 107 and program compiles and runs ok.</p>
<p>Regards,<br />
wings</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mouro</title>
		<link>http://mouro.info/signal-generator-using-arduino-and-dds/comment-page-1/#comment-431</link>
		<dc:creator>mouro</dc:creator>
		<pubDate>Tue, 12 Apr 2011 11:28:25 +0000</pubDate>
		<guid isPermaLink="false">http://mouro.info/?p=631#comment-431</guid>
		<description>The components I used were spare ones, I don&#039;t remember the values by heart. 
1)  You can replace R1 and R2 with a linear POT to adjust the volume (for instance 10Kohm); Keep in mind that the line input should be kept in the 1V Peak to Peak range.
2) The low pass filter components R3 and C1 could be 1Kohm and .01uF for a cuttof frequency of ~16KHz.
3)  The AC coupling capacitor you actually don&#039;t need it since the computer line input already has AC coupling builtin.

 I haven&#039;t tried these values, but I hope this helps.</description>
		<content:encoded><![CDATA[<p>The components I used were spare ones, I don&#8217;t remember the values by heart.<br />
1)  You can replace R1 and R2 with a linear POT to adjust the volume (for instance 10Kohm); Keep in mind that the line input should be kept in the 1V Peak to Peak range.<br />
2) The low pass filter components R3 and C1 could be 1Kohm and .01uF for a cuttof frequency of ~16KHz.<br />
3)  The AC coupling capacitor you actually don&#8217;t need it since the computer line input already has AC coupling builtin.</p>
<p> I haven&#8217;t tried these values, but I hope this helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: J M Wilkes</title>
		<link>http://mouro.info/signal-generator-using-arduino-and-dds/comment-page-1/#comment-430</link>
		<dc:creator>J M Wilkes</dc:creator>
		<pubDate>Thu, 07 Apr 2011 00:37:51 +0000</pubDate>
		<guid isPermaLink="false">http://mouro.info/?p=631#comment-430</guid>
		<description>Could you email the values of the components in the oscillator schematic that generates a 440Hzfrequency sinewave?

Thanks</description>
		<content:encoded><![CDATA[<p>Could you email the values of the components in the oscillator schematic that generates a 440Hzfrequency sinewave?</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mouro</title>
		<link>http://mouro.info/signal-generator-using-arduino-and-dds/comment-page-1/#comment-403</link>
		<dc:creator>mouro</dc:creator>
		<pubDate>Sat, 04 Dec 2010 14:21:23 +0000</pubDate>
		<guid isPermaLink="false">http://mouro.info/?p=631#comment-403</guid>
		<description>Hi Alessando, 

For defining which wavetable you want to use, you can either use a
digital pin (for 2 different waveforms) , &#039;n&#039; digital pins (for 2^n
different waveforms) or a analog signal with different waveforms
mapped onto it.

If you only use two wavetables, you can use one digital pin for this purpose:

(...)
  // ... main loop
    if (digitalRead(waveSelectorPin) == HIGH)
        waveSelector = SINE_WAVE;
    else
         waveSelector = SQUARE_WAVE;
(...)

If using more than 2 wavetables and you need the digital pins for
other stuff, just use an analog pin.

(...)
   // main loop
   int waveSelector_analog = analogRead(waveSelectorPin);
   if (waveSelector_analog &lt; ANALOG_TOP_SINE)
       waveSelector = SINE_WAVE;
   else if (waveSelector_analog &lt; ANALOG_TOP_SQUARE)
       waveSelector = SQUARE_WAVE;
  ....
    else (waveSelector_analog &lt; ANALOG_TOP_TOOTHSAW)
       waveSelector = TOOTHSAW_WAVE;
(...)

The values ANALOG_TOP_TOOTHSAW, ANALOG_TOP_SQUARE, ANALOG_TOP_SINE,
etc , depend on the number of wavetables you use, and how you map them
in the analog signal. for instance, using 3 tables you&#039;ll have:
 ANALOG_TOP_SINE = 1023/3
 ANALOG_TOP_SQUARE = 1023/2
 ANALOG_TOP_SINE = 1023/1

so values between [0, 1023/3[ are for sinewave selection,  [1023/3,
1023/2[ squarewave selection, and [1023/2, 1023] for toothsaw wave.

(please note that this is one way of doing this.)


Now you should use the &#039;waveSelector&#039; value on the ISR to select the table:

ISR(TIMER1_OVF_vect)
{
   static uint8_t osc = 0;

   // Send oscillator output to PWM
   OCR1A = osc;

   // Update accumulator
   phaseAccumulator += phaseIncrement;
   index = phaseAccumulator &gt;&gt; 8;

   // Read oscillator value for next interrupt
   switch(waveSelector)
   {
       case SQUARE_WAVE:
            osc = pgm_read_byte( &amp;squareTable[index] );
            break;
       case SINE_WAVE:
            osc = pgm_read_byte( &amp;squareTable[index] );
            break;
       ....

       case TOOTHSAW_WAVE:
            osc = pgm_read_byte( &amp;toothsawTable[index] );
            break;
   }
}


hope this hels,
regards</description>
		<content:encoded><![CDATA[<p>Hi Alessando, </p>
<p>For defining which wavetable you want to use, you can either use a<br />
digital pin (for 2 different waveforms) , &#8216;n&#8217; digital pins (for 2^n<br />
different waveforms) or a analog signal with different waveforms<br />
mapped onto it.</p>
<p>If you only use two wavetables, you can use one digital pin for this purpose:</p>
<p>(&#8230;)<br />
  // &#8230; main loop<br />
    if (digitalRead(waveSelectorPin) == HIGH)<br />
        waveSelector = SINE_WAVE;<br />
    else<br />
         waveSelector = SQUARE_WAVE;<br />
(&#8230;)</p>
<p>If using more than 2 wavetables and you need the digital pins for<br />
other stuff, just use an analog pin.</p>
<p>(&#8230;)<br />
   // main loop<br />
   int waveSelector_analog = analogRead(waveSelectorPin);<br />
   if (waveSelector_analog < ANALOG_TOP_SINE)<br />
       waveSelector = SINE_WAVE;<br />
   else if (waveSelector_analog < ANALOG_TOP_SQUARE)<br />
       waveSelector = SQUARE_WAVE;<br />
  ....<br />
    else (waveSelector_analog < ANALOG_TOP_TOOTHSAW)<br />
       waveSelector = TOOTHSAW_WAVE;<br />
(...)</p>
<p>The values ANALOG_TOP_TOOTHSAW, ANALOG_TOP_SQUARE, ANALOG_TOP_SINE,<br />
etc , depend on the number of wavetables you use, and how you map them<br />
in the analog signal. for instance, using 3 tables you'll have:<br />
 ANALOG_TOP_SINE = 1023/3<br />
 ANALOG_TOP_SQUARE = 1023/2<br />
 ANALOG_TOP_SINE = 1023/1</p>
<p>so values between [0, 1023/3[ are for sinewave selection,  [1023/3,<br />
1023/2[ squarewave selection, and [1023/2, 1023] for toothsaw wave.</p>
<p>(please note that this is one way of doing this.)</p>
<p>Now you should use the 'waveSelector' value on the ISR to select the table:</p>
<p>ISR(TIMER1_OVF_vect)<br />
{<br />
   static uint8_t osc = 0;</p>
<p>   // Send oscillator output to PWM<br />
   OCR1A = osc;</p>
<p>   // Update accumulator<br />
   phaseAccumulator += phaseIncrement;<br />
   index = phaseAccumulator >> 8;</p>
<p>   // Read oscillator value for next interrupt<br />
   switch(waveSelector)<br />
   {<br />
       case SQUARE_WAVE:<br />
            osc = pgm_read_byte( &#038;squareTable[index] );<br />
            break;<br />
       case SINE_WAVE:<br />
            osc = pgm_read_byte( &#038;squareTable[index] );<br />
            break;<br />
       &#8230;.</p>
<p>       case TOOTHSAW_WAVE:<br />
            osc = pgm_read_byte( &#038;toothsawTable[index] );<br />
            break;<br />
   }<br />
}</p>
<p>hope this hels,<br />
regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alessandro</title>
		<link>http://mouro.info/signal-generator-using-arduino-and-dds/comment-page-1/#comment-223</link>
		<dc:creator>Alessandro</dc:creator>
		<pubDate>Sun, 03 Oct 2010 14:23:19 +0000</pubDate>
		<guid isPermaLink="false">http://mouro.info/?p=631#comment-223</guid>
		<description>Hi Mouro,
first i want to thank you for sharing the article and the sketch!
When i started looking for a way to produce a sine wave out of an arduino i found lots of posts and discussions, but yours was the most precise and easy to understand, at least for a DDS newbie as i am!

By the way i started tweaking here and there, and produced an 8-note keyboard with an octave switch succesfully.
Now i just wanted to add a waveform switch: i added a square wave wavetable to the sketch and have it working by changing the value in
osc = pgm_read_byte( &amp;squareTable[index] );

but still i can&#039;t find how to make it dynamic, i mean, having a trimpot or something like that to make me switch between different wavetables...

i tried different ways and googled the ISR(TIMER1_OVF_vect) part of the sketch to try and understand that part better, but i&#039;m stuck, so that&#039;s the reason i&#039;m writing here.

Maybe you can have any suggestion or explain how this part of the code, where the sineTable is used, works?

Thanks a lot in advance and keep up the good work!

alessandro</description>
		<content:encoded><![CDATA[<p>Hi Mouro,<br />
first i want to thank you for sharing the article and the sketch!<br />
When i started looking for a way to produce a sine wave out of an arduino i found lots of posts and discussions, but yours was the most precise and easy to understand, at least for a DDS newbie as i am!</p>
<p>By the way i started tweaking here and there, and produced an 8-note keyboard with an octave switch succesfully.<br />
Now i just wanted to add a waveform switch: i added a square wave wavetable to the sketch and have it working by changing the value in<br />
osc = pgm_read_byte( &amp;squareTable[index] );</p>
<p>but still i can&#8217;t find how to make it dynamic, i mean, having a trimpot or something like that to make me switch between different wavetables&#8230;</p>
<p>i tried different ways and googled the ISR(TIMER1_OVF_vect) part of the sketch to try and understand that part better, but i&#8217;m stuck, so that&#8217;s the reason i&#8217;m writing here.</p>
<p>Maybe you can have any suggestion or explain how this part of the code, where the sineTable is used, works?</p>
<p>Thanks a lot in advance and keep up the good work!</p>
<p>alessandro</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mouro</title>
		<link>http://mouro.info/signal-generator-using-arduino-and-dds/comment-page-1/#comment-221</link>
		<dc:creator>mouro</dc:creator>
		<pubDate>Thu, 02 Sep 2010 10:53:02 +0000</pubDate>
		<guid isPermaLink="false">http://mouro.info/?p=631#comment-221</guid>
		<description>Hi Patrick,
i’m using the PWM(+Low Band Fitler) to generate the analog output instead of using an 8bit DAC. Timer1 is configured to 8-bit fast PWM, no prescaler – clock io = cpu clock, so it’s running at 16MHz and overflows every 256 clock cycles (62.5kHz). And this is the frequency used to update the output signal.

You can decrease the sampling frequency to gain more processing time. Keep in mind though that the sampling frequency should be at least the double of the maximum frequency you want to generate (Nyquist theorem).

To decrease the sampling frequency, you can either change the PWM mode to 9 or 10bit PWM mode, thus gaining more time for background processing or you can select a different clock source to TIMER1 instead of using no prescaler. Each possibility has drawbacks.

If I do recall properly, the Atmega168 TIMER1 has 4 clock sources with prescaler: clkio/8, clio/64, clkio/256, clkio/1024. If you use clkio/8, TIMER1 will overflow every 7.815kHz (16000000/8*256) which allow you to reconstruct signals up to 3.9kHz which isn’t that good for audio applications.

With a 10 bit fast PWM no prescaling, the sampling frequency would be (16000000/1024*1) 15.625kHz thus allowing analog reconstruction of signals up to 7.8125 kHz. However this would require the need of 10 bit lookup tables instead of 8bit tables thus increasing the memory footprint.

“If I try to add some more, for example volume, it all breaks due to timing errors.”
You can add a potentiometer at the output stage to control the volume, no need for CPU power for that.

If you need another oscillator, you can use OCR1B to generate a waveform output on OC1B pin, using the same timer. This is a good option for example, if you want stereo output.

“I found that using a prescale lowers the load on the processor, but i cannot see in this code how to keep the waveforms correct.” – I forgot to answer this one. :)

If you use a prescaler you’re changing the sampling frequency. For the sketch to continue to work properly you need to recompute the dds ‘resolution’ according to the sampling frequency.

resolution = 2^16 * 2^16/ (samplingFrequency)

cheers
Hope this helps,
mouro</description>
		<content:encoded><![CDATA[<p>Hi Patrick,<br />
i’m using the PWM(+Low Band Fitler) to generate the analog output instead of using an 8bit DAC. Timer1 is configured to 8-bit fast PWM, no prescaler – clock io = cpu clock, so it’s running at 16MHz and overflows every 256 clock cycles (62.5kHz). And this is the frequency used to update the output signal.</p>
<p>You can decrease the sampling frequency to gain more processing time. Keep in mind though that the sampling frequency should be at least the double of the maximum frequency you want to generate (Nyquist theorem).</p>
<p>To decrease the sampling frequency, you can either change the PWM mode to 9 or 10bit PWM mode, thus gaining more time for background processing or you can select a different clock source to TIMER1 instead of using no prescaler. Each possibility has drawbacks.</p>
<p>If I do recall properly, the Atmega168 TIMER1 has 4 clock sources with prescaler: clkio/8, clio/64, clkio/256, clkio/1024. If you use clkio/8, TIMER1 will overflow every 7.815kHz (16000000/8*256) which allow you to reconstruct signals up to 3.9kHz which isn’t that good for audio applications.</p>
<p>With a 10 bit fast PWM no prescaling, the sampling frequency would be (16000000/1024*1) 15.625kHz thus allowing analog reconstruction of signals up to 7.8125 kHz. However this would require the need of 10 bit lookup tables instead of 8bit tables thus increasing the memory footprint.</p>
<p>“If I try to add some more, for example volume, it all breaks due to timing errors.”<br />
You can add a potentiometer at the output stage to control the volume, no need for CPU power for that.</p>
<p>If you need another oscillator, you can use OCR1B to generate a waveform output on OC1B pin, using the same timer. This is a good option for example, if you want stereo output.</p>
<p>“I found that using a prescale lowers the load on the processor, but i cannot see in this code how to keep the waveforms correct.” – I forgot to answer this one. <img src='http://mouro.info/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If you use a prescaler you’re changing the sampling frequency. For the sketch to continue to work properly you need to recompute the dds ‘resolution’ according to the sampling frequency.</p>
<p>resolution = 2^16 * 2^16/ (samplingFrequency)</p>
<p>cheers<br />
Hope this helps,<br />
mouro</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Noto Yota</title>
		<link>http://mouro.info/signal-generator-using-arduino-and-dds/comment-page-1/#comment-218</link>
		<dc:creator>Noto Yota</dc:creator>
		<pubDate>Fri, 27 Aug 2010 13:06:34 +0000</pubDate>
		<guid isPermaLink="false">http://mouro.info/?p=631#comment-218</guid>
		<description>Hi, i&#039;ve working with this piece of code to create a DDS oscillator.
I&#039;m relatively new to the AVR timers.
Could you explain a little bit more how this works?
Is it for example possible to have this working with a timer with prescale?
I have one oscillator running on a duemilanove and can do nothing more. If I try to add some more, for example volume, it all breaks due to timing errors.
I found that using a prescale lowers the load on the processor, but i cannot see in this code how to keep the waveforms correct.

Nice work.
Regards,
Patrick</description>
		<content:encoded><![CDATA[<p>Hi, i&#8217;ve working with this piece of code to create a DDS oscillator.<br />
I&#8217;m relatively new to the AVR timers.<br />
Could you explain a little bit more how this works?<br />
Is it for example possible to have this working with a timer with prescale?<br />
I have one oscillator running on a duemilanove and can do nothing more. If I try to add some more, for example volume, it all breaks due to timing errors.<br />
I found that using a prescale lowers the load on the processor, but i cannot see in this code how to keep the waveforms correct.</p>
<p>Nice work.<br />
Regards,<br />
Patrick</p>
]]></content:encoded>
	</item>
</channel>
</rss>

