<?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>Hive76 &#187; MSP430</title>
	<atom:link href="http://www.hive76.org/category/msp430/feed" rel="self" type="application/rss+xml" />
	<link>http://www.hive76.org</link>
	<description>Making Things Awesome, Making Awesome Things</description>
	<lastBuildDate>Fri, 10 May 2013 13:53:18 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Giving the Gift of Making</title>
		<link>http://www.hive76.org/giving-the-gift-of-making</link>
		<comments>http://www.hive76.org/giving-the-gift-of-making#comments</comments>
		<pubDate>Fri, 21 Dec 2012 21:43:49 +0000</pubDate>
		<dc:creator>Sean McBeth</dc:creator>
				<category><![CDATA[Cool Projects]]></category>
		<category><![CDATA[MSP430]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.hive76.org/?p=4297</guid>
		<description><![CDATA[This year I wanted to do something a little different for Christmas gifts. Instead of just getting people electronics or video games or clothes, I wanted to give something that encouraged creativity and making. A lot of people never even think to try to make things on their own, so maybe a little hobby-style gift [...]]]></description>
				<content:encoded><![CDATA[<p>This year I wanted to do something a little different for Christmas gifts. Instead of just getting people electronics or video games or clothes, I wanted to give something that encouraged creativity and making. A lot of people never even think to try to make things on their own, so maybe a little hobby-style gift will give them a taste and spark an interest.</p>
<div id="attachment_4300" class="wp-caption alignright" style="width: 306px"><a href="https://estore.ti.com/MSP-EXP430G2-MSP430-LaunchPad-Value-Line-Development-kit-P2031.aspx"><img class="size-full wp-image-4300" title="msp430" src="http://www.hive76.org/wp-content/uploads/2012/12/msp430.jpg" alt="" width="296" height="170" /></a><p class="wp-caption-text">Texas Instruments MSP430 LaunchPad.</p></div>
<p>To that end, I did two things. First, I bought ten MSP430 LaunchPads. <a href="https://estore.ti.com/MSP-EXP430G2-MSP430-LaunchPad-Value-Line-Development-kit-P2031.aspx">These things are really inexpensive</a>, so they make great stocking-stuffers. If you don&#8217;t know what the MSP430 is already (really, we talk about it constantly, where have you been), it&#8217;s a 16-bit microcontroller with really low-power consumption needs. They run on 1.8 to 3.6v power supplies at up to 16MHz, making them quite a powerful little beast for only $4.30, which includes the chip programmer. If you were to buy the chips alone, they cost about $0.50 each, with a few different serial communication protocols built in, and requiring only a small selection of external parts (2 resistors and 2 caps if you want to do it right, 1 resistor if you&#8217;re living dangerously, and face it, at $0.50, you can afford to live dangerously). It&#8217;s something of a long-term project plan of mine to buy 100 of these and try to build a small, physical neural network computer.</p>
<p>A lot of people have shied away from the MSP430 because the <a href="http://www.ti.com/tool/ccstudio">Code Composer Studio</a> software&#8211;based on the professional-grade <a href="http://www.eclipse.org/">Eclipse</a> development environment&#8211;is very difficult to use in comparison to the <a href="http://www.processing.org">Processing</a>-based software typically used to program <a href="http://www.arduino.cc">Arduinos</a>. But luckily, someone has taken the Arduino cue and created <a href="https://github.com/energia/Energia">Energia</a>, a Processing-based editor for use with TI&#8217;s LaunchPad line of MCUs! If you&#8217;re experienced with Arduino, using Energia is a snap, and if you&#8217;re not experienced at all, it&#8217;s really not that big of a learning curve.</p>
<div class="wp-caption alignright" style="width: 310px"><img src="http://ecx.images-amazon.com/images/I/419MyNmmi2L._SL500_AA300_.jpg" alt="" width="300" height="300" /><p class="wp-caption-text">I prefer to call it Serious Putty</p></div>
<p>Second, I bought supplies to make &#8220;magnetic Silly Putty&#8221;. About a week ago, I saw <a href="http://www.instructables.com/id/magnetic-silly-putty/">this Instructable</a> about kneading some Iron-Oxide powder into a little Silly Putty and jumped on Amazon right away to get a <a href="http://www.amazon.com/Toysmith-Original-Silly-Putty-104-48/dp/B003UYTMNE/ref=sr_1_2?s=toys-and-games&amp;ie=UTF8&amp;qid=1356124123&amp;sr=1-2&amp;keywords=silly+putty">6-pack of Silly Putty egg</a>s and a <a href="http://www.amazon.com/gp/product/B004KICAVU/ref=oh_details_o07_s00_i00">5 lbs bag of black Iron-Oxide pigment</a>. Honstely, 5-lbs is way too much, but there are plenty of other things you can do with it, like <a href="http://www.hive76.org/open-house-for-831">make ferrofluids</a> or <a href="http://www.hive76.org/making-paint">your own paint</a>, so it&#8217;s handy to have around. You will need <a href="http://www.amazon.com/Rare-Earth-Neodymium-Magnet-thick-Approx/dp/B002JWR4BK/ref=sr_1_13?s=toys-and-games&amp;ie=UTF8&amp;qid=1356125774&amp;sr=1-13&amp;keywords=neodymium+magnets">a fairly strong neodymium magnet</a>, but again, these things are fun enough to have around anyway, so have at it!</p>
<p>Making the putty is really easy. I pooled all 6 eggs of putty together in a non-stick pan. On very low heat, I warmed up the putty until it was just too hot to handle with my bare hands. If it starts to become the consistency of chewing gum and sticks to the pan, don&#8217;t worry, it will unstick when it cools down. Don&#8217;t heat it further than that though, it will start to smoke and burn. Wearing rubber gloves to give me just enough insulation from the heat and to keep my hands from getting stained black, it&#8217;s just a matter of working a large, heaping tablespoon-full of the black powder into the putty. You will need to work the putty like taffy, stretching it and folding it to blend the powder evenly into it. Once the powder is sufficiently kneaded in to the putty, it will not stain anything, so keep testing it on the back of your rubber glove to see if it leaves any marks. I then cut the putty into 6 equal chunks and shoved them back in their eggs. It took 10 minutes total. I thought about taking some photos of the process to show it off, but really, it could not be simpler.</p>
<p>I&#8217;m hoping these gifts will be completely unexpected and will inspire people to try something they never would have considered on their own. The MSP430s are just a really easy, cheap, fun way to get into programming, and the magnetic Silly Putty is a great example of something you can&#8217;t buy as a product that is also extremely easy to make.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hive76.org/giving-the-gift-of-making/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Philly Tech Week &#8211; We&#8217;re Booked Solid</title>
		<link>http://www.hive76.org/philly-tech-week-were-booked-solid</link>
		<comments>http://www.hive76.org/philly-tech-week-were-booked-solid#comments</comments>
		<pubDate>Tue, 24 Apr 2012 13:58:50 +0000</pubDate>
		<dc:creator>Jim Fisher</dc:creator>
				<category><![CDATA[3D Printing]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[artists]]></category>
		<category><![CDATA[Classes]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Hackers]]></category>
		<category><![CDATA[Hackerspaces]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[MSP430]]></category>
		<category><![CDATA[Philadelphia]]></category>
		<category><![CDATA[physical computing]]></category>

		<guid isPermaLink="false">http://www.hive76.org/?p=3564</guid>
		<description><![CDATA[Monday &#8211; MMMM  Microcontroller Madness Tuesday &#8211; DIY Music Night Wednesday &#8211; Open House Thursday &#8211; Game Night Featuring Tetris Arm Wrestling Tournament Friday &#8211; PTW Gala demonstration (offsite) Events at Hive76 Monday through Thursday start at 7pm and  ARE OPEN TO THE PUBLIC. Friday Gala Ticketing information available here.]]></description>
				<content:encoded><![CDATA[<p><strong>Monday &#8211; </strong>MMMM  Microcontroller Madness</p>
<p><strong>Tuesday &#8211; </strong>DIY Music Night</p>
<p><strong>Wednesday &#8211; </strong>Open House</p>
<p><strong>Thursday &#8211; </strong>Game Night Featuring Tetris Arm Wrestling Tournament</p>
<p><strong>Friday &#8211; </strong>PTW Gala demonstration (offsite)</p>
<p style="text-align: center"><strong>Events at Hive76 Monday through Thursday start at 7pm and </strong></p>
<p style="text-align: center"><strong>ARE OPEN TO THE PUBLIC.</strong></p>
<p>Friday Gala Ticketing information available<a title="PTW Gala Ticket info" href="http://tp.ticketleap.com/ptwsig/"> here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hive76.org/philly-tech-week-were-booked-solid/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crafty Computer &#8230;</title>
		<link>http://www.hive76.org/crafty-computer</link>
		<comments>http://www.hive76.org/crafty-computer#comments</comments>
		<pubDate>Mon, 13 Feb 2012 03:50:14 +0000</pubDate>
		<dc:creator>pez</dc:creator>
				<category><![CDATA[artists]]></category>
		<category><![CDATA[MSP430]]></category>
		<category><![CDATA[physical computing]]></category>
		<category><![CDATA[high-low-tech]]></category>

		<guid isPermaLink="false">http://www.hive76.org/?p=3335</guid>
		<description><![CDATA[After visiting The Hacktory&#8217;s &#8220;Soft Circuit&#8221; event, PJ and I were inspired to take a stab at making some micro-controller circuits using alternative, &#8220;high/low tech&#8221; approaches.  PJ made an MCU circuit using conductive paint (has potential, but needs some tweaks).  I opted to try a circuit board using metal leaf.  That happened to work on [...]]]></description>
				<content:encoded><![CDATA[<div id="attachment_3336" class="wp-caption alignleft" style="width: 310px"><a href="http://www.hive76.org/wp-content/uploads/2012/02/IMG_20120211_211619.jpg"><img class="size-medium wp-image-3336" title="IMG_20120211_211619" src="http://www.hive76.org/wp-content/uploads/2012/02/IMG_20120211_211619-300x225.jpg" alt="" width="300" height="225" /></a><p class="wp-caption-text">Back-lit view of paper and foil micro-controller board</p></div>
<p>After visiting The Hacktory&#8217;s &#8220;<a href="http://www.thehacktory.org/?p=1974">Soft Circuit</a>&#8221; event, PJ and I were inspired to take a stab at making some micro-controller circuits using alternative, &#8220;high/low tech&#8221; approaches.  PJ made an MCU circuit using conductive paint (has potential, but needs some tweaks).  I opted to try a circuit board using metal leaf.  <strong><em>That</em></strong> happened to work on the first shot &#8212; although careful scrutiny of the picture on the left suggests there was some luck involved (there are holes in the circuit that come dangerously close to wrecking it).<span id="more-3335"></span></p>
<div id="attachment_3388" class="wp-caption alignleft" style="width: 310px"><a href="http://www.hive76.org/wp-content/uploads/2012/02/IMG_20120211_211540.jpg"><img class="size-medium wp-image-3388" title="Paper and foil MCU board, fresh off the bench" src="http://www.hive76.org/wp-content/uploads/2012/02/IMG_20120211_211540-300x225.jpg" alt="" width="300" height="225" /></a><p class="wp-caption-text">Looks good from this angle and all the connections check -- you&#39;d never guess it was hanging by a thread ...</p></div>
<p>I had considered using scored foil as a way to make free-hand, one-off circuit boards for quite some time &#8212; but until recently, I never had the mix of free time and raw nerve to actually try it.  It turns out that my reservations were probably well-founded, but it also happens that the technique is workable, and the results are actually aesthetically interesting.</p>
<p>We decided to make the board in a hexagonal shape (Hive76 &#8212; hexagon &#8212; get it?). First, we prepped circuit board material by spraying adhesive on card-stock and then sticking the faux gold-leaf on the prepared surface (this sounds simple, but the foil is maddening stuff, so the process involved profanity and a certain amount of despair).  Then we cut the foiled card-stock into hexagons. After that, we cut out a rectangle where the IC was going to go, so that there were no conductive paths under the chip.  Once the board was roughly prepped, we made a &#8220;squashed bug&#8221; of the IC , splayed its pins out, and soldered it to the gilded surface.  Using the gaps between the pins as a guide for an exacto knife, we cut free-hand traces that routed the pins of the chip to large zones on the edge of the hexagon (I was a little surprised that the cuts were free of bridges). Finally, we soldered a capacitor between the MCU&#8217;s Vcc and ground and soldered a 47k resistor between Vcc and the MCU&#8217;s reset line.  At that point, we had a working circuit that was in-system programmable &#8212; at least in theory.</p>
<p><a href="http://www.hive76.org/wp-content/uploads/2012/02/IMG_20120211_214100.jpg"><img class="alignleft size-medium wp-image-3340" title="IMG_20120211_214100" src="http://www.hive76.org/wp-content/uploads/2012/02/IMG_20120211_214100-300x225.jpg" alt="" width="300" height="225" /></a>Unfortunately, I had no idea how we might program the MCU or hook it up to external circuitry without damaging the fragile structure.  PJ came up with the idea that made it all workable &#8230; magnets.  All really good magic is done with magnets.  The idea here was to place the paper computer on a steel surface, which allowed us to stick magnets wherever we wanted to make a connection.  With steel under the circuit, the down-force of the magnets gave us firm-but-gentle electrical contact with the delicate foil. Once the magnets were in place, we only needed to touch alligator clips to them &#8212; since the clips were steel, they stuck happily. With the clips secured to selected points on the MCU, we were free to connect the opposite ends of the clips to the various external items needed for the circuit.  Note the ingenious use of paper-clips.  PJ again &#8212; see a pattern here?</p>
<p>Our first connection was power (two magnet connections, one for +3.6 volts, the other for ground).  Then we hooked up the<a href="http://en.wikipedia.org/wiki/Spy-Bi-Wire"> Spy-bi-wire</a> programming interface (two wires, two more magnets).  After that, we wrote the obligatory &#8220;blink LED&#8221; program and loaded it into the paper computer.  Naturally, we wanted to see the results &#8212; two more connections for the LED terminals and &#8212; Voila!  Here&#8217;s the movie &#8230;</p>
<p><iframe width="500" height="375" src="http://www.youtube.com/embed/QFBg8Wii8r0?feature=oembed" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hive76.org/crafty-computer/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Monthly Monday Microcontroller Madness: Motors!</title>
		<link>http://www.hive76.org/monthly-monday-microcontroller-madness-motors</link>
		<comments>http://www.hive76.org/monthly-monday-microcontroller-madness-motors#comments</comments>
		<pubDate>Fri, 09 Sep 2011 16:47:26 +0000</pubDate>
		<dc:creator>pez</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[artists]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[kinetic art]]></category>
		<category><![CDATA[MSP430]]></category>
		<category><![CDATA[Study Groups]]></category>

		<guid isPermaLink="false">http://www.hive76.org/?p=2738</guid>
		<description><![CDATA[After speaking to a few folks that expressed an interest in the MMMM workshop, it became apparent (a) most folks were newbs who want to learn the basics and (b) everyone wants to control motors.  Excellent!  We&#8217;ll do that. Although motor control is potentially a vast and complex topic, with highly specialized branches, the basics [...]]]></description>
				<content:encoded><![CDATA[<p><iframe width="420" height="345" src="http://www.youtube.com/embed/XQgIEHk7aqo" frameborder="0" allowfullscreen></iframe><br />
After speaking to a few folks that expressed an interest in the MMMM workshop, it became apparent (a) most folks were newbs who want to learn the basics and (b) everyone wants to control motors.  Excellent!  We&#8217;ll do that.</p>
<p>Although motor control is potentially a vast and complex topic, with highly specialized branches, the basics are fairly easy to learn &#8212; and they&#8217;ll take you pretty far.   So &#8230; we&#8217;ll be prepared to present the following items:</p>
<ul>
<li>DC motors</li>
<li>H-bridge circuits &#8212; these let puny microcontrollers run fairly powerful motors</li>
<li>Stepper motors &#8212; just a little more complex to program than DC motors and they use H-bridge circuits too</li>
<li>Quadrature Encoders &#8212; these are a  simple and accurate way to read the position of something</li>
</ul>
<p>We&#8217;ll also try to discuss some organizational items &#8212; like the logistics of future workshops and the use of the MMMM GitHub, so that we can build up assets collectively, share them with the world and manage changes and contributions in a free-and-easy-but-organized way.</p>
<p>If you are coming , please bring:</p>
<ul>
<li>Yourself &#8212; If you&#8217;re a newb, welcome &#8212; If you&#8217;re an MCU Yoda, then attend you must and wisdom to newbs impart</li>
<li>Some ideas</li>
<li>A laptop if you have one</li>
<ul>
<li>You may want to install VMWare Player or VMWare Fusion before you arrive</li>
</ul>
<li>An MCU development kit if you have one or &#8230;</li>
<li>Some money if you don&#8217;t.  We&#8217;ll have some development kits that you can buy.  Plan on at least $10 for the kits and some parts that you can use for small learning projects.</li>
<li>A bread-board if you want to build some live circuits to keep.  We&#8217;ll have breadboards to loan, but if you want to take one home, it has to be one that arrived with you.</li>
</ul>
<p>That&#8217;s about it &#8212; see you all Monday.  To whet your appetite, there is some prototype code below for reading a quadrature encoded position detector (not really elegant enough for a final effort, but it&#8217;s a start).  We&#8217;ll have you writing stuff like this in no-time.</p>
<p><span id="more-2738"></span></p>
<p>This code is part of an effort to turn salvaged InkJet printers into motion controllers.  Most of these positioners let you position an InkJet head to within 1/600 inch &#8212; they&#8217;re fast, accurate, compact, surprisingly strong &#8230; and dirt-cheap.</p>
<pre>#include  <span style="color: blue; font-size: xx-small;">&lt;</span>msp430x20x2.h<span style="color: blue; font-size: xx-small;">&gt;</span>

#define LED0 BIT0
#define LED1 BIT6
#define PHASE1 BIT1
#define PHASE2 BIT2
#define PHASE_MASK <span style="color: brown;">6</span>
#define PHASE_SHIFT <span style="color: brown;">1</span>

<span style="color: red;"><strong>int</strong></span> state<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>     <span style="color: green;"><em>// used to hold current state of encoder bits (00, 01, 10 or 11) </em></span><span style="color: red;"><strong>
int</strong></span> lastState<span style="color: blue; font-size: xx-small;"><strong>;</strong></span><span style="color: green;"><em> // used to hold previous state of encoder bits (00, 01, 10 or 11) 
</em></span><span style="color: red;"><strong>int</strong></span> pos<span style="color: blue; font-size: xx-small;"><strong>;</strong></span> <span style="color: green;"><em> // used to count steps. A 1/150" encoder (the most common kind) yields 600 steps per inck. </em></span>

<span style="color: green;"><em>// -- prototype of common bit of code used to compute the present state value </em></span><span style="color: red;"><strong>
void</strong></span> updateState<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: red;"><strong>void</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>

<span style="color: red;"><strong>int</strong></span> main<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: red;"><strong>void</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span>
<span style="color: blue; font-size: xx-small;"><strong>{</strong></span>
	WDTCTL <span style="color: blue; font-size: xx-small;">=</span> WDTPW <span style="color: blue; font-size: xx-small;">+</span> WDTHOLD<span style="color: blue; font-size: xx-small;"><strong>;</strong></span> <span style="color: green;"><em>// Stop watchdog timer </em></span>
	<span style="color: green;"><em>// --- set up some initial values </em></span>	
        pos <span style="color: blue; font-size: xx-small;">=</span> <span style="color: brown;">0</span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
	P1DIR <span style="color: blue; font-size: xx-small;">&amp;</span><span style="color: blue; font-size: xx-small;">=</span> <span style="color: blue; font-size: xx-small;">~</span><span style="color: blue; font-size: xx-small;"><strong>(</strong></span>PHASE1 <span style="color: blue; font-size: xx-small;">+</span> PHASE2<span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span> <span style="color: green;"><em>// Set P1.1 and P1.2 as inputs </em></span>	
        P1DIR <span style="color: blue; font-size: xx-small;">|</span><span style="color: blue; font-size: xx-small;">=</span> <span style="color: blue; font-size: xx-small;"><strong>(</strong></span>LED0 <span style="color: blue; font-size: xx-small;">+</span> LED1<span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span> <span style="color: green;"><em>// Set P1.0 and P1.6 to outputs. These are the LEDs on a LaunchPad. 

</em></span>	<span style="color: green;"><em>// --- get initial conditions so that the first interrupt </em></span>	<span style="color: green;"><em>
 // has the right "edge" values and so that position calculations are based on feasible transitions </em></span>	
        updateState<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
	lastState <span style="color: blue; font-size: xx-small;">=</span> state<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>

	P1IFG <span style="color: blue; font-size: xx-small;">&amp;</span><span style="color: blue; font-size: xx-small;">=</span> <span style="color: blue; font-size: xx-small;">~</span><span style="color: blue; font-size: xx-small;"><strong>(</strong></span>PHASE1 <span style="color: blue; font-size: xx-small;">|</span> PHASE2<span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span> <span style="color: green;"><em>// clear interrupt flags for P1.1 and P1.2 </em></span>	
        P1IE <span style="color: blue; font-size: xx-small;">|</span><span style="color: blue; font-size: xx-small;">=</span> <span style="color: blue; font-size: xx-small;"><strong>(</strong></span>PHASE1 <span style="color: blue; font-size: xx-small;">|</span> PHASE2<span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span> <span style="color: green;"><em>// P1.1 and P1.2 interrupt enabled </em></span>
	__enable_interrupt<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span> <span style="color: green;"><em>// enable all interrupts </em></span>	<span style="color: red;"><strong>
 for</strong></span><span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span>
	<span style="color: blue; font-size: xx-small;"><strong>{</strong></span> <span style="color: green;"><em>/* just loop forever and let the interrupts do all the work */</em></span> <span style="color: blue; font-size: xx-small;"><strong>}</strong></span>
<span style="color: blue; font-size: xx-small;"><strong>}</strong></span>

<span style="color: green;"><em>// updateState() calculates updates for the edge detectors used in the interrupts </em></span><span style="color: green;"><em>
// and also updates the "lastState" variable 
</em></span><span style="color: red;"><strong>void</strong></span> updateState<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: red;"><strong>void</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>{</strong></span>
	state <span style="color: blue; font-size: xx-small;">=</span> P1IN <span style="color: blue; font-size: xx-small;">&amp;</span> PHASE_MASK<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>

	<span style="color: red;"><strong>if</strong></span> <span style="color: blue; font-size: xx-small;"><strong>(</strong></span>state <span style="color: blue; font-size: xx-small;">&amp;</span> PHASE1<span style="color: blue; font-size: xx-small;"><strong>)</strong></span>
		P1IES <span style="color: blue; font-size: xx-small;">|</span><span style="color: blue; font-size: xx-small;">=</span> PHASE1<span style="color: blue; font-size: xx-small;"><strong>;</strong></span> <span style="color: green;"><em>// PHASE1 high, then interrupt on falling edge </em></span>	
        <span style="color: red;"><strong>else</strong></span>
		P1IES <span style="color: blue; font-size: xx-small;">&amp;</span><span style="color: blue; font-size: xx-small;">=</span> <span style="color: blue; font-size: xx-small;">~</span>PHASE1<span style="color: blue; font-size: xx-small;"><strong>;</strong></span> <span style="color: green;"><em>// PHASE1 low, then interrupt on rising edge </em></span>
	<span style="color: red;"><strong>if</strong></span> <span style="color: blue; font-size: xx-small;"><strong>(</strong></span>state <span style="color: blue; font-size: xx-small;">&amp;</span> PHASE2<span style="color: blue; font-size: xx-small;"><strong>)</strong></span>
		P1IES <span style="color: blue; font-size: xx-small;">|</span><span style="color: blue; font-size: xx-small;">=</span> PHASE2<span style="color: blue; font-size: xx-small;"><strong>;</strong></span> <span style="color: green;"><em>// PHASE2 high, then interrupt on falling edge </em></span>	
        <span style="color: red;"><strong>else</strong></span>
		P1IES <span style="color: blue; font-size: xx-small;">&amp;</span><span style="color: blue; font-size: xx-small;">=</span> <span style="color: blue; font-size: xx-small;">~</span>PHASE2<span style="color: blue; font-size: xx-small;"><strong>;</strong></span> <span style="color: green;"><em>// PHASE2 low, then interrupt on rising edge </em></span>

	<span style="color: green;"><em>// ---"right-justify" state so that it is in the range 0..3</em></span>	
       state <span style="color: blue; font-size: xx-small;">=</span>  <span style="color: blue; font-size: xx-small;"><strong>(</strong></span>state <span style="color: blue; font-size: xx-small;">&gt;</span><span style="color: blue; font-size: xx-small;">&gt;</span> PHASE_SHIFT<span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
<span style="color: blue; font-size: xx-small;"><strong>}</strong></span>

<span style="color: green;"><em>// Port 1 interrupt service routine </em></span>#pragma vector<span style="color: blue; font-size: xx-small;">=</span>PORT1_VECTOR
__interrupt <span style="color: red;"><strong>void</strong></span> Port_1<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: red;"><strong>void</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span>
<span style="color: blue; font-size: xx-small;"><strong>{</strong></span>
    updateState<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>

    <span style="color: green;"><em>// --- test for all clockwise incremental cases </em></span>    <span style="color: green;"><em> 
 // if we stepped clockwise, then increment the position </em></span>    
    <span style="color: red;"><strong>if</strong></span> <span style="color: blue; font-size: xx-small;"><strong>(</strong></span> <span style="color: blue; font-size: xx-small;"><strong>(</strong></span>lastState <span style="color: blue; font-size: xx-small;">=</span><span style="color: blue; font-size: xx-small;">=</span> <span style="color: brown;">0</span> <span style="color: blue; font-size: xx-small;">&amp;</span> state <span style="color: blue; font-size: xx-small;">=</span><span style="color: blue; font-size: xx-small;">=</span> <span style="color: brown;">2</span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span>
       <span style="color: blue; font-size: xx-small;"><span style="color: blue; font-size: xx-small;">|</span><span style="color: blue; font-size: xx-small;">|</span></span><span style="color: blue; font-size: xx-small;"><strong>(</strong></span>lastState <span style="color: blue; font-size: xx-small;">=</span><span style="color: blue; font-size: xx-small;">=</span> <span style="color: brown;">2</span> <span style="color: blue; font-size: xx-small;">&amp;</span> state <span style="color: blue; font-size: xx-small;">=</span><span style="color: blue; font-size: xx-small;">=</span> <span style="color: brown;">3</span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span>
       <span style="color: blue; font-size: xx-small;"><span style="color: blue; font-size: xx-small;">|</span><span style="color: blue; font-size: xx-small;">|</span></span><span style="color: blue; font-size: xx-small;"><strong>(</strong></span>lastState <span style="color: blue; font-size: xx-small;">=</span><span style="color: blue; font-size: xx-small;">=</span> <span style="color: brown;">3</span> <span style="color: blue; font-size: xx-small;">&amp;</span> state <span style="color: blue; font-size: xx-small;">=</span><span style="color: blue; font-size: xx-small;">=</span> <span style="color: brown;">1</span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span>
       <span style="color: blue; font-size: xx-small;"><span style="color: blue; font-size: xx-small;">|</span><span style="color: blue; font-size: xx-small;">|</span></span><span style="color: blue; font-size: xx-small;"><strong>(</strong></span>lastState <span style="color: blue; font-size: xx-small;">=</span><span style="color: blue; font-size: xx-small;">=</span> <span style="color: brown;">1</span> <span style="color: blue; font-size: xx-small;">&amp;</span> state <span style="color: blue; font-size: xx-small;">=</span><span style="color: blue; font-size: xx-small;">=</span> <span style="color: brown;">0</span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>{</strong></span>
         pos<span style="color: blue; font-size: xx-small;"><span style="color: blue; font-size: xx-small;">+</span><span style="color: blue; font-size: xx-small;">+</span></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
    <span style="color: blue; font-size: xx-small;"><strong>}</strong></span>
    <span style="color: green;"><em>// --- If we didn't move clockwise, then we must have moved counter-clockwise </em></span>    <span style="color: green;"><em>
 // so decrement the position </em></span>    
    <span style="color: red;"><strong>else</strong></span><span style="color: blue; font-size: xx-small;"><strong>{</strong></span>
        pos<span style="color: blue; font-size: xx-small;"><span style="color: blue; font-size: xx-small;">-</span><span style="color: blue; font-size: xx-small;">-</span></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
    <span style="color: blue; font-size: xx-small;"><strong>}</strong></span>

    <span style="color: green;"><em>// --- record last state </em></span>    
    lastState <span style="color: blue; font-size: xx-small;">=</span> state<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>

    <span style="color: green;"><em>// --- update LEDs just to help debug </em></span>    
    <span style="color: green;"><em>// use "state" as intermediate variable so that we can see the output value in the debugger easily </em></span>    
    <span style="color: green;"><em>// This is just so that we can see the encoder signal. No functional purpose. </em></span>    
    state <span style="color: blue; font-size: xx-small;">=</span> state <span style="color: blue; font-size: xx-small;">+</span> <span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: blue; font-size: xx-small;"><strong>(</strong></span>state <span style="color: blue; font-size: xx-small;">&lt;</span><span style="color: blue; font-size: xx-small;">&lt;</span> <span style="color: brown;">5</span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span> <span style="color: blue; font-size: xx-small;">&amp;</span> <span style="color: pink;">0x40</span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
    P1OUT <span style="color: blue; font-size: xx-small;">=</span> state<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>

    <span style="color: green;"><em>// --- clear the interrupt flags </em></span>    
    P1IFG <span style="color: blue; font-size: xx-small;">&amp;</span><span style="color: blue; font-size: xx-small;">=</span> <span style="color: blue; font-size: xx-small;">~</span><span style="color: blue; font-size: xx-small;"><strong>(</strong></span>PHASE1 <span style="color: blue; font-size: xx-small;">|</span> PHASE2<span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span> <span style="color: green;"><em>// clear interrupt flags for P1.1 and P1.2 </em></span><span style="color: blue; font-size: xx-small;"><strong> 
}</strong></span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.hive76.org/monthly-monday-microcontroller-madness-motors/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>TIWrap makes your LaunchPad steak house handle like an Arduino bistro</title>
		<link>http://www.hive76.org/tiwrap-makes-your-launchpad-steak-house-handle-like-an-arduino-bistro</link>
		<comments>http://www.hive76.org/tiwrap-makes-your-launchpad-steak-house-handle-like-an-arduino-bistro#comments</comments>
		<pubDate>Sun, 13 Mar 2011 03:49:48 +0000</pubDate>
		<dc:creator>pez</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[MSP430]]></category>
		<category><![CDATA[physical computing]]></category>
		<category><![CDATA[TIWrap]]></category>

		<guid isPermaLink="false">http://www.hive76.org/?p=2137</guid>
		<description><![CDATA[We whipped up a Wiring-ish wrapper for the MSP430 a while back in order to simplify the task of porting Arduino libraries for use with MSP430 microcontrollers.  It turns out, we weren&#8217;t the only ones that thought of it.  PJ spotted a post on Hack A Day where someone unveiled something remarkably similar, and that [...]]]></description>
				<content:encoded><![CDATA[<p><iframe width="500" height="375" src="http://www.youtube.com/embed/sTIb7mSWCHk?feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p>We whipped up a Wiring-ish wrapper for the MSP430 a while back in order to simplify the task of porting Arduino libraries for use with MSP430 microcontrollers.  It turns out, <a href="http://hackaday.com/2011/03/09/header-file-brings-arduino-sketches-to-the-ti-launchpad/?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed%3A+hackaday%2FLgoM+%28Hack+a+Day%29" target="_blank">we weren&#8217;t the only ones that thought of it</a>.  PJ spotted a post on Hack A Day where someone unveiled something remarkably similar, and that post resulted in at least two other folks besides us posting <em>their </em>similar ideas &#8212; so there are at least four of these wrapper libraries out there.</p>
<p>Naturally, we&#8217;d like to think that ours is the best of the bunch, and the best named too &#8212; <strong><em>TIWrap</em></strong>.  Seriously, though, we seem to be genuinely different in that that we have bundled in actual libraries ported from Arduino, such as the <a href="http://en.wikipedia.org/wiki/HD44780_Character_LCD" target="_blank">HD44780</a> and <a href="http://www.maxim-ic.com/datasheet/index.mvp/id/1339" target="_blank">MAX7221</a> libraries.  There are some piezo buzzer libraries and we expect to add some Charlieplexing utilities soon.  You can get a copy of TiWrap <a href="http://bigvulcandeal.com/msp430/sample_code/TiWrap_demos.zip" target="_blank">here</a>.</p>
<p>The demo above is a &#8220;Fancy Flashlight&#8221; concept proposed by Matt Torbin.   It&#8217;s just one MSP430, two LEDs, a button and a bit of code which you can find in the TiWrap examples.</p>
<p><a href="http://boards.ign.com/futurama/b7920/66839899/p1/">And in case the title left you puzzled &#8230;</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hive76.org/tiwrap-makes-your-launchpad-steak-house-handle-like-an-arduino-bistro/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
