<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Greg Surges &#187; Arduino</title>
	<atom:link href="http://gregsurges.com/tag/arduino/feed/" rel="self" type="application/rss+xml" />
	<link>http://gregsurges.com</link>
	<description>Computer Musician, Programmer, Hardware Hacker</description>
	<lastBuildDate>Mon, 14 May 2012 19:59:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>tabulaRasa user demos</title>
		<link>http://gregsurges.com/original-music/electronic-music/tabularasa-wavetable-oscillator-arduino-shield/tabularasa-user-demos/</link>
		<comments>http://gregsurges.com/original-music/electronic-music/tabularasa-wavetable-oscillator-arduino-shield/tabularasa-user-demos/#comments</comments>
		<pubDate>Thu, 05 Apr 2012 18:59:48 +0000</pubDate>
		<dc:creator>Greg Surges</dc:creator>
				<category><![CDATA[tabulaRasa - wavetable oscillator Arduino shield]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[oscillator]]></category>
		<category><![CDATA[pucktronix]]></category>
		<category><![CDATA[sound]]></category>
		<category><![CDATA[tabulaRasa]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[wavetable]]></category>

		<guid isPermaLink="false">http://gregsurges.com/?p=1501</guid>
		<description><![CDATA[Here are two new tabulaRasa demos: From Clarke Robinson (who designed the panel in the video), using a set of vocal waveforms, no effects: From Greg Davis, using tables composed of mixed harmonically-related sinusoids, through a filter, and a delay:]]></description>
			<content:encoded><![CDATA[<p>Here are two new tabulaRasa demos:</p>
<p>From Clarke Robinson (who designed the panel in the video), using a set of vocal waveforms, no effects:<br />
<iframe width="480" height="360" src="http://www.youtube.com/embed/600VLAokojw" frameborder="0" allowfullscreen></iframe></p>
<p>From Greg Davis, using tables composed of mixed harmonically-related sinusoids, through a filter, and a delay:<br />
<iframe width="100%" height="166" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F42061963&#038;show_artwork=true"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://gregsurges.com/original-music/electronic-music/tabularasa-wavetable-oscillator-arduino-shield/tabularasa-user-demos/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Interfacing an MT8816 crosspoint switch with Arduino</title>
		<link>http://gregsurges.com/programming/interfacing-an-mt8816-crosspoint-switch-with-arduino/</link>
		<comments>http://gregsurges.com/programming/interfacing-an-mt8816-crosspoint-switch-with-arduino/#comments</comments>
		<pubDate>Sun, 11 Sep 2011 03:35:11 +0000</pubDate>
		<dc:creator>Greg Surges</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[pucktronix.snake.corral]]></category>
		<category><![CDATA[analog]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[mt8816]]></category>
		<category><![CDATA[synth]]></category>
		<category><![CDATA[teensy]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://gregsurges.com/?p=1280</guid>
		<description><![CDATA[I thought I would post a bit of information about using a Zarlink MT8816 crosspoint switch (datasheet) with an Arduino or similar microcontroller. The MT8816 is a 40-pin IC which allows you to route any of its 8 X pins to any of its 16 Y pins &#8211; the connections are bidirectional, so you have [...]]]></description>
			<content:encoded><![CDATA[<p>I thought I would post a bit of information about using a Zarlink MT8816 crosspoint switch (<a href="http://www.zarlink.com/zarlink/zweb-mt8816-datasheet-jan10.pdf" target="_blank">datasheet</a>) with an Arduino or similar microcontroller. The MT8816 is a 40-pin IC which allows you to route any of its 8 X pins to any of its 16 Y pins &#8211; the connections are bidirectional, so you have do 8 ins, 16 outs or 16 ins, 8 outs. What you get from this is a cool matrix signal router &#8211; a great device to have for musical or other nefarious purposes.</p>
<p>Here&#8217;s the pinout:</p>
<p><a href="http://gregsurges.com/wp-content/uploads/2011/09/Screen-shot-2011-09-10-at-7.59.56-PM.png" rel="lightbox[1280]"><img class="aligncenter size-full wp-image-1282" title="Screen shot 2011-09-10 at 7.59.56 PM" src="http://gregsurges.com/wp-content/uploads/2011/09/Screen-shot-2011-09-10-at-7.59.56-PM.png" alt="Screen shot 2011-09-10 at 7.59.56 PM" width="293" height="334" /></a></p>
<p>Each of the pins beginning with &#8220;A&#8221; is an address pin &#8211; they&#8217;re how you address a specific X/Y connection. To interface this with an Arduino, you need to connect 11 digital output pins from the Arduino:</p>
<ul>
<li>7 address pins (AX0-AX3, AY0-AX2, these use a strange binary-ish number system &#8211; more on that later)</li>
<li>DATA (High or low to indicate whether to open or close the specified switch)</li>
<li>CS (Chip Select &#8211; you can just tie this high if you&#8217;re only using one)</li>
<li>STROBE (Setting this high writes the DATA to the indicated address)</li>
<li>RESET (I found that if I didn&#8217;t reset the chip upon powering the circuit, I&#8217;d get strange results)</li>
</ul>
<p>Other than that, you need to connect VDD, VSS, and VEE to +, GND, and &#8211; supplies.</p>
<p>So, as I mentioned, the addressing scheme is a little strange &#8211; and caused me 2 &#8211; 3 lost days of head-scratching and frustration. Here&#8217;s the info from the datasheet:</p>
<p><a href="http://gregsurges.com/wp-content/uploads/2011/09/Screen-shot-2011-09-10-at-8.10.24-PM.png" rel="lightbox[1280]"><img class="size-full wp-image-1284 alignnone" title="Screen shot 2011-09-10 at 8.10.24 PM" src="http://gregsurges.com/wp-content/uploads/2011/09/Screen-shot-2011-09-10-at-8.10.24-PM.png" alt="Screen shot 2011-09-10 at 8.10.24 PM" width="634" height="392" /></a></p>
<p>As you can see, the address pins indicate an address in a parallel, binary-ish scheme. So, if we&#8217;re going to select a particular matrix point &#8211; let&#8217;s use X3/Y1 &#8211; we use all of the address pins at once to indicate the numbers we need. Pins AX0 &#8211; AX3 give us 4 X address pins &#8211; 4four bits, which lets us count from 0 &#8211; 15 in binary. AY0 &#8211; AY2 give us 3 bits, 0 &#8211; 7 in binary. The 4-bit binary representation of our X address, 3, is 0011, and our Y address, 1, is 001. Consulting the table above, we can look up the value for X3 and see that it is actually 0110, and if we jump down a bit, we see that Y1 is 001. So, to represent our X3/Y1 we just turn our Arduino pins X1, X2, and Y0 high, and leave the others low.</p>
<p>This is all pretty clear, and the addressing follows binary counting rules until you get to X6. Look at the data sheet &#8211; X12 and X13 are actually represented by the binary numbers 6 (0110) and 7 (0111). I found an easy fix for my application, but long story short &#8211; never assume your chip follows any logic, and always read the datasheet thoroughly. I will admit to much profanity upon discovery of this design &#8220;feature&#8221; &#8211; you can see I had fun on this one&#8230;</p>
<p><a href="http://gregsurges.com/wp-content/uploads/2011/09/Screen-shot-2011-09-10-at-8.33.01-PM.png" rel="lightbox[1280]"><img class="alignnone size-full wp-image-1286" title="Screen shot 2011-09-10 at 8.33.01 PM" src="http://gregsurges.com/wp-content/uploads/2011/09/Screen-shot-2011-09-10-at-8.33.01-PM.png" alt="Screen shot 2011-09-10 at 8.33.01 PM" width="536" height="181" /></a></p>
<p>Here&#8217;s my code, apologies for crummy WordPress formatting. Note that I&#8217;m only using an 8 x 8 subset of the chip, so my compensation may not work for your needs.</p>
<p><code>void togglePins(int chip, uint8_t x, uint8_t y, int state){<br />
if(x &gt;= 6){ // compensate for strange x-axis addressing scheme<br />
x += 2;<br />
}<br />
digitalWrite(chip, HIGH);<br />
// next lines convert from integer to binary address<br />
// bitRead returns whether a given bit position in the binary representation of a value is high or low<br />
if(bitRead(x, 0)) digitalWrite(X0, HIGH);<br />
if(bitRead(x, 1)) digitalWrite(X1, HIGH);<br />
if(bitRead(x, 2)) digitalWrite(X2, HIGH);<br />
if(bitRead(x, 3)) digitalWrite(X3, HIGH);<br />
if(bitRead(y, 0)) digitalWrite(Y0, HIGH);<br />
if(bitRead(y, 1)) digitalWrite(Y1, HIGH);<br />
if(bitRead(y, 2)) digitalWrite(Y2, HIGH);<br />
// after address pins are set, set strobe high<br />
digitalWrite(STROBE, HIGH);<br />
// make sure DATA pin is the correct value<br />
digitalWrite(DATA, state);<br />
// reset all pins to low<br />
digitalWrite(STROBE, LOW);<br />
digitalWrite(X0, LOW);<br />
digitalWrite(X1, LOW);<br />
digitalWrite(X2, LOW);<br />
digitalWrite(X3, LOW);<br />
digitalWrite(Y0, LOW);<br />
digitalWrite(Y1, LOW);<br />
digitalWrite(Y2, LOW);<br />
digitalWrite(chip, LOW);<br />
}</code></p>
<p>It&#8217;s a pretty simple function, and you can see the rest of the program in my <a href="https://bitbucket.org/pucktronix/pucktronix.snake.corral/src/8d934c721f7a/pucktronix.snake.corral.firmware.pde" target="_blank">bitbucket repository</a>.</p>
<p>I&#8217;ll be posting more soon about the device I&#8217;m building &#8211; it&#8217;s called pucktronix.snake.corral. I hope this helps decipher the datasheet, and saves some possible head-scratching.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregsurges.com/programming/interfacing-an-mt8816-crosspoint-switch-with-arduino/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Colleen Ludwig&#8217;s &#8220;Shiver&#8221;</title>
		<link>http://gregsurges.com/programming/colleen-ludwigs-shiver/</link>
		<comments>http://gregsurges.com/programming/colleen-ludwigs-shiver/#comments</comments>
		<pubDate>Sun, 13 Mar 2011 00:21:14 +0000</pubDate>
		<dc:creator>Greg Surges</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[colleen ludwig]]></category>
		<category><![CDATA[Installation]]></category>
		<category><![CDATA[Interactive]]></category>
		<category><![CDATA[shiver]]></category>

		<guid isPermaLink="false">http://gregsurges.com/?p=1176</guid>
		<description><![CDATA[Here&#8217;s a video documenting Colleen Ludwig&#8217;s interactive installation &#8220;Shiver&#8221; &#8211; a project I worked on this past year. I helped design the interactivity and wrote the code, which ran on two Arduino Megas, reading 35 motion sensors and controlling 71 solenoid valves.]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a video documenting Colleen Ludwig&#8217;s interactive installation &#8220;Shiver&#8221; &#8211; a project I worked on this past year. I helped design the interactivity and wrote the code, which ran on two Arduino Megas, reading 35 motion sensors and controlling 71 solenoid valves.</p>
<p><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="640" height="401" id="babble_embed"><param name="movie" value="http://files.artbabble.org.s3.amazonaws.com/embed-player.swf" /><param name="allowScriptAccess" value="always" /><param name="allowFullscreen" value="true" /><param name="flashvars" value='video_id="69546f26a07101ee"&#038;poster_index="04"' /><embed type="application/x-shockwave-flash" id="babble_embed" allowScriptAccess="always" allowFullscreen="true" src="http://files.artbabble.org.s3.amazonaws.com/embed-player.swf" width="640" height="401" name="babble_embed" flashvars='video_id="69546f26a07101ee"&#038;poster_index="04"'/></object></p>
]]></content:encoded>
			<wfw:commentRss>http://gregsurges.com/programming/colleen-ludwigs-shiver/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>tabulaRasa PCB</title>
		<link>http://gregsurges.com/original-music/electronic-music/tabularasa-wavetable-oscillator-arduino-shield/tabularasa-pcb/</link>
		<comments>http://gregsurges.com/original-music/electronic-music/tabularasa-wavetable-oscillator-arduino-shield/tabularasa-pcb/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 00:34:36 +0000</pubDate>
		<dc:creator>Greg Surges</dc:creator>
				<category><![CDATA[tabulaRasa - wavetable oscillator Arduino shield]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[modular]]></category>
		<category><![CDATA[tabulaRasa]]></category>
		<category><![CDATA[wavetable oscillator]]></category>

		<guid isPermaLink="false">http://gregsurges.com/?p=1138</guid>
		<description><![CDATA[Making progress on the tabulaRasa hardware &#8211; ordered the second prototypes from dorkbotpdx today. More soon.]]></description>
			<content:encoded><![CDATA[<div id="attachment_1139" class="wp-caption aligncenter" style="width: 310px"><a href="http://gregsurges.com/wp-content/uploads/2011/01/tabulaRasaPrototype.jpg" rel="lightbox[1138]"><img class="size-medium wp-image-1139" title="tabulaRasaPrototype" src="http://gregsurges.com/wp-content/uploads/2011/01/tabulaRasaPrototype-300x225.jpg" alt="Here's the first prototype of my tabulaRasa wavetable oscillator module" width="300" height="225" /></a><p class="wp-caption-text">Here&#39;s the first prototype of my tabulaRasa wavetable oscillator module</p></div>
<p>Making progress on the tabulaRasa hardware &#8211; ordered the second prototypes from dorkbotpdx today. More soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregsurges.com/original-music/electronic-music/tabularasa-wavetable-oscillator-arduino-shield/tabularasa-pcb/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>tabulaRasa: Cycling through waveforms.</title>
		<link>http://gregsurges.com/original-music/electronic-music/tabularasa-wavetable-oscillator-arduino-shield/tabularasa-cycling-waveforms/</link>
		<comments>http://gregsurges.com/original-music/electronic-music/tabularasa-wavetable-oscillator-arduino-shield/tabularasa-cycling-waveforms/#comments</comments>
		<pubDate>Tue, 26 Oct 2010 15:14:52 +0000</pubDate>
		<dc:creator>Greg Surges</dc:creator>
				<category><![CDATA[tabulaRasa - wavetable oscillator Arduino shield]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[shield]]></category>
		<category><![CDATA[tabulaRasa]]></category>
		<category><![CDATA[wavetable oscillator]]></category>

		<guid isPermaLink="false">http://gregsurges.com/?p=1025</guid>
		<description><![CDATA[My tabulaRasa cycling through 11 different custom waveforms:]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://www.gregsurges.com/circuitry/tabularasa/" target="_blank">tabulaRasa</a> cycling through 11 different custom waveforms:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/e03SlRDjE1k?fs=1&amp;hl=en_US" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="385" src="http://www.youtube.com/v/e03SlRDjE1k?fs=1&amp;hl=en_US" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://gregsurges.com/original-music/electronic-music/tabularasa-wavetable-oscillator-arduino-shield/tabularasa-cycling-waveforms/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>tabulaRasa</title>
		<link>http://gregsurges.com/original-music/electronic-music/tabularasa-wavetable-oscillator-arduino-shield/tabularasa/</link>
		<comments>http://gregsurges.com/original-music/electronic-music/tabularasa-wavetable-oscillator-arduino-shield/tabularasa/#comments</comments>
		<pubDate>Tue, 19 Oct 2010 14:02:04 +0000</pubDate>
		<dc:creator>Greg Surges</dc:creator>
				<category><![CDATA[tabulaRasa - wavetable oscillator Arduino shield]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[shield]]></category>
		<category><![CDATA[tabulaRasa]]></category>
		<category><![CDATA[wavetable oscillator]]></category>

		<guid isPermaLink="false">http://gregsurges.com/?p=997</guid>
		<description><![CDATA[Added a page for my new project, a wavetable oscillator on an Arduino shield, called tabulaRasa. Here&#8217;s an early demo, reading a sine waveform:]]></description>
			<content:encoded><![CDATA[<p>Added a page for my new project, a wavetable oscillator on an Arduino shield, called <a href="http://www.gregsurges.com/circuitry/tabularasa/">tabulaRasa</a>.</p>
<p>Here&#8217;s an early demo, reading a sine waveform:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="244" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://www.youtube.com/v/1SHCDzEgy-c&amp;hl=en_US&amp;feature=player_embedded&amp;version=3" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="400" height="244" src="http://www.youtube.com/v/1SHCDzEgy-c&amp;hl=en_US&amp;feature=player_embedded&amp;version=3" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://gregsurges.com/original-music/electronic-music/tabularasa-wavetable-oscillator-arduino-shield/tabularasa/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Breadboard Octomod</title>
		<link>http://gregsurges.com/original-music/electronic-music/breadboard-octomod/</link>
		<comments>http://gregsurges.com/original-music/electronic-music/breadboard-octomod/#comments</comments>
		<pubDate>Thu, 14 Oct 2010 20:46:48 +0000</pubDate>
		<dc:creator>Greg Surges</dc:creator>
				<category><![CDATA[Electronic Music]]></category>
		<category><![CDATA[USB - Control Voltage Interface]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[control voltage]]></category>
		<category><![CDATA[DIY Synth]]></category>
		<category><![CDATA[George Macklin]]></category>
		<category><![CDATA[usb-octomod]]></category>

		<guid isPermaLink="false">http://gregsurges.com/?p=968</guid>
		<description><![CDATA[George Macklin wrote about his breadboard version of the Octomod here. Here&#8217;s his (super-clean) version:]]></description>
			<content:encoded><![CDATA[<p>George Macklin wrote about his breadboard version of the <a href="http://www.gregsurges.com/circuitry/usb-octomod/">Octomod</a> <a href="http://granularmatter.blogspot.com/2010/10/octomod-breadboard.html" target="_blank">here</a>.</p>
<p>Here&#8217;s his (super-clean) version:</p>
<p><a href="http://www.flickr.com/photos/gmacklin/5079460732/"><img class="aligncenter size-full wp-image-969" title="Breadboard Octomod" src="http://gregsurges.com/wp-content/uploads/2010/10/5079459828_75fcf555e9.jpg" alt="Breadboard Octomod" width="500" height="375" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://gregsurges.com/original-music/electronic-music/breadboard-octomod/feed/</wfw:commentRss>
		<slash:comments>66</slash:comments>
		</item>
		<item>
		<title>Updates and Arduino Wavetable Oscillator</title>
		<link>http://gregsurges.com/original-music/electronic-music/usb-control-voltage-interface-electronic-music-original-music/updates-arduino-wavetable-oscillator/</link>
		<comments>http://gregsurges.com/original-music/electronic-music/usb-control-voltage-interface-electronic-music-original-music/updates-arduino-wavetable-oscillator/#comments</comments>
		<pubDate>Thu, 23 Sep 2010 00:10:01 +0000</pubDate>
		<dc:creator>Greg Surges</dc:creator>
				<category><![CDATA[USB - Control Voltage Interface]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[diy control voltage interface]]></category>
		<category><![CDATA[teensy 2.0]]></category>
		<category><![CDATA[usb-octomod]]></category>
		<category><![CDATA[wavetable oscillator]]></category>

		<guid isPermaLink="false">http://gregsurges.com/?p=945</guid>
		<description><![CDATA[Here&#8217;s my finished Octomod: The project continues: Second batch of PCBs has arrived. A small number of component sets has been ordered for kits and assembled boards. Teensy 2.0s should be back in stock within a week. My new project is a voltage-controlled wavetable oscillator, with SD card storage, voltage control over waveform blending, and [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s <em>my</em> finished <a href="http://www.gregsurges.com/circuitry/usb-octomod/">Octomod</a>:</p>
<div id="attachment_946" class="wp-caption aligncenter" style="width: 310px"><a href="http://gregsurges.com/wp-content/uploads/2010/09/DSCN07471.JPG" rel="lightbox[945]"><img class="size-medium wp-image-946" title="USB - Octomod DIY USB to Control Voltage Generator" src="http://gregsurges.com/wp-content/uploads/2010/09/DSCN07471-300x225.jpg" alt="My Octomod Enclosure" width="300" height="225" /></a><p class="wp-caption-text">My Octomod Enclosure</p></div>
<p>The project continues:</p>
<ul>
<li>Second batch of PCBs has <a href="http://www.gregsurges.com/circuitry/store/">arrived</a>.</li>
<li>A small number of component sets has been ordered for kits and assembled boards.</li>
<li>Teensy 2.0s should be back in stock within a week.</li>
</ul>
<p>My new project is a voltage-controlled wavetable oscillator, with SD card storage, voltage control over waveform blending, and in an Arduino shield format. I&#8217;m currently breadboarding the prototype, and really pushing the Arduino platform. It&#8217;s going to be awesome.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregsurges.com/original-music/electronic-music/usb-control-voltage-interface-electronic-music-original-music/updates-arduino-wavetable-oscillator/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Arduino Modification for USB-Octomod</title>
		<link>http://gregsurges.com/original-music/electronic-music/arduino-modification-usb-octomod/</link>
		<comments>http://gregsurges.com/original-music/electronic-music/arduino-modification-usb-octomod/#comments</comments>
		<pubDate>Wed, 15 Sep 2010 02:41:15 +0000</pubDate>
		<dc:creator>Greg Surges</dc:creator>
				<category><![CDATA[Electronic Music]]></category>
		<category><![CDATA[USB - Control Voltage Interface]]></category>
		<category><![CDATA[analog synthesizer]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[cv]]></category>
		<category><![CDATA[usb interface]]></category>
		<category><![CDATA[usb-octomod]]></category>
		<category><![CDATA[voltage control]]></category>

		<guid isPermaLink="false">http://gregsurges.com/?p=937</guid>
		<description><![CDATA[Spent the better part of Sunday afternoon making the USB-Octomod work with an Arduino. There is a bundle containing code and instructions linked here.]]></description>
			<content:encoded><![CDATA[<p>Spent the better part of Sunday afternoon making the USB-Octomod work with an Arduino. There is a bundle containing code and instructions linked <a href="http://www.gregsurges.com/circuitry/usb-octomod/" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregsurges.com/original-music/electronic-music/arduino-modification-usb-octomod/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Using OSC, Processing, and a Microcontroller to connect Max/MSP and a DAC IC.</title>
		<link>http://gregsurges.com/programming/osc-processing-microcontroller-connect-maxmsp-dac-ic/</link>
		<comments>http://gregsurges.com/programming/osc-processing-microcontroller-connect-maxmsp-dac-ic/#comments</comments>
		<pubDate>Fri, 27 Aug 2010 17:04:06 +0000</pubDate>
		<dc:creator>Greg Surges</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[USB - Control Voltage Interface]]></category>
		<category><![CDATA[analog synthesis]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[bit shifting]]></category>
		<category><![CDATA[DAC]]></category>
		<category><![CDATA[Max/MSP]]></category>
		<category><![CDATA[max5250]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[OSC]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[serial]]></category>
		<category><![CDATA[teensy]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://gregsurges.com/?p=786</guid>
		<description><![CDATA[My most recent project, the USB-Octomod, uses Processing to create an OpenSoundControl (OSC) interface between any OSC-ready software and a hardware DAC device I built. I&#8217;m going to break down the connections between different pieces of software and hardware, in order to explain how the system works and to provide the basis for a future [...]]]></description>
			<content:encoded><![CDATA[<p>My most recent project, the <a href="http://gregsurges.com/circuitry/usb-octomod/">USB-Octomod</a>, uses <a href="http://www.processing.org/">Processing</a> to create an <a href="http://www.opensoundcontrol.org/">OpenSoundControl</a> (OSC) interface between any OSC-ready software and a hardware DAC device I built. I&#8217;m going to break down the connections between different pieces of software and hardware, in order to explain how the system works and to provide the basis for a future tutorial on how one might use the device.</p>
<p>You can read more about the Octomod <a href="http://gregsurges.com/circuitry/usb-octomod/">here</a>, but it essentially allows computer control over the analog control voltages commonly used in analog synthesizers. Input a number 0 &#8211; 1023, and the device will output an analog voltage from -5V to +5V.</p>
<p>The OSC interface presents the inputs to the device, in the form of 8 numbered channels. The user sends an OSC message from their software of choice, and the interface program receives, processes, and communicates the data to the microcontroller in the device. I used a <a href="http://www.pjrc.com/teensy/">Teensy 2.0</a>, which is very similar to Arduino, and any of this information should easily translate to the Arduino.</p>
<p><strong>The OSC Interface</strong></p>
<p>The OSC interface is simple. In your host program, you need to create a message formatted as follows:</p>
<p><code>/dac chanOne chanTwo chanThree chanFour chanFive chanSix chanSeven chanEight</code></p>
<p>For example:</p>
<p><code>/dac 256 273 50 1020 756 902 840 111</code></p>
<p>The trick here is that instead of sending an individual message whenever a channel changes, you can reduce network traffic by packaging all of the channels in one message, and updating that message at the rate of the most rapidly changing channel.</p>
<p><strong>Sending OSC from Max/MSP</strong></p>
<p>Here&#8217;s what it looks like in Max:</p>
<p><a href="http://gregsurges.com/wp-content/uploads/2010/08/Screen-shot-2010-08-25-at-8.55.57-AM.png" rel="lightbox[786]"><img class="aligncenter size-medium wp-image-794" title="Screen shot 2010-08-25 at 8.55.57 AM" src="http://gregsurges.com/wp-content/uploads/2010/08/Screen-shot-2010-08-25-at-8.55.57-AM-300x197.png" alt="Screen shot 2010-08-25 at 8.55.57 AM" width="300" height="197" /></a></p>
<p>What is this code doing?</p>
<ol>
<li>The <code>pak</code> object outputs all eight of its inputs as a list whenever any one of the inputs changes.</li>
<li>The message box below appends the <code>/dac</code> prefix to the list. Now the OSC message is formatted correctly.</li>
<li>We don&#8217;t want the message to send automatically whenever a channel updates, so we buffer it with the second message box. This is done by sending the first message to the right inlet of the second message box.</li>
<li>Finally, the <code>metro</code> object triggers the full OSC message to be sent once every 10ms.</li>
</ol>
<p>The OSC interface application is expecting data on port <code>9999</code>, and we&#8217;re going to be using the software locally, so we use the localhost address: <code>127.0.0.1</code>. The Max <code>udpsend</code> object takes those two numbers as arguments, and transmits the OSC message.</p>
<p><strong>Receiving OSC in Processing</strong></p>
<p>The OSC interface program is written in Processing. OSC is easy to use in Processing as well. With a couple of lines of code, we&#8217;re ready to go:</p>
<p><code></p>
<pre>import oscP5.*; // import the oscP5 library
import netP5.*; // the netP5 library is also required for the osc library
OscP5 oscP5;
oscP5 = new OscP5(this, 9999); // all you need to start oscp5 listening on port 9999</pre>
<p></code></p>
<p style="text-align: left;">Now all we have to do is tell our program what to do when an OSC message is received. This is done by defining the oscEvent function.</p>
<p style="text-align: left;">After parsing out each of the eight input numbers, we check if a given channel needs to update its state. If so, we pass it to the <code>writeValue()</code> function. If not, we ignore it and don&#8217;t have to waste processor time sending the redundant data over the serial port. In my experience, this allows update rates of up to (possibly beyond) 1ms.</p>
<p><code> </code></p>
<p><code></p>
<pre>void oscEvent(OscMessage theOscMessage){
 if(theOscMessage.checkAddrPattern("/dac")==true){
   for(int i = 0; i &lt; 8; i++){
     data[i] = theOscMessage.get(i).intValue();
     channelData[i] = data[i];
   }
   for(int i = 0; i &lt; 8; i++){
     writeValue(i, data[i]);
   }
 }
}</pre>
<p></code></p>
<p><strong>Writing Serial Data to the Teensy</strong></p>
<p><code> </code></p>
<p><code></p>
<pre>Serial teensy;
teensy = new Serial(this, Serial.list()[0], 19200);</pre>
<p></code></p>
<p>The above lines are used in Processing to initialize a <code>Serial</code> object, allowing both read and write operations. The <code>Serial.list()[0]</code> argument indicates which actual serial port we want to write to. On my system, the Teensy always shows up as port 0 &#8211; this might be different on yours. Finally, the baud rate of <code>19200</code> is specified. Baud rate is the number of distinct signal events per second, and is a measure of data transfer speed.</p>
<p>Below is our <code>writeValue()</code> function, which was referenced above. The function is called repeatedly, once for each new sample to be written. First, we have to choose which of our two DAC chips should receive the data. Channels 0 &#8211; 3 go to chip A, 4 &#8211; 7 to chip B.</p>
<p>The MAX5250 is expecting a two byte word, which is assembled in the next section of code.</p>
<p style="text-align: left;">The SPI data expected by the MAX5250 DAC is as follows:<br />
<a href="http://gregsurges.com/wp-content/uploads/2010/08/Screen-shot-2010-08-27-at-10.48.25-AM.png" rel="lightbox[786]"><img style="display: block; margin-left: auto; margin-right: auto; border: 0px initial initial;" title="Screen shot 2010-08-27 at 10.48.25 AM" src="http://gregsurges.com/wp-content/uploads/2010/08/Screen-shot-2010-08-27-at-10.48.25-AM.png" alt="Screen shot 2010-08-27 at 10.48.25 AM" width="487" height="145" /></a></p>
<p>The first two bits select which of the four-per-chip channels to use, the second two bits allow us to write data with or without updating the actual voltage outputs, the next 10 bits are the actual data to be assigned, and the last two bits are unused. So, to write a data value of <code>512</code> to channel 3 and immediately output a voltage, we would send <code>1011001110110100</code>.</p>
<p>As you can see, it&#8217;s a bit involved, and that&#8217;s why we want to avoid running all of this code unless the data has actually changed. We end up with three bytes to send to the Teensy 2.0, a one byte digit to indicate which DAC we want to write to, and the two additional SPI bytes. These are put into a buffer (really just an array) which is only transmitted when the buffer is full. This is to circumvent some timing weirdness in the USB to Serial conversion hardware.</p>
<p><code> </code></p>
<p><code></p>
<pre>void writeValue(int _channel, int _data){
 if(_channel &gt; 3) { // assign one of two dac chips to respond
    dacChip = 1;
  } else {
    dacChip = 0;
  }

  /* bit shifting and masking to assemble proper list of bits for the DAC */
  _channel = _channel &lt;&lt; 14;
  updateBits = 3 &lt;&lt; 12;
  _channel = _channel | updateBits;
  _data = _data &lt;&lt; 2;   spiWord = _channel | _data;
  binaryString = binary(spiWord, 16); // at this point, we've assembled our proper list of 16 bits
  outputData.add(byte(dacChip)); // so we'll throw them into an array, to facilitate transfer over serial
  outputData.add(byte(unbinary(binaryString.substring(0, 8))));
  outputData.add(byte(unbinary(binaryString.substring(8, 16))));
  if(outputData.size() &gt;= 24){
    outputBytes = new byte[outputData.size()];
    for(int i = 0; i &lt; outputData.size(); i++){
      outputBytes[i] = outputData.get(i);
    }
    teensy.write(outputBytes);
    dataIndex = 0;
    outputData = new ArrayList();
    previousUpdate = currentTime;
  }
}</pre>
<p></code></p>
<p><strong>Initializing SPI on the Teensy 2.0</strong></p>
<p>Here&#8217;s an explanation of SPI from Wikipedia:</p>
<p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; line-height: 1.5em;">The SPI bus specifies four logic signals.</p>
<ul style="line-height: 1.5em; list-style-type: square; margin-top: 0.3em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 1.5em; list-style-image: url(http://bits.wikimedia.org/skins-1.5/vector/images/bullet-icon.png?1); padding: 0px;">
<li style="margin-bottom: 0.1em;">SCLK — Serial Clock (output from master)</li>
<li style="margin-bottom: 0.1em;">MOSI/SIMO — Master Output, Slave Input (output from master)</li>
<li style="margin-bottom: 0.1em;">MISO/SOMI — Master Input, Slave Output (output from slave)</li>
<li style="margin-bottom: 0.1em;">SS — Slave Select (active low; output from master)</li>
</ul>
<p>Essentially, the Master (Teensy 2.0 here) triggers the Slave chip by setting the SS pin low. Then the SCLK pin outputs a periodic clock pulse while the MOSI pin transmits the data (holding the SS pin low for the entire transfer). Here&#8217;s an image of the transmission from the MAX5250 datasheet &#8211; note that they use DIN (Data In) instead of MOSI, but it&#8217;s the same thing.</p>
<p style="text-align: center;"><a href="http://gregsurges.com/wp-content/uploads/2010/08/Screen-shot-2010-08-27-at-10.24.55-AM1.png" rel="lightbox[786]"><img class="aligncenter size-full wp-image-829" title="Screen shot 2010-08-27 at 10.24.55 AM" src="http://gregsurges.com/wp-content/uploads/2010/08/Screen-shot-2010-08-27-at-10.24.55-AM1.png" alt="Screen shot 2010-08-27 at 10.24.55 AM" width="485" height="123" /></a></p>
<p>The first bit of code here is just a couple of statements to simplify our SPI communication. The DACs have a &#8220;Slave Select&#8221; pin, which allows them to either receive or ignore incoming data. This allows for easier wiring, you can connect all of the SPI lines to each chip, and just select which chip should respond at a given moment. Our DAC select byte (from above, in the writeValue() function) interfaces with the Slave Select code on the Teensy, and allows us to route data to the appropriate chip.Below, in the setup() function, we set the SS pins to output and set them both HIGH, so that no data is accidentally received by the DACs.</p>
<p>Finally, we call the <code>setup_spi()</code> function, found in Andrew Smallbone&#8217;s SPI library. These settings define how the Teensy should handle SPI, whether the DACs read the data on the rising or falling edge of the clock pulse, the SPI transmission rate as related to the Teensy clock, and a couple of other settings. You might notice that the serial interface is being initialized with a baud rate of <code>9600</code>. The Teensy 2.0 actually ignores any baud rate argument and runs at full USB 2.0 speed.</p>
<p><code> </code></p>
<p><code></p>
<pre>&#35;define SELECT&#95;DAC&#95;ONE digitalWrite(PORTB0, LOW);
&#35;define DESELECT&#95;DAC&#95;ONE digitalWrite(PORTB0, HIGH);
&#35;define SELECT&#95;DAC&#95;TWO digitalWrite(PORTD0, LOW);
&#35;define DESELECT&#95;DAC&#95;TWO digitalWrite(PORTD0, HIGH);

void setup(){
  CPU_PRESCALE(CPU&#95;4MHz);
  pinMode(PORTB0, OUTPUT);
  pinMode(PORTD0, OUTPUT);
  Serial.begin(9600);
  DESELECT&#95;DAC&#95;ONE;
  DESELECT&#95;DAC&#95;TWO;
  setup_spi(SPI&#95;MODE&#95;0, SPI&#95;MSB, SPI&#95;NO&#95;INTERRUPT, SPI&#95;MSTR&#95;CLK2);
}</pre>
<p></code></p>
<p style="text-align: left;">The last bit of code here reads incoming serial data, and immediately sends it out to the proper DAC. The serial buffering on the Teensy is a little bit different than the Arduino, in that it receives an entire USB packet at a time. The timing of the calls to <code>Serial.read()</code> can then be an issue. We want to make sure that we&#8217;re reading our three bytes in the proper order, and not getting out of phase with the host app, so we check that our first byte is either a 1 or a 0. Since the SPI interface packs data into the first and last bits of our data word (the second two bytes), a byte with the value of 1 or 0 will only appear as the first byte in the series. Timing is also important here, we need to introduce some brief delays so that we&#8217;re not reading or writing data too quickly.</p>
<pre><code>void loop(){
  pollAndWrite();
}

void pollAndWrite(){
 data = false;
 while(!data){
  if(Serial.available()) { // look into the receive buffering - not receiving from Max properly
    firstByte = Serial.read();
    delayMicroseconds(100);
    if(firstByte == B00000000) {
      secondByte = Serial.read();
      delayMicroseconds(100);
      thirdByte = Serial.read();
      SELECT_DAC_ONE;
      send_spi(secondByte);
      send_spi(thirdByte);
      delayMicroseconds(10);
      DESELECT_DAC_ONE;
      data = true;
    }
      if(firstByte == B00000001){
        secondByte = Serial.read();
        delayMicroseconds(100);
        thirdByte = Serial.read();
        SELECT_DAC_TWO;
        send_spi(secondByte);
        send_spi(thirdByte);
        delayMicroseconds(10);
        DESELECT_DAC_TWO;
        data = true;
    }
  }
 }
}</code></pre>
<p>So that&#8217;s the software side of the USB-Octomod. Although it&#8217;s fairly involved, there are only a few tricky spots, and the OSC interface greatly simplifies what the end-user actually has to think about during composition or performance.  Once the Processing and Teeny code is compiled and loaded, it becomes a plug-and-play device.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregsurges.com/programming/osc-processing-microcontroller-connect-maxmsp-dac-ic/feed/</wfw:commentRss>
		<slash:comments>589</slash:comments>
		</item>
	</channel>
</rss>

