<?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>Your Warranty Is Void.com &#187; Microcontrollers</title>
	<atom:link href="http://www.yourwarrantyisvoid.com/category/microcontrollers/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.yourwarrantyisvoid.com</link>
	<description>Linux, Hardware, Software and Chaos. What more is there?</description>
	<lastBuildDate>Wed, 18 Jan 2012 03:59:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Reviews: Sparkfun Inventor&#8217;s Kit at Mircocenter</title>
		<link>http://www.yourwarrantyisvoid.com/2011/09/09/reviews-sparkfun-inventors-kit-at-mircocenter/</link>
		<comments>http://www.yourwarrantyisvoid.com/2011/09/09/reviews-sparkfun-inventors-kit-at-mircocenter/#comments</comments>
		<pubDate>Sat, 10 Sep 2011 00:07:25 +0000</pubDate>
		<dc:creator>firestorm_v1</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[microcontroller]]></category>
		<category><![CDATA[parts]]></category>

		<guid isPermaLink="false">http://www.yourwarrantyisvoid.com/?p=1012</guid>
		<description><![CDATA[After reading this post on Hack-a-day, I went to the local MicroCenter to see what all they had to offer in a brick-and-mortar store.  I remember when Parallax and RadioShack had joined together and while the new availability had made it easier to get started with microcontrollers, the most common expression recalled is one of [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_1013" class="wp-caption aligncenter" style="width: 198px"><img class="size-full wp-image-1013" title="Sparkfun logo" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2011/09/sparkfun.gif" alt="Sparkfun logo" width="188" height="105" /><p class="wp-caption-text">Sparkfun at Microcenter!</p></div>
<p>After reading <a href="http://hackaday.com/2011/09/07/need-something-in-a-pinch-sparkfun-products-now-at-micro-center/" target="_blank">this post on Hack-a-day</a>, I went to the local MicroCenter to see what all they had to offer in a brick-and-mortar store.  I remember when Parallax and RadioShack had joined together and while the new availability had made it easier to get started with microcontrollers, the most common expression recalled is one of sadness at the general disarray of the parts cabinets.  Thankfully Microcenter seems to have done Sparkfun right.  Read on for my initial impressions of Microcenter&#8217;s offerings and a full review of my first Arduino kit, the Sparkfun Inventor&#8217;s Kit.<span id="more-1012"></span></p>
<p>If you are interested solely in the review, scroll down to the &#8220;<strong>Finally, the review!</strong>&#8221; section below.</p>
<h3> Online Only stores and Brick and Mortar stores intersect, a bit of history.</h3>
<p>A lot of online-only stores have made offerings into brick and mortar retail stores  with varying amounts of success, unlike retail stores going into online offerings which anyone would say has been a huge success and convenience.  Unfortunately, the DIY/Hobbyist market hasn&#8217;t seen such a success and for the most part has remained largely an online-only affair.</p>
<p>Several years ago, Parallax announced that they would start offering some sensors and kits for sale at Radio Shack.  After hearing the news, I was tentatively excited however after seeing their initial offering, I don&#8217;t think Parallax was done right by Radioshack. They were given half of a disorganized &#8220;parts drawer&#8221;  and a couple of pegs to offer hanging merchandise.  Despite Parallax&#8217;s attempt, the move into retail ultimately floundered. It is my belief that if Radio Shack had given Parallax&#8217;s parts offering a bit more shelf space  and Parallax had made more of an initial offer in Parallax&#8217;s own packaging, they might have been able to make it more successful. Instead, Parallax&#8217;s limited offering (around 10 sensors and the &#8220;What&#8217;s A Microcontroller&#8221; kit) and Radio Shack&#8217;s shoddy mismanagement of the parts bins where the sensors were stored served to bury the Parallax name in the forgotten corners of the store.</p>
<p>Although there was a post several months ago with a shot of custom Parallax retail packaging, I can&#8217;t find the link now, nor did any searching reveal any information. Several other companies watched the Parallax and Radio Shack situation unfold and took notes, now it&#8217;s time to evaluate another initial transitional offering from online only to online/brick-and-mortar offerings.</p>
<h3>Now, to Sparkfun and Microcenter&#8230;</h3>
<p>Sparkfun Electronics has been well known in the Arduino community with their extensive offerings online. Chances are, if there&#8217;s a sensor out there, they have it either in kit form or as a complete pre-fab module.  When I heard that they are making an offering through Microcenter, I was thankful that I lived near Microcenter. Using Parallax and Radio Shack as an example of a failed attempt, I went to Microcenter to scope out their product  offerings.  I was very pleasantly surprised.  Sparkfun&#8217;s initial product offering outpaces Parallax&#8217;s offering by a significant margin as shown in the image below.  Not only do they offer a Getting Started kit (reviewed below), they also offer a wide variety of parts and shields for the Arduino platform.</p>
<div id="attachment_1014" class="wp-caption aligncenter" style="width: 235px"><img class="size-medium wp-image-1014" title="Sparkfun Offering at Microcenter." src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2011/09/IMG_20110909_105030-e1315601462879-225x300.jpg" alt="Sparkfun Offering at Microcenter." width="225" height="300" /><p class="wp-caption-text">Sparkfun Offering at Microcenter.</p></div>
<p>You can see in the above photo that they have a lot to offer. From my estimates, they had the Arduino platform as well as the Inventor&#8217;s kit and several other non-Arduino projects.  They also offered a wide array of sensors and components as well as several Arduino shields in kit form. Some of the shields they offer is the Arduino motor shield, Arduino Prototype Shield with microSD card reader and the Arduino Joystick Shield.  Their component offering is equally impressive with a multitude of sensors, both serial and parallel character LCD displays, breadboards and modules. Something I saw that I plan on getting later on is a dedicated 3.7V Lithium Polymer charging module with battery.  This module will charge off a USB port and will keep an Arduino running for 50 hours according to the box.  Having something like this is a big bonus when working on embedded hardware.</p>
<p>They also offer several kits like the X-Bee modules kit (which is probably my next purchase) which contain everything you need to get started.  You get a USB to Serial converter board, two X-Bee modules and an X-Bee to Arduino interface shield.  Their RFID kit also has the same level of thought put into it with the necessary adapter board, the RFID sensor and sample RFID cards to experiment with.</p>
<p>In addition to their parts and components, I found something I had been wanting personally. They had tool kits available in store. The kits were ranged according to skill level (easy, medium and complex) with the complex kit featuring a multimeter and soldering iron, while the medium kit only offered the soldering iron.  As the user&#8217;s skill level progresses, they can add to their kit as needed.</p>
<p>One thing that seemed to stand out about their Arduino offering is that they introduced three flavors of Arduino.  The Arduino Uno (which comes in the Inventor&#8217;s kit as well as individually), The Arduino Mini (and the related FTDI programming module) and the Breadboard Arduino (Arduino made on breadboard rather than the standard PCB board).</p>
<p>For those of you asking about cost, this was one of my concerns as well.  In my previous experience, anything in a brick-and-mortar store is usually more expensive.  I did a side-by-side comparison with my phone as I priced random components and kits and I found that the cost at the store was pretty much dead on, only varying by a few cents.</p>
<h3>Final thoughts</h3>
<p>I am thankful that Sparkfun and Microcenter teamed up and I am hoping that they continue to expand their product selection.  I have a feeling that there are a lot of people out there that are wanting to get into microcontrollers and embedded electronics however just aren&#8217;t convinced and need that one little push over from &#8220;Maybe&#8221; to &#8220;Definitely&#8221;.  I can&#8217;t wait to see what is &#8220;in store&#8221; next.  (That was a pun, laugh!)</p>
<p>And without more blathering about Sparkfun and Microcenter, finally we get to the review.</p>
<h2><strong>Finally, the Review!</strong></h2>
<p>The kit I picked up is the <a href="http://www.sparkfun.com/products/10339" target="_blank">Retail version of the SparkFun Inventor&#8217;s Kit (SIK)<strong></strong></a>which has everything one would need to get started with the Arduino and electronics. I won&#8217;t enumerate the full list of materials in the box, however I will present several pictures as shown below.</p>
<div id="attachment_1015" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-1015" title="SIK kit cover" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2011/09/DSCF2138-300x225.jpg" alt="SIK Kit cover" width="300" height="225" /><p class="wp-caption-text">SIK Kit cover</p></div>
<p>Most of the kits on the market have a hinge at one end however Sparkfun&#8217;s kit has a completely detached cover meant to be removed. This presents the bonus of not eating up twice the kit&#8217;s floor space on your desk.</p>
<div id="attachment_1016" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-1016" title="Kit Contents" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2011/09/DSCF2139-300x225.jpg" alt="Kit Contents" width="300" height="225" /><p class="wp-caption-text">Kit Contents</p></div>
<p>Inside the kit comes a nicely packaged assortment of parts in the right hand compartments and in the top compartment.  More on those in a bit.  The left hand compartment contains several pin jumpers for breadboarding and Arduino connections and the center large compartment holds the USB cable, the circuit flash cards, the Arduino in its own box and the mounting plate and breadboard.</p>
<div id="attachment_1017" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-1017" title="Arduino Box" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2011/09/DSCF2140-300x225.jpg" alt="Arduino Box" width="300" height="225" /><p class="wp-caption-text">Arduino Box</p></div>
<p>The Arduino Uno comes in its own little box, prepackaged and QC&#8217;ed from Italy where the Arduino was built and designed.</p>
<div id="attachment_1018" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-1018" title="Unboxed Arduino" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2011/09/DSCF2141-300x225.jpg" alt="Unboxed Arduino" width="300" height="225" /><p class="wp-caption-text">Unboxed Arduino</p></div>
<p>Along with the Arduino Uno comes a handful of stickers and a little pamphlet with more information about the Arduino.</p>
<div id="attachment_1019" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-1019" title="Mounted Arduino and Breadboard" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2011/09/DSCF2142-300x225.jpg" alt="Mounted Arduino and Breadboard" width="300" height="225" /><p class="wp-caption-text">Mounted Arduino and Breadboard</p></div>
<p>The mounted Arduino and breadboard on the included Sparkfun mounting plate.  This gives the user a good and stable place to work with the Arduino and the sample circuits in order to understand the Arduino&#8217;s capabilities.</p>
<div id="attachment_1020" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-1020" title="Parts Pictures" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2011/09/DSCF2143-300x225.jpg" alt="Parts Pictures" width="300" height="225" /><p class="wp-caption-text">Parts Pictures</p></div>
<p>The other parts of the SIK kit include:</p>
<ul>
<li> 74HC595 shift register (pictured)</li>
<li>Rotary Potentiometer</li>
<li>Photoresistor</li>
<li>Two pushbuttons</li>
<li>Piezo speaker</li>
<li>Several LEDs</li>
<li>Several Resistors in a few different values</li>
<li>two Diodes</li>
<li>Transistor (2N2222 variant)</li>
<li>Subminiature Hobby Servo</li>
<li>DC Motor</li>
<li>Flex sensor (top center)</li>
<li>Variable Flex resistor (under sensor)</li>
<li>Additional headers and pins</li>
</ul>
<p>The kit also includes a small booklet that has several circuits and sample code to get started.</p>
<div id="attachment_1021" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-1021" title="Manual, flashcards and USB cable" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2011/09/DSCF2144-300x225.jpg" alt="Manual, flashcards and USB cable" width="300" height="225" /><p class="wp-caption-text">Manual, flashcards and USB cable</p></div>
<p>The booklet (pictured) contains several circuits and is intended to be used with the flash cards together in order to guide the novice through building the circuits and becoming familiar with the Arduino.  The flash cards each contain a circuit diagram that correlates to how the components should be connected to the Arduino and the book contains sample code with a brief explanation of how the code works.</p>
<h3>Thoughts on the booklet itself</h3>
<p>The book is targeted at new users to the Arduino platform however I quickly came to the conclusion that this kit is not targeted at beginners to electronics.   Coming from the &#8220;What&#8217;s A Microcontroller&#8221; world that explained everything including the basic 101&#8242;s of electronics, this may be a bit off-putting for some however with an understanding of some of the basics, this may serve to bridge the gap between building basic passive electronics projects and more advanced digital electronics projects.</p>
<p>Unlike the &#8220;What&#8217;s A Microcontroller&#8221; kit, there is no complete guide to the command reference included in the kit however the Basic Stamp and the Arduino both have extensive community support.</p>
<h3>Final Thoughts on the Kit</h3>
<p>The Sparkfun Inventor&#8217;s Kit appears to be well stocked with a typical selection of components fit for a beginner&#8217;s kit and will make a good start in working with the Arduino, even if you have never had any microcontroller experience.  While I can&#8217;t recommend this kit as a complete beginner&#8217;s guide to electronics, any newbie should be able to perform additional research to locate the answers they seek.  This is not a completely offline course but I do not consider this to be enough of a deterrent to stop from recommending the kit.  I feel that this kit will be a great addition to any electronics bench and will help anyone with even the most basic electronics experience get started with the Arduino.</p>
<p><strong>Verdict:  Buy!</strong></p>
<p>Cost: $99</p>
<p>Found at: Microcenter and sparkfun.com (sku: <a href="http://www.sparkfun.com/products/10339" target="_blank">RTL-10339</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yourwarrantyisvoid.com/2011/09/09/reviews-sparkfun-inventors-kit-at-mircocenter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GUIDemo &#8211; A full VGA Library for the Propeller</title>
		<link>http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/</link>
		<comments>http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 06:12:04 +0000</pubDate>
		<dc:creator>firestorm_v1</dc:creator>
				<category><![CDATA[Embedded devices]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[How-To's]]></category>
		<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[Parallax]]></category>
		<category><![CDATA[propeller]]></category>
		<category><![CDATA[PS/2]]></category>
		<category><![CDATA[VGA]]></category>

		<guid isPermaLink="false">http://www.yourwarrantyisvoid.com/?p=686</guid>
		<description><![CDATA[The Parallax VGA GUI Demo is great for adding a pre-built GUI for your projects. The bonus is that the drivers for using a PS/2 keyboard and mouse and a VGA display are pre-built and ready to run.  With a little bit of configuration, you can add a well built UI to your application and [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-79" href="http://www.yourwarrantyisvoid.com/2009/08/31/parts-parallax-vgadual-ps2-breadboard-adapter/parallax_logo/"><img class="aligncenter size-medium wp-image-79" title="parallax_logo" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2009/08/parallax_logo-300x97.jpg" alt="" width="300" height="97" /></a></p>
<p>The Parallax VGA GUI Demo is great for adding a pre-built GUI for your projects. The bonus is that the drivers for using a PS/2 keyboard and mouse and a VGA display are pre-built and ready to run.  With a little bit of configuration, you can add a well built UI to your application and make it easier to display output and receive input from the user.</p>
<p>In this article, I will demonstrate some of the basic options that are needed in order to get the GUI up and running.  While our application is going to be turning on a few LEDs, once you have these basics down you should be able to use this article and build whatever user elements are required for your application.<span id="more-686"></span></p>
<h1>Prerequisites:</h1>
<p>If you haven&#8217;t already, I would recommend the Parallax PS/2 and VGA Adapter board. This board provides two PS/2 ports (mouse and keyboard) and a 15 pin VGA port in an easy to use modular design that is breadboard compatible.  Here is a <a href="http://www.parallax.com/Store/Accessories/CablesConverters/tabid/166/CategoryID/40/List/0/SortField/0/catpageindex/2/Level/a/ProductID/583/Default.aspx" target="_blank">link to the VGA board on Parallax&#8217;s site</a> and here is the link to <a href="http://www.yourwarrantyisvoid.com/2009/08/31/parts-parallax-vgadual-ps2-breadboard-adapter/" target="_blank">my earlier article</a>.</p>
<p>In addition to the Adapter Board, you will need<br />
- A PS/2 mouse (Not a USB mouse with a PS/2 adapter)<br />
- A PS/2 keyboard (Not a USB keyboard with a PS/2 adapter)<br />
- A 15 pin VGA monitor<br />
- six LEDs, any color<br />
- six 100 ohm resistors (Brown-Black-Brown)<br />
- Jumper Wires for the Adapter board<br />
- A PC with USB port for the PropPlug USB programmer.<br />
- 9V Battery or other 9VDC power source</p>
<h1>Understanding the concept of a UI</h1>
<p>Before we get started, let&#8217;s discuss the basic differences between a Prompt and a UI.</p>
<p>A Prompt:</p>
<ul>
<li> &#8211; asks for something direct like &#8220;Your Name&#8221;</li>
<li> &#8211; Reads the response, Input halts until requirement satisfied, e.g. (Press any key to continue)</li>
<li> &#8211; Treats the response as programmed, e.g. $YourName</li>
<li> &#8211; is programmed in a linear fashion. e.g. You prompt for your name, then you prompt for your address, then you prompt for your date of birth, etc&#8230;</li>
</ul>
<p>A GUI:</p>
<ul>
<li>Shows multiple items to interact with</li>
<li> Reads a response when triggered with an event and does not wait.</li>
<li>Performs actions based on event triggers.</li>
<li>Can perform actions in a non-linear fashion. e.g. Clicking Button 1, Button 3, Button 2, Button 6, Button 1 again.</li>
</ul>
<p>Remember, although a GUI can contain prompts (&#8220;Click OK to Continue&#8221;), it&#8217;s not often that a prompt becomes a GUI. Also remember that a GUI is Event driven, not prompted.</p>
<h2>Events</h2>
<p>It&#8217;s important to understand that performing any action with the mouse and keyboard triggers an event. It&#8217;s when the event (in most cases, a mouse click) occurs on a GUI element (a checkbox for example), we get something to happen.  By programming the Parallax GUI Demo, you will build GUI Elements (things to click on or type into) using Mouse and Keyboard Events in order to generate some kind of output (Lighting LEDs).</p>
<p>Keep this in mind, as generating events and how to deal with them are the cornerstone of any GUI programming (not just Parallax!).</p>
<h2>Elements</h2>
<p>Mouse events are nothing without something to interact with, so that brings us to the point where we have to talk about the GUI. Each object in a GUI, checkboxes, menu items, windows, submit buttons, etc. are all considered elements of the GUI. We build the GUI using elements to satisfy our program&#8217;s needs.  For the &#8220;What is your name?&#8221; prompt, we would need a window element (with a Window Title element), a text element saying &#8220;What is your name?&#8221;, a text field element (so we can get the name back to the program) and a submit button element.  That&#8217;s Five elements! Thankfully, only two of them are interactive.  The text field needs to be clicked on (to tell the GUI that keyboard input goes here), and the Submit button needs to be clicked on to tell the program to continue.</p>
<p>Even though we started out with five elements, thankfully we only have to code for two events.</p>
<p>Below is a screenshot of various elements that the Parallax UI is able to generate.</p>
<div id="attachment_688" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-688" href="http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/dscf2001/"><img class="size-medium wp-image-688" title="Parallax VGA Demo Screenshot" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/DSCF2001-300x225.jpg" alt="Parallax VGA Demo Screenshot" width="300" height="225" /></a><p class="wp-caption-text">Parallax VGA Demo Screenshot</p></div>
<p>In this screenshot, we can see the following interactive elements:<br />
- Spin Boxes &#8211; A single element with up and down arrows that allow you to select from a list of predefined options. (like a Page Count field on a Print window)<br />
- Checkboxes &#8211; A listed series of predefined options that allow for multiple options to be selected.<br />
- Radio Buttons &#8211; A listed series of predefined options that allow only a single option be selected.<br />
- Pushbuttons &#8211; A single element that is clickable (like a submit button).<br />
- Menu Bar &#8211; A horizontal element containing multiple pushbuttons.<br />
- A Text Input field &#8211; Another horizontal element that takes input from the keyboard.</p>
<p>We also see the following non-interactive but still needed elements:<br />
- Windows &#8211; We need windows to keep these elements organized, otherwise it doesn&#8217;t work too well.<br />
- Status Lamps &#8211; Think of these as the GUI equivalent to an LED and resistor. They can be toggled on or off.</p>
<p>Now that we know what all the elements are, let&#8217;s do something.</p>
<h2>Getting the hardware ready</h2>
<p>Connect the 15 pin VGA/PS2 breakout kit to the lower right hand corner of the breadboard as shown in the image below. The breadboard should be oriented as shown with the PropPlug mounted on the top, usb cable pointing right. You can then connect the 12 pins straight across (watch out for the crystal) to the 12 pins on the right hand side of the Propeller (P16-P27).  Attach the Vss lead to any of the Vss busses (black lines) on your breadboard.</p>
<div id="attachment_689" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-689" href="http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/dscf2003/"><img class="size-medium wp-image-689" title="VGA adapter hooked up" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/DSCF2003-300x225.jpg" alt="VGA adapter hooked up" width="300" height="225" /></a><p class="wp-caption-text">VGA adapter hooked up</p></div>
<p>In order to get the required +5V for the PS/2 mouse and keyboard, look closely at the two voltage regulators at the top of the board. There is an LM2940 (back regulator on the picture below) that provides the 5V and a LM2937 (front regulator) which provides a 3.3V source for the Propeller. Be sure to attach to the OUTPUT of the LM2940 as shown in the picture below.  As a hint, my wire is in the third horizontal row from the top of the LM2940 which is its output lead.</p>
<div id="attachment_690" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-690" href="http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/dscf2004/"><img class="size-medium wp-image-690" title="+5V location" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/DSCF2004-300x225.jpg" alt="+5V location" width="300" height="225" /></a><p class="wp-caption-text">+5V location</p></div>
<p>DO NOT CONNECT YOUR +5V LEAD TO THE +9V BATTERY OTHERWISE DAMAGE TO THE PROPELLER, MOUSE AND KEYBOARD MAY RESULT.</p>
<p>After you have the VGA adapter connected, hook up the LEDs so that the cathodes go to ground and the anodes run through the 100ohm resistors to P0-6 as shown below.</p>
<div id="attachment_691" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-691" href="http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/dscf2005/"><img class="size-medium wp-image-691" title="LED connection" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/DSCF2005-300x225.jpg" alt="LED connection" width="300" height="225" /></a><p class="wp-caption-text">LED connection</p></div>
<h2>Get the software</h2>
<p>If you haven&#8217;t already done so, download the VGA Text GUI Demo from here:  <a href="http://obex.parallax.com/objects/413/" target="_blank">http://obex.parallax.com/objects/413/</a></p>
<p>Unzip the archive, load it up in your Propeller Tool application and load it into RAM to save write cycles on your EEPROM.  If everything works properly, you should be able to move the mouse, click on things and be able to type text in to the &#8220;COMMAND&#8221; field at the bottom. Play around with it for a bit and get used to how the elements interact with each other.  If you want to ensure that your wiring is correct, read the GUIDEMO and GUIBASE section below.</p>
<p>Before proceeding, it&#8217;s recommended to make a backup of the unzipped Propeller VGA demo so that you will have something to refer to in case you accidentally delete part of the demo application. Load the copy of the code for the next step and leave the original copy untouched.</p>
<h1>Hacking up the Code</h1>
<p>Now that you&#8217;re up and running with the test code, let&#8217;s take a look at the existing code and start modifying it.  We&#8217;ll cover important aspects of the existing code along the way. In our application, we will be using the UI to draw a simple window containing six checkboxes that correspond to the six LEDs we have installed.  Once finished, when we check a box, it will light the corresponding LED. If we clear that checkbox, it will extinguish the LED.</p>
<p>So let&#8217;s get started.</p>
<h2>GUIDEMO.spin</h2>
<p>The GUIDemo.spin file is considered the &#8220;Top Level&#8221; or &#8220;root&#8221; (if you&#8217;re a Linux admin like I am) of the entire  application. This file references sub-codebases through  an OBJ (Object) declaration. Although Parallax called it Top Level, I have always referred to it as the &#8220;root&#8221; as in the root of the project much like the root of a filesystem.</p>
<p>Without getting into the syntax of Spin (the Propeller coding language, a topic that Parallax is much better suited for than I am) just know that this is the trunk of the tree as far as all other pieces of code in the VGA Demo are concerned.</p>
<div id="attachment_692" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-692" href="http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/codeheirachy/"><img class="size-medium wp-image-692" title="Code Heirachy" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/CodeHeirachy-300x286.jpg" alt="Code Heirachy" width="300" height="286" /></a><p class="wp-caption-text">Code Heirachy</p></div>
<p>Starting at the top of the GUIDemo.spin file, you see a secion labeled CON. This is for the constants that GUIBase uses to initialize the PS/2 mouse and keyboard and the 15pin VGA port.</p>
<p>The vga_base should point to the I/O pin that is connected to the &#8220;V&#8221; pin of the PS/2 VGA adapter. The GUIBase will assume that the rest are mapped accordingly.  If you are using something other than the Parallax adapter, you will want to ensure that your adapter is wired up as shown below:</p>
<p>I/O Pin        Function<br />
P16        V &#8211; Vertical Scan<br />
P17        H &#8211; Horizontal Scan<br />
P18        B0 &#8211; Blue Positive?<br />
P19        B1 &#8211; Blue Neutral?<br />
P20        G0 &#8211; Green Positive?<br />
P21        G1 &#8211; Green Neutral?<br />
P22        R0 &#8211; Red Positive?<br />
P23        R1 &#8211; Red Neutral?</p>
<p>* Please note, the ?&#8217;s mean I&#8217;m not certain on polarity, but I am sure on the grouping. The reason is that I only have the Parallax VGA adapter so I haven&#8217;t tried to fabricate my own adapter.</p>
<p>The mouse and keyboard each require two pins, &#8220;dat&#8221; and &#8220;clk&#8221;.  The Parallax Adapter has each pin&#8217;s function silkscreened onto the adapter&#8217;s PCB for easy connection and are mapped as shown below:</p>
<p>I/O Pin        Function<br />
P24        Mouse Data<br />
P25        Mouse Clock<br />
P26        Keyboard Data<br />
P27        Keyboard Clock</p>
<p>If you&#8217;re using Parallax&#8217;s VGA adapter, then make sure that your values match what is shown above.  If you are using another adapter, make sure that the values match your respective device&#8217;s pins.</p>
<p>The OBJ section is where we declare any additional code that needs to be included. In the original code, you can see there are three objects declared (GUI, TMRS and NUMS) however for our program, we only need the first one (GUI).  Delete the two lines starting with TMRS and NUMS highlighted in the green square in the image below.</p>
<div id="attachment_693" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-693" href="http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/externalobjects/"><img class="size-medium wp-image-693" title="External Objects" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/ExternalObjects-300x198.jpg" alt="External Objects" width="300" height="198" /></a><p class="wp-caption-text">External Objects</p></div>
<p>When it comes time for you to add your own routines, you can include them here by defining them as objects. For now, just scroll down to the next section.</p>
<p>The VAR section is important because the code shows that all of the interactive elements in the GUI require a byte be assigned to them. This is important as this is how the GUI keeps track of what element is called when an event is triggered. It is critical to remember when you are designing your own GUI, that each interactive element has it&#8217;s own unique ID. This will be important later when we tie the elements into events. For now, remove all the declared bytes and add the below in it&#8217;s place:</p>
<div id="attachment_694" class="wp-caption aligncenter" style="width: 265px"><a rel="attachment wp-att-694" href="http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/varbytes/"><img class="size-medium wp-image-694" title="Variable Bytes" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/VARbytes-255x300.jpg" alt="Variable Bytes" width="255" height="300" /></a><p class="wp-caption-text">Variable Bytes</p></div>
<p>In the above image, we are declaring six CHKB elements numbers 1 through 6.  The naming convention is important as there is code later on where these get defined.</p>
<p>Scroll down to the PUB statement below. This section is the actual code of the program and where we will be doing most of the editing.  First off, make sure that you can see between the CreateUI statement and the PUB statement (top of the blue section of code as pictured below. We will be removing the code there as it was used with the timers code object (that we removed) was initialized at start.  Just like before, delete all the code within the green box. It&#8217;s not needed and will generate errors if you attempt to compile it.</p>
<div id="attachment_695" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-695" href="http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/pubdelete/"><img class="size-medium wp-image-695" title="PUBlic function to delete" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/PUBdelete-300x194.jpg" alt="PUBlic function to delete" width="300" height="194" /></a><p class="wp-caption-text">PUBlic function to delete</p></div>
<p>We will replace the deleted code with our own code. This  is the initialization code for our application and occurs prior to the GUI being set up. All our code does is ensure that the first six I/O pins (P0-P5) are set as outputs and are set low so that the LEDs are off.</p>
<p>When you are developing your own program, be sure that the initialization code occurs before the CreateUI statement for best results.</p>
<div id="attachment_697" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-697" href="http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/pubadd/"><img class="size-medium wp-image-697" title="PUBlic INIT code to add" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/PUBadd-300x159.jpg" alt="PUBlic INIT code to add" width="300" height="159" /></a><p class="wp-caption-text">PUBlic INIT code to add</p></div>
<p>At this point, we have removed excess objects from our code and declared six variables for our checkbox elements and we have initialized the LEDs. Now we will tell the application what to do when an event has been triggered in order to get the LEDs to light up.</p>
<p>If you look at the code, you will notice that it is a very large repeat loop that contains a case loop inside it. The way it works is that the Propeller will constantly evaluate GUI.ProcessUI. When evaluated, it will check gx against the list of elements and if gx matches a defined element ID, it will then perform the appropriate action.</p>
<p>For now, start at the line that reads &#8220;case gx&#8221; and highlight the text down until you get to the &#8220;START OF UI HELPER FUNCTIONS&#8221;. Since we are not using the demo code in our application, we can safely remove it.</p>
<p>Once removed, add the code in the below image to tie in the events with our custom function. (We&#8217;ll write it next).</p>
<div id="attachment_696" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-696" href="http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/pubevents/"><img class="size-medium wp-image-696" title="Public Events to add" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/PubEvents-300x162.jpg" alt="Public Events to add" width="300" height="162" /></a><p class="wp-caption-text">Public Events to add</p></div>
<p>In the above code, we are calling LEDFunction with a different parameter corresponding to each of the six LEDs. Now we need to write the function LEDFunction so it actually does something.</p>
<p>In your application, you may end up writing all of your code in another .spin file and then using an OBJ to declare it.  If you do that, then you can reference your OBJ functions instead of using a basic function here.</p>
<p>Start off by copying that CON statement and inserting it into the empty space. This will create a line we can use when reading the code to make it easier.  Change it from &#8220;UI HELPER FUNCTIONS&#8221; to &#8220;UI APPLICATION FUNCTIONS&#8221; and add the below code as shown.</p>
<div id="attachment_698" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-698" href="http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/prifunction/"><img class="size-medium wp-image-698" title="PRIvate Function to add" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/PRIFunction-300x115.jpg" alt="PRIvate Function to add" width="300" height="115" /></a><p class="wp-caption-text">PRIvate Function to add</p></div>
<p>In this section of code, we will write our function for the events.  All we are doing is taking the function&#8217;s parameter and inverting it&#8217;s existing value. If it&#8217;s 1 (on) it is then set 0 (off) and vice versa.  Although we return the value of the I/O pin, it is not used elsewhere and will get overwritten elsewhere.</p>
<p>Scroll further down and we finally get to the CreateUI function.  This is where the UI gets built and the bytes for the elements earlier get defined.</p>
<p>We can see that there are a lot of commands listed here. Don&#8217;t let that intimidate you as we are going to remove most of them. Find the line that starts off with &#8220;vga_cols&#8221; and highlight all the way down to the MIT License.  Remove the code and add the code in the picture.</p>
<div id="attachment_699" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-699" href="http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/guicode/"><img class="size-medium wp-image-699" title="GUI Code to add" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/GUICode-300x141.jpg" alt="GUI Code to add" width="300" height="141" /></a><p class="wp-caption-text">GUI Code to add</p></div>
<p>This code draws out the Text box for our project and gives it a text label. Don&#8217;t worry about the syntax, we&#8217;ll cover that in the GUI CODE section later.</p>
<p>Basically what happens here is that a Simple Box (SBOX) gets drawn with the title of &#8220;LEDs&#8221;.  Inside that box, six checkboxes are drawn, each with their own text description. Pretty straightforward on the UI, right?</p>
<p>We&#8217;re almost done and ready to test our new GUI.</p>
<h2>GUIBASE</h2>
<p>Now, there&#8217;s one more thing we need to do before we go loading this project into RAM and seeing if it works. We need to make an edit to GUIBase.<br />
At the very top of GUIBase, in the CON section, you can see that there is a note describing the GUI Element Inventory that must be present.  We need to edit the code and tell GUIBase that we&#8217;re only using six checkboxes.  However, as the note describes, we can&#8217;t just go set GZ_CHKB to 6 and all others to 0, as this would throw a compiler error.</p>
<p>Go ahead and set all of the GZ_ variables to 1 except for GZ_CHKB which will get a value of 6 since we have six LEDs as shown below.</p>
<div id="attachment_700" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-700" href="http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/guibase/"><img class="size-medium wp-image-700" title="GUIBase changes" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/GUIBase-300x145.jpg" alt="GUIBase changes" width="300" height="145" /></a><p class="wp-caption-text">GUIBase changes</p></div>
<p>Once modified, be sure to save your work and then go to &#8220;Run&#8221;, Compile Top, Load RAM.  You should get something like the below image on your display.</p>
<div id="attachment_701" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-701" href="http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/dscf2006/"><img class="size-medium wp-image-701" title="Our GUI LED demo" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/DSCF2006-300x225.jpg" alt="Our GUI LED demo" width="300" height="225" /></a><p class="wp-caption-text">Our GUI LED demo</p></div>
<p>If all went well and you didn&#8217;t get a compiler error, you should get this GUI.  The little green square is the mouse cursor.  Go ahead and try it out. Make sure that checking each checkbox lights up an LED and that clearing the checkbox turns it off.</p>
<p>Now that we&#8217;ve got a working GUI up and running, let&#8217;s review what all we did aside from removing a lot of extra stuff.</p>
<ul>
<li>We declared a byte for each GUI element.</li>
<li>We added initialization code.</li>
<li>We added a declaration in the main loop to handle events from the UI to point to our function</li>
<li>We wrote a function that did something based on the events we had given it.</li>
<li>We updated GUIBase with the element count so that the GUI code knew how much it had to work with.</li>
</ul>
<p>These are the fundamental steps for creating a UI with the propeller using the GUIBase code. Now that you understand the basics as far as what is required, let&#8217;s take a look at some other stuff you can do too.</p>
<h1>Looking further into the GUI Code</h1>
<p>In the GUIBase.spin file, you can find the code required to draw the various elements of your GUI.  Reading through the code,  most of the options required are in terms of position.  For example, the code for the simple box (window) shown earlier, required an X and Y coordinates (in rows/cols) to place the upper left hand corner of the UI, then the width and length of the box and a title.  The Checkboxes each required an X and Y coordinate, then a text length and finally a label.</p>
<p>If we were to use a Radio Button group, we would need to provide an X and Y coordinates, a text length, a text label and a Group ID.  The Group ID is used to associate the radio buttons together.  Below is a screenshot of my implementation along with an Apply button:</p>
<div id="attachment_702" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-702" href="http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/pushbuttoncode/"><img class="size-medium wp-image-702" title="Radio Buttons and Pushbutton code" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/PushbuttonCode-300x81.jpg" alt="Radio Buttons and Pushbutton code" width="300" height="81" /></a><p class="wp-caption-text">Radio Buttons and Pushbutton code</p></div>
<p>In the above code, you can see that I have established five radio buttons (RADIO1 to RADIO5) in addition to PUSHBTN1 pushbutton. These are set up in the main loop below:</p>
<div id="attachment_703" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-703" href="http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/pushbuttoncodeandfunctions/"><img class="size-medium wp-image-703" title="Push Button UI Code and Functions" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/PushButtonCodeandFunctions-300x252.jpg" alt="Push Button UI Code and Functions" width="300" height="252" /></a><p class="wp-caption-text">Push Button UI Code and Functions</p></div>
<p>In the above code, you can see that the SetLEDStorage passes a number which gets stored in LEDState. When the Apply button is pressed, CommitLEDs takes LEDState and sets the six LEDs to the binary value of whatever was in it.  Below is what the UI looks like:</p>
<div id="attachment_704" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-704" href="http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/dscf2011/"><img class="size-medium wp-image-704" title="Radio Button GUI" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/DSCF2011-300x225.jpg" alt="Radio Button GUI" width="300" height="225" /></a><p class="wp-caption-text">Radio Button GUI</p></div>
<p>Just like adding the checkboxes, I followed those same steps here:</p>
<ul>
<li> &#8211; I declared my additional UI elements&#8217; GUID bytes (RADIO1 to RADIO5), my Radio Button group (RBGID1), my  pushbutton (PUSHBTN1) and my LEDState variable.</li>
<li> &#8211; I added my init code (setting LEDState to 0, not pictured)</li>
<li> &#8211; I added routines for my elements to call user functions. (SetLEDStorage and CommitLEDs)</li>
<li> &#8211; I declared the routines so that they did something (stored the LED value, applied the value to the first six I/O pins)</li>
<li> &#8211; I updated GUIBase.spin with the new list of items ( added five radiobuttons and one pushbutton.)</li>
</ul>
<p>Give the code a try and you will see that while the checkboxes set the LED state instantly, the radio buttons do nothing until they are applied with clicking on the Apply button. This is important because as you design your GUI, you will need to decide if something must happen when the mouse is clicked right then (immediate action) or if the action will get applied later on via an &#8220;Apply&#8221; button. This is entirely up to you and there is no need to do things only one way.  Either method works but whether or not it works properly for your application will be your choosing.</p>
<h1>Tips and Tricks, and things to watch out for</h1>
<p>While developing this article, there were a couple of things I came across that you may want to watch out for. Don&#8217;t worry, you won&#8217;t blow up your Prop if you make a mistake in coding, however there are a few things you may want to keep an eye on:</p>
<ul>
<li>- Load to RAM, load to RAM, load to RAM and check your battery.<br />
In my writing this article, I found out real quick that driving a display, mouse and full size keyboard will drain a 9V transistor battery very quick.  A symptom of this drain is the Green LED that is present on the Propeller Education Kit. If it starts to pulse and your monitor loses sync, it&#8217;s time for a new 9V or consider a 5V USB power cord. Also, to save write cycles on the EEPROM, load to RAM whenever possible. Your computer&#8217;s hard  drive is more suited to incremental saves, EEPROMs are not.  Only save to EEPROM when you are ready to test your application in real life.</li>
<li>- There is no boundary checking.  If you overlap your windows, then there is no going back. When in doubt, you can use the Mouse code to print the mouse coordinates on your project to help you identify and troubleshoot positioning.  Remember that all GUI elements start by defining the upper left hand corner of the element. You will need to include the NUMS object (SimpleNumbers.spin) and the code from the original GUIDEMO.spin (lines 314 to 316) in order to have it show up.  You can see an example of the boundary overlap in the below image.</li>
</ul>
<div id="attachment_705" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-705" href="http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/dscf2012/"><img class="size-medium wp-image-705" title="Button overlaps window" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/DSCF2012-300x225.jpg" alt="Button overlaps window" width="300" height="225" /></a><p class="wp-caption-text">Button overlaps window</p></div>
<ul>
<li>- There is no off-edge boundary checking either.  If you are setting a text field too far right of the video display or too far down, it will get cut off and your entire GUI will not work right.  In this case, I set the Predefines window to X40,Y75 and 25 columns wide which was out of the limits of the current VGA resolution.  The below image was the result and my UI only partially worked.  Resetting and reloading RAM fixed it.</li>
</ul>
<div id="attachment_706" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-706" href="http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/dscf2013/"><img class="size-medium wp-image-706" title="Window moved out of range" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/DSCF2013-300x225.jpg" alt="Window moved out of range" width="300" height="225" /></a><p class="wp-caption-text">Window moved out of range  </p></div>
<ul>
<li>- Also as demonstrated in the image above, UI elements are not bound to the window you create them under. Assuming that both windows were same size and I mis-typed the coordinates, the Apply button could very easily show up under the checkboxes instead of the radio buttons leading to a confusing display.  You will want to make sure that your UI elements do not overlap at all as this could affect how the UI interprets your mouse actions.</li>
</ul>
<h1>Last Thoughts</h1>
<p>There is so much you can do with the Propeller UI to make your applications more interactive.  With little work, you could build something like a serial terminal and embed your project in an LCD monitor or you could make a basic home automation system with a touchscreen LCD and a wireless transceiver. The possibilities are endless and with the Propeller, you can now use full GUI capability with keyboard and mouse support.</p>
<p>As always, Happy Hacking!</p>
<p>FIRESTORM_v1</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 3785px; width: 1px; height: 1px;">http://www.yourwarrantyisvoid.com/2009/08/31/parts-parallax-vgadual-ps2-breadboard-adapter/</div>
]]></content:encoded>
			<wfw:commentRss>http://www.yourwarrantyisvoid.com/2010/11/19/guidemo-a-full-vga-library-for-the-propeller/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>TI Launchpad Dev Kit for under $5!</title>
		<link>http://www.yourwarrantyisvoid.com/2010/11/05/ti-launchpad-dev-kit-for-under-5/</link>
		<comments>http://www.yourwarrantyisvoid.com/2010/11/05/ti-launchpad-dev-kit-for-under-5/#comments</comments>
		<pubDate>Sat, 06 Nov 2010 04:50:08 +0000</pubDate>
		<dc:creator>firestorm_v1</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[Product Reviews]]></category>
		<category><![CDATA[microcontroller]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[schwag]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.yourwarrantyisvoid.com/?p=664</guid>
		<description><![CDATA[So many months ago (in June), Hackaday and Make were all abuzz about the TI Launchpad which is a new development platform centered around the TI MSP430 microprocessor.  The most interesting thing aside from the processor spec itself was that the entire platform came under $5 for a professionally built development kit. I placed my [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-665" href="http://www.yourwarrantyisvoid.com/2010/11/05/ti-launchpad-dev-kit-for-under-5/launchpad/"><img class="aligncenter size-full wp-image-665" title="LaunchPad" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/LaunchPad.jpg" alt="" width="103" height="120" /></a>So many months ago (in June), Hackaday and Make were all abuzz about the TI Launchpad which is a new development platform centered around the TI MSP430 microprocessor.  The most interesting thing aside from the processor spec itself was that the entire platform came under $5 for a professionally built development kit. I placed my order and in a week, I got a backorder slip and eventually forgot about it.  (June is years ago for those of us with ADD.)  Well even though I had forgotten about it, TI had not.  A couple of days ago, I got a call from the apartment complex that it had arrived! Read on to find out what all&#8217;s in the box!</p>
<p><span id="more-664"></span></p>
<p>A little background on the TI MSP430 first.</p>
<p>This is TI&#8217;s approach to the microcontroller market that is not targeted at the industrial segment, but rather at us the hardware DIY crowd.  I have to admit that they did it right with the $4.30 price point and I can&#8217;t wait to get started.  The kit includes two of the MSP430 chips:</p>
<ul>
<li>﻿MSP430G2211IPN14  -2kB of on-die flash, 128 bytes of RAM, 10 GPIO pins, One 16-bit timer, a Watchdog timer, a BOR and a comparator.  You can download the datasheet <a href="http://bit.ly/cCLh3w" target="_blank">from here</a>.</li>
<li>MSP430G2231IPN14 &#8211; 2kB of on-die flash, 128 bytes of RAM, 10 GPIO pins, One 16-bit timer, a Watchdog timer, a BOR, a Serial Interface (for I2C or SPI), an internal temperature sensor and an 8 channel 10bit ADC.  This chip&#8217;s datasheet can be <a href="http://bit.ly/c4LFN4" target="_blank">found here</a>.</li>
</ul>
<p>The 2231 chip comes preinstalled and pre-programmed with a basic temperature demo which shows off the internal temperature sensor.  It&#8217;s definitely more than the blinking LED demo that comes with most sample programs.</p>
<p>So, let&#8217;s take a look at the thing.</p>
<div id="attachment_671" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-671" href="http://www.yourwarrantyisvoid.com/2010/11/05/ti-launchpad-dev-kit-for-under-5/dscf0764/"><img class="size-medium wp-image-671" title="Launchpad box" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/DSCF0764-300x225.jpg" alt="Launchpad Box" width="300" height="225" /></a><p class="wp-caption-text">Launchpad Box</p></div>
<p>The box comes in a very nice black cardboard box with TI&#8217;s launchpad Wiki printed on the front.  On the back of the box is TI&#8217;s other site URL straight to the chip specs, <a href="http://www.ti.com/430value" target="_blank">http://www.ti.com/430value</a>.</p>
<div id="attachment_672" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-672" href="http://www.yourwarrantyisvoid.com/2010/11/05/ti-launchpad-dev-kit-for-under-5/dscf0766/"><img class="size-medium wp-image-672" title="Devboard" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/DSCF0766-300x225.jpg" alt="The Development  board." width="300" height="225" /></a><p class="wp-caption-text">The Development board with an MSP430G2231 mounted and ready to fire up.</p></div>
<p>The board itself is in a small anti-static bag, and when you open it up, you get a red development board like above.  There is a chip pre-programmed and ready to go.  Just like the Arduino, this board is USB powered and USB programmed.  There is a socket in the middle that you can plug a chip into, program, and then remove for use in your own projects or breadboard.  For the Arduino crowd, there is even a couple of headers included to populate the left and right solder pads for an easy method of attaching jumpers to the board for prototyping.</p>
<div id="attachment_673" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-673" href="http://www.yourwarrantyisvoid.com/2010/11/05/ti-launchpad-dev-kit-for-under-5/dscf0770/"><img class="size-medium wp-image-673" title="Accessories" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/DSCF0770-300x225.jpg" alt="Accessories" width="300" height="225" /></a><p class="wp-caption-text">Accessories</p></div>
<p>In addition to the development board, you also get the above accessories.  Left is the two single row headers for the board (both female connector and male pins are included).  At the top is the second chip, (the chip without SPI/I2C and the Serial interface) and in the foreground is a 32.768kHz crystal that you can solder onto the development board for a more accurate clock.  The MSP430&#8242;s do include their own internal clock source however for those time sensitive projects, the external crystal is preferred and this board gives you you ready access to it should you find you need one.  Also included is a USB A to Mini-B cable.</p>
<div id="attachment_674" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-674" href="http://www.yourwarrantyisvoid.com/2010/11/05/ti-launchpad-dev-kit-for-under-5/dscf0772/">A<img class="size-medium wp-image-674" title="Plugged in" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/11/DSCF0772-300x225.jpg" alt="Plugged In" width="300" height="225" /></a><p class="wp-caption-text">Plugged in and ready for action!</p></div>
<p>Here is a picture of the board plugged in and ready to rock.  Although the LED&#8217;s brightness blurs the camera, there is a red LED and a green LED located next to the switch in the foreground.  When you first apply power to the board, the back LED (near the USB header) lights indicating power is applied, and the two LEDs near the left switch blink alternating, indicating that the chip is ready to be programmed.  In this image, I was using the chip that was already inserted, so all I had to do to run the simple test application was to hit the left pushbutton and start the program.</p>
<p>According to the wiki page, there are nine variants of the MSP430, some offering more flash (code) storage, some offering additional features however they are all pretty consistent at the 128-byte RAM.  Many people on the <a href="http://hackaday.com/2010/06/22/ti-makes-a-big-bid-for-the-hobby-market/#comments" target="_blank">Hack-a-day article</a> expressed concern at the windows only compiler however Hack-a-day released <a href="http://hackaday.com/2010/08/11/how-to-launchpad-programming-with-linux/" target="_blank">another article</a> later on about how to code it in our favorite OS.</p>
<p>Generally speaking, cost has been the #1 thing that has distracted me from getting started with the Arduino ($35 for a board) and the PIC microcontroller suffers the same fate.  While the chips for each are quite inexpensive, it&#8217;s the programmers that usually ends up costing you in the end.  TI definitely has my attention with a $5 price point and extra chips.  I look forward to playing around with it very soon!</p>
<p>If you&#8217;ve gotten ahold of one of these, please let me know what you&#8217;ve done in the comments.  I&#8217;ve read several articles on Hack-a-day which have been appealing to me, especially the <a href="http://hackaday.com/2010/09/30/launchpad-takes-ultra-low-power-to-the-extreme/" target="_blank">low power article here</a>.</p>
<p>Happy Hacking!</p>
<p>FIRESTORM_v1</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yourwarrantyisvoid.com/2010/11/05/ti-launchpad-dev-kit-for-under-5/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Parts: Parallax RFID scanner now $10!</title>
		<link>http://www.yourwarrantyisvoid.com/2010/06/14/parts-parallax-rfid-scanner-now-10/</link>
		<comments>http://www.yourwarrantyisvoid.com/2010/06/14/parts-parallax-rfid-scanner-now-10/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 01:21:09 +0000</pubDate>
		<dc:creator>firestorm_v1</dc:creator>
				<category><![CDATA[Embedded devices]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[microcontroller]]></category>
		<category><![CDATA[Parallax]]></category>
		<category><![CDATA[RFID]]></category>

		<guid isPermaLink="false">http://www.yourwarrantyisvoid.com/?p=491</guid>
		<description><![CDATA[Hello Everyone!   If you&#8217;ve been in a Radio Shack sometime in the last year or so, you&#8217;ll know that Radio Shack and Parallax have teamed up to bring some variety to the parts drawers.  This once $50 serial RFID reader kit is now $10 at Radio shack although it only comes with two tags.  Read [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_492" class="wp-caption aligncenter" style="width: 260px"><a href="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/06/32390-M.jpg"><img class="size-full wp-image-492" title="Parallax RFID" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/06/32390-M.jpg" alt="" width="250" height="250" /></a><p class="wp-caption-text">Image courtesy of Parallax.com</p></div>
<p style="text-align: left;">Hello Everyone!   If you&#8217;ve been in a Radio Shack sometime in the last year or so, you&#8217;ll know that Radio Shack and Parallax have teamed up to bring some variety to the parts drawers.  This once $50 serial RFID reader kit is now $10 at Radio shack although it only comes with two tags.  Read more for additional details about the Serial RFID reader now on sale!<span id="more-491"></span></p>
<p style="text-align: left;">The Parallax Serial RFID reader is 5 volt TTL compatible signalling and requires two I/O pins.  One is output for the &#8220;enable&#8221; pin which when brought low, turns on the RFID reader.  The tag data comes in on another pin to be read by your 5V TTL compatible microcontroller.   If you are using the 5V Basic Stamp or the 3.3V (5V tolerant) Propeller, then this is just a snap-in add on, no additional hardware is required.  Other controllers may require additional voltage converters to drop the TTL signal down to a voltage compatible for your controller.</p>
<p style="text-align: left;">Also take note that this is a 125kHz tag reader, so reading your company&#8217;s HID RFID tag will more than likely not work unless you have a 125kHz tag.</p>
<p style="text-align: left;">You can find the full datasheet, sample code and schematics from <a href="http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/rfid/List/0/SortField/4/ProductID/114/Default.aspx" target="_blank">Parallax&#8217;s product web page here</a>.</p>
<p style="text-align: left;">If two tags just aren&#8217;t going to cut it, you can take a look at all of <a href="http://www.parallax.com/tabid/768/txtSearch/rfid+tag/List/0/SortField/4/Default.aspx" target="_blank">Parallax&#8217;s tags here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yourwarrantyisvoid.com/2010/06/14/parts-parallax-rfid-scanner-now-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Basic Stamp: A quick guide on using a legacy joystick</title>
		<link>http://www.yourwarrantyisvoid.com/2010/02/03/basic-stamp-a-quick-guide-on-using-a-legacy-joystick/</link>
		<comments>http://www.yourwarrantyisvoid.com/2010/02/03/basic-stamp-a-quick-guide-on-using-a-legacy-joystick/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 20:28:19 +0000</pubDate>
		<dc:creator>firestorm_v1</dc:creator>
				<category><![CDATA[Embedded devices]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[How-To's]]></category>
		<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[microcontroller]]></category>
		<category><![CDATA[Parallax]]></category>

		<guid isPermaLink="false">http://www.yourwarrantyisvoid.com/?p=356</guid>
		<description><![CDATA[In this post, we&#8217;ll be going over the basics of using an old regular PC-gameport joystick with Parallax&#8217;s Basic Stamp powered Boe-Bot.  This howto will have all the information you need to get started including code, schematics and a parts list.  We will be covering how the joystick is wired and how to go about [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="aligncenter size-full wp-image-357" title="BS2 joystick header image" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/BS2_Joystick.jpg" alt="Joystick + Basic Stamp BOE-BOT = World Domination" width="477" height="102" /></p>
<p style="text-align: left;">In this post, we&#8217;ll be going over the basics of using an old regular PC-gameport joystick with Parallax&#8217;s Basic Stamp powered Boe-Bot.  This howto will have all the information you need to get started including code, schematics and a parts list.  We will be covering how the joystick is wired and how to go about interfacing it with the Boe-Bot for an easy to use and easy to expand analog control method for your Boe-Bot.  Next step, world domination!<span id="more-356"></span></p>
<h2 style="text-align: left;">Foreword</h2>
<p style="text-align: left;">The joystick is something that has been around quite a long time, even longer than computers.  The idea of being to control something on-screen by using a joystick is one that takes almost no learning curve,  is easy to start and you only end up getting better.  Even today in modern gaming, it is easy to find controllers with at least one analog joystick on it.  My Xbox 360 controllers feature two sticks per controller which give the gamer a very precise method for movement and aiming accuracy, something that buttons can&#8217;t quite provide.  As long as I&#8217;ve been working on computers, I always remember using PC analog joysticks in my games.</p>
<p style="text-align: left;">Nowadays, the modern PC joystick has all but gone the way of the dodo, however those few that are around now are USB and have a ton of buttons.  The legacy joystick (or &#8220;gameport&#8221; joystick) still has a bit of usefulness in it and today we will be covering how to get it to work with a Basic Stamp microcontroller.</p>
<p style="text-align: left;">Of course someone&#8217;s going to ask, &#8220;Why use a PC joystick?, Why not (insert control method here)?&#8221;.  My answers are:</p>
<p style="text-align: left;">1:  Cost &#8211; The PC joystick used in this tutorial was bought at a Goodwill for $3.</p>
<p style="text-align: left;">2: Ease of use &#8211; Once you have programmed your application, you just grab it and go. There&#8217;s no need to go over complex control methods or trying to remember what does what now.</p>
<p style="text-align: left;">3: Low Parts Count &#8211; In this tutorial, I used two capacitors and six resistors to get the joystick working.  Most other control schemes require a lot more parts.</p>
<h2 style="text-align: left;">Basic Theory of Operations</h2>
<p>The way an analog PC joystick works is not very complex at all.  You have a stick which is capable of moving any position along two axes (X and Y) and with two switches or &#8220;buttons&#8221; for interaction.  The position of the stick is detected via two variable resistors usually around 10Kohm, one running horizontal (left/right) and one running vertical (towards you/away from you).  The computer would send a pulse out to the joystick and get return values from the variable resistors.  Using the returned pulse it could then decide on what action to take, how far/fast to move your character, etc..</p>
<p>The two buttons (or more) are detected through simple momentary contact switches. If the switch pin was high, then the button was depressed otherwise, the button was released.  These button switches are normally open and while the gameport pinout supports up to four buttons, additional buttons were made by figuring out how to multiplex them as shown in the chart below:<img class="aligncenter size-full wp-image-361" title="Analog Joystick Button Map" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/buttonmap.jpg" alt="Analog Joystick Button Map" /></p>
<p>When using the PC gameport joystick, you would need to go through calibration which taught the computer the limits of your axes and the button layout.  Because variable resistors are not terribly accurate across manufacturers this calibration was a requirement as no two joysticks, not even those made by the same manufacturer,  would behave exactly alike. There would always be minute differences between the joystick&#8217;s behaviors so the calibration was a way to standardize the measurements and clean up the inaccuracy of the joystick.</p>
<p>In our tutorial, we will be using a two-button model.  This joystick is a very standard stick and has a trigger button and a thumb switch button.  It connects to the computer via a 15 pin D-sub connector usually to the sound card which has a Gameport connector on it.  This connector is usually orange on newer motherboards, if it exists at all.<a href="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/DSCF0500.jpg"><img class="aligncenter size-medium wp-image-362" title="standard PC joystick" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/DSCF0500-300x225.jpg" alt="standard PC joystick" width="300" height="225" /></a></p>
<p>On the bottom of this joystick, there are two sliders.  These two sliders can be used to &#8220;tune&#8221; the position of the VRs in order to be able to get the best range of motion for the stick.  You may need to use these during the next step for calibration.  Here is a picture of the bottom of my joystick.  The large circular things are suction cups which help keep the base down on the table while you move the joystick around:</p>
<p><a href="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/DSCF0508.jpg"><img class="aligncenter size-medium wp-image-369" title="Underside of jostick" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/DSCF0508-300x225.jpg" alt="Underside of joystick" width="300" height="225" /></a></p>
<p>After taking the bottom off, we can  see the setup of the two variable resistors (VRs).  Unlike most joysticks this one uses linear VRs and not the rotary VRs (sometimes called pots) that are commonly found for volume controls. We have oneVR on the left for the Y axis, and the other one along the bottom for the X axis, some support hardware and a small PCB:</p>
<p><a href="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/DSCF0502.jpg"><img class="aligncenter size-medium wp-image-363" title="opened joystick" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/DSCF0502-300x225.jpg" alt="opened joystick" width="300" height="225" /></a></p>
<p>The little circuit board at the top of the stick doesn&#8217;t conceal any electronics, It&#8217;s only a bypass as shown in these next two images:<a href="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/DSCF0503.jpg"><img class="aligncenter size-medium wp-image-366" title="closeup view of PCB" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/DSCF0503-300x225.jpg" alt="closeup view of PCB" width="300" height="225" /></a></p>
<p>This picture is of the bottom of the circuit board, As stated before, this only acts as a pass through to make wiring the joystick easier during production.<a href="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/DSCF0505.jpg"><img class="aligncenter size-medium wp-image-367" title="backside of PCB" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/DSCF0505-300x225.jpg" alt="backside of PCB" width="300" height="225" /></a></p>
<p>Here is a picture of one of the two linear variable resistors.  These are 100Kohm but yours might be different:<a href="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/DSCF0504.jpg"><img class="aligncenter size-medium wp-image-368" title="linear variable resistors" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/DSCF0504-300x225.jpg" alt="linear variable resistors" width="300" height="225" /></a></p>
<p>Now that the joystick has been opened up and we know all it&#8217;s secrets, it&#8217;s time to start on the interface for the BOE-BOT.</p>
<h2>The interface circuit</h2>
<p>The interface for your joystick is actually quite simple.  You will need the following items:</p>
<ul>
<li>A 15 pin female D-sub connector with ribbon cable &#8211; I used the one from an old PC that I had many years ago.  The long ribbon was perfect for this job.</li>
<li>4x 220ohm resistors</li>
<li>2x 10K resistors</li>
<li>2x .1uF capacitors &#8211; Note: I used ceramic capacitors in my project as they are easier to work with however in theory electrolytic capacitors should work as well. If you use electrolytics, please pay careful attention to the polarity as electrolytics can explode if hooked in backwards and may risk hurting you and/or damaging your microcontroller.</li>
<li>Jumper wire as needed</li>
</ul>
<p>This will provide the basic parts needed to perform our calibration test.  You will need to hook up the parts as shown in this schematic below.  Click on the image for a full size one if you need it.</p>
<p><a href="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/joystick-schematic.jpg"><img class="aligncenter size-medium wp-image-370" title="joystick schematic" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/joystick-schematic-300x205.jpg" alt="joystick schematic" width="300" height="205" /></a></p>
<p>Here is a full pinout of the PC gameport connector that shows all of the various things that the pins are used for: (<a href="http://pinouts.ru/Inputs/GameportPC_pinout.shtml" target="_blank">Pinouts obtained from pinouts.ru &#8211; a good site to have handy</a>)<a href="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/joystick-pinout.jpg"><img class="aligncenter size-medium wp-image-372" title="joystick pinout" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/joystick-pinout-300x201.jpg" alt="Joystick pinout" width="300" height="201" /></a></p>
<p>In my D-Sub connector, pin 4 and pin 5 are shorted together however this may be done either at the joystick end or in your D-sub cable as well. When in doubt, test it with a multimeter.  If you find that during your calibration test, your buttons do not respond at all try examing those two pins to make sure that they are both shorted together.  <strong>WARNING!</strong> Although the pinouts.ru pinout provided above has some things labeled &#8220;Ground&#8221; and &#8220;+5VDC&#8221; use my schematic as the final verdict.   The reason for this is the pinouts.ru site describes the joystick&#8217;s gameport connector on a computer.  Since we are not using a computer and this is not a digital joystick, I have changed some of the meanings of the pins as shown in my schematic.  If you hook it up differently, you might damage your microcontroller.</p>
<h2>Calibration Software</h2>
<p>Now that the interface is built, we need to write the code needed for making the BOE-BOT &#8220;read&#8221; the joystick and to make it do stuff.  We will be using the RCTIME<span style="text-decoration: underline;"> </span>function of the Basic Stamp to charge and time the two .1uF capacitors.  By timing their discharge rates, we can then mathematically calculate the position of the joystick.</p>
<p>As far as the buttons go, they are just as easy as any other two buttons for your microcontroller.  The BOE-BOT will monitor pin2 and 3 and if they are brought high (by pushing a button) the BS2 will sense it and perform whatever action you have programmed.  For now, we are just getting the calibration information and to make sure everything works properly.  The tags for &#8220;Lights&#8221; and &#8220;Horn&#8221; will come in the next section.</p>
<p>You can download the source code called &#8220;BS2_joystick_diagnostics.bs2&#8243; from my downloads page, or <a href="http://www.yourwarrantyisvoid.com/downloads/files/BS2_joystick_diagnostics.bs2" target="_blank">here is the direct link</a> You might need to right click on the link and go to &#8220;Save As&#8221;.</p>
<p>After loading it into your BOE-BOT, be sure to leave a debug window open, as this is where you can see the RCTIME counts and the buttons.  You may  notice that the values will be all over the place and will constantly be changing but this is normal.  Play around with it a bit and get a general feel for how your joystick works.</p>
<p>If for some reason, your RCTIME is stuck at 0, this indicates that the Basic Stamp is not seeing the capacitor or is not sensing the capacitor&#8217;s discharge.  You will need to check your wiring to make sure everything&#8217;s lined up. If need be, you can use a 100Kohm resistor between pins 1 and 3 or between pins 1 and 6  on your 15 pin D-sub connector to test.  If RCTIME shows up there, then use the multimeter on your joystick&#8217;s D-sub cable and make sure that you can see the resistance changing on those two sets of pins.  If you get no connection on the joystick, you could have a bad joystick on your hands.</p>
<p>Here are the images of my RCTIME output along with a picture showing the position of my joystick.  You will have different numbers, but the format is still the same.</p>
<div id="attachment_377" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/0-position.jpg"><img class="size-medium wp-image-377" title="Center or &quot;zero&quot; position" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/0-position-300x256.jpg" alt="Center or &quot;zero&quot; position" width="300" height="256" /></a><p class="wp-caption-text">Center or &quot;zero&quot; position</p></div>
<div id="attachment_380" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/X-left.jpg"><img class="size-medium wp-image-380" title="X (horizontal) axis left" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/X-left-300x255.jpg" alt="X (horizontal) axis left" width="300" height="255" /></a><p class="wp-caption-text">X (horizontal) axis left</p></div>
<div id="attachment_381" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/X-right.jpg"><img class="size-medium wp-image-381" title="X (horizontal) axis right" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/X-right-300x238.jpg" alt="X (horizontal) axis right" width="300" height="238" /></a><p class="wp-caption-text">X (horizontal) axis right</p></div>
<div id="attachment_383" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/Y-up.jpg"><img class="size-medium wp-image-383 " title="Y (vertical) axis up" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/Y-up-300x183.jpg" alt="Y axis (vertical) up" width="300" height="183" /></a><p class="wp-caption-text">Y (vertical) axis up</p></div>
<div id="attachment_382" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/Y-down.jpg"><img class="size-medium wp-image-382" title="Y (vertical) axis down" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/Y-down-300x225.jpg" alt="Y (vertical) axis down" width="300" height="225" /></a><p class="wp-caption-text">Y (vertical) axis down</p></div>
<div id="attachment_378" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/Button-0.jpg"><img class="size-medium wp-image-378" title="Button 0 pressed" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/Button-0-300x210.jpg" alt="Button 0 pressed" width="300" height="210" /></a><p class="wp-caption-text">Button 0 pressed</p></div>
<div id="attachment_379" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/Button-1.jpg"><img class="size-medium wp-image-379" title="Button 1 pressed" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/01/Button-1-300x212.jpg" alt="Button 1 pressed" width="300" height="212" /></a><p class="wp-caption-text">Button 1 pressed</p></div>
<p style="text-align: left;">Once you have a &#8220;feel&#8221; for how the joystick responds, let&#8217;s actually do something with this. You will need to figure out the zones on where to apply the speed settings.   The BS2_Rover application contains routines that can filter out and adjust pulses sent to the servos however this requires a bit of calibration (hence the calibration application).  All you need to do is to figure out where your joystick should switch between off and low, low and medium and lastly medium and high.    The reason for this is that for precise movements, we don&#8217;t want the BOE-BOT to lurch out of control, and while high speed all the time might not be a bad idea, it can be cumbersome trying to get into a small space with it.</p>
<h2>Getting it to work</h2>
<p>Go ahead and download the file &#8220;BS2_joystick_rover.bs2&#8243; from my Downloads page or via <a href="http://www.yourwarrantyisvoid.com/downloads/files/BS2_joystick_rover.bs2" target="_blank">this direct link.</a> Load it up in your Basic Stamp Editor  as now we need to make some adjustments to it.  I&#8217;m pretty sure that your joystick will behave differently than mine will which is why my code won&#8217;t work out of the box.  Well let me rephrase that, the CODE will work, but the joystick calibration will be off.   Using the calibration application above, you can get the RCTIME values needed to make the servo speeds and the directions work properly.  Look at my speed chart below and you will get a better understanding how the BS2 rover works:</p>
<p style="text-align: center;"><a href="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/02/speed-chart.jpg"><img class="aligncenter size-full wp-image-390" title="speed chart - fear my awesome mspaint skillz..." src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/02/speed-chart.jpg" alt="speed chart" width="569" height="158" /></a></p>
<p>With this chart you can see at which points the BOE-BOT will change speeds.  You will need to make a similar chart for your joystick using the calibration program and then you can edit the BS2 Rover file and add those settings in the two GOSUB statements.  The DEADZONE is important as this is the point where your stick&#8217;s RCTIMEs will fall when no one is touching the joystick.  It is important to have a deadzone that matches your joystick to prevent your BOE-BOT from running away from you.</p>
<p>Something of note is that my chart starts at &#8220;1&#8243; and not &#8220;0&#8243;.  This is because if the VR is at minimum resistance RCTIME will still return a &#8220;1&#8243;.   The only time RCTIME will return a 0 is if there is no load for the capacitor to discharge to, for instance when the joystick is disconnected.  In the event that RCTIME does return a 0, then we will send out the same pulses as what we send out in our deadzone so that way our BOE-BOT does not move once the joystick is unplugged.</p>
<p>Here&#8217;s how the two subroutines work in a nutshell.  You start off with a pulse value of 200 and depending on where your RCTIME is, you will either add to it which makes the servo rotates one direction at one of three speeds or you will subtract from it which will make the servo rotate the other direction at one of three speeds.  Once the comparisons are done,  you add a constant value of 550 to the pulse value.  This pulse value will then get pulsed out to the servos and the wheel turns.</p>
<p>The reason 550 was selected was because 550+200 = 750 which is the point at which your servos do nothing. In the speed chart below, we can see how the offset affects the servo pulses and how each of the two items correspond with the speed levels:</p>
<p><a href="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/02/speed-chart-w-servo-pulses.jpg"><img class="aligncenter size-full wp-image-392" title="speed chart with servo pulses" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/02/speed-chart-w-servo-pulses.jpg" alt="speed chart with servo pulses" width="709" height="254" /></a>So now that you understand the two subroutines, go ahead and edit them to match your joystick&#8217;s behavior and desired positions.</p>
<h2>Extra fun stuff</h2>
<p>Now that we have the complex part out of the way, we can also instruct the BOE-BOT to do something when we press the buttons on the joystick.  I have added a buzzer, a 220 ohm resistor and an LED to the last schematic so that now when we press the trigger button, the piezo buzzer will make a beep-beep sound and when you hit the thumb button, you will see the LED turn on and off.   Here is the updated schematic with our new parts. (Click on it for a full size image)</p>
<p><a href="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/02/joystickschematic2.jpg"><img class="aligncenter size-medium wp-image-393" title="Joystick Schematic 2" src="http://www.yourwarrantyisvoid.com/wp-content/uploads/2010/02/joystickschematic2-300x264.jpg" alt="Joystick Schematic 2" width="300" height="264" /></a></p>
<p>Once you have made the needed changes to your code, there&#8217;s one last thing that needs to be done before you upload it to your BOE-BOT.  Check one last time and make sure everything is set properly, otherwise you might have unexpected results.  If all looks well, go ahead and upload then try it out.</p>
<p style="text-align: left;">Here is a video I made of my BOE-BOT in action.  For this test, I used a white ultrabright LED which produced a lot more light than the standard LEDs that came with the BOE-BOT.</p>
<p style="text-align: center;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" 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/kZrFU7r2F74&amp;hl=en_US&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/kZrFU7r2F74&amp;hl=en_US&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>The &#8220;chugging&#8221; motion is normal.  This is the BOE-BOT, checking the RCTIME of X, pulsing out the X servo, checking RCTIME of Y, pulsing out the Y servo, checking the buttons then repeating itself.  Since the BOE-BOT is a single-process chip, it can only do one thing at a time otherwise the motion would be a lot smoother than it is.   If you are using the Propeller, you will get smoother action out of it by dedicating a COG to monitoring the joystick&#8217;s X and Y axes, and another COG to controlling the servos.</p>
<h2>Last words</h2>
<p>Using an analog joystick for your robotics projects can be an excellent way to bring an easy and intuitive interface for robot control into your project and I hope that this article shows you how easy it is to use.  It doesn&#8217;t take any fancy coding, expensive hardware or overkill designs, just some basic knowledge of how RCTIME works and a few bucks for the joystick. With a minimal part count, you can increase the flexibility of your robot&#8217;s design quite easily and you might even save yourself some programming headaches later on.</p>
<p>As always, thank you for reading.</p>
<p>FIRESTORM_v1</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yourwarrantyisvoid.com/2010/02/03/basic-stamp-a-quick-guide-on-using-a-legacy-joystick/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

