<?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>Starlino Electronics</title>
	<atom:link href="http://www.starlino.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.starlino.com</link>
	<description>Electronics and Robotics Projects, Tutorials, Reviews, Experiments</description>
	<lastBuildDate>Wed, 15 May 2013 15:11:20 +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>Shpero &#8211; a robotic project success story</title>
		<link>http://www.starlino.com/shpero-a-robotic-project-success-story.html</link>
		<comments>http://www.starlino.com/shpero-a-robotic-project-success-story.html#comments</comments>
		<pubDate>Wed, 15 May 2013 14:56:33 +0000</pubDate>
		<dc:creator>starlino</dc:creator>
				<category><![CDATA[Benchmarks and Reviews]]></category>

		<guid isPermaLink="false">http://www.starlino.com/?p=644</guid>
		<description><![CDATA[I recently got my first Sphero and I have to admit as with any new product I was skeptical in the beginning. However just after few minutes of playing with it I had to admit – boy, this stuff really works and is&#160; lots of fun !&#160; Sphero is a simple ball (well, not so [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.amazon.com/gp/product/B005ONTD42/ref=as_li_qf_sp_asin_tl?ie=UTF8&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B005ONTD42&amp;linkCode=as2&amp;tag=librarian06-20" target="_blank"><img alt="http://orbotix.wpengine.netdna-cdn.com/wp-content/uploads/2013/05/Lifestyle2013-4535.jpg" src="http://orbotix.wpengine.netdna-cdn.com/wp-content/uploads/2013/05/Lifestyle2013-4535.jpg" width="720" height="480" /></a></p>
<p>I recently got my first Sphero and I have to admit as with any new product I was skeptical in the beginning. However just after few minutes of playing with it I had to admit – boy, this stuff really works and is&#160; lots of fun !&#160; Sphero is a simple ball (well, not so simple on the inside) robot that you can control via your tablet or phone via bluetooth (major devices supported). There are many available apps on the market besides the stock control app. It also has a nice SDK that allows to use Sphero for your own projects. Because it contains an IMU sensor inside, Sphero can be used as controller for a game or application. </p>
<p>Only few years ago Shpero was just a crazy idea. Now Ortobotix is a company with dozens of employees. As it happens with many new projects Sphero was not perfect from the start. At their lowest point the founders (Ian Bernstein and Adam Wilson) admit they were so depressed that they were contemplating to pull out of CES 2011 at the last moment. Then something magical happened and the team was able to sort out all problems making it a hit at 2011th CES ! Morale of the story – never give up! </p>
<p>To find out more about the Sphero’s success story read up here:&#160; <a title="http://www.gosphero.com/tag/startup/" href="http://www.gosphero.com/tag/startup/">http://www.gosphero.com/tag/startup/</a> .&#160; Sphero is available on <a href="http://www.amazon.com/gp/product/B005ONTD42/ref=as_li_qf_sp_asin_tl?ie=UTF8&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B005ONTD42&amp;linkCode=as2&amp;tag=librarian06-20" target="_blank">Amazon</a> and other retailers. Get yourself one, I guarantee it – it’s not just a toy but also a great research tool if you’re into electronics or robotics !</p>
<p>//s//</p>
]]></content:encoded>
			<wfw:commentRss>http://www.starlino.com/shpero-a-robotic-project-success-story.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tenma 72-7740 Autorange Multimeter Review</title>
		<link>http://www.starlino.com/tenma-72-7740-autorange-multimeter-review.html</link>
		<comments>http://www.starlino.com/tenma-72-7740-autorange-multimeter-review.html#comments</comments>
		<pubDate>Wed, 03 Apr 2013 20:40:07 +0000</pubDate>
		<dc:creator>starlino</dc:creator>
				<category><![CDATA[Benchmarks and Reviews]]></category>
		<category><![CDATA[multimiter tenma review]]></category>

		<guid isPermaLink="false">http://www.starlino.com/?p=637</guid>
		<description><![CDATA[When it comes to test equipment a hobbyist is often asking himself &#8211; should I invest in top of the line equipment or can I compromise and go with a mid-range or even low-end version ? It obviously depends on the budget you have. The truth is that not everyone has $300-$500 dollars to invest [...]]]></description>
				<content:encoded><![CDATA[<p>When it comes to test equipment a hobbyist is often asking himself &#8211; should I invest in top of the line equipment or can I compromise and go with a mid-range or even low-end version ? It obviously depends on the budget you have. The truth is that not everyone has $300-$500 dollars to invest in a top-of-the-line multimeter.</p>
<p>In this article I will review the <a href="http://www.newark.com/tenma/72-7740/multimeter-digital-handheld-3-3/dp/02J5541" target="_blank">Tenma 72-7740 Multimiter</a> which aims to provide most of the functionality of an advanced multimeter , but at a lower price. So let&rsquo;s see how well it does it.</p>
<p>First let&rsquo;s have a glance at the specs of this device:</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2013/04/tenma_mm_specs.jpg"><img alt="tenma_mm_specs" border="0" height="772" src="http://www.starlino.com/wp-content/uploads/2013/04/tenma_mm_specs_thumb.jpg" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" title="tenma_mm_specs" width="538" /></a></p>
<p>&nbsp;</p>
<p>These specs are not the best you can get , but very reasonable for the price tag you pay (around $72 at <a href="http://www.newark.com/tenma/72-7740/multimeter-digital-handheld-3-3/dp/02J5541" target="_blank">element14</a>). For instance a Fluke 87-V could give you a DC Accuracy of 0.05%+1 but at a much higher price tag.</p>
<p>Next let&rsquo;s go through some features of this millimeter and examine them in more detail.</p>
<p><strong>Box Contents</strong></p>
<p><a href="http://www.starlino.com/wp-content/uploads/2013/04/20130305_154702.jpg"><img alt="20130305_154702" border="0"  src="http://www.starlino.com/wp-content/uploads/2013/04/20130305_154702_thumb.jpg" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" title="20130305_154702" width="740" /></a></p>
<p>&nbsp;</p>
<p>The box contents are: the multimeter, a set of probes (sharp ends and decent quality) , a temperature probe, the manual and the battery.</p>
<p><strong>Basic Operation, Look and Feel</strong></p>
<p>The multimeter seems well build, no flimsy parts , the dial does not have well defined detents so it is actually possible to move it to a position between two points. The stand is solid an you can operate the dial and buttons with one hand while the multimeter is resting on stand.</p>
<p><strong>Autoranging&nbsp; Feature</strong></p>
<p>I tested the auto-ranging speed of this multimeter in Voltage mode and it seems to lock within 2 seconds &#8211; pretty impressive and much faster then I expected. The lack of a bargraph that you would find on a higher end multimeter is however a minus and you might miss some fluctuations that cannot be represented by the digit display. Other measurements such as Resistance and Capacitance seem to be slower to lock but still fairly fast.</p>
<p><strong>Voltage Measurements</strong></p>
<p>Perhaps 90% of measurements you do with a multimeter are voltage measurements. And this multimeter does it well and within specs &ndash; no complains here. If you don&rsquo;t like the autoranging feature you can switch to a fixed range by pressing the &ldquo;Range&rdquo; button.</p>
<p><strong>Resistance Measurements</strong></p>
<p>Seems to be within specs, however if you touch the leads of the probes the multimeter will start with a value that seems to be the true resistance of the probes (~0.4Ohm) but then will slowly decrease to (0 Ohm). This seems to be a very odd behavior, perhaps some &ldquo;clever&rdquo; way to compensate for the resistance of the probes,&nbsp; but I would prefer it showing the true value of the leads resistance, rather then trying to compensate for it. If I would want to exclude the resistance of the leads , I could press the REL button while touching the leads, thus nulling out the leads&rsquo; resistance.</p>
<p><strong>Current Measurements</strong></p>
<p>In current mode this multimeter has a considerable internal resistance, this is particularly noticeable in the low-current ranges. So be aware if you measure small currents this multimeter might actually affect your current by as much as 10% based on my tests.</p>
<p><strong>Temperature Measurements</strong></p>
<p>Seems to be within specs, however while the rating of the multimeter is &ldquo;up to 1000C&rdquo;, the black insulation on the supplied probe will start to melt at about 300C &ndash; it seems to be a regular shrink wrap tube.&nbsp; So if you&rsquo;re planning to measure anything near 1000C you will need a different probe.</p>
<p><strong>Capacitance Measurements</strong></p>
<p>Seems to work well. I recommend pressing the REL button before measurement to compensate for the capacitance of the leads. One annoying fact about this multimeter but also others is the lack of the pico-farad range.</p>
<p><strong>Frequency / Duty Cycle Measurement</strong></p>
<p>Seems to work as advertised &ndash; a very useful feature if you don&rsquo;t have an oscilloscope available for basic frequency/duty cycle measurement , however when I fed a certain round number frequency like&nbsp; 1000Hz from my frequency generator , it always seems to show one least significant digit lower like 999.9Hz. Since these are digital measurements I don&rsquo;t think it is so hard to be spot on &hellip; especially on lower frequencies.</p>
<p><strong>Backlight</strong></p>
<p>The backlight is non-uniform, the diffuser seems to fail doing its job. The green color is very &ldquo;retro&rdquo;. However honestly,&nbsp; if I ever find myself using a multimeter in the dark I wouldn&rsquo;t complain much as long as I can see the numbers .</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2013/04/20130305_154806.jpg"><img alt="20130305_154806" border="0" height="148" src="http://www.starlino.com/wp-content/uploads/2013/04/20130305_154806_thumb.jpg" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" title="20130305_154806" width="244" /></a></p>
<p><strong>Teardown</strong></p>
<p>The multimeter is held together with two screws that are hidden behind the rubber feet. However to completely remove the cover you need to reach two plastic latches with a flat screwdriver on the other side. There&rsquo;s a basic shield, that is basically a piece of foil laminated in plastic &ndash; not sure how effective it is especially because the shielding is only on one side. The screws are self-tapping type , no metal inserts. The buzzer is mounted on the cover and two springs on the PCB are used to make contact with the buzzer. Input protection has two fuses &ndash; you need to remove the cover to replace them, it would be better if they were accessible from the battery compartment. There are no hanging wires &ndash; which is good , battery connectors are mounted on the PCB. The bottom part of the PCB has some calibration pots.</p>
<p>&nbsp;</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2013/04/IMG_6974.jpg"><img alt="IMG_6974" border="0"  src="http://www.starlino.com/wp-content/uploads/2013/04/IMG_6974_thumb.jpg" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" title="IMG_6974" width="740" /></a></p>
<p>&nbsp;</p>
<p>By removing more screws and flipping over the PCB we can reveal more components:</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2013/04/IMG_6976.jpg"><img alt="IMG_6976" border="0"  src="http://www.starlino.com/wp-content/uploads/2013/04/IMG_6976_thumb.jpg" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" title="IMG_6976" width="740" /></a></p>
<p>The main processor is a CS7721CN (by SEMICO). I couldn&rsquo;t find the datasheet for this chip however an interested reader could fish it out on Google with some more research. The other 8-pin chip is marked as 220Z3 , again couldn&rsquo;t find any info on it but I suspect it is either an ADC or an op-amp chip.</p>
<p>The assembly quality seems to be decent &#8211; mostly SMD parts. As you can see the input protection is very basic, no serious PCB isolation, or blast protection walls on the case. Although the multimeter is rated CAT IV 600V / CAT III 1000V, some might not be conmfortable using it at such high voltages given the very basic input protection.</p>
<p><strong>Conclusion</strong></p>
<p>The Tenma 72-7740 is an affordable multimeter that has some advanced functions that can be found on higher end multimeters. It is a good compromise for those constrained by budget. It certainly does its job in the voltage measurements department, but some of the add-on features need some more refinement. Still a good value for the abundance of features that you get for the price.</p>
<p><strong>Thanks:</strong></p>
<p>Many thanks to <a href="http://www.newark.com/" target="_blank">element14</a> for providing this sample for review. For the full line of digital multimeters that element14 has to offer please visit: <a href="http://www.newark.com/digital-multimeter" title="http://www.newark.com/digital-multimeter">http://www.newark.com/digital-multimeter</a>.</p>
<p>//s//</p>
]]></content:encoded>
			<wfw:commentRss>http://www.starlino.com/tenma-72-7740-autorange-multimeter-review.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing the QuadHybrid &#8211; a stable, maneuverable and cheap flying robotic platform</title>
		<link>http://www.starlino.com/quadhybrid_intro.html</link>
		<comments>http://www.starlino.com/quadhybrid_intro.html#comments</comments>
		<pubDate>Sun, 02 Dec 2012 17:34:33 +0000</pubDate>
		<dc:creator>starlino</dc:creator>
				<category><![CDATA[Fun Projects]]></category>
		<category><![CDATA[IMU Theory and Experiments]]></category>
		<category><![CDATA[Quadcopter]]></category>
		<category><![CDATA[Robotics]]></category>
		<category><![CDATA[imu]]></category>
		<category><![CDATA[mcu]]></category>
		<category><![CDATA[motor]]></category>
		<category><![CDATA[pic]]></category>
		<category><![CDATA[quadcopter]]></category>
		<category><![CDATA[rc]]></category>

		<guid isPermaLink="false">http://www.starlino.com/?p=624</guid>
		<description><![CDATA[Introduction &#38; Demo of the QuadHybrid Design I’ve been experimenting for quite a while with different configurations of Multi-Copters and RC Helicopters, basically looking for a stable robotic platform that can be used for my machine vision or other sensor-enabled flying robotic projects. RC helicopters have been around for quite a while, however (with the [...]]]></description>
				<content:encoded><![CDATA[<h1>Introduction &amp; Demo of the Quad<em><u>Hybrid</u></em> Design</h1>
<p>I’ve been experimenting for quite a while with different configurations of Multi-Copters and RC Helicopters, basically looking for a stable robotic platform that can be used for my machine vision or other sensor-enabled flying robotic projects. RC helicopters have been around for quite a while, however (with the exception of some 3-Channel helicopters) they are not easy to fly, not very stable and not too precise in maneuverability – in other words not exactly good match for a flying robot. Then came the quadcopters and everyone loved them, talked about them , and eventually wanted to or actually built one.&#160; I built a few &#8211; and what I learned is that&#160; they have a great lifting power, great maneuverability (basically equivalent to a 4ch or 6ch heli), however&#160;&#160; they rely entirely and heavily on relatively expensive IMU sensors&#160; to achieve this stability.&#160; I a QuadCopter you basically have four “monster” motors on each beam than must be synchronized precisely. Because you’re controlling so much power with your IMU sensors &#8211; any small deviation or lack of callibration and your platform is no longer stable. That’s why the sensors are crucial in a quadcopter&#160; &#8211; without them the quadcopter will not fly at all !&#160; </p>
<p>After many trial designs – my conclusion was that a suitable flying robotic platform must not rely too much (or at all) on its sensors to be stable while hovering. It must be mechanically symmetric, preferably with it’s center of mass in the center.&#160; At the same time it must have the maneuverability&#160; capabilities of a quadcopter –&#160; and namely I wanted it to fly sideways, forward &amp; back&#160; and rotate around its axis. Although the solution I came up with might seem to some (including myself) a little strange&#160; and out of the ordinary –&#160; as turned out it flew surprisingly well , was very stable and maneuverable, and best of all – had a very low price tag due to the fact that it was easy to built from the off-the-shelf toy helicopter replacement parts.</p>
<p>Without further adieu – below is the picture of the machine that I called “QuadHybrid”:</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/12/image.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.starlino.com/wp-content/uploads/2012/12/image_thumb.png" width="740" height="500" /></a></p>
<p><em>My very first QuadHybrid prototype.</em></p>
<p>Below you can see some flying test video:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:f57e9f50-73b4-4e1f-95a3-e2b3d0dec400" class="wlWriterEditableSmartContent">
<div><object width="733" height="411"><param name="movie" value="http://www.youtube.com/v/jf2GU_pO5OY?hl=en&amp;hd=1"></param><embed src="http://www.youtube.com/v/jf2GU_pO5OY?hl=en&amp;hd=1" type="application/x-shockwave-flash" width="733" height="411"></embed></object></div>
</div>
<p>&#160;</p>
<h1>So What Exactly is a Quad<u><em>Hybrid</em></u> ?</h1>
<p>Let’s have a closer look at QuadHybrid’s pictures. A simple way to look at it is:&#160; a co-axial helicopter on top of a quadcopter &#8211; it’s actually as simple as that. </p>
<p>In total QuadHybrid has 6 motors and 6 propellers (2 large one center from the helicopter + 4 small on each arm from the quadcopter).</p>
<p><strong>The two large center propellers in the center </strong>consist of 2 heli-type blades – they provide all the lifting power needed. They spin in opposite directions to compensate for the yaw rotation introduced by any rotating propeller and are stabilized by an <em>optional</em> vertically mounted MEMS gyroscope&#160; (the only sensor used in this design). The slight difference in speed of the top and bottom blades is used to control the desired yaw rotation.&#160; Thus the center motors provide the throttle and yaw control of the QuadHybrid – in other words ability to fly up/down or rotate about its center vertical axis.</p>
<p><strong>The four small rotors on the four arms</strong> are actually small tail motors from a 3ch helicopter, they provide the remaining maneuverability&#160; functions – pitch/roll or – or in other words the ability to fly&#160; forward &amp; backwards or shift sideways&#160; (right / left) .&#160; </p>
<p>The resemblance to a quadcopter and a helicopter can be seen in the picture below where they are put side by side.</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/12/QuadHybrid_Origins.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="QuadHybrid_Origins" border="0" alt="QuadHybrid_Origins" src="http://www.starlino.com/wp-content/uploads/2012/12/QuadHybrid_Origins_thumb.jpg" width="740" height="441" /></a></p>
<p>&#160;</p>
<p><em></em></p>
<h1>How Does a Quad<em><u>Hybrid</u></em> Work and How to Build One</h1>
<p>QuadHybrid has all the maneuverability of a 4 channel helicopter or a quadcopter (throttle, yaw, pitch and roll). A 3 channel helicopter as we know it &#8211; only has 3 controls (throttle, yaw and pitch). The problem with a co-axial 4CH helicopter for instance is that it relies on a swash plate and servos to achieve the pitch/roll control. Basically it is a servo mechanism for tilting the axis of rotation of the bottom rotor – it is not easy to fine tune and it needs frequent maintenance. A 3CH toy helicopters on the other hand relies on a tail rotor to achieve the pitch control – and this is one of the ideas I used for QuadHybrid – basically I multiplied the tail boom and rotor on a 3CH helicopter by four.</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/12/eh-ek-e303ra-7_3.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="eh-ek-e303ra-7_3" border="0" alt="eh-ek-e303ra-7_3" src="http://www.starlino.com/wp-content/uploads/2012/12/eh-ek-e303ra-7_3_thumb.jpg" width="640" height="448" /></a></p>
<p><em>This is how a typical 4CH helicopter is build. Please note that the bottom blade can be tilted by using 2 servos that tilt the swashplate. In the QuadHybrid design we are going to eliminate the servos and the swashplate and replace them with 4 small motors mounted on 4 arms (beams), just like on a quadcopter.</em></p>
<p>I built my QuadHybrid, from spare RC or “toy” heli&#160; parts. They are widely available and thanks to the fact that manufactures copy each other in some cases bluntly, these parts are compatible in many cases&#160; so I was able to mix-and-match. I took the electronics from a E-Sky Lama V3 helicopter&#160; &#8211; that is a 4 channel heli so it has a swashplate and 2 servos to control the pitch and roll. Because I didn’t wanted the swashplate (the roll/pitch on QuadHybrid is controlled by the 4 small quadcopter style rotors), I used the frame and blades from another toy helicompter&#160; – Syma S001 and I was able to fit the Esky motors into that frame which are bigger and more powerful than the S001 stock motors.&#160; </p>
<p>To clarify the design let’s look at the guts of the E-Sky Lama V3 helicopter . I actually used all electronics in this 4CH helicopter, except the servos (as will become clearer in the next diagram):</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/12/lama_v3_electronics.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="lama_v3_electronics" border="0" alt="lama_v3_electronics" src="http://www.starlino.com/wp-content/uploads/2012/12/lama_v3_electronics_thumb.jpg" width="740" height="405" /></a></p>
<p>&#160;</p>
<p>The main idea of the QuadHybrid design is: to achieve a better Pitch/Roll&#160; control I replaced the servos with a custom control board called “QuadHybrid Controller V1”. This board basically takes the servo RC signals (Pitch and Yaw) as inputs and controls the 4 arm motors using a set of 4 transistors. This allows QuadHybrid to fly just like a quadcopter in “+”&#160; or “X”&#160; configurations (for explanation of “+” or “X”&#160; flying configurations&#160; see for example <a title="http://technicaladventure.blogspot.com/2012/09/quadcopter-stabilization-control-system.html" href="http://technicaladventure.blogspot.com/2012/09/quadcopter-stabilization-control-system.html">http://technicaladventure.blogspot.com/2012/09/quadcopter-stabilization-control-system.html</a>).</p>
<p>&#160;</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/12/QuadHybrid_electronics.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="QuadHybrid_electronics" border="0" alt="QuadHybrid_electronics" src="http://www.starlino.com/wp-content/uploads/2012/12/QuadHybrid_electronics_thumb.jpg" width="740" height="776" /></a></p>
<p>&#160;</p>
<p>On the mechanical part &#8211; the swashplate on the bottom blade was replaced with a fixed blade mount from a 3CH helicopter. This made the bottom blade of the 4CH fixed. Normally on a 4CH heli it is being tilted by servos that are connected to the swashplate using 2 links.</p>
<p><img border="0" alt="Main Rotor Head" src="http://www.esky-heli.com/images/products_detail/esky/ek1h-e300ya/ek1h-e300ya_2_s.jpg" width="280" height="210" /></p>
<p><em>This is a swashplate assembly on a 4Ch helicopter it is the black disk under the blades mount. It is connected to the blade mount with two links. Two servos that are controlled by the RC receiver are able to tilt the swashplate and thus alter the axis of rotation of the bottom blade. This is how the roll and pitch is controlled in a 4 channel helicopter. It is far from perfect and requires frequent tune-ups.</em></p>
<p>&#160;</p>
<p><img src="http://dominicanewsonline.com/news/wp-content/uploads/awpcp/1309266683_1.jpg" width="700" height="337" /></p>
<p><em>A gyro-stabilized co-axial 3 channel toy helicopter is fairly stable, as opposed to a 4CH helicopter- it uses the tail rotor to control the pitch (flying forward or backward). Note the bottom blade is fixed , just like on the QuadHybrid.</em></p>
<p><em></em></p>
<h1>Quad<em><u>Hybrid</u></em> Controller Board and Software</h1>
<p>Below is the schematic of the QuadHybrid V1 controller (the blue board on the diagram above that controls the 4 motors). This is the only custom component that is not available from RC toys parts.</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/12/image1.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.starlino.com/wp-content/uploads/2012/12/image_thumb1.png" width="740"  /></a></p>
<p>At the heart of the QuadHybrid V1 controller board is a PIC16F1825 microcontroller – it’s main task is to capture the servo signals received on ports RA5(ROLL) and RA4(PITCH) and convert them&#160; to 4 PWM signals that control the 4 rotors mounted on arms. The motors are driven using 4 NPN transistors – these can be any NPN transistors as long as they have a current rating of at least 1A (or the maximum current of your arm-mounted motors) and a low Collector-Emitter resistance (&lt; 0.3Ohm or so).&#160; MOSFET could be used instead of NPN transistors, with slight schematic change &#8211; however I found hard to source them in an easy to solder and light-weight TO-92 package so I used NPNs instead.</p>
<p>QuadHybrid V1 controller board operates by default in “+” configuration. If you want to operate it in “X” configuration then connect the X_CONF jumper – this will give you better control with smaller motors , since for example flying forward will activate two motors at once (3 &amp; 2). The only thing to keep in mind when flying in “X” configuration is that the “Front” is a imaginary line between arm #0 and #1 .</p>
<p>QuadHybrid V1 PCB was created as a all through-hole design so that anyone can assemble it and covert a toy RC helicopter into a QuadHybrid:</p>
<p><img alt="http://uploads.oshpark.com/uploads/project/top_image/BaiOVPXQ/thumb_i.png" src="http://uploads.oshpark.com/uploads/project/top_image/BaiOVPXQ/thumb_i.png" /></p>
<p>For anyone wishing to spend time on creating their own QuadHybrid V1 controller board – source code and Eagle files are available on the <a href="https://code.google.com/p/quadhybrid-v1/source/browse/#svn%2Ftrunk%2F%20quadhybrid-v1" target="_blank">SVN repository</a>, otherwise easy to solder kits will be available in my <a href="http://www.starlino.com/store" target="_blank">Store</a>.</p>
<p>If you would like just to peak over the source code here is a direct link:</p>
<p><a title="https://code.google.com/p/quadhybrid-v1/source/browse/trunk/%20quadhybrid-v1/src/main.c" href="https://code.google.com/p/quadhybrid-v1/source/browse/trunk/%20quadhybrid-v1/src/main.c">https://code.google.com/p/quadhybrid-v1/source/browse/trunk/%20quadhybrid-v1/src/main.c</a></p>
<p>As you can see it is a fairly simple project a(for anyone familiar with C&#160; and microcontrollers) and a good placeholder for further improvements and add-ons. </p>
<p>&#160;</p>
<h1>Mechanical Construction</h1>
<p>On top of QuadHybrid prototype is basically a stripped down frame of a 3ch helicopter and namely it comes from Syma S001:</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/12/image2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.starlino.com/wp-content/uploads/2012/12/image_thumb2.png" width="740" height="452" /></a></p>
<p>&#160;</p>
<p>Under the frame are 2 aluminum tubing pieces that form the 4 arms. At the end of each arm I attached a tail rotor from the same Syma S001 helicopter model:</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/12/image3.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.starlino.com/wp-content/uploads/2012/12/image_thumb3.png" width="740" height="452" /></a></p>
<p>&#160;</p>
<p>Then, to house all the electronics and battery I just sandwiched two perforated&#160; boards with nylon spacers (Tip: most bolts,nuts and spacers used in this design are nylon-made to lower the weight) :</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/12/image4.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.starlino.com/wp-content/uploads/2012/12/image_thumb4.png" width="344" height="560" /></a></p>
<p>For landing gear I just used a RC helicopter training kit that consist of a round bracket attached to the bottom deck, four carbon fiber rods and four (orange) ping-pong balls:</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/12/image5.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.starlino.com/wp-content/uploads/2012/12/image_thumb5.png" width="740" height="452" /></a></p>
<p><strong></strong></p>
<p><strong>Please note that: </strong>although all the mechanical parts are from a 3Channel helicopter (Syma S001), you will need electronics from a 4Ch helicopter! The main reason for using a 3CH helicopter for mechanical part is because the bottom blade bracket was already fixed (3Ch helicopters have no swashplate):</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/12/image6.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.starlino.com/wp-content/uploads/2012/12/image_thumb6.png" width="344" height="560" /></a></p>
<p>&#160;</p>
<p>It might be more economical to get a 4Ch helicopter (mainly for its electronics that support pitch &amp; roll not just pitch as a 3Ch helicopter) and then just remove the servos and the swashplate and then fix the bottom blade bracket using screws and/or glue.&#160; As I did in the photo below (E-Sky Big Lama parts shown):</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/12/image7.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.starlino.com/wp-content/uploads/2012/12/image_thumb7.png" width="724" height="436" /></a></p>
<p>&#160;</p>
<p>As an alternative to fixing the bottom blade bracket, you can also get a fixed blade bracket from a 3CH helicopter &#8211; it must be same inner diameter as the one from your 4CH helicopter. The diameter of the outer drive shafts are typically 4mm ( and 5mm , 6mm and even 8mm for larger helicopters).</p>
<p>Esky helicopters are best to use in terms of electronics because they have standard signal RC protocols in their transmitter / receiver boards that you can tap-into to get the Pitch/Roll signals needed for the QuadHybrid controller board. Syma helicopters integrated boards are harder to hack into &#8211; <a href="http://www.kerrywong.com/2012/08/27/reverse-engineering-the-syma-s107g-ir-protocol/" target="_blank">however some people have managed</a> to hack into them and reverse engineer the signals.</p>
<p>&#160;</p>
<p><em></em></p>
<h1>Conclusion: What are The Advantages and Disadvantages of the Quad<u><em>Hybrid</em></u> Design over a traditional QuadCopter or a RC Helicopter </h1>
<p>While building the QuadHybrid&#160; I selected the best features of a quadcopter and a helicopter and put them together, this resulted in a machine that took the best of the two worlds:</p>
<p>- QuadHybrid is mechanically symmetrical and stable. As opposed to a QuadCopter it does not rely on sensor to achieve this, the main hovering stability comes from the co-axial design and the centrifugal momentum of the fly-bar (the black bar on top of the blades with two weights on each side) – this is basically the same principle at work as in <a href="www.youtube.com/watch?v=DsOU0WEc6OU&amp;list=UUeQEKFH31vvD-InkTGSvCrA" target="_blank">a mechanical gyroscope</a>.     </p>
<p>- QuadHybrid only requires two lifting “powerful” motors, the other 4 small motors are used for steering and are not crucial for device stability. There’s no need for motors to be brushless, and no need for brushless ESC controllers, they can be cheap RC-type brushed motors that can be driven by MOSFETs or transistors, there’s no need to reverse rotation of any motors, however it will be a feature in V2 of the controller board. Also there’s no need for CW and CCW propellers for the motors mounted on arms. All this vastly reduces the complexity and cost of the design.     </p>
<p>- Partial or complete failure of any motor will still keep device in the air and give the operator/program a good chance to land it safely. In the worst case scenario – if a driving motor fails , the device will loose lifting power and will spin in the air, but will still at least stay on it’s vertical axis. In case of a quadcopter &#8211; failure of any motor is fatal – it will basically flip the quadcopter, or make it fly sideways with great chance to hit something. This is of course debatable, but in any case statistics tells us that the probability of one of the 4 motors to fail is twice of that of one of the two motors to fail (and economics tells us it’s also cheaper to get two motors than four).&#160; Failure of any arm-mounted motor on a QuadHybrid is not critical, the device will still hover in the air and can be landed safely.     </p>
<p>- Safety (we all know it should be first). A QuadCopter without&#160; shielded high-powered rotors is a pretty dangerous device,&#160; its propellers are spinning with an incredible force and are ready to cut into anything that falls in their way – they can do a lot of damage to humans, pets or property. QuadHybrid only has four low-powered motors on its arms since they are only used for steering, not lifting. The center driving propellers on a QuadHybrid are shielded away by its arms, also they have a folding design, so if they hit something it will somewhat make the impact less destructive.&#160; Overall QuadHybrid is more suitable for indoor applications such as schools , universities or research facilities. Make no mistake though &#8211; QuadHybrid&#160; can&#160; still do damage and safety procedures must he observed at all times !     </p>
<p>Few advantages of Quadcopters over QuadHybrid worth mentioning may be:</p>
<p>- because they have four powerful motors, Quadcopters&#160; have greater lifting power. However this is more of a “brute-force” advantage – one could always get more powerful motors and battery for a QuadHybrid to achieve the desired lift power.    </p>
<p>- Quadcopters can do some serious aerobatics (if you’re a good pilot)&#160; including fly upside down or do 3D stunts. This is not really an advantage for some people, specifically when you are actually trying to build a nice and stable robotic platform – on the contrary it’s more something you try to avoid.&#160; </p>
<p><strong>In conclusion:</strong> although this first version of QuadHybrid was not designed to do 3D stunts or fly with high speeds –&#160; it has a great hovering and maneuvering stability. I think it will find most of its use as a highly stable and controllable indoor flying robotic platform. However similar spin-offs could be expected to be developed for flying outdoors and/or with higher speeds.</p>
<p>&#160;</p>
<p>//starlino//</p>
<p><em>This article is dedicated to all my math and science teachers ! </em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.starlino.com/quadhybrid_intro.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>USB firmware debugging with USBTrace, PicKit &amp; MPLAB IDE</title>
		<link>http://www.starlino.com/usb-firmware-debugging-with-usbtrace-pickit-mplab-ide.html</link>
		<comments>http://www.starlino.com/usb-firmware-debugging-with-usbtrace-pickit-mplab-ide.html#comments</comments>
		<pubDate>Mon, 24 Sep 2012 03:22:26 +0000</pubDate>
		<dc:creator>starlino</dc:creator>
				<category><![CDATA[Benchmarks and Reviews]]></category>
		<category><![CDATA[Tricks and Tips]]></category>
		<category><![CDATA[c18]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[debugger]]></category>
		<category><![CDATA[firmware]]></category>
		<category><![CDATA[interrupt]]></category>
		<category><![CDATA[mplab]]></category>
		<category><![CDATA[pic]]></category>
		<category><![CDATA[PicKit]]></category>
		<category><![CDATA[serial]]></category>
		<category><![CDATA[usart]]></category>
		<category><![CDATA[usb]]></category>
		<category><![CDATA[USBTrace]]></category>
		<category><![CDATA[volatile]]></category>

		<guid isPermaLink="false">http://www.starlino.com/?p=582</guid>
		<description><![CDATA[Ah, the joy of firmware debugging! I’ve been working on a USB firmware for my new upcoming product that involves a dual traditional TTL (Serial) and a USB-TO-SERIAL converter (CDC Communication Port) implemented in the same firmware. The firmware was written in C18 , using the USB stack from Microchip Applications Libraries. Everything worked well [...]]]></description>
				<content:encoded><![CDATA[<p>Ah, the joy of firmware debugging! I’ve been working on a USB firmware for my new upcoming product that involves a dual traditional TTL (Serial) and a USB-TO-SERIAL converter (CDC Communication Port) implemented in the same firmware. The firmware was written in C18 , using the USB stack from <a href="https://www.google.com/search?q=microchip applications libraries" target="_blank">Microchip Applications Libraries</a>.</p>
<p>Everything worked well until I suddenly discovered that while sending data over the CDC port from the computer to the device, the device would *sometimes* receive garbage data instead of what I sent. This wouldn’t be so discouraging if the data received would be the same, or at least this would happen always not *sometimes*.&#160; The bug was caught in the act on the screenshot below, the arrows show the data I actually sent ‘stop’ followed by LF (0xA) char and the character codes (in decimal) actually received. This is garbage because 92,162,62,180 are note the ASCII chars for ‘stop’.&#160; Please note that this will only occur *sometimes*, however I could almost consistently repeat it after several retries of sending a command to the device.</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/09/image.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.starlino.com/wp-content/uploads/2012/09/image_thumb.png" width="575" height="436" /></a></p>
<p>The tracking of this bug turned out to be so adventurous and involved that I decided to write a tutorial about it. It involved some tools that I didn’t use often before, but now they proved indispensable in locating this furry and fuzzy code pest . As you’ll see at the end of the article the bug was pretty obvious at least for me (I already made this mistake many times , but forgot about it), however it might be really useful for someone just starting working with microcontrollers,&#160; C and/or&#160; interrupts. It also provides an opportunity to review some tools I used in the process.</p>
<p>So where do we go from here ? Same data is send over a USB CDC Serial Emulator Port&#160; but sometimes the microcontroller receives garbage instead of the original data. A general rule of thumb is – start at the source and go up. Let’s identify the possible problems:</p>
<p><strong>#1&#160; &#8211; the computer terminal, or USB driver has gone crazy, it is sending something else instead of what was typed     <br /></strong>#2&#160; &#8211; there’s a hardware noise problem on the USB lines    <br />#3&#160; &#8211; there’s a bug in the Microchip USB Stack    <br />#4&#160; &#8211; there’s a bug in my code </p>
<p>Ok so we start with #1 , how do we see that the terminal is actually sending the correct data ? We need a way to see the actual packets send via USB. For someone who had a hardware USB protocol analyzer it would be a good time to power it up. Unfortunately these devices are really costly (let me know in the comments if I am wrong and you know any affordable solutions), and luckily for us there are decent software USB protocol analyzers that we can use instead. The tool that I used and that I highly recommend is <a href="http://www.sysnucleus.com/" target="_blank">USBTrace</a>. It is not free , but still affordable and a great value that will pay off if you value your debug time. The reason I like USBTrace is that is so easy to use. You know a good product because after you start it you don’t have to read a manual to perform a basic function. Once I started USBTrace on the left side I was able to find a list of all USB devices, it was easy to track down my virtual CDC Serial port because in the bottom panel I could see the device descriptors. Please note that I also had connected a FTDI serial converter that I could have confused with my device. However my device had some strings in the descriptor that I recognized from my firmware such as “CDC RS-23 Emulation Demo”. Once I checked my device I was ready to click the green Run buttons. And the packets started pouring in … </p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/09/image1.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.starlino.com/wp-content/uploads/2012/09/image_thumb1.png" width="740"  /></a></p>
<p>Wow , that was an overwhelming number of packets! My device was in streaming mode and sending a lot of data to the EndPoint #82. I only needed data that I send to device so how do I do that ? Again USBTrace was great and very intuitive , clicked on the funnel icon (Filter) and I got following dialog:</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/09/image2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.starlino.com/wp-content/uploads/2012/09/image_thumb2.png" width="327" height="590" /></a></p>
<p>Here I was able to set the Direction of the packet – OUT. Please note that for USB packets , by convention , the direction is as looking from host &#8211; so OUT from computer to device. I also set the CDC OUT endpoint as specified in my firmware #2, finally I set the request type to BULK_OR_INTRRUPT_TRANSFER.</p>
<p>Now all I had to do is to send the ‘stop’ command couple of times until the bug happened again, that was easy to spot since the streaming would not stop once garbage was received. And once it happened, I checked the contents of the last packet in USBTrace, and what do I see:</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/09/image3.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.starlino.com/wp-content/uploads/2012/09/image_thumb3.png" width="731" height="328" /></a></p>
<p>The data is completely correct, so my first guess is ruled out. Let the bug hunt continue. Moving on to #2.</p>
<p><strong>#2 &#8211; there’s a hardware noise problem on the USB lines</strong></p>
<p>I had a look at the cables, I had a look at the device, I knew the hardware setup worked perfectly before. If I had a hardware USB analyzer I would hook it up. But I didn’t so I took a leap of faith and I skipped #2. This wasn’t by the books. However it was all I could do in reasonable time. So moving on to #3.</p>
<p><strong>#3 &#8211; there’s a bug in the Microchip USB stack</strong></p>
<p>Once you download the USB stack, and integrate into your project , it becomes part of your project. So tracking Microchip’s bug was no different than tracking my own code bug. So I moved to #4 and handled #3 in the same step. </p>
<p><strong>#4 &#8211; there’s a bug in my code</strong> </p>
<p>Ok so here we are in the MPLAB IDE 8.83. My PIC device is capable of up to 4 Hardware breakpoints. This means that the MCU can halt on specific memory locations, it also can halt when a specific memory location is written or read.&#160; By scanning through the USB Stack code, I found that it stores the incoming&#160; USB CDC data in the cdc_data_rx[] buffer . From the .map file I was able to determine that this buffer address is starting at 0xE08. The MAP file is basically a file the compiler creates and where you can find all your variables and code and at what address they are stored, look for it in the same folder where you output .hex file is.</p>
<p>Setting a memory breakpoint is accomplished by clicking on the “ADV.B”&#160; blue button in the debugger toolbar, this brings up a dialog like this:</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/09/image4.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.starlino.com/wp-content/uploads/2012/09/image_thumb4.png" width="521" height="529" /></a></p>
<p>I just punched in the address of my buffer, selected access type as Write. Now when the first byte in the incoming CDC buffer is written with good / or garbage data the code should break and point me to where the data writing happened. Again I stared sending data, and I had to click on the green debug run icon couple of times, to skip through good cases until the bad garbage write happened. The MPLAB debugger didn’t stop every time the bad case happened , I am not sure if this is a limitation of the debugger or something caused by my code bug, but finally it stopped at a place where I defined some code that was executed inside an interrupt.</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/09/image5.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.starlino.com/wp-content/uploads/2012/09/image_thumb5.png" width="492" height="332" /></a></p>
<p>This is the code for receiving the data over the other port the TTL USART, not the one having problems CDC Serial !&#160; It basically fills out a buffer called usart_rx_buf, but this not the cdc_data_rx buffer so how could they interfere?&#160; Eureka ! Buffer overflow &#8211; the index used to access the buffer byte&#160; uasart_rx_pos was going crazy out of bounds. Indeed I looked at how usart_rx_pos was declared:</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/09/image6.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.starlino.com/wp-content/uploads/2012/09/image_thumb6.png" width="351" height="27" /></a></p>
<p>The only other place where this variable was used was in this non-interrupt code:</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/09/image7.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.starlino.com/wp-content/uploads/2012/09/image_thumb7.png" width="717" height="141" /></a></p>
<p>Now this is a big problem, let’s look at the last statement</p>
<p>usart_rx_pos = 0</p>
<p>If we look at the disable of this instruction, on a PIC 8 bit controller we can see that it takes actually 2 instruction to complete it:</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/09/image8.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.starlino.com/wp-content/uploads/2012/09/image_thumb8.png" width="503" height="53" /></a></p>
<p>This is because this is a 2 bytes variable . Now think what would happen if the interrupt happens between these two instructions. The interrupt mentioned above modifies the variable. So while the main code thinks it has “0” in usart_rx_pos, in fact it only sets to 0 the second part of the variable the first one could have been modified by an interrupt! Thus the unpredictable behavior … usart_rx_pos becomes a random variable which causes the buffer overflow. Data is written at random locations in program memory . Scarrrrrry !</p>
<p>So how did this happened , even if&#160; “I’ve been there done that” many times ? Well the timer interrupt code was not inside an interrupt initially , I later migrated it to an interrupt and forgot to do a sanity check of variable types. In fact I don’t need an int for usart_rx_pos (the buffer is smaller than 255). So I changed it’s declaration&#160; to:</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/09/image9.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.starlino.com/wp-content/uploads/2012/09/image_thumb9.png" width="418" height="121" /></a></p>
<p>Now that writing of one byte is done in single instruction there’s no risk of corruption by an interrupt updating same variable. However as we’ll see below this is only part of the solution. Below is the disassembly code of writing 0 to a one byte variable:</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/09/image10.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.starlino.com/wp-content/uploads/2012/09/image_thumb10.png" width="740"  /></a></p>
<p>Please note that I also added an important ‘volatile’ specification in front of all variables modified by the interrupt code.&#160; Actually the lack of ‘volatile’ was my second guess why the bug happened. Without ‘volatile’ compiler might think that there’s no other place where the variable can change besides the spot it compiles. So it might optimize the code in weird ways. Here is an example, if a variable is not volatile the compiler could theoretically update this code </p>
<p>x =&#160; 1;   <br />y = 0;    <br />x = 1;</p>
<p>to simply</p>
<p> x = 1;  <br />y = 0;  <br /> 
<p>It removes the second assignment of x since it considers it redundant, while in fact if you have an interrupt executing let’s say before y=0 , and modifying x=0 thus in this case the&#160; x=1 at the end is necessary ! So ‘volatile’ basically tells the compiler that a variable can change suddenly ‘out of the blue’ and it should take care while optimizing the code and not to remove any assignments even if they look redundant.</p>
<p>I’ll now present my final solution to ensure the interrupt code does not modify usart_rx_pos and usart_rx_buf&#160; while we’re processing it in non-interrupt code.&#160; The solution is to prevent the interrupt from happening during that time. No worries, if interrupt has to happen while it was disabled by us -&#160; there ‘s usually&#160; a flag set and the interrupt will happen eventually once we’re re-enabling it. Because the processing in session_new_char() might take a while (and you don’t want to disable USART receiving interrupts for a long time) my strategy was to declare two SAFE non-volatile variables and copy data over quickly then re-enable the interrupt. Please note that this code would work fine even if usart_rx_pos was an int (dual instruction assignment) :</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/09/image11.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.starlino.com/wp-content/uploads/2012/09/image_thumb11.png" width="444" height="51" /></a></p>
<p>&#160;</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2012/09/image12.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.starlino.com/wp-content/uploads/2012/09/image_thumb12.png" width="740"  /></a></p>
<p>&#160;</p>
<p>Please note that I didn’t have to disable all interrupts, it was enough to disable only the interrupts that would cause our variable to be modified (the USART Receive interrupt). It’s enabled&#160; or disabled by the RC1IE flag in PIE1 register.</p>
<p>After testing this new code, the problem was gone. So now I am thinking “everything is for the best” , I spent some time tracing a bug, but I learned along the way and sure thing&#160; I wrote this tutorial so I never again forget that interrupts can modify variables when you don’t expect to !</p>
<p>Bottom line:</p>
<p>A.&#160; Declare variables modified in interrupts as&#160; ‘volatile’ to stop compiler doing nasty things to them    <br />B.&#160; Disable the interrupts that can modify those variables, while working with these variables in a non-interrupt code (both reading and writing), this will create a so called ‘atomic’ code, called so because it cannot be split by an interrupt.     <br />C.&#160; Keep ‘the atomic’ code short &#8211; the interrupts can wait , but not for too long in some cases.&#160; For example the hardware USART buffer on my device only has 2 bytes – so it would get filled and lost soon if the processing done in the interrupt&#160;&#160; would be halted for too long.    <br />D. Have fun. Life is beautiful even when debugging <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://www.starlino.com/wp-content/uploads/2012/09/wlEmoticon-smile.png" /></p>
<p>/starlino/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.starlino.com/usb-firmware-debugging-with-usbtrace-pickit-mplab-ide.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Add a simple mechanical fine tune control to any bench instrument without voiding warranty</title>
		<link>http://www.starlino.com/add-a-simple-mechanical-fine-tune-control-to-any-bench-instrument-without-voiding-warranty.html</link>
		<comments>http://www.starlino.com/add-a-simple-mechanical-fine-tune-control-to-any-bench-instrument-without-voiding-warranty.html#comments</comments>
		<pubDate>Fri, 11 Nov 2011 00:11:19 +0000</pubDate>
		<dc:creator>starlino</dc:creator>
				<category><![CDATA[Tricks and Tips]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[fine-tune]]></category>
		<category><![CDATA[power supply]]></category>

		<guid isPermaLink="false">http://www.starlino.com/add-a-simple-mechanical-fine-tune-control-to-any-bench-instrument-without-voiding-warranty.html</guid>
		<description><![CDATA[I was looking for a way to make the adjustment for my power supply more precise and easier to dial let&#8217;s say to a voltage like 3.3 , but without a built-in fine tune potentiometer this was difficult so I found one of those foam rings that are always on top of a CD box, [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.starlino.com/wp-content/uploads/2011/11/image.png"><img alt="image" border="0" height="461" src="http://www.starlino.com/wp-content/uploads/2011/11/image_thumb.png" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" width="614" /></a></p>
<p>I was looking for a way to make the adjustment for my power supply more precise and easier to dial let&rsquo;s say to a voltage like 3.3 , but without a built-in fine tune potentiometer this was difficult so I found one of those foam rings that are always on top of a CD box, and it fit perfectly over the dial making it bigger and now easier to dial any voltage. This works based on the &ldquo;gears&rdquo; principle&nbsp; &#8211; with the larger &ldquo;gear&rdquo; attached , finger has to travel a longer distance to make same change, thus easier to dial anything in between that was before harder.</p>
<p>Plain and simple, but just thought to share the non-warranty voiding trick &ndash; acceptable choice if you can&rsquo;t really open up the power supply and add a new potentiometer in series with the main one.&nbsp; I am also glad I finally found a use for those CD foam rings <img alt="Smile" class="wlEmoticon wlEmoticon-smile" src="http://www.starlino.com/wp-content/uploads/2011/11/wlEmoticon-smile.png" style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" /> If you&rsquo;re curious what power supply it is on the picture, it is a Tenma budget 10A linear power supply works well except the above mentioned lack of fine-tune dial.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.starlino.com/add-a-simple-mechanical-fine-tune-control-to-any-bench-instrument-without-voiding-warranty.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some (Free!) Feedback for TI MSP430 LaunchPad&#8217;s Development and Marketing Team</title>
		<link>http://www.starlino.com/launchpad_feedback.html</link>
		<comments>http://www.starlino.com/launchpad_feedback.html#comments</comments>
		<pubDate>Tue, 18 Oct 2011 00:54:47 +0000</pubDate>
		<dc:creator>starlino</dc:creator>
				<category><![CDATA[News and Discussions]]></category>
		<category><![CDATA[launchpad ti mcu msp430]]></category>

		<guid isPermaLink="false">http://www.starlino.com/some-free-feedback-for-ti-msp430-launchpads-development-and-marketing-team.html</guid>
		<description><![CDATA[I finally got a minute to play with the MSP430 LaunchPad Kit I received, well almost for free from TI and immediately got some feedback to share with the development and marketing team. First overall I think Launchpad is a great product and I am looking forward to seeing it improve, secondly my understanding is [...]]]></description>
				<content:encoded><![CDATA[<div class="post-content">
<p>I finally got a minute to play with the MSP430 LaunchPad Kit I received, well almost for free from TI and immediately got some feedback to share with the development and marketing team.</p>
<p>First overall I think Launchpad is a great product and I am looking forward to seeing it improve, secondly my understanding is that its targeted market is starting engineers , hobbyist and alike &hellip; and I am speaking from that perspective.</p>
<p>I know you might hate me for this and maybe this is a banned word in your company but you should really look at <b>Arduino </b> and try to understand why it became so popular, in a nutshell let me break it down:</p>
<p>- the secret is in details, you might have a better product at a better price but if you can&rsquo;t present it correctly it will not catch up with developers<br />
		- simplicity , simplicity , simplicity, too much information is as bad as no information, getting started manual DOES NOT have to be 182 pages long, half of which are telling about the entire TI lineup and various clock setup , get straight to the point show us the fun part !<br />
		- people don&rsquo;t want so many options, so you must make choices for them , for example &ndash; choose a fixed clock mode (crystal or internal clock) and make it standard, let advanced users hack it if necessary, this will also make Launchpad programs more portable if you choose and &ldquo;official&rdquo; operating clock speed.<br />
		- make a free compiler and IDE : it makes no sense to have a paid compiler and charge a developer &ldquo;pennies&rdquo; compared to what that developer can bring you in hardware sales if he uses your chips , instead of spending money on giveaways and free lunches at trade shows , etc, just give the developers a free unlimited IDE and compiler, best promotion you can make and best boost in hardware sales for the future ! It is no coincidence Arduino was based on AVR the only major MCU manufacture to have multi-platform free compilers and IDE (both Microchips and TI&rsquo;s free editions are limited and crippled).<br />
		- give free and no &ldquo;string attached&rdquo; MCU samples as Microchip has, same reason as above , you can&rsquo;t cook dinner with MCUs if someone is ordering them they are an engineer and they might make a product that will use millions of your chips in the future, if you don&rsquo;t make samples easy and fast , he might choose Microchip because today he is a student and he is broke, call it fate or whatever &ndash; unfair but fair ..<br />
		- in coding hide all the ugly details like the clock setup , in worst case scenario make a &ldquo;launchpad&rdquo; header file to contain all the technical stuff, if you make the &ldquo;blinking led&rdquo; program a one or two line program than you know you&rsquo;re on the right way !<br />
		- make changing pin direction (output / input) prettier and more straightforward and avoid the | (OR) bit assignments, in worst case you can use some macros (as I explain here <a href="../port_macro.html">http://www.starlino.com/port_macro.html</a>) , this style of assignments is confusing for beginners</p>
<p>Well that&rsquo;s it for now, i might add more ideas &hellip; so check back or contact me directly if you&rsquo;d like more feedback.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.starlino.com/launchpad_feedback.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Arduino &#8211; to clone or not to clone ?</title>
		<link>http://www.starlino.com/arduino-to-clone-or-not-to-clone.html</link>
		<comments>http://www.starlino.com/arduino-to-clone-or-not-to-clone.html#comments</comments>
		<pubDate>Wed, 27 Jul 2011 03:18:02 +0000</pubDate>
		<dc:creator>starlino</dc:creator>
				<category><![CDATA[News and Discussions]]></category>
		<category><![CDATA[arduino microchip ti]]></category>

		<guid isPermaLink="false">http://www.starlino.com/arduino-to-clone-or-not-to-clone.html</guid>
		<description><![CDATA[Microchip started marketing an Arduino clone called chipKit. Is this a correct decision to clone an open source platform as opposed to Texas Instrument&#39;s decision to create it&#39;s own platform LaunchPad ? &#160; &#160; By the way the TI&#39;s platform is really cheap, I would say cheaper than components and PCB + shipping. Obviously TI [...]]]></description>
				<content:encoded><![CDATA[<p><img border="0" height="321" src="http://www.starlino.com/wp-content/uploads/2011/07/TDGL002_chipKITTM_Uno-32TM_Web.jpg" title="" width="450" /></p>
<p>Microchip started marketing an Arduino clone called <a href="http://www.microchip.com/pagehandler/en-us/chipKIT-Development-Platform.html" target="_blank">chipKit</a>. Is this a correct decision to clone an open source platform as opposed to Texas Instrument&#39;s decision to create it&#39;s own platform <a href="http://processors.wiki.ti.com/index.php/MSP430_LaunchPad_%28MSP-EXP430G2%29" target="_blank">LaunchPad</a> ?</p>
<p>&nbsp;</p>
<p><img border="0" src="http://www.starlino.com/wp-content/uploads/2011/07/300px-LaunchPad_wireframe1.png" title="" /></p>
<p>&nbsp;</p>
<p>By the way the TI&#39;s platform is really cheap, I would say cheaper than components and PCB + shipping. Obviously TI wants more people to use it, however what it is lacking is the relaxed open-source crowd around it.</p>
<p>Is Arduino really something to follow ? What do you think ?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.starlino.com/arduino-to-clone-or-not-to-clone.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DCM Tutorial &#8211; An Introduction to Orientation Kinematics</title>
		<link>http://www.starlino.com/dcm_tutorial.html</link>
		<comments>http://www.starlino.com/dcm_tutorial.html#comments</comments>
		<pubDate>Fri, 27 May 2011 02:15:31 +0000</pubDate>
		<dc:creator>starlino</dc:creator>
				<category><![CDATA[IMU Theory and Experiments]]></category>
		<category><![CDATA[accelerometer]]></category>
		<category><![CDATA[Acc_Gyro]]></category>
		<category><![CDATA[dcm]]></category>
		<category><![CDATA[gyro]]></category>
		<category><![CDATA[gyroscope]]></category>
		<category><![CDATA[imu]]></category>
		<category><![CDATA[inclination]]></category>
		<category><![CDATA[kinematics]]></category>
		<category><![CDATA[mems]]></category>
		<category><![CDATA[orientation]]></category>
		<category><![CDATA[sensor]]></category>

		<guid isPermaLink="false">http://www.starlino.com/?p=226</guid>
		<description><![CDATA[Introduction This article is a continuation of my IMU Guide, covering additional orientation kinematics topics. I will go through some theory first and then I will present a practical example with code build around an Arduino and a 6DOF IMU sensor (acc_gyro_6dof). The scope of this experiment is to create an algorithm for fusing gyroscope [...]]]></description>
				<content:encoded><![CDATA[<h2>Introduction</h2>
<p>This article is a continuation of my <a href="http://www.starlino.com/imu_guide.html">IMU Guide</a>, covering additional orientation kinematics topics. I will go through some theory first and then I will present a practical example with code build around an Arduino and a 6DOF IMU sensor (acc_gyro_6dof). The scope of this experiment is to create an algorithm for fusing gyroscope and accelerometer data in order to create an estimation of the device orientation in space. Such an algorithm was already presented in part 3 of my &ldquo;IMU Guide&rdquo; and a practical Arduino experiment with code was presented in the &ldquo;<a href="http://www.starlino.com/imu_kalman_arduino.html">Using a 5DOF IMU</a>&rdquo; article and was nicknamed &ldquo;Simplified Kalman Filter&rdquo;, providing a simple alternative to the well known Kalman Filter algorithm. In this article we&rsquo;ll use another approach utilizing the DCM (Direction Cosine Matrix). For the reader that is unfamiliar with MEMS sensors it is recommended to read Part 1 and 2 of the IMU Guide article. Also for following the experiments presented in this text it is recommended to acquire an Arduino board and an <a href="http://www.gadgetgangster.com/367">acc_gyro_6dof</a> sensor.</p>
<h2>Prerequisites</h2>
<p>No really advanced math is necessary. Find a good book on matrix operations, that&rsquo;s all you might need above school math course. If you would like to refresh your knowledge below are some quick articles: <br />
	Cartesian Coordinate System &#8211; <a href="http://en.wikipedia.org/wiki/Cartesian_coordinate_system">http://en.wikipedia.org/wiki/Cartesian_coordinate_system</a> <br />
	Rotation &#8211; <a href="http://en.wikipedia.org/wiki/Rotation_%28mathematics%29">http://en.wikipedia.org/wiki/Rotation_%28mathematics%29</a> <br />
	Vector scalar product &#8211; <a href="http://en.wikipedia.org/wiki/Dot_product">http://en.wikipedia.org/wiki/Dot_product</a> <br />
	Vector cross product &#8211; <a href="http://en.wikipedia.org/wiki/Cross_product">http://en.wikipedia.org/wiki/Cross_product</a> <br />
	Matrix Multiplication &#8211; <a href="http://en.wikipedia.org/wiki/Matrix_multiplication">http://en.wikipedia.org/wiki/Matrix_multiplication</a> <br />
	Block Matrix &#8211; <a href="http://en.wikipedia.org/wiki/Block_matrix">http://en.wikipedia.org/wiki/Block_matrix</a> <br />
	Transpose Matrix &#8211; <a href="http://en.wikipedia.org/wiki/Transpose">http://en.wikipedia.org/wiki/Transpose</a> <br />
	Triple Product &#8211; <a href="http://en.wikipedia.org/wiki/Triple_product">http://en.wikipedia.org/wiki/Triple_product</a></p>
<h2>Notations</h2>
<p>Vectors are marked in <b>bold text </b>-<b> </b>so for example &ldquo;<b>v</b>&rdquo;<b> </b>is a vector and &ldquo;v&rdquo; is a scalar (if you can&rsquo;t distinguish the two there&rsquo;s problem with the text formatting wherever you&rsquo;re reading this).</p>
<h2>Part 1. The DCM Matrix</h2>
<p>Generally speaking orientation kinematics deals with calculating the relative orientation of a body relative to a global coordinate system. It is useful to attach a coordinate system to our body frame and call it Oxyz, and another one to our global frame and call it OXYZ. Both the global and the body frames have the same fixed origin O (see <i>Fig. 1</i>). Let&rsquo;s also define <b>i, j, k</b> to be unity vectors co-directional with the body frame&rsquo;s x, y, and z axes &#8211; in other words they are versors of Oxyz and let <b>I, J, K </b>be the versors of global frame OXYZ.</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0024.jpg"><img alt="clip_image002[4]" border="0" height="249" src="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0024_thumb.jpg" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image002[4]" width="279" /></a></p>
<p><i>Figure 1</i></p>
<p>Thus, by definition, expressed <b>in terms of global coordinates</b> vectors <b>I, J, K</b> can be written as:</p>
<p><b>I</b><sup>G</sup> = {1,0,0}<b><sup> T</sup></b>, <b>J</b><sup>G</sup>={0,1,0}<b><sup> T</sup></b> , <b>K</b><sup>G</sup> = {0,0,1}<b><sup> T </sup></b></p>
<p><i>Note: we use {&hellip;}<sup> T </sup>notation to denote a column vector, in other words a column vector is a translated row vector. The orientation of vectors (row/column) will become relevant once we start multiplying them by a matrix later on in this text.</i></p>
<p>And similarly, <b>in terms of body coordinates </b>vectors<b> i, j, k </b>can be written as:</p>
<p><b>i</b><sup>B</sup> = {1,0,0}<b><sup> T</sup></b>, <b>j</b><sup>B</sup>={0,1,0}<b><sup> T</sup></b> , <b>k</b><sup>B</sup> = {0,0,1}<b><sup> T</sup></b></p>
<p>Now let&rsquo;s see if we can write vectors <b>i, j, k </b>in terms of global coordinates. Let&rsquo;s take vector <b>i </b>as an example and write its global coordinates:</p>
<p><b>i</b><sup>G</sup> = {i<sub>x</sub><sup>G</sup> , i<sub>y</sub><sup>G </sup>, i<sub>z</sub><sup>G</sup>}<b><sup> T</sup></b></p>
<p>Again, by example let&rsquo;s analyze the X coordinate i<sub>x</sub><sup>G</sup>, it&rsquo;s calculated as the length of projection of the <b>i </b>vector onto the global X axis.</p>
<p>i<sub>x</sub><sup>G </sup>= |<b>i</b>| cos(X,<b>i</b>) = cos(<b>I</b>,<b>i</b>)</p>
<p>Where |<b>i</b>| is the norm (length) of the <b>i</b> unity vector and cos(<b>I</b>,<b>i</b>) is the cosine of the angle formed by the vectors <b>I</b> and <b>i</b>. Using the fact that |<b>I</b>| = 1 and |<b>i</b>| = 1 (they are unit vectors by definition). We can write:</p>
<p>i<sub>x</sub><sup>G </sup>= cos(<b>I</b>,<b>i</b>) = |<b>I</b>||<b>i</b>| cos(<b>I</b>,<b>i</b>) = <b>I.i </b></p>
<p>Where <b>I.i</b>. is the scalar (dot) product of vectors <b>I</b> and <b>i</b>. For the purpose of calculating scalar product <b>I.i </b>it doesn&rsquo;t matter in which coordinate system these vectors are measured as long as they are both expressed in the same system, since a rotation does not modify the angle between vectors so: <b>I.i = I</b><sup>B</sup><b>.i</b><sup>B</sup> = <b>I</b><sup>G</sup><b>.i</b><sup>G </sup>= cos(<b>I</b><sup>B</sup><b>.i</b><sup>B</sup>) = cos(<b>I</b><sup>G</sup><b>.i</b><sup>G</sup>) , so for simplicity we&rsquo;ll skip the superscript in scalar products <b>I.i , J.j , K.k </b>and in cosines<b> </b>cos(<b>I</b>,<b>i</b>), cos(<b>J</b>,<b>j</b>), cos(<b>K</b>,<b>k</b>).</p>
<p>Similarly we can show that:</p>
<p>i<sub>y</sub><sup>G</sup> = <b>J.i</b><sup> </sup>, i<sub>z</sub><sup>G</sup>=<b>K.i </b>, so now we can write vector <b>i</b> in terms of global coordinate system as:</p>
<p><b>i</b><sup>G</sup>= {<b> I.i, J.i, K.i</b>}<sup>T</sup><b> </b></p>
<p>Furthermore, similarly it can be shown that <b>j</b><sup>G</sup>= {<b> I.j, J.j, K.j</b>}<sup> T</sup><b> , k</b><sup>G</sup>= {<b> I.k, J.k, K.k</b>}<sup> T</sup>.</p>
<p>We now have a complete set of global coordinates for our body&rsquo;s versors <b>i, j, k </b>and we can organize these values in a convenient matrix form:</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0044.gif"><img alt="clip_image004[4]" border="0" height="74" src="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0044_thumb.gif" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image004[4]" width="620" /></a><i> (Eq. 1.1)</i><i> <br />
	</i></p>
<p>This matrix is called Direction Cosine Matrix for now obvious reasons &#8211; it consists of cosines of angles of all possible combinations of body and global versors.</p>
<p>The task of expressing the global frame versors <b>I</b><sup>G</sup>, <b>J</b><sup>G</sup>, <b>K</b><sup>G</sup> in body frame coordinates is symmetrical in nature and can be achieved by simply swapping the notations <b>I, J, K </b>with <b>i, j, k, </b>the results being:</p>
<p><b>I</b><sup>B</sup>= {<b> I.i, I.j, I.k</b>}<sup>T</sup><b> </b>,<b> J</b><sup>B</sup>= {<b> J.i, J.j, J.k</b>}<sup>T</sup><b> , K</b><sup>B</sup>= {<b> K.i, K.j, K.k</b>}<sup>T</sup><b> </b></p>
<p>and organized in a matrix form:</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0064.gif"><img alt="clip_image006[4]" border="0" height="74" src="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0064_thumb.gif" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image006[4]" width="620" /></a><i> (Eq. 1.2)</i></p>
<p>It is now easy to notice that DCM<sup>B</sup> = (DCM<sup>G</sup>)<sup>T </sup>or DCM<sup>G</sup> = (DCM<sup>B</sup>)<sup>T </sup>, in other words the two matrices are translates of each other, we&rsquo;ll use this important property later on.</p>
<p>Also notice that DCM<sup>B</sup>. DCM<sup>G</sup> = (DCM<sup>G</sup>)<sup>T</sup> .DCM<sup>G</sup> = DCM<sup>B</sup>. (DCM<sup>B</sup>)<sup>T</sup> = I<sub>3</sub> , where I<sub>3</sub> is the 3&#215;3 identity matrix. In other words the DCM matrices are orthogonal.</p>
<p>This can be proven by simply expanding the matrix multiplication in block matrix form:</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0084.gif"><img alt="clip_image008[4]" border="0" height="145" src="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0084_thumb.gif" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image008[4]" width="624" /></a><i> (Eq. 1.3)</i></p>
<p>To prove this we use such properties as for example: <b>i</b><sup>GT</sup>.<b> i</b><sup>G</sup> = |<b> i</b><sup>G</sup>||<b> i</b><sup>G</sup>|cos(0) = 1 and <b>i</b><sup>GT</sup>.<b> j</b><sup>G</sup> = 0 because (<b>i </b>and<b> j</b> are orthogonal) and so forth.</p>
<p>The DCM matrix (also often called the rotation matrix) has a great importance in orientation kinematics since it defines the rotation of one frame relative to another. It can also be used to determine the global coordinates of an arbitrary vector if we know its coordinates in the body frame (and vice versa).</p>
<p>Let&rsquo;s consider such a vector with body coordinates:</p>
<p><b>r</b><sup>B</sup>= {<b> </b>r<sub>x</sub><sup>B</sup>, r<sub>y</sub><sup>B</sup>, r<sub>z</sub><sup>B</sup>}<sup> T</sup> and let&rsquo;s try to determine its coordinates in the global frame, by using a known rotation matrix DCM<sup>G</sup>.</p>
<p>We start by doing following notation:</p>
<p><b>r</b><sup>G</sup> = { r<sub>x</sub><sup>G</sup> , r<sub>y</sub><sup>G</sup> , r<sub>z</sub><sup>G</sup> } <sup>T</sup>.</p>
<p>Now let&rsquo;s tackle the first coordinate r<sub>x</sub><sup>G</sup>:</p>
<p>r<sub>x</sub><sup>G</sup> = |<b> r</b><sup>G</sup>| cos(<b>I</b><sup>G</sup>,<b>r</b><sup>G</sup>) , because r<sub>x</sub><sup>G</sup> is the projection of <b>r</b><sup>G</sup> onto X axis that is co-directional with <b>I</b><sup>G</sup>.</p>
<p>Next let&rsquo;s note that by definition a rotation is such a transformation that does not change the scale of a vector and does not change the angle between two vectors that are subject to the same rotation, so if we express some vectors in a different rotated coordinate system the norm and angle between vectors will not change:</p>
<p>|<b> r</b><sup>G</sup>| = |<b> r</b><sup>B</sup>| , |<b> I</b><sup>G</sup>| = |<b> I</b><sup>B</sup>| = 1 and cos(<b>I</b><sup>G</sup>,<b>r</b><sup>G</sup>) = cos(<b>I</b><sup>B</sup>,<b>r</b><sup>B</sup>), so we can use this property to write</p>
<p>r<sub>x</sub><sup>G</sup> = |<b> r</b><sup>G</sup>| cos(<b>I</b><sup>G</sup>,<b>r</b><sup>G</sup>) = |<b> I</b><sup>B</sup> ||<b> r</b><sup>B</sup>| cos(<b>I</b><sup>B</sup>,<b>r</b><sup>B</sup>) = <b>I</b><sup>B</sup>.<b> r</b><sup>B</sup> = <b>I</b><sup>B</sup>. {<b> </b>r<sub>x</sub><sup>B</sup>, r<sub>y</sub><sup>B</sup>, r<sub>z</sub><sup>B</sup>}<sup> T</sup> , by using one the two definition of the scalar product.</p>
<p>Now recall that <b>I</b><sup>B</sup>= {<b> I.i, I.j, I.k</b>}<sup>T</sup><b> </b>and by using the other definition of scalar product:</p>
<p>r<sub>x</sub><sup>G</sup> = <b>I</b><sup>B</sup>.<b> r</b><sup>B</sup> = {<b> I.i, I.j, I.k</b>}<sup>T</sup><b> . </b>{<b> </b>r<sub>x</sub><sup>B</sup>, r<sub>y</sub><sup>B</sup>, r<sub>z</sub><sup>B</sup>}<sup> T</sup> = r<sub>x</sub><sup>B</sup><b> I.i </b>+<b> </b>r<sub>y</sub><sup>B</sup><b> I.j </b>+ r<sub>z</sub><sup>B</sup><b> I.k</b></p>
<p>In same fashion it can be shown that:</p>
<p>r<sub>y</sub><sup>G</sup> = r<sub>x</sub><sup>B</sup><b> J.i </b>+<b> </b>r<sub>y</sub><sup>B</sup><b> J.j </b>+ r<sub>z</sub><sup>B</sup><b> J.k <br />
	</b>r<sub>z</sub><sup>G</sup> = r<sub>x</sub><sup>B</sup><b> K.i </b>+<b> </b>r<sub>y</sub><sup>B</sup><b> K.j </b>+ r<sub>z</sub><sup>B</sup><b> K.k</b></p>
<p>Finally let&rsquo;s write this in a more compact matrix form:</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0104.gif"><img alt="clip_image010[4]" border="0" height="80" src="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0104_thumb.gif" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image010[4]" width="386" /></a><i> (Eq. 1.4)</i></p>
<p>&nbsp;</p>
<p>Thus the DCM matrix can be used to covert an arbitrary vector <b>r<sup>B</sup></b> expressed in one coordinate system B, to a rotated coordinate system G.</p>
<p>We can use similar logic to prove the reverse process:</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0124.gif"><img alt="clip_image012[4]" border="0" height="26" src="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0124_thumb.gif" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image012[4]" width="125" /></a><i> (Eq. 1.5)</i></p>
<p>Or we can arrive at the same conclusion by multiplying both parts in <i>(Eq. 1.4) </i>by DCM<sup>B</sup> which equals to DCM<sup>GT</sup>, and using the property that DCM<sup>GT</sup>.DCM<sup>G</sup> = I<sub>3</sub> , see (<i>Eq. 1.3)</i>:</p>
<p>DCM<sup>B</sup><b> r</b><sup>G</sup> = DCM<sup>B</sup> DCM<sup>G</sup><b> r</b><sup>B</sup> = DCM<sup>GT</sup> DCM<sup>G</sup><b> r</b><sup>B</sup> = I<sub>3</sub><b> r</b><sup>B </sup>= <b>r</b><sup>B</sup></p>
<h4>&nbsp;</h4>
<h2>Part 2. Angular Velocity</h2>
<p>So far we have a way to characterize the orientation of one frame relative to another rotated frame, it is the DCM matrix and it allows us to easily convert the global and body coordinates back and forth using <i>(Eq. 1.4) </i>and <i>(Eq. 1.5). </i>In this section we&rsquo;ll analyze the rotation as a function of time that will help us establish the rules of updating the DCM matrix based on a characteristic called angular velocity. Let&rsquo;s consider an arbitrary rotating vector <b>r </b>and define it&rsquo;s coordinates at time t to be <b>r</b>(t). Now let&rsquo;s consider a small time interval dt and make the following notations: <b>r</b> = <b>r</b> (t) , <b>r&rsquo;</b>= <b>r</b> (t+dt) and d<b>r = r</b>&rsquo; &ndash; <b>r</b>:</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0144.jpg"><img alt="clip_image014[4]" border="0" height="205" src="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0144_thumb.jpg" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image014[4]" width="199" /></a></p>
<p><i>Figure 2</i></p>
<p>Let&rsquo;s say that during a very small time interval dt &rarr; 0 the vector <b>r </b>has<b> </b>rotated about an axis co-directional with a unity vector <b>u</b><sub> </sub>by an angle d&theta; and ended up in the position <b>r&rsquo;</b>. Since <b>u </b>is our axis of rotation it is perpendicular to the plane in which the rotation took place (the plane formed by<b> r</b> and <b>r</b>&rsquo;) so <b>u </b>is orthogonal to both <b>r</b> and <b>r</b>&rsquo;. There are two unity vectors that are orthogonal to the plane formed by <b>r</b> and <b>r&rsquo;</b>, they are shown on the picture as <b>u </b>and <b>u&rsquo;</b> since we&rsquo;re still defining things we&rsquo;ll choose the one that is co-directional with the cross product <b>r</b> x <b>r&rsquo;</b>, following the rule of <a href="http://en.wikipedia.org/wiki/Right-hand_rule">right-handed coordinate system</a>. Thus because <b>u </b>is a unity vector |<b>u</b>| = 1 and is co-directional with <b>r</b> x <b>r&rsquo; </b>we can deduct it as follows:</p>
<p><b>u</b> =<b> </b>(<b>r</b> x <b>r</b>&rsquo;) / |<b>r</b> x <b>r</b>&rsquo;| =<b> </b>(<b>r</b> x <b>r</b>&rsquo;) / (|<b>r</b>||<b> r</b>&rsquo;|sin(d&theta;)) = (<b>r</b> x<b> r</b>&rsquo;) / (|<b>r</b>|<sup>2</sup> sin(d&theta;)) <i>(Eq. 2.1)</i></p>
<p>Since a rotation does not alter the length of a vector we used the property that|<b> r</b>&rsquo;| = |<b>r</b>|.</p>
<p>The linear velocity of the vector <b>r </b>can<b> </b>be defined as the vector:</p>
<p><b>v = </b>d<b>r </b>/ dt = (<b> r</b>&rsquo; &#8211; <b>r</b>) / dt <i>(Eq. 2.2)</i></p>
<p>Please note that since our dt approaches 0 so does d&theta; &rarr; 0, hence the angle between vectors <b>r</b> and d<b>r </b>(let&rsquo;s call it &alpha;)<b> </b>can be found from the isosceles triangle contoured by <b>r </b>, <b>r&rsquo; </b>and<b> </b>d<b>r: </b></p>
<p>&alpha; = (&pi; &ndash; d&theta;) / 2 and because d&theta; &rarr; 0 , then &alpha; &rarr; &pi;/2</p>
<p>What this tells us is that <b>r </b>is perpendicular to<b> </b>d<b>r</b> when dt &rarr; 0 and hence <b>r</b> is perpendicular to <b>v</b> since <b>v</b> and d<b>r</b> are co-directional from<b> </b><i>(Eq. 2.2): </i></p>
<p><b><i>v</i></b> &perp; r <i>(Eq. 2.21)</i></p>
<p>We are now ready to define the angular velocity vector. Ideally such a vector should define the rate of change of the angle &theta; and the axis of the rotation, so we define it as follows:</p>
<p><b>w </b>= (d&theta;/dt ) <b>u </b><i>(Eq. 2.3)</i></p>
<p>Indeed the norm of the <b>w</b> is |<b>w</b>| = d&theta;/dt and the direction of <b>w </b>coincides with the axis of rotation <b>u</b>. Let&rsquo;s expand <i>(Eq. 2.3) </i>and try to establish a relationship with the linear velocity <b>v:</b></p>
<p>Using <i>(Eq. 2.3) </i>and<i> (Eq. 2.1)</i>:</p>
<p><b>w </b>= (d&theta;/dt ) <b>u </b>= (d&theta;/dt ) (<b>r</b> x<b> r</b>&rsquo;) / (|<b>r</b>|<sup>2</sup> sin(d&theta;))</p>
<p>Now note that when dt &rarr; 0, so does d&theta; &rarr; 0 and hence for small d&theta;, sin(d&theta;) &asymp; d&theta; , we end up with:</p>
<p><b>w </b>= (<b>r</b> x<b> r</b>&rsquo;) / (|<b>r</b>|<sup>2</sup> dt) <i>(Eq. 2.4)</i></p>
<p>Now because <b>r</b>&rsquo; = <b>r</b> + d<b>r</b> , d<b>r</b>/dt = <b>v , r </b>x <b>r = 0 </b>and using the distributive property of cross product over addition:</p>
<p><b>w </b>= (<b>r</b> x (<b>r</b> + d<b>r)</b>) / (|<b>r</b>|<sup>2</sup> dt) = (<b>r</b> x <b>r</b> + <b>r </b>x d<b>r)</b>) / (|<b>r</b>|<sup>2</sup> dt) = <b>r </b>x (d<b>r</b>/dt) / |<b>r</b>|<sup>2</sup></p>
<p>And finally:</p>
<p><b>w </b>= <b>r</b> x <b>v </b>/ |<b>r</b>|<sup>2</sup>&shy; <i>(Eq. 2.5)</i></p>
<p>This equation establishes a way to calculate angular velocity from a known linear velocity <b>v</b>.</p>
<p>We can easily prove the reverse equation that lets us deduct linear velocity from angular velocity:</p>
<p><b>v </b>=<b> w </b>x<b> r </b>&shy; <i>(Eq. 2.6)</i></p>
<p>This can be proven simply by expanding <b>w</b> from <i>(Eq. 2.5) </i>and using vector <a href="http://en.wikipedia.org/wiki/Triple_product">triple product</a> rule (<b>a </b>x <b>b</b>) x <b>c</b> = (<b>a</b>.<b>c</b>)<b>b</b> &#8211; (<b>b</b>.<b>c</b>)<b>a</b>. Also we&rsquo;ll use the fact that <b>v </b>and<b> r </b>are perpendicular <i>(Eq. 2.21)</i> and thus <b>v</b>.<b>r </b>= 0</p>
<p><b>w </b>x<b> r </b>=<b> </b>(<b>r</b> x <b>v </b>/ |<b>r</b>|<sup>2</sup>&shy;) x <b>r </b>= (<b>r</b> x <b>v) </b>x <b>r</b> / |<b>r</b>|<sup>2</sup>&shy; = ((<b>r</b>.<b>r</b>) <b>v</b> + (<b>v</b>.<b>r</b>)<b>r</b>) / |<b>r</b>|<sup>2</sup>&shy; = ( |<b>r</b>|<sup>2</sup>&shy; <b>v</b> + 0) |<b>r</b>|<sup>2 </sup>= <b>v</b></p>
<p>So we just proved that <i>(Eq. 2.6)</i> is true. Just to check <i>(Eq. 2.6) </i>intuitively &#8211; from <i>Figure 2 </i>indeed <b>v </b>has the direction of <b>w </b>x<b> r </b>using the right hand rule and indeed <b><i>v</i></b> &perp; <b>r </b>and <b><i>v</i></b> &perp; <b>w </b>because it is in the same plane with<b> r </b>and <b>r&rsquo;</b>.</p>
<h4>&nbsp;</h4>
<h2>Part 3. Gyroscopes and angular velocity vector</h2>
<p>A 3-axis MEMS gyroscope is a device that senses rotation about 3 axes attached to the device itself (body frame). If we adopt the device&rsquo;s coordinate system (body&rsquo;s frame), and analyze some vectors attached to the earth (global frame), for example vector <b>K </b>pointing to the zenith or vector <b>I </b>pointing North &#8211; then it would appear to an observer inside the device that these vector rotate about the device center. Let w<sub>x </sub>, w<sub>y </sub>, w<sub>z </sub>be the outputs of a gyroscope expressed in rad/s &#8211; the measured rotation about axes x, y , z respectively. Converting from the raw output of the gyroscope to physical values is discussed for example here: <a href="http://www.starlino.com/imu_guide.html">http://www.starlino.com/imu_guide.html</a> . If we query the gyroscope at regular, small time intervals <b>dt, </b>then what gyroscope output tells us is that during this time interval the earth rotated about gyroscope&rsquo;s <i>x</i> axis by an angle of d&theta;<sub>x</sub> = w<sub>x</sub>dt, about <i>y</i> axis by an angle of d&theta;<sub>y</sub> = w<sub>y</sub>dt and about <i>z</i> axis by an angle of d&theta;<sub>z</sub> = w<sub>z</sub>dt. These rotations can be characterized by the angular velocity vectors: <b>w</b><sub>x<b> </b></sub>= w<sub>x</sub><b> i </b>= {w<sub>x </sub>, 0<sub> </sub>, 0<sub> </sub>}<sup>T </sup>, <b>w</b><sub>y<b> </b></sub>= w<sub>y</sub><b> j </b>= { 0<sub> </sub>, w<sub>y </sub>, 0<sub> </sub>}<sup>T</sup> , <b>w</b><sub>z<b> </b></sub>= w<sub>z</sub><b> k </b>= { 0<sub> </sub>, 0, w<sub>z </sub>}<sup>T</sup> , where <b>i,j,k </b>are versors of the local coordinate frame (they are co-directional with body&rsquo;s axes x,y,z respectively). Each of these three rotations will cause a linear displacement which can be expressed by using <i>(Eq. 2.6)</i>:</p>
<p>d<b>r</b><sub>1</sub> = dt <b>v</b><sub>1</sub><b> </b>= dt (<b>w</b><sub>x</sub><b> </b>x<b> r</b>) ; d<b>r</b><sub>2</sub> = dt <b>v</b><sub>2</sub><b> </b>= dt (<b>w</b><sub>y</sub><b> </b>x<b> r</b>) ; d<b>r</b><sub>3</sub> = dt <b>v</b><sub>3</sub><b> </b>= dt (<b>w</b><sub>z</sub><b> </b>x<b> r</b>) <i>. </i></p>
<p>The combined effect of these three displacements will be:</p>
<p>d<b>r </b>= d<b>r</b><sub>1 </sub>+ d<b>r</b><sub>2 </sub>+ d<b>r</b><sub>3 </sub>= dt (<b>w</b><sub>x</sub><b> </b>x<b> r </b>+ <b>w</b><sub>y</sub><b> </b>x<b> r </b>+<b> w</b><sub>z</sub><b> </b>x<b> r</b>) = dt (<b>w</b><sub>x</sub><b> </b>+ <b>w</b><sub>y</sub><b> </b>+<b> w</b><sub>z</sub>) x<b> r </b>(cross product is distributive over addition)</p>
<p>Thus the equivalent linear velocity resulting from these 3 transformations can be expressed as:</p>
<p><b>v</b> = d<b>r/</b>dt = (<b>w</b><sub>x</sub><b> </b>+ <b>w</b><sub>y</sub><b> </b>+<b> w</b><sub>z</sub>) x<b> r </b>= <b>w </b>x<b> r </b>, where we introduce <b>w</b> = <b>w</b><sub>x</sub><b> </b>+ <b>w</b><sub>y</sub><b> </b>+<b> w</b><sub>z</sub> = {w<sub>x </sub>, w<sub>y </sub>, w<sub>z </sub>}</p>
<p>Which looks exactly like <i>(Eq. 2.6) </i>and suggests that<i> </i>the combination of three <b>small</b> rotations about axes x,y,z characterized by angular rotation vectors <b>w</b><sub>x</sub><b> </b>, <b>w</b><sub>y</sub><b> </b>,<b> w</b><sub>z</sub> is equivalent to one <b>small</b> rotation characterized by angular rotation vector <b>w</b> = <b>w</b><sub>x</sub><b> </b>+ <b>w</b><sub>y</sub><b> </b>+<b> w</b><sub>z</sub> = {w<sub>x </sub>, w<sub>y </sub>, w<sub>z </sub>}. Please note that we&rsquo;re stressing out that these are <b>small</b> rotations, since in general when you combine large rotations the order in which rotations are performed become important and you cannot simply sum them up. Our main assumption that let us go from a linear displacement to a rotation by using <i>(Eq. 2.6) </i>was that dt is really small, and thus the rotations d&theta;<i><sub> </sub></i>and linear displacement dr are small as well. In practice this means that the larger the dt interval between gyro queries the larger will be our accumulated error, we&rsquo;ll deal with this error later on. Now, since w<sub>x </sub>, w<sub>y </sub>, w<sub>z </sub>are the output of the gyroscope, then we arrive at the conclusion that in fact a 3 axis gyroscope measures the instantaneous angular velocity of the world rotating about the device&rsquo;s center.</p>
<h2>Part 4. DCM complimentary filter algorithm using 6DOF or 9DOF IMU sensors</h2>
<p>In the context of this text a 6DOF device is an IMU device consisting of a 3 axis gyroscope and a 3 axis accelerometer. A 9DOF device is an IMU device of a 3 axis gyroscope, a 3 axis accelerometer and a 3 axis magnetometer. Let&rsquo;s attach a global right-handed coordinate system to the Earth&rsquo;s frame such that the <b>I </b>versor points North, <b>K </b>versor points to the Zenith and thus, with these two versors fixed, the <b>J </b>versor<b> </b>will be constrained to point<b> </b>West.</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0164.jpg"><img alt="clip_image016[4]" border="0" height="331" src="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0164_thumb.jpg" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image016[4]" width="359" /></a></p>
<p><i>Figure 3 </i></p>
<p>Also let&rsquo;s consider the body coordinate system to be attached to our IMU device (acc_gyro used as an example),</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0184.jpg"><img alt="clip_image018[4]" border="0" height="175" src="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0184_thumb.jpg" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image018[4]" width="257" /></a></p>
<p><i>Figure 4 </i></p>
<p>We already established the fact that gyroscopes can measure the angular velocity vector. Let&rsquo;s see how accelerometer and magnetometer measurements will fall into our model.</p>
<p>Accelerometers are devices that can sense gravitation. Gravitation vector is pointing towards the center of the earth and is opposite to the vector pointing to Zenith <b>K</b><sup>B</sup>. If the 3 axis accelerometer output is <b>A </b>= {A<sub>x </sub>, Ay , A<sub>z</sub> } and we assume that there are no external accelerations or we have corrected them then we can estimate that <b>K</b><sup>B</sup> = -<b>A</b>. (See this IMU Guide for more clarifications <a href="http://www.starlino.com/imu_guide.html">http://www.starlino.com/imu_guide.html</a>).</p>
<p>Magnetometers are devices that are really similar to accelerometers, except that instead of gravitation they can sense the Earth&rsquo;s magnetic North. Just like accelerometers they are not perfect and often need corrections and initial calibration. If the corrected 3-axis magnetometer output is <b>M </b>= {M<sub>x </sub>, My , M<sub>z</sub> }, then according to our model <b>I</b><sup>B</sup> is pointing North , thus <b>I</b><sup>B</sup> = <b>M</b>.</p>
<p>Knowing <b>I</b><sup>B</sup> and <b>K</b><sup>B</sup> allows us calculate <b>J</b><sup>B</sup> = <b>K</b><sup>B</sup> x <b>I</b><sup>B</sup>.</p>
<p>Thus an accelerometer and a magnetometer alone can give us the DCM matrix , expressed either as DCM<sup>B</sup> or DCM<sup>G </sup></p>
<p>DCM<sup>G</sup> = DCM<sup>BT</sup> = [<b>I</b><sup>B</sup>,<b> J</b><sup>B</sup>,<b> K</b><sup>B</sup>]<sup>T</sup></p>
<p>The DCM matrix can be used to convert any vector from body&rsquo;s(devices) coordinate system to the global coordinate system. Thus for example if we know that the nose of the plane has some fixed coordinates expressed in body&rsquo;s coordinate system as <b>r<sup>B</sup></b> = {1,0,0}, the we can find where the device is heading in other words the coordinates of the nose in global coordinate systems using <i>(Eq. 1.4)</i>:</p>
<p><b>r</b><sup>G</sup><b> </b>= DCM<sup>G</sup> <b>r</b><sup>B</sup></p>
<p>So far you&rsquo;re asking yourself if an accelerometer and a magnetometer gives us the DCM matrix at any point in time, why do we need the gyroscope ? The gyroscope is actually a more precise device than the accelerometer and magnetomer are , it is used to &ldquo;fine-tune&rdquo; the DCM matrix returned by the accelerometer and magnetometer.</p>
<p>Gyroscopes have no sense of absolute orientation of the device , i.e. they don&rsquo;t know where north is and where zenith is (things that we can find out using the accelerometer and magnetometer), instead if we know the orientation of the device at time t, expressed as a DCM matrix DCM(t) , we can find a more precise orientation DCM(t+dt) using the gyroscope , then the one estimated directly from the accelerometer and magnetometer direct readings which are subject to a lot of noise in form of external (non-gravitational) inertial forces (i.e. acceleration) or magnetically forces that are not caused by the earth&rsquo;s magnetic field.</p>
<p>These facts call for an algorithm that would combine the readings from all three devices (accelerometer, magnetometer and gyroscope) in order to create our best guess or estimate regarding the device orientation in space (or space&rsquo;s orientation in device&rsquo;s coordinate systems), the two orientations are related since they are simply expressed using two DCM matrices that are transpose of one another (DCM<sup>G</sup> = DCM<sup>BT </sup>).</p>
<p>We&rsquo;ll now go ahead and introduce such an algorithm.</p>
<p>We&rsquo;ll work with the DCM matrix that consists of the versors of the global (earth&rsquo;s) coordinate system aligned on each row:</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0204.gif"><img alt="clip_image020[4]" border="0" height="149" src="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0204_thumb.gif" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image020[4]" width="624" /></a></p>
<p>If we read the rows of DCM<sup>G</sup> we get the vectors <b>I</b><sup>B</sup>,<b> J</b><sup>B</sup>,<b> K</b><sup>B</sup>. We&rsquo;ll work mostly with vectors <b>K</b><sup>B</sup> (that can be directly estimated by accelerometer) and vector <b>I</b><sup>B </sup>(that can be directly estimated by the magnetometer). The vector <b>J</b><sup>B </sup>is simply calculated as <b>J</b><sup>B</sup> = <b>K</b><sup>B</sup> x <b>I</b><sup>B</sup> , since it&rsquo;s orthogonal to the other two vectors (remember versors are unity vectors with same direction as coordinate axes).</p>
<p>Let&rsquo;s say we know the zenith vector expressed in body frame coordinates at time t<sub>0</sub> and we note it as <b>K</b><sup>B</sup><sub>0. </sub>Also let&rsquo;s say we measured our gyro output and we have determined that our angular velocity is <b>w = </b>{w<sub>x </sub>, w<sub>y </sub>, w<sub>z </sub>}. Using our gyro we want to know the position of our zenith vector after a small period of time dt has passed we&rsquo;ll note it as <b>K</b><sup>B</sup><sub>1G </sub>. And we find it using <i>(Eq. 2.6)</i>:</p>
<p><b>K</b><sup>B</sup><sub>1G</sub> &asymp; <b>K</b><sup>B</sup><sub>0</sub> + dt<b> v </b>= <b>K</b><sup>B</sup><sub>0</sub> + dt (<b>w<sub>g</sub> </b>x<b> K</b><sup>B</sup><sub>0</sub>) = <b>K</b><sup>B</sup><sub>0</sub> + ( d<b>&theta;<sub>g</sub> </b>x<b> K</b><sup>B</sup><sub>0</sub>)</p>
<p>Where we noted d<b>&theta;<sub>g</sub> </b>= dt <b>w<sub>g</sub></b>. Because <b>w<sub>g</sub> </b>is angular velocity as measured by the gyroscope. We&rsquo;ll call d<b>&theta;<sub>g</sub> </b>angular displacement. In other words it tells us by what <b>small</b> angle (given for all 3 axis in form of a vector) has the orientation of a vector <b>K</b><sup>B</sup> changed during this <b>small</b> period of time dt.</p>
<p>Obviously, another way to estimate <b>K</b><sup>B</sup> is by making another reading from accelerometer so we can get a reading that we note as <b>K</b><sup>B</sup><sub>1A </sub>.</p>
<p>In practice the values <b>K</b><sup>B</sup><sub>1G</sub> will be different from from <b>K</b><sup>B</sup><sub>1A. </sub>One was estimated using our gyroscope and the other was estimated using our accelerometer.</p>
<p>Now it turns out we can go the reverse way and estimate the angular velocity <b>w</b><sub>a</sub> or angular displacement d<b>&theta;<sub>a &shy;</sub></b>=<b> </b>dt <b>w<sub>a</sub></b> , from the new accelerometer reading <b>K</b><sup>B</sup><sub>1A&shy; </sub>, we&rsquo;ll use <i>(Eq. 2.5):</i></p>
<p><b>w</b>&shy;<sub>a</sub><b> </b>= <b>K</b><sup>B</sup><sub>0</sub> x <b>v<sub>a</sub> </b>/ |<b> K</b><sup>B</sup><sub>0</sub>|<sup>2</sup>&shy;</p>
<p>Now <b>v</b><sub>a </sub>= (<b>K</b><sup>B</sup><sub>1A&shy; </sub>- <b>K</b><sup>B</sup><sub>0</sub>) / dt , and is basically the linear velocity of the vector <b>K</b><sup>B</sup><sub>0</sub>. And |<b> K</b><sup>B</sup><sub>0</sub>|<sup>2</sup>&shy;&shy; = 1 , since <b>K</b><sup>B</sup><sub>0</sub> is a unity vector. So we can calculate:</p>
<p>d<b>&theta;<sub>a &shy;</sub></b>=<b> </b>dt <b>w<sub>a </sub></b>= <b>K</b><sup>B</sup><sub>0</sub> x (<b>K</b><sup>B</sup><sub>1A&shy; </sub>- <b>K</b><sup>B</sup><sub>0</sub>)</p>
<p>The idea of calculating a new estimate <b>K</b><sup>B</sup><sub>1 &shy;</sub> that combines both <b>K</b><sup>B</sup><sub>1A</sub> and <b>K</b><sup>B</sup><sub>1G</sub> is to first estimate d<b>&theta; </b>as a weighted average of<b> </b>d<b>&theta;<sub>a</sub> </b>and d<b>&theta;<sub>g</sub></b> : <br />
	<b><sub> <br />
	</sub></b>d<b>&theta; </b>= (s<sub>a</sub> d<b>&theta;<sub>a</sub> </b>+<b> </b>s<sub>g</sub> d<b>&theta;<sub>g</sub></b>) / (s<sub>a</sub> + s<sub>g&shy;</sub>), we&rsquo;ll discuss about the weights later on , but shortly they are determined and tuned experimentally in order to achieve a desired response rate and noise rejection.</p>
<p>And then <b>K</b><sup>B</sup><sub>1 &shy; </sub>is calculated similar to how we calculated <b>K</b><sup>B</sup><sub>1G</sub>:</p>
<p><b>K</b><sup>B</sup><sub>1</sub> &asymp; <b>K</b><sup>B</sup><sub>0</sub> + ( d<b>&theta; </b>x<b> K</b><sup>B</sup><sub>0</sub>)</p>
<p>Why we went all the way to calculate d<b>&theta; </b>and did not apply the weighted average formula directly to <b>K</b><sup>B</sup><sub>1A</sub> and <b>K</b><sup>B</sup><sub>1G </sub>? Because d<b>&theta; </b>can be used to calculate the other elements of our DCM matrix in the same way:</p>
<p><b>I</b><sup>B</sup><sub>1</sub> &asymp; <b>I</b><sup>B</sup><sub>0</sub> + ( d<b>&theta; </b>x<b> I</b><sup>B</sup><sub>0</sub>)</p>
<p><b>J</b><sup>B</sup><sub>1</sub> &asymp; <b>J</b><sup>B</sup><sub>0</sub> + ( d<b>&theta; </b>x<b> J</b><sup>B</sup><sub>0</sub>)</p>
<p>The idea is that all three versors <b>I</b><sup>B</sup>,<b> J</b><sup>B</sup>,<b> K</b><sup>B</sup> are attached to each other and will follow the same angular displacement d<b>&theta; </b>during our small interval dt. So in a nutshell this is the algorithm that allows us to calculate the DCM<sub>1</sub> matrix at time t<sub>1 </sub>from our previous estimated DCM<sub>0 </sub>matrix at time t&shy;&shy;<sub>0</sub>. It is applied recursively at regular small time intervals dt and gives us an updated DCM matrix at any point in time. The matrix will not drift too much because it is fixed to the absolute position dictated by the accelerometer and will not be too noisy from external accelerations because we also use the gyroscope data to update it.</p>
<p>So far we didn&rsquo;t mention a word about our magnetometer. One reasons being that it is not available on all IMU units (6DOF) and we can go away without using it, but our resulting orientation will then have a drifting heading (i.e. it will not show if we&rsquo;re heading north, south, west or east), or we can introduce a virtual magnetometer that is always pointing North, to introduce stability in our model. This situation is demonstrated in the accompanying source code that used a 6DOF IMU.</p>
<p>Now we&rsquo;ll show how to integrate magnetometer readings into our algorithm. As it turns out it is really simple since magnetometer is really similar to accelerometer (they even use similar calibration algorithms), the only difference being that instead of estimating the Zenith vector <b>K</b><sup>B</sup><sub> </sub>vector it estimates the vector pointing North <b>I</b><sup>B</sup>. Following the same logic as we did for our accelerometer we can determine the angular displacement according to the updated magnetometer reading as being:</p>
<p>d<b>&theta;<sub>m &shy;</sub></b>=<b> </b>dt <b>w<sub>m </sub></b>= <b>I</b><sup>B</sup><sub>0</sub> x (<b>I</b><sup>B</sup><sub>1M&shy; </sub>- <b>I</b><sup>B</sup><sub>0</sub>)</p>
<p>Now let&rsquo;s incorporate it into our weighted average:</p>
<p>d<b>&theta; </b>= (s<sub>a</sub> d<b>&theta;<sub>a</sub> </b>+<b> </b>s<sub>g</sub> d<b>&theta;<sub>g </sub></b>+<b> </b>s<sub>m</sub> d<b>&theta;<sub>m</sub></b>) / (s<sub>a</sub> + s<sub>g</sub> +<sub>&shy; </sub>s<sub>m</sub>)</p>
<p>From here we go the same path to calculate the updated DCM<sub>1&shy;</sub></p>
<p><b>I</b><sup>B</sup><sub>1</sub> &asymp; <b>I</b><sup>B</sup><sub>0</sub> + ( d<b>&theta; </b>x<b> I</b><sup>B</sup><sub>0</sub>) , <b>K</b><sup>B</sup><sub>1</sub> &asymp; <b>K</b><sup>B</sup><sub>0</sub> + ( d<b>&theta; </b>x<b> K</b><sup>B</sup><sub>0</sub>) and <b>J</b><sup>B</sup><sub>1 </sub>&asymp; <b>J</b><sup>B</sup><sub>0</sub> + ( d<b>&theta; </b>x<b> J</b><sup>B</sup><sub>0</sub>),</p>
<p>In practice we&rsquo;ll calculate <b>J</b><sup>B</sup><sub>1 </sub>= <b>K</b><sup>B</sup><sub>1 </sub>x <b>I</b><sup>B</sup><sub>1,</sub> after correcting <b>K</b><sup>B</sup><sub>1 </sub>and <b>I</b><sup>B</sup><sub>1 </sub>to be perpendicular unity vectors again , note that all our logic is approximated and dependent on dt being small, the larger the dt the larger the error we&rsquo;ll accumulate.</p>
<p>So if vectors <b>I</b><sup>B</sup><sub>0</sub>,<b> J</b><sup>B</sup><sub>0</sub>,<b> K</b><sup>B</sup><sub>0 </sub>form a valid DCM matrix , in other words they are orthogonal to each other and are unity vectors, then we can&rsquo;t say the same about <b>I</b><sup>B</sup><sub>1</sub>,<b> J</b><sup>B</sup><sub>1</sub>,<b> K</b><sup>B</sup><sub>1 </sub>, the formulas used for calculating them does not guarantee the orthogonality or length of the vector to be preserved , however we will not get a big error if dt is small, all we need to do is to correct them after each iteration.</p>
<p>First let&rsquo;s see how we can ensure that two vectors are orthogonal again. Let&rsquo;s consider two unity vectors <b>a </b>and <b>b</b> that are &ldquo;almost orthogonal&rdquo; in other words the angle between these two vectors is close to 90&deg;, but not exactly 90&deg;. We&rsquo;re looking to find a vector <b>b&rsquo;</b> that is orthogonal to <b>a</b> and that is in the same plane formed by the vectors <b>a </b>and <b>b. </b>Such a vector is easy to find as shown in Figure 5. First we find vector <b>c = a x b </b>that by the rules of cross product is orthogonal to both <b>a</b> and <b>b </b>and thus is perpendicular to the plane formed by <b>a</b> and <b>b</b>. Next the vector <b>b&rsquo; = c x a </b>is calculated as the cross product of <b>c</b> and <b>a. </b>From the definition of cross product <b>b&rsquo; </b>is orthogonal to <b>a </b>and because it is also orthogonal to <b>c</b> &#8211; it end up in the plane orthogonal to <b>c</b> , which is the plane formed by <b>a </b>and <b>b. </b>Thus <b>b&rsquo;</b> is the corrected vector we&rsquo;re seeking that is orthogonal to <b>a</b> and belongs to the plane formed by <b>a</b> and <b>b</b>. <br />
	<a href="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0224.jpg"><img alt="clip_image022[4]" border="0" height="272" src="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0224_thumb.jpg" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image022[4]" width="307" /></a></p>
<p><i>Figure 5</i></p>
<p>We can extend the equation using <a href="http://en.wikipedia.org/wiki/Triple_product">the triple product rule</a> and the fact that <b>a.a</b> = |<b>a</b>| = 1:</p>
<p><b>b&rsquo;</b> = <b>c</b> x <b>a</b> = (<b>a</b> x <b>b</b>) x <b>a</b> = -<b>a</b> (<b>a</b>.<b>b</b>) + b(<b>a</b>.<b>a</b>) = <b>b</b> &ndash; <b>a</b> (<b>a.b</b>) = <b>b </b>+<b> d , </b>where <b>d </b>=<b> &#8211; a (a.b) </b>(Scenario 1, <b>a</b> is fixed <b>b</b> is corrected)</p>
<p>You can reflect a little bit on the results &hellip; So we obtain corrected vector <b>b&rsquo; </b>from vector <b>b </b>by adding a &ldquo;correction&rdquo; vector<b> d </b>=<b> &#8211; a (a.b). </b>Notice that <b>d</b> is parallel to <b>a</b>. Its direction is dependent upon the angle between <b>a</b> and <b>b</b>, for example in Figure 5 <b>a</b>.<b>b</b> = cos (<b>a</b>,<b>b</b>) &gt; 0 , because angle between <b>a</b> and <b>b</b> is less than<b> </b>90&deg;thus <b>d </b>has opposite direction from <b>a</b> and a magnitutde of cos(<b>a</b>,<b>b</b>)<b> </b>=<b> </b>sin(<b>b,b&rsquo;</b>).</p>
<p>In the scenario above we considered that vector <b>a </b>is fixed and we found a corrected vector <b>b&rsquo;</b> that is orthogonal to <b>a</b>. We can consider the symmetric problem &ndash; we fix <b>b</b> and find the corrected vector <b>a&rsquo;:</b></p>
<p><b>a&rsquo; </b>= <b>a</b> &ndash; <b>b</b> (<b>b</b>.<b>a</b>) = <b>a</b> &ndash; <b>b</b> (<b>a</b>.<b>b</b>) = <b>a</b> + <b>e</b>, where <b>e </b>=<b> </b>-<b> b </b>(<b>a.b</b>) (Scenario 2, <b>b</b> is fixed <b>a</b> is corrected)</p>
<p>Finally in the third scenario we want both vectors to move towards their corrected state, we consider them both &ldquo;equally wrong&rdquo;, so intuitively we apply half correction to both vectors from scenario 1 and 2:</p>
<p><b>a&rsquo; </b>= <b>a</b> &ndash; <b>b</b> (<b>a</b>.<b>b</b>) / 2 (Scenario 3, both <b>a</b> and <b>b</b> are corrected) <br />
	<b>b&rsquo; </b>= <b>b</b> &ndash; <b>a</b> (<b>a</b>.<b>b</b>) / 2</p>
<p><a href="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0244.jpg"><img alt="clip_image024[4]" border="0" height="272" src="http://www.starlino.com/wp-content/uploads/2011/11/clip_image0244_thumb.jpg" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image024[4]" width="307" /></a></p>
<p><i>Figure 6</i></p>
<p>This is an relatively easy formula to calculate on a microprocessor since we can pre-compute Err = (<b>a</b>.<b>b</b>)/2 and then use it to correct both vectors:</p>
<p><b>a&rsquo; </b>= <b>a</b> &#8211; Err * <b>b</b> <br />
	<b>b&rsquo; </b>= <b>b</b> &#8211; Err * <b>a</b></p>
<p>Please note that we&rsquo;re not proving that <b>a&rsquo;</b> and <b>b&rsquo; </b>are orthogonal in Scenario 3, but we presented the intuitive reasoning why the angle between <b>a&rsquo;</b> and <b>b&rsquo;</b> will get closer to 90&deg;if we apply the above corrective transformations.</p>
<p>Now going back to our updated DCM matrix that consists of three vectors <b>I</b><sup>B</sup><sub>1</sub>,<b> J</b><sup>B</sup><sub>1</sub>,<b> </b>we apply the following corrective actions before reintroducing the DCM matrix into the next loop:</p>
<p>Err = ( <b>I</b><sup>B</sup><sub>1</sub> . <b>J</b><sup>B</sup><sub>1 </sub>) / 2</p>
<p><b>I</b><sup>B</sup><sub>1</sub><sup>&rsquo; </sup>= <b>I</b><sup>B</sup><sub>1</sub> &ndash; Err * <b>J</b><sup>B</sup><sub>1 <br />
	</sub><b>J</b><sup>B</sup><sub>1</sub><sup>&rsquo; </sup>= <b>J</b><sup>B</sup><sub>1</sub> &ndash; Err * <b>I</b><sup>B</sup><sub>1 <br />
	</sub><b>I</b><sup>B</sup><sub>1</sub><sup>&rsquo;&rsquo; </sup>= Normalize[<b>I</b><sup>B</sup><sub>1</sub><sup>&rsquo;</sup>] <br />
	<b>J</b><sup>B</sup><sub>1</sub><sup>&rsquo;&rsquo; </sup>= Normalize[<b>J</b><sup>B</sup><sub>1</sub><sup>&rsquo;</sup>] <br />
	<b>K</b><sup>B</sup><sub>1</sub><sup>&rsquo;&rsquo; </sup>= <b>I</b><sup>B</sup><sub>1</sub><sup>&rsquo;&rsquo;</sup> x <b>J</b><sup>B</sup><sub>1</sub><sup>&rsquo;&rsquo;</sup></p>
<p>Where Normalize[<b>a</b>] = <b>a </b>/ |<b>a</b>| , is the formula calculating the unit vector co-directional with <b>a</b>.</p>
<p>So finally our corrected DCM<sub>1</sub> matrix can be recomposed from vectors <b>I</b><sup>B</sup><sub>1</sub><sup>&rsquo;&rsquo;</sup>, <b>J</b><sup>B</sup><sub>1</sub><sup>&rsquo;&rsquo;</sup>, <b>K</b><sup>B</sup><sub>1</sub><sup>&rsquo;&rsquo; </sup>that have been ortho-normalized (each vector constitutes a row of the updated and corrected DCM matrix).</p>
<p>We repeat the loop to find DCM<sub>2 ,</sub> DCM<sub>3 ,</sub> or in general DCM<sub> n </sub>, at any time interval n.</p>
<h2>References</h2>
<p>1. <a href="http://www.amazon.com/gp/product/1441917497/ref=as_li_qf_sp_asin_tl?ie=UTF8&amp;tag=librarian06-20&amp;linkCode=as2&amp;camp=217145&amp;creative=399353&amp;creativeASIN=1441917497">Theory of Applied Robotics: Kinematics, Dynamics, and Control (Reza N. Jazar)</a></p>
<p>2. <a href="http://www.amazon.com/gp/product/0321287134/ref=as_li_qf_sp_asin_tl?ie=UTF8&amp;tag=librarian06-20&amp;linkCode=as2&amp;camp=217145&amp;creative=399349&amp;creativeASIN=0321287134">Linear Algebra and Its Applications (David C. Lay)</a></p>
<p>3. <a href="http://www.amazon.com/gp/product/0470528338/ref=as_li_qf_sp_asin_tl?ie=UTF8&amp;tag=librarian06-20&amp;linkCode=as2&amp;camp=217145&amp;creative=399353&amp;creativeASIN=0470528338">Fundamentals of Matrix Computations (David S. Watkins)</a></p>
<p>4. <a href="http://gentlenav.googlecode.com/files/DCMDraft2.pdf">Direction Cosine Matrix IMU: Theory (W Premerlani)</a></p>
<h2>Additional Notes</h2>
<p>For the implementation of the algorithm for now see my quadcopter project in particular releases 6/7 have a nice <a href="http://processing.org/" target="_blank">Processing </a>program for visual display of the DCM matrix and a model plane. The entire code is on SVN repository:</p>
<p><a href="http://code.google.com/p/picquadcontroller/source/browse/?r=7#svn%2Ftrunk" target="_blank">http://code.google.com/p/picquadcontroller/source/browse/?r=7#svn%2Ftrunk</a></p>
<p>The code is in imu.h file:</p>
<p><a href="http://code.google.com/p/picquadcontroller/source/browse/trunk/imu.h?r=7" target="_blank">http://code.google.com/p/picquadcontroller/source/browse/trunk/imu.h?r=7</a></p>
<p>A PDF Version of this article is available here</p>
<p><span style="background-color: #ffff00"><strong><a href="http://www.starlino.com/wp-content/uploads/data/dcm_tutorial/Starlino_DCM_Tutorial_01.pdf" target="_blank">DCM Tutorial &#8211; An Introduction to Orientation Kinematics by Starlino (PDF, Rev 0.1 Draft)</a> </strong></span></p>
<p>Please mention and link to the source when using information in this article:</p>
<p><a href="http://www.starlino.com/dcm_tutorial.html">http://www.starlino.com/dcm_tutorial.html</a></p>
<p>Starlino Electronics&nbsp; // Spring , 2011</p>
]]></content:encoded>
			<wfw:commentRss>http://www.starlino.com/dcm_tutorial.html/feed</wfw:commentRss>
		<slash:comments>57</slash:comments>
		</item>
		<item>
		<title>Use extra-long headers to hold a board on a  pogo pins testing jig</title>
		<link>http://www.starlino.com/headers-to-hold-board-on-pego-testing-jig.html</link>
		<comments>http://www.starlino.com/headers-to-hold-board-on-pego-testing-jig.html#comments</comments>
		<pubDate>Wed, 16 Mar 2011 03:53:13 +0000</pubDate>
		<dc:creator>starlino</dc:creator>
				<category><![CDATA[Soldering and DIY Fabrication]]></category>
		<category><![CDATA[Tricks and Tips]]></category>
		<category><![CDATA[pogo pcb testing headers]]></category>

		<guid isPermaLink="false">http://www.starlino.com/?p=215</guid>
		<description><![CDATA[Adafruit has a nice tutorial on how to build a neat testing jig that allows you to test a breakout board without having to actually solder the header. So I decided to build one for&#160; the the acc_gyro boards. But how do you hold the board in place ? Using screws is secure but takes [...]]]></description>
				<content:encoded><![CDATA[<p>Adafruit has a nice tutorial on how to build a <a href="http://ladyada.net/make/pogojig/" target="_blank">neat testing jig</a> that allows you to test a breakout board without having to actually solder the header.</p>
<p>So I decided to build one for&nbsp; the the <a href="http://gadgetgangster.com/213" target="_blank">acc_gyro</a> boards. But how do you hold the board in place ? Using screws is secure but takes long time to put a board in and out. I needed a faster way to test a larger amount of boards.</p>
<p>Well after several experimentations with velcro tape, rubber bands , and even custom fitted clamps made out of polymorth , I arrived at this simple solution, just use some headers with extra long leads , the pictures tell it all:</p>
<p><img alt="" height="480" src="http://www.starlino.com/wp-content/uploads/data/pogo_test_rig/pogo_test_rig_holder_1.jpg" width="720" /></p>
<p>The board is basically held by the plastic parts of 2 long headers. You simply spread them apart, insert the board and then , when they come back together they hold the board in place by the spring action of the pogo pins that pushes the board up.</p>
<p><img alt="" src="http://www.starlino.com/wp-content/uploads/data/pogo_test_rig/pogo_test_rig_holder_2.jpg" /></p>
<p>To remove the board simply spread the headers again and the board pops up &#8230;</p>
<p>Hope the method could be useful to someone , so decided to share.</p>
<p>//starlino//</p>
]]></content:encoded>
			<wfw:commentRss>http://www.starlino.com/headers-to-hold-board-on-pego-testing-jig.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Radioshack Replies</title>
		<link>http://www.starlino.com/radioshack-replies.html</link>
		<comments>http://www.starlino.com/radioshack-replies.html#comments</comments>
		<pubDate>Wed, 29 Dec 2010 16:42:29 +0000</pubDate>
		<dc:creator>starlino</dc:creator>
				<category><![CDATA[News and Discussions]]></category>
		<category><![CDATA[parts]]></category>
		<category><![CDATA[radioshack]]></category>
		<category><![CDATA[store]]></category>

		<guid isPermaLink="false">http://www.starlino.com/?p=185</guid>
		<description><![CDATA[So we finally received a reply from Radioshack &#34;Wake Up Letter to Radioshack&#34;&#160; it was posted in the comments (and has been confirmed to be coming from Radioshacks corporate). Here it is: Dear Electronics Hobbyists of America, We have heard your voices. We are not going to deny that we have let the hobbyist business [...]]]></description>
				<content:encoded><![CDATA[<p>So we finally received a reply from Radioshack &quot;<a href="http://www.starlino.com/wake-up-letter-to-radioshack-the-hobbyists-are-back.html">Wake Up Letter to Radioshack</a>&quot;&nbsp; it was posted in the comments (and has been confirmed to be coming from Radioshacks corporate). Here it is:</p>
<div class="comment-text">
<blockquote>
<p><em>Dear Electronics Hobbyists of America,</em></p>
<p><em>We have heard your voices. We are not going to deny that we have let the hobbyist business run on auto-pilot for several years now. The times changed, so we changed with it. Now the times are changing again. Hobbyists have remained dedicated to RadioShack for the better part of a century and we recognize that you deserve the same dedication from us. Our goal is to substantiate our loyalty to you. We know we must have a greater selection of products that you want and as much of it as you need. We promise we are working on it and that it is as important to us as it is to you. In the last two years, we have added over 150 new items to our technical assortment. We are working on a plan to get more hobby kits and test equipment into stores but we don&rsquo;t expect that to be the end of the conversation. We do not underestimate the power of the online community, and we would love to hear more from you. We think this is a great beginning to a dialogue and we are listening.</em></p>
<p><em>RadioShack-Team Technical</em></p>
</blockquote>
</div>
<p>Well Radioshack first thank you for replying and not ignoring us altogether. But we would like to see more actions being done. As a reply I will leave you with a related comment from a 10th grade student:</p>
<blockquote>
<p><em>Hello, my name is Nic. I&#39;m in grade 10 and I have an interest in electronics. But I have a lot of restrictions. I live in Canada in a town where there is no electronics shop other than &quot;The Source&quot; (Radioshack was bought out by The Source) which sells overpriced components that aren&#39;t the greatest quality, I&#39;m far away from A1 Electronics which is a brilliant store in missisauga. And There is no Electronics course in my high school.&nbsp; &#8230; <br />
		</em></p>
<p>[Source: <a href="http://www.instructables.com/id/New-Life-for-Old-Printed-Circuit-Boards/">http://www.instructables.com/id/New-Life-for-Old-Printed-Circuit-Boards/</a> ]</p>
<p>&nbsp;</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.starlino.com/radioshack-replies.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IMU breakout boards from ST</title>
		<link>http://www.starlino.com/new-cheap-imu-breakout-boards-from-st-dont-miss-out.html</link>
		<comments>http://www.starlino.com/new-cheap-imu-breakout-boards-from-st-dont-miss-out.html#comments</comments>
		<pubDate>Thu, 11 Nov 2010 02:20:27 +0000</pubDate>
		<dc:creator>starlino</dc:creator>
				<category><![CDATA[News and Discussions]]></category>
		<category><![CDATA[accelerometer]]></category>
		<category><![CDATA[breakout]]></category>
		<category><![CDATA[gyroscope]]></category>
		<category><![CDATA[imu]]></category>
		<category><![CDATA[magenteometer]]></category>

		<guid isPermaLink="false">http://www.starlino.com/?p=163</guid>
		<description><![CDATA[Sign that someone from ST is reading the blogs &#8211; a series of breakout boards directly from ST , just couple of good ones: $26.95&#160; STEVAL-MKI093V1 ( breakout for LYPR540AH&#160; &#8211; 3 axis analog gyro ) http://www.mouser.com/ProductDetail/STMicroelectronics/STEVAL-MKI093V1/?qs=Mmr5WwCtLzNTGieQUi715w%3d%3d Looks like , Mouser has all datasheet , pictures and descriptions wrong at the time of this post. [...]]]></description>
				<content:encoded><![CDATA[<p>Sign that someone from ST is reading the blogs &#8211; a series of breakout boards directly from ST , just couple of good ones:</p>
<p><img alt="" height="361" src="http://www.starlino.com/wp-content/uploads/11-10-2010 9-13-59 PM.png" width="460" /></p>
<p><strong>$26.95&nbsp; </strong><span id="ctl00_ContentMain_lblManufacturerPartNum">STEVAL-MKI093V1 ( breakout for </span><span id="ctl00_ContentMain_lblDescription">LYPR540AH&nbsp; &#8211; </span><span id="ctl00_ContentMain_lblManufacturerPartNum">3 axis analog gyro )<br />
	</span></p>
<p><a href="http://www.mouser.com/ProductDetail/STMicroelectronics/STEVAL-MKI093V1/?qs=Mmr5WwCtLzNTGieQUi715w%3d%3d">http://www.mouser.com/ProductDetail/STMicroelectronics/STEVAL-MKI093V1/?qs=Mmr5WwCtLzNTGieQUi715w%3d%3d<br />
	</a></p>
<p>Looks like , Mouser has all datasheet , pictures and descriptions wrong at the time of this post.</p>
<p><span id="ctl00_ContentMain_lblManufacturerPartNum">correct datasheet&nbsp;&nbsp; <a href="http://www.st.com/stonline/products/literature/bd/17906/steval-mki093v1.pdf ">http://www.st.com/stonline/products/literature/bd/17906/steval-mki093v1.pdf </a></span></p>
<p>&nbsp;</p>
<p><img alt="" height="374" src="http://www.starlino.com/wp-content/uploads/11-10-2010 9-14-26 PM.png" width="490" /></p>
<p>&nbsp;</p>
<p><span id="ctl00_ContentMain_lblMouserPartNum"><strong>$26.95</strong> STEVAL-MKI064V1 (breakout for </span><span id="ctl00_ContentMain_lblDescription">LSM303DLH&nbsp; 3-axis magnetometer + 3-axis accelerometer)<br />
	</span></p>
<p><a href="http://www.mouser.com/ProductDetail/STMicroelectronics/STEVAL-MKI064V1/?qs=Mmr5WwCtLzNMjRxMWs1ArA%3d%3d"><span>http://www.mouser.com/ProductDetail/STMicroelectronics/STEVAL-MKI064V1/?qs=Mmr5WwCtLzNMjRxMWs1ArA%3d%3d</span><br />
	</a></p>
<p>correct datasheet <a href="http://www.st.com/stonline/products/literature/bd/17844/steval-mki064v1.pdf">http://www.st.com/stonline/products/literature/bd/17844/steval-mki064v1.pdf<br />
	</a></p>
<p>&nbsp;</p>
<p>Order while they are in stock :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.starlino.com/new-cheap-imu-breakout-boards-from-st-dont-miss-out.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Open pde files with Arduino under Windows</title>
		<link>http://www.starlino.com/oped-pde-files-with-arduino-under-windows.html</link>
		<comments>http://www.starlino.com/oped-pde-files-with-arduino-under-windows.html#comments</comments>
		<pubDate>Sun, 03 Oct 2010 21:16:02 +0000</pubDate>
		<dc:creator>starlino</dc:creator>
				<category><![CDATA[Tricks and Tips]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[pde]]></category>

		<guid isPermaLink="false">http://www.starlino.com/?p=149</guid>
		<description><![CDATA[This has been bugging me for while &#8211; I could not associate .pde files with arduino executable , I would select Open With&#8230; choose the executable but it won&#39;t work , so I decided to write a .reg script to correct the problem. After some research turns out other people had the same problem it [...]]]></description>
				<content:encoded><![CDATA[<p>This has been bugging me for while &#8211; I could not associate .pde files with arduino executable , I would select Open With&#8230; choose the executable but it won&#39;t work , so I decided to write a .reg script to correct the problem. After some research turns out other people had the same problem it happens with Windows 7 and might have something to do&nbsp; with having Processing installed, in any case if you have this problem here is the fix.</p>
<p>Create a file called&nbsp; arduino.reg with the following contents:</p>
<hr />
<p>Windows Registry Editor Version 5.00</p>
<p>[HKEY_CLASSES_ROOT\.pde]<br />
	@=&quot;Arduino.Document&quot;</p>
<p>[HKEY_CLASSES_ROOT\Arduino.Document\shell\open\command]<br />
	@=&quot;\&quot;<span style="background-color: rgb(255, 255, 0);">C:\\arduino\\arduino.exe</span>\&quot; \&quot;%1\&quot;&quot;</p>
<hr />
<p>Please note this assumes your arduino installation was unzipped to <span style="background-color: rgb(255, 255, 0);">C:\arduino\</span> . If different , update accordingly the reg file but make sure to use double quotes \\ for path delimiter as highlighted above.</p>
<p>Next simply double click on the arduino.reg file you have created and the keys will be imported to your registry. Now when you right click on the .pde file you should see arduino as one of the options (and you can make it default program to open pde files).&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.starlino.com/oped-pde-files-with-arduino-under-windows.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>ST launches Multi sensor application (MuSA) board platform</title>
		<link>http://www.starlino.com/st-launches-multi-sensor-application-musa-board-platform.html</link>
		<comments>http://www.starlino.com/st-launches-multi-sensor-application-musa-board-platform.html#comments</comments>
		<pubDate>Mon, 20 Sep 2010 13:35:12 +0000</pubDate>
		<dc:creator>starlino</dc:creator>
				<category><![CDATA[News and Discussions]]></category>
		<category><![CDATA[accelerometer]]></category>
		<category><![CDATA[imu]]></category>
		<category><![CDATA[sensor]]></category>
		<category><![CDATA[ST]]></category>

		<guid isPermaLink="false">http://www.starlino.com/?p=141</guid>
		<description><![CDATA[For $99&#160; MuSA&#160; could be a nice hackable platform for all sorts of motion-enabled applications.&#160; It has a&#160; built-in accelerometer , LCD&#160; and a simple casing. Here is the description from ST: &#34;The platform comes with the LIS331DLH preinstalled on the board, but can support any digitaloutput accelerometer from ST in 3&#215;3 or 3&#215;5 mm [...]]]></description>
				<content:encoded><![CDATA[<p><img alt="" src="http://www.starlino.com/wp-content/uploads/data/_misc/musa.jpg" /></p>
<p>For $99&nbsp; MuSA&nbsp; could be a nice hackable platform for all sorts of motion-enabled applications.&nbsp; It has a&nbsp; built-in accelerometer , LCD&nbsp; and a simple casing. Here is the description from ST:</p>
<p>&quot;The platform comes with the LIS331DLH preinstalled on the board, but can support any digitaloutput accelerometer from ST in 3&#215;3 or 3&#215;5 mm packages connected to the microcontroller through an SPI interface, as well as the LIS344ALH analog-output accelerometer.</p>
<p>	The MuSA platform features four buttons for navigating the menus. A mini-USB connector is available to exchange data with a PC, depending on the specific application, and also recharges the internal Li-ion battery. The battery is capable of providing power for approximately 7 hours of operation.&quot;</p>
<p>For device demonstration see video here:</p>
<p><a href="http://www.st.com/stonline/domains/support/edemoroom/index.htm?id=14" target="_blank">http://www.st.com/stonline/domains/support/edemoroom/index.htm?id=14</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.starlino.com/st-launches-multi-sensor-application-musa-board-platform.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wake-up letter to Radioshack – the hobbyists are back !</title>
		<link>http://www.starlino.com/wake-up-letter-to-radioshack-the-hobbyists-are-back.html</link>
		<comments>http://www.starlino.com/wake-up-letter-to-radioshack-the-hobbyists-are-back.html#comments</comments>
		<pubDate>Thu, 16 Sep 2010 19:04:00 +0000</pubDate>
		<dc:creator>starlino</dc:creator>
				<category><![CDATA[News and Discussions]]></category>
		<category><![CDATA[business]]></category>
		<category><![CDATA[community]]></category>
		<category><![CDATA[electronics]]></category>

		<guid isPermaLink="false">http://www.starlino.com/?p=121</guid>
		<description><![CDATA[Have you been to Radioshack lately ? You might have needed a part for that last moment project, of course you could buy it online but you need it NOW! So you finally decide to step into that quiet&#160; long forgotten Radioshack store. You walk in and you see cell phones , batteries , chargers [...]]]></description>
				<content:encoded><![CDATA[<p>Have you been to Radioshack lately ? You might have needed a part for that last moment project, of course you could buy it online but you need it NOW! So you finally decide to step into that quiet&nbsp; long forgotten Radioshack store. You walk in and you see cell phones , batteries , chargers , computer accessories, more cell phones ! , and finally in the back, here they are , on the dusty shelves some electronics parts. In an uninviting&nbsp; metal drawer cabinet you see them nicely marked by category, you look around , is it safe to look inside&nbsp; ? or should I call the clerk , &quot;Naaaah he probably has no clue&quot;, is it locked ? will the alarm sound if I open it ? You finally gather the courage to look inside , and you feel like an explorer opening the cabins of Titanic, here is a transistor, a voltage regulator , a kit of resistors &#8211; &quot;I might need it&quot;, a proto-board &#8211; &quot;Nice!&quot;. You finally grabbed a cart of parts, although you didn&#39;t find what you were looking for in first place, you&#39;re little disappointed.&nbsp; You&#39;re&nbsp; finally&nbsp; heading to the register, not without stopping to observe the Radioshack branded&nbsp; multimeters and charges &#8211; and the whole place still feels just like a museum . The clerk was getting nervous already, you didn&#39;t even notice that an hour has passed. Now he is scanning your parts, he looks scared, half of the things he is scanning look dangerous to him, &quot;this guy is up to something dangerous, we are dooooomed !&quot;. Oh no , now he is asking your address , is he going to call the cops ? :) </p>
<p>	If you found yourself in this funny situation you&#39;re not alone, the truth is that<strong> at this time&nbsp; there are no serious retail stores for the electronics hobbyist, however there&#39;s a booming market !</strong>&nbsp;<strong> Due to the current economic environment I doubt that someone would venture to open a nation-wide retail chain like the one Radioshack has, </strong>this being the reason I decided to write an open letter to the company. You might not like the Radioshack company but the truth is that we need them and they need us !</p>
<p><span id="more-121"></span>I am NOT going to send them this letter, instead I will put it out in the wild-wild web&nbsp; and let the natural selection do its work. If it makes (or when it makes)&nbsp; to someone in the Radioshack management&nbsp; &#8211; it means there are enough people who think like I think to make it happen.</p>
<p>That being said , here is the letter, if you&#39;d like to join the petition, leave a comment, post it on your blog, do whatever you feel like, just keep it civilized please.</p>
<p>&quot;Dear RADIOSHACK,</p>
<p>We the electronics hobbyists of America would like to inform you that we are back ! Our soldering irons got cold during the 90&#39;s and 2000&#39;s&nbsp; which made you pull all that interesting stuff to the back shelves. But we are the new generation and we are here to continue what our fathers and mothers have started, we are here to invent , change modify and rebuild this country back to it&#39;s glory days. We need your help though, we want our voices to be heard, we feel like you&#39;re not in touch with reality, while you were sleeping companies like <a href="http://www.adafruit.com/">Adafruit</a>, <a href="http://sparkfun.com/">Sparkfun</a>, <a href="http://makezine.com/">Make Magazine</a> and many many others , have created a huge online community of new engineers and inventors who are the only hope that this country will once again regain it&#39;s edge in the technological field !</p>
<p><strong>You shouldn&#39;t be threatened by these online retailers, neither should they be threatened by you, you should instead try to work together with them.</strong> In fact as a start you should try to resell their kits, they don&#39;t mind anyone copying their work, in fact they publish the schematics, code and advices how to use their products. They are not threatened by anyone, because they will never run out of ideas, they will always be one step ahead, and as long as this happens in our country we all have to gain !</p>
<p>We admire that you started carrying&nbsp; Parallax products, however we find it somehow funny that <a href="http://www.starlino.com/wp-content/uploads/data/radioshack/radioshack_arduino_search_shows_basic_stamps.png" target="_blank">searching for &quot;Arduino&quot; on Radioshack site returns &quot;The BASIC Stamp Kit&quot;</a> , why not just start carrying Arduino just like <a href="http://jameco.com">Jameco </a>recently did ?</p>
<p>If you&#39;re concerned that you don&#39;t have the market yet to pull those products from back shelves and create a larger inventory, don&#39;t forget that a market is not only the market that you have, but the market that you&#39;re going to create. Next time a father or mother&nbsp; enters your store to buy batteries she might see all those interesting electronics kits and decide that&#39;s a good thing for their children to do in order to keep them busy and away from trouble. Why not get more involved in the community and organize or sponsor some electronics clubs, because we know you were sleeping &#8211; they are called nowdays&nbsp; &quot;<a href="http://hackerspaces.org/wiki/List_of_Hacker_Spaces">hackerspaces</a>&quot;. But don&#39;t worry they have nothing to do with hackers and bad guys, in fact they are very friendly and open to anyone.</p>
<p>We understand that things might be tough in the financial chapter right now, it might seem strange but we want to give you our money , just give us the stuff we need!&nbsp; We are here to help and give you feedback. Together&nbsp; we can change many things for the better. Never underestimate the power that our online community has!</p>
<p>With love,</p>
<p>The Electronics Hobbyists of America</p>
<p>&quot;</p>
<p>Once again, if you&#39;d like to join the petition please leave a comment or publish it on your site, let&#39;s hope they will hear us :)</p>
<p>//starlino//&nbsp;&nbsp;</p>
<p>September 16, 2010</p>
]]></content:encoded>
			<wfw:commentRss>http://www.starlino.com/wake-up-letter-to-radioshack-the-hobbyists-are-back.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Hobby electronics is a serious business !</title>
		<link>http://www.starlino.com/hobby-electronics-is-serious-business.html</link>
		<comments>http://www.starlino.com/hobby-electronics-is-serious-business.html#comments</comments>
		<pubDate>Wed, 15 Sep 2010 23:22:39 +0000</pubDate>
		<dc:creator>starlino</dc:creator>
				<category><![CDATA[News and Discussions]]></category>
		<category><![CDATA[business]]></category>
		<category><![CDATA[electronics]]></category>

		<guid isPermaLink="false">http://www.starlino.com/?p=108</guid>
		<description><![CDATA[I can&#39;t help myself but notice that more and more electronics giants are starting to realize that hobby electronics is becoming a serious business ! Newark has just launched their new hobbyist / maker oriented web site www.element14.com as well as their own video blog&#160; persona Ben Heck. When I first saw Ben I thought [...]]]></description>
				<content:encoded><![CDATA[<p>I can&#39;t help myself but notice that more and more electronics giants are starting to realize that hobby electronics is becoming a serious business !</p>
<p><strong>Newark </strong>has just launched their new hobbyist / maker oriented web site <a href="http://www.element14.com/">www.element14.com</a> as well as their own video blog&nbsp; persona Ben Heck. When I first saw Ben I thought &quot;I didn&#39;t know <a href="http://en.wikipedia.org/wiki/Conan_O%27Brien">Conan O&#39;Brian</a> is into electronics. Wait that&#39;s not Conan !&quot;. Just like David L. Jones from <a href="http://eevblog.com">EEVBlog</a> , Ben likes to take things apart even before turning them on. I enjoyed very much his <a href="http://www.youtube.com/watch?v=cdK1jeEJGZY">X-Box tear down and custom foot controlled XBox controller&nbsp;</a> and I am looking forward to seeing more videos like this.</p>
<p><strong>Jameco</strong> has teamed up with <a href="http://makezine.com/">Make Magazine &#39;s</a>&nbsp;&nbsp; <a href="http://blog.makezine.com/archive/author/collin_cunningham/">Collin Cunningham</a> and forged a series of <a href="http://www.youtube.com/watch?v=ihoX7x0RBz8">video tutorials</a> aimed towards electronics beginners. And yes they finally carry <a href="http://www.jameco.com/webapp/wcs/stores/servlet/StoreCatalogDrillDownView?langId=-1&amp;storeId=10001&amp;catalogId=10001&amp;search_type=jamecoall&amp;freeText=arduino">Arduino in stock</a>&nbsp; !</p>
<p>In the same spirit , <strong>Texas Instruments</strong> launched few months ago a subsidized development platform <a href="http://processors.wiki.ti.com/index.php/MSP430_LaunchPad_%28MSP-EXP430G2%29?DCMP=launchpad&amp;HQS=Other+PR+launchpadwiki-pr">MSP430 LaunchPad</a> trying to win the hearts of all those Microchip PIC and Atmel AVR fanboys out there. But word along the benches is that it ain&#39;t gonna happen unless they make it Arduino shield pin compatible :).</p>
<p>Old news already &#8211; but <strong>ST</strong> tried a similar move with their <a href="http://www.st.com/mcu/contentid-130-113-STM8S_DISCOVERY.html">STM8S-Discovery kit</a> , not sure how many people they converted but it&#39;s interesting to see some competition going on for this hobbyist /&nbsp; maker , no-longer-niche market.</p>
<p><strong><a href="http://www.adafruit.com/">Adafruit</a></strong> and <strong><a href="http://www.sparkfun.com/">Sparkfun&nbsp;</a></strong> are two wonderful pioneer companies that showed to the world that &nbsp; [title of this post]&nbsp; = TRUE&nbsp; ! They started&nbsp; from zero and reached millions of dollars in sales in just few years. A good example that if you like what you&#39;re doing and you are passionate about it &#8211; you&#39;re going to go a long way.</p>
<p>Overall my feeling is that we are witnessing a new boom right now.&nbsp; Robotics and Electronics is for 2010&#39;s what&nbsp; Internet was for 2000&#39;s and personal computers for 1990&#39;s. For all those still in doubt , or who haven&#39;t&nbsp; send their college applications yet &#8211; this is THE FIELD to work in the next decade ! A lot of wonderful things are just waiting to happen ! Stay tuned and enjoy the ride.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.starlino.com/hobby-electronics-is-serious-business.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hakko 808 Desoldering Tool Review</title>
		<link>http://www.starlino.com/hakko-808-desoldering-tool-review.html</link>
		<comments>http://www.starlino.com/hakko-808-desoldering-tool-review.html#comments</comments>
		<pubDate>Tue, 27 Jul 2010 16:20:03 +0000</pubDate>
		<dc:creator>starlino</dc:creator>
				<category><![CDATA[Benchmarks and Reviews]]></category>
		<category><![CDATA[desoldering]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://starlino_wp/?p=42</guid>
		<description><![CDATA[If you&#39;re into electronics sooner or later you will need to desolder something. Also, if you don&#39;t have the proper tools or skills you&#39;ll damage a component or two or even the PCB. Been there done that &#8211; desoldering braid, cheap one-shot mechanical pumps, running the soldering iron from one pin to another &#8230; until [...]]]></description>
				<content:encoded><![CDATA[<p>If you&#39;re into electronics sooner or later you will need to desolder something. Also, if you don&#39;t have the proper tools or skills you&#39;ll damage a component or two or even the PCB. Been there done that &#8211; desoldering braid, cheap one-shot mechanical pumps, running the soldering iron from one pin to another &#8230; until one day I decided to look for a good professional desoldering tool. First I&nbsp; purchased an all-in-one system that among the soldering iron and hot air,&nbsp; had a desoldering funtion. The pump was in the main unit and the desoldering iron was connected by a rubber tube. As it turns out these units have a typical design flaw &#8211; because the pump is so far away from the desoldering iron&nbsp; tip the suction is somewhat weak. Keep in mind that air is flexible so the longer the tube the more pressure is lost along the way. So if you&#39;re buying such a unit make sure the pump is really strong and has a gauge that will allow you to monitor the pressure. That unit has been returned and I am not even going to mention its name ! Then I came across Hakko 808 and until this day this is one of my favorite tools in my workshop. The suction power of this tool is amazing, easy to handle , heats up quickly , not very expensive. It requires regular maintenance (it&#39;s almost like a pet), but if you take care of it you&#39;ll save hours of work and many components and PCBs. Here is an example of what it can do, I received this LiPo charger with some terminal headers that I wanted to replace with different ones:</p>
<p><object height="385" width="480"><param name="movie" value="http://www.youtube.com/v/e3MCUf1ISAw&amp;hl=en_US&amp;fs=1" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><embed allowfullscreen="true" allowscriptaccess="always" height="385" src="http://www.youtube.com/v/e3MCUf1ISAw&amp;hl=en_US&amp;fs=1" type="application/x-shockwave-flash" width="480"></embed></object></p>
<p><span id="more-42"></span>Here are close-ups of the before and after desoldering:</p>
<p><img alt="" height="480" src="/wp-content/uploads/data/hako_808_desoldering_tool_review/IMG_1383.JPG" width="640" /></p>
<p><img alt="" height="480" src="/wp-content/uploads/data/hako_808_desoldering_tool_review/IMG_1379.JPG" width="640" /></p>
<p>As you can see desoldering something is really easy, and you get a really-really clean result with this tool.</p>
<p>There are few things to take care of though:</p>
<p>- do not touch the PCB traces for more than one second, this tool is hot and if you heat up the pads for too long it will suck them up<br />
	- buy several tip sizes for different jobs ,&nbsp; i got&nbsp; 1mm (comes in the kit) and additionally I got&nbsp; 1.8mm and 2.3mm tips<br />
	- clean your tool regularly. The most replaced items are the ceramic filters so stock up on those, when they harden from the flux it&#39;s time to replace them.</p>
<p><img alt="" height="897" src="http://www.starlino.com/wp-content/uploads/data/hako_808_desoldering_tool_review/hakko_808_how_to_use.png" width="533" /></p>
<p><em>Source: <a href="http://www.starlino.com/wp-content/uploads/data/hako_808_desoldering_tool_review/Hakko_808_Manual.pdf" target="_blank">Hakko 808 Manual&nbsp; (Download PDF)</a><br />
	</em></p>
<p>Hakko 808 Kit comes with a carry-on case and few spare parts. What is missing is a holder, that you can buy separately (Hakko 633), however the tool will lay on it&#39;s side on the table without touching the surface so that will suffice if you don&#39;t have a holder. Another feature that is missing is a&nbsp; an on/off switch, unplugging this from power outlet is not convenient especially if you have to crawl under the table with a hot tool on the table :)</p>
<p><a href="http://www.starlino.com/wp-content/uploads/data/hako_808_desoldering_tool_review/IMG_1490.JPG" target="_blank"><img alt=""  src="http://www.starlino.com/wp-content/uploads/data/hako_808_desoldering_tool_review/IMG_1490.JPG" width="740" /></p>
</a><p><img alt="" height="480" src="/wp-content/uploads/data/hako_808_desoldering_tool_review/IMG_1385.JPG" width="640" /></p>
<p>Overall Hakko 808 is great tool , worth every penny, and I would buy it again if it breaks, speaking of which it is nicely build and has spare parts available so self-repair is possible and even encouraged and explained in the manual.</p>
<p>//starlino//</p>
<p>&nbsp;</p>
<p><iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://rcm.amazon.com/e/cm?lt1=_blank&amp;bc1=000000&amp;IS1=1&amp;bg1=FFFFFF&amp;fc1=000000&amp;lc1=0000FF&amp;t=librarian06-20&amp;o=1&amp;p=8&amp;l=as1&amp;m=amazon&amp;f=ifr&amp;asins=B000ARPULW" style="width: 120px; height: 240px;"></iframe></p>
<p><a href="http://www.amazon.com/gp/product/B000B63604?ie=UTF8&amp;tag=librarian06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B000B63604">Hakko A1229: Hakko Replacement Pre-Filters for 808-5, 10/pkg.</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=librarian06-20&amp;l=as2&amp;o=1&amp;a=B000B63604" style="border: medium none ! important; margin: 0px ! important;" width="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.starlino.com/hakko-808-desoldering-tool-review.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Upgrade your RC Transmitter with a DIY Tilt Motion Control Module</title>
		<link>http://www.starlino.com/rc_transmitter_accelerometer.html</link>
		<comments>http://www.starlino.com/rc_transmitter_accelerometer.html#comments</comments>
		<pubDate>Thu, 24 Jun 2010 23:44:03 +0000</pubDate>
		<dc:creator>starlino</dc:creator>
				<category><![CDATA[IMU Theory and Experiments]]></category>
		<category><![CDATA[accelerometer]]></category>
		<category><![CDATA[imu]]></category>
		<category><![CDATA[motion]]></category>
		<category><![CDATA[op-amp]]></category>
		<category><![CDATA[rc]]></category>
		<category><![CDATA[transmitter]]></category>

		<guid isPermaLink="false">http://rc_transmitter_accelerometer</guid>
		<description><![CDATA[If you are into Radio Control Models or robotics chances are that you have an old RC transmitter laying around. This article describes how to create a motion control module for your RC transmitter, that will allow you to control your model or robot by simply tilting the transmitter case. That's right no more wiggling the sticks!]]></description>
				<content:encoded><![CDATA[<p>If you are into Radio Control Models or robotics chances are that you have an old RC transmitter laying around. This article describes how to create a motion control module for your RC transmitter, that will allow you to control your model or robot by simply tilting the transmitter case. That&#39;s right not sticks!</p>
<h2>Demo</h2>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" height="344" width="425"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/U0FaM6A1zDE&amp;hl=en&amp;fs=1" /><embed allowfullscreen="true" allowscriptaccess="always" height="344" src="http://www.youtube.com/v/U0FaM6A1zDE&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash" width="425"></embed></object></p>
<p><span id="more-23"></span>Testing one axis:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" height="344" width="425"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/GqEDDWv6-ak&amp;hl=en&amp;fs=1" /><embed allowfullscreen="true" allowscriptaccess="always" height="344" src="http://www.youtube.com/v/GqEDDWv6-ak&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash" width="425"></embed></object></p>
<h2>Schematic</h2>
<p><img alt="rc_transmitter_motion_control_schematic_full.png" src="data/rc_transmitter_accelerometer/rc_transmitter_motion_control_schematic_full.png" /></p>
<p>&nbsp;</p>
<h2>How it Works</h2>
<p>The RC transmitter uses a potentiometer for each axis, it acts as a voltage divider sending a voltage of 0..5V (the middle position corresponds to 2.5V) to the analog input that is converted into a pule of&nbsp; 1..2ms that is sent over RF.</p>
<p>This module converts (amplifies and shifts) the accelerometer analog output , usually&nbsp; 1.65 +/- 0.4V to the same range of the potentiometer and sends it to the transmitter instead.</p>
<p>An op-amp in an inverting amplifier configuration is used. Vref is set manually by tuning the output to be 2.5V (or the PWM pulse to be 1.5 ms). However it is possible to calculate the theoretical value as follows:</p>
<p>Note that according to the rules of&nbsp; a feedback op-amp the voltage on it&#39;s inverting/non-inverting terminals tends to equalize so &nbsp; V(+) = V(-) and in our case&nbsp; = Vref.</p>
<p>Since no significant current enters the op-amp , the currents going through R1 and R2 are equal:</p>
<p>( V(-) &#8211; Vin ) / R1 = ( Vout &#8211; V(-) ) / R2&nbsp;&nbsp;</p>
<p>(Vref &#8211; Vin) / R1 = (Vout &#8211; Vref) / R2</p>
<p>solving for Vout gives us</p>
<p>Vout = Vref -&nbsp; R2/R1 (Vin &#8211; Vref)&nbsp;&nbsp;&nbsp; =&nbsp;&nbsp; Vref( 1 + R2/R1)&nbsp; &#8211; R2/R1 * Vin</p>
<p>now let&#39;s do some notations</p>
<p>G = &#8211; R2/R1</p>
<p>Vout = Vref( 1 &#8211; G)&nbsp; -&nbsp; G * Vin</p>
<p>According to our schematic&nbsp; G =&nbsp; R2 / R1 =&nbsp; &#8211; 5.12 , this will convert the accelerometer swing of 0.4 V to a swing of&nbsp;&nbsp; 0.4 V * 5.12&nbsp; ~&nbsp; 2V .</p>
<p>We want&nbsp; to make &nbsp; Vin = 1.65&nbsp; correspond to a&nbsp; Vout = 2.5 so we&nbsp; have the equation</p>
<p>2.5 =&nbsp; Vref (1 + 5.12)&nbsp; &#8211; 5.12 * 1.65</p>
<p>from here we find</p>
<p>Vref =&nbsp; (2.5 + 5.12 * 1.65 ) /&nbsp; (1 + 5.12) = 1.78888 V</p>
<p>Well, this is the theoretical value , in practice we adjust the trimmer R3 until the output is 2.5 while the accelerometer is in laying in horizontal position (has an output of 1.65V).</p>
<h2>How to Build</h2>
<p>To build use a small proto-board following schematic. Part numbers are mentioned on schematic. Hook-up with the transmitter is described in images below and on the schematic. For accelerometer use <a href="http://www.gadgetgangster.com/213">Acc_Gyro</a> or similar module, <a href="surface_mount_reflow.html">or build your own accelerometer break-out board</a>.</p>
<h2><img alt="rc_transmitter_tap_in.jpg" src="data/rc_transmitter_accelerometer/rc_transmitter_tap_in.jpg" /></h2>
<h2>&nbsp;</h2>
<h2><img alt="rc_transmitter_tap_in_switch.JPG" src="data/rc_transmitter_accelerometer/rc_transmitter_tap_in_switch.JPG" /></h2>
<p>&nbsp;</p>
<p>The module is mounted in a free space under antenna using double-sided foam tape &#8211; best way to mount an accelerometer to avoid vibration. Note that we get +5V power for the module from the potentiometer contacts. You can test&nbsp; with a led that the power contacts can deliver at least 20mV, the module uses far less &lt;5mA.</p>
<p><img alt="IMG_1485.JPG" src="data/rc_transmitter_accelerometer/IMG_1485.JPG" /></p>
<p>Here is a close-up of the module, as you can see I did&nbsp; <a href="surface_mount_reflow.html">my own accelerometer break-out board</a>, but you can buy a pre-assembled one , there are many choices. You will need an analog accelerometer for this project.</p>
<p><img alt="IMG_1483.JPG" src="data/rc_transmitter_accelerometer/IMG_1483.JPG" /></p>
<p>&nbsp;</p>
<p>Enjoy your new RC Tilt Transmitter. For any comments/questions use the comment form below.</p>
<p>&nbsp;</p>
<p>//starlino//</p>
]]></content:encoded>
			<wfw:commentRss>http://www.starlino.com/rc_transmitter_accelerometer.html/feed</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Quadcopter Prototype using Acc_Gyro and a PIC</title>
		<link>http://www.starlino.com/quadcopter_acc_gyro.html</link>
		<comments>http://www.starlino.com/quadcopter_acc_gyro.html#comments</comments>
		<pubDate>Wed, 09 Jun 2010 23:27:15 +0000</pubDate>
		<dc:creator>starlino</dc:creator>
				<category><![CDATA[Quadcopter]]></category>
		<category><![CDATA[accelerometer]]></category>
		<category><![CDATA[gyroscope]]></category>
		<category><![CDATA[imu]]></category>
		<category><![CDATA[pic]]></category>
		<category><![CDATA[quadcopter]]></category>

		<guid isPermaLink="false">http://quadcopter_acc_gyro</guid>
		<description><![CDATA[<p>This article introduces a new project I am working on - a&#160; Quadcopter using Acc_Gyro and a PIC. I share some things I learned along the way so far.</p>]]></description>
				<content:encoded><![CDATA[<p>For anyone following this site, here is what I&#39;ve been up to lately &#8211; building a quadcopter based on the <a href="http://gadgetgangster.com/213">Acc_Gyro 5DOF IMU</a> sensor and a 16bit PIC. Although it&#39;s still a work in progress I decided to start putting together an article placeholder and build it up as project evolves. It&#39;s going to be a long one !</p>
<p>The source code will be Open-Source and will be hosted on Google Code, you can get code for quad copter here:</p>
<p><a href="http://code.google.com/p/picquadcontroller/source/browse/#svn/trunk">http://code.google.com/p/picquadcontroller/source/browse/#svn/trunk</a></p>
<p>As usual I like to start with a video demo, it&#39;s basically me controlling the tilt of the quad using a RC controller:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" height="505" width="640"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/q_BZfG2xYdI&amp;hl=en_US&amp;fs=1&amp;" /><embed allowfullscreen="true" allowscriptaccess="always" height="505" src="http://www.youtube.com/v/q_BZfG2xYdI&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" width="640"></embed></object></p>
<p><span id="more-22"></span>This is a PID feedback algorithm and a &quot;Simplified Kalman Filter&quot; as&nbsp; described in my other articles.</p>
<p>First of all there&#39;s a a RCGroups thread where I first introduced the project</p>
<p>http://www.rcgroups.com/forums/showthread.php?t=1235360</p>
<p>You&#39;ll find some specs there and I will put some material here&nbsp; as well.</p>
<p>Here is Revision 0.1 of schematic (what I started with):</p>
<p><a href="data/PicQuadController/PicQuadControllerRev01.pdf">PicQuadControllerRev01.pdf</a></p>
<p>The major parts list is as follows:</p>
<p><strong>MCU:</strong>&nbsp; DSPIC33FJ128MC802&nbsp; (<a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en532302">http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en532302</a>)</p>
<p><strong>Sensors</strong>: 5DOF Acc_Gyro ( <a href="http://gadgetgangster.com/213">http://gadgetgangster.com/213</a> )&nbsp; + 1Dof Pololu LIST300AL-BREAKOUT (<a href="http://www.pololu.com/catalog/product/765">http://www.pololu.com/catalog/product/765</a>).</p>
<p><strong>Motor Drivers:</strong>&nbsp; Power N-Channel Mosfets (Many choices -Low Rds(on) and rated for the current , I used&nbsp; IRLR8743 ). Schottky diodes to protect against back-EMF ( I used SS2H10-E3/52T )</p>
<p><strong>Frame , motors propellers</strong>: I picked a ready platform that was on sale <a href="http://www.rctoys.com/rc-toys-and-parts/DF-COMPLETE-AIRFRAME/RC-PARTS-DRAGANFLYER-FRAME.html" target="_blank">Dragandfly IV Frame</a> these are actually brushed motors same ones as used in Esky helicopters.</p>
<p>I did some tests on the lift force potential of this frame+motors+props, and was surprise to find out it performed better than some entry-level brushless motors. The lift force of this platform is up to 2.25 lbs.&nbsp; The results of lift-force experiments are compiled in this spreadheet: <a href="data/PicQuadController/MotorLiftPower.pdf" target="_blank">MotorLiftPower.pdf</a>.</p>
<p>How I measured the lift force ?&nbsp; I didn&#39;t have any fancy equipment so I simply fixed the quad in a vise and weighted&nbsp; it it at different throttle levels &#8211; the difference in weight gave me the lift power.</p>
<p><a href="/wp-content/uploads/data/PicQuadController/IMG_1463.JPG" target="_blank"><img alt="IMG_1463.JPG"  src="/wp-content/uploads/data/PicQuadController/IMG_1463.JPG" width="740" /></p>
</a><p>For testing just one motor, I used a string attached to the weight:</p>
<p><a href="/wp-content/uploads/data/PicQuadController/IMG_1460.JPG" target="_blank"><img alt="IMG_1460.JPG"  src="/wp-content/uploads/data/PicQuadController/IMG_1460.JPG" width="740" /></p>
</a><p>I built a test rig out of wood for testing the tilt balancing algorithm as you see in the video.</p>
<p>Here are some close-ups of the motor drivers. You&#39;ll&nbsp; see the Mosfets and the Schottky diodes, also note the extra solder added to support the high currents that will flow through those traces ( up to 5A per motor !).</p>
<p><a href="/wp-content/uploads/data/PicQuadController/IMG_1465.JPG" target="_blank"><img alt="IMG_1465.JPG"  src="/wp-content/uploads/data/PicQuadController/IMG_1465.JPG" width="740" /></p>
</a><p>Finally here is a view on the top of the board ( notice the PIC , the switching regulator&nbsp; ,&nbsp; Acc_Gyro 5DOF IMU and single axes Gyro breakout , from top-left to bottom right).</p>
<p><a href="/wp-content/uploads/data/PicQuadController/IMG_1466.JPG" target="_blank"><img alt="IMG_1466.JPG"  src="/wp-content/uploads/data/PicQuadController/IMG_1466.JPG" width="740" /></p>
</a><p>This is it for now hope to bring you more interesting stuff on this and other projects if time allows&nbsp; !</p>
<p>//starlino//</p>
]]></content:encoded>
			<wfw:commentRss>http://www.starlino.com/quadcopter_acc_gyro.html/feed</wfw:commentRss>
		<slash:comments>48</slash:comments>
		</item>
		<item>
		<title>Play PC games the iPad style  &#8211; Using a PIC with  USB,  accelerometer  and optional Gyroscope</title>
		<link>http://www.starlino.com/usb_thumb_imu.html</link>
		<comments>http://www.starlino.com/usb_thumb_imu.html#comments</comments>
		<pubDate>Tue, 06 Apr 2010 12:43:50 +0000</pubDate>
		<dc:creator>starlino</dc:creator>
				<category><![CDATA[Motion Sensing USB Devices]]></category>
		<category><![CDATA[accelerometer]]></category>
		<category><![CDATA[Acc_Gyro]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[imu]]></category>
		<category><![CDATA[motion]]></category>
		<category><![CDATA[usb]]></category>
		<category><![CDATA[UsbThumb]]></category>

		<guid isPermaLink="false">http://usb_thumb_imu</guid>
		<description><![CDATA[<p>The iPad is finally out - one feature that might caught your attention is the built-in accelerometer and the ability to control a game by tilting the device. But it turns out you can do same thing on your laptop. Read on to find out how.</p>]]></description>
				<content:encoded><![CDATA[<p>The iPad is finally out &#8211; one feature that might caught your attention is the built-in accelerometer and the ability to control a game by tilting the device. For more than a year I was working on a similar idea for the PC Notebook market based on my original&nbsp; motion gamepad project that would&nbsp; allow playing a game by tilting the laptop/netbook. Now that iPad is out I hope that the notebook/netbook manufactures will catch up by incorporating MEMS sensor into their devices. Here is the result of my prototype , it is a USB attached device, but ideally I think this should be embedded into the laptop.</p>
<p><strong>Demo:</strong></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" height="385" width="640"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/CTSlfDLNlUo&amp;hl=en_US&amp;fs=1&amp;" /><embed allowfullscreen="true" allowscriptaccess="always" height="385" src="http://www.youtube.com/v/CTSlfDLNlUo&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" width="640"></embed></object></p>
<p><span id="more-21"></span></p>
<p><strong>About the project:</strong></p>
<p>For the hardware I used the <a href="http://www.gadgetgangster.com/213">Acc_Gyro</a> sensor and a thumb-size PIC platform <a href="http://www.gadgetgangster.com/240">UsbThumb</a> built around the inexpensive PIC18F14K50 chip that provides all the necessary USB connectivity and ADC inputs.</p>
<p>This setup is actually hardware compatible with my original <a href="http://www.gadgetgangster.com/231">Motion Gamepad</a> design so all the software utilities and firmware will work on the Acc_Gyro + UsbThumb combination that is available as a kit under the name of <a href="http://www.gadgetgangster.com/290">UsbThumbImu </a>. The Acc_Gyro fits on top of UsbThumb and this is not a coincidence since UsbThumb was designed as microcontroller helper for the Acc_Gyro with the idea of being able to provide the USB/Serial/SPI/I2C interface, as well as making use of the built-in 10bit ADC module of the PIC18F14K50.</p>
<p><img alt="" height="244" src="http://www.gadgetgangster.com/scripts/thumbs/pic/290/4433949229_26c3104238_b.jpg" width="300" /></p>
<p>&nbsp;</p>
<p><img alt="" height="244" src="http://www.gadgetgangster.com/scripts/thumbs/pic/290/4434725210_859ebbffe2_b.jpg" width="300" /></p>
<p>&nbsp;</p>
<p>In the pictures above headers are used to connect the device, so the end result is a little taller&nbsp; than you could get if you&#39;d simply solder the two boards together. Both devices have been designed for people that would like to extend&nbsp; or experiment with the existing solution so there is a second row of connectors on the UsbThumb that can be used to connect buttons or other devices to the project.&nbsp;</p>
<p>&nbsp;</p>
<p>All that&#39;s it for now &#8211; hope you liked the project. It was really easy to built having the two important components UsbThumb and Acc_Gyro. You&#39;ll find more info on individual components on my website as well as&nbsp; on the <a href="http://www.gadgetgangster.com/290">GadgetGangster</a> site with whom I partnered to provide kits for anyone interested. If you don&#39;t find the necessary information, or you have any any suggestions, ideas or questions &#8211; as always feel free to drop me a line with in the comment area below.</p>
<p>&nbsp;</p>
<p>//starlino//</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://www.gadgetgangster.com/240"><br />
	</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.starlino.com/usb_thumb_imu.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Trickster Mouse Emulator – April Fools Day Practical Joke</title>
		<link>http://www.starlino.com/usbthumb_mouse_emulator.html</link>
		<comments>http://www.starlino.com/usbthumb_mouse_emulator.html#comments</comments>
		<pubDate>Wed, 31 Mar 2010 18:57:43 +0000</pubDate>
		<dc:creator>starlino</dc:creator>
				<category><![CDATA[Fun Projects]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[mouse]]></category>
		<category><![CDATA[pic]]></category>
		<category><![CDATA[usb]]></category>
		<category><![CDATA[UsbThumb]]></category>

		<guid isPermaLink="false">http://usbthumb_mouse_emulator</guid>
		<description><![CDATA[<p>Trickster is a simple application built on UsbThumb platform. It tricks your victim into thinking they have a virus on their computer, by hardware emulating and moving their mouse in circles on intermittent intervals.</p>]]></description>
				<content:encoded><![CDATA[<p>Trickster is a simple application built on UsbThumb platform. It tricks your victim into thinking they have a virus on their computer, by hardware emulating and moving their mouse in circles on intermittent intervals.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" height="300" width="400"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=10510369&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed allowfullscreen="true" allowscriptaccess="always" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=10510369&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" width="400"></embed></object></p>
<p><span id="more-20"></span>It is basically a customization of Mouse emulation demo that Microchip bundles with their USB Framework.</p>
<p>The code responsible for enabling/disabling mouse emulation is triggered by a timer interrupt like so:</p>
<p>
	<span class="edit_monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OpenTimer0( TIMER_INT_ON &amp;<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; T0_16BIT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; T0_SOURCE_INT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; T0_PS_1_256);</p>
<p>	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8230;&#8230;&#8230;&#8230;.</span></p>
<p><span class="edit_monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //These are your actual interrupt handling routines.</span></p>
<p>&nbsp;</p>
<p><span class="edit_monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #pragma interrupt YourHighPriorityISRCode<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void YourHighPriorityISRCode()<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Check which interrupt flag caused the interrupt.<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Service the interrupt<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Clear the interrupt flag<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Etc.<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #if defined(USB_INTERRUPT)<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; USBDeviceTasks();<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #endif<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(INTCONbits.TMR0IF){<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; counter_s++; <br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //to interrupt every 1s we need to count FOSC / 4/ 256&nbsp; = 46875 ticks (0xB71B)<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //to count these ticks till overflow we need to set TMR0 to&nbsp; 0xFFFF &#8211; 0xB71B = 0x48E4 <br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TMR0H = 0&#215;48; //will write to TMR0H buffer<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TMR0L = 0xE4; //will write actual TMR0L / TMR0H&nbsp; </p>
<p>	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INTCONbits.TMR0IF = 0;<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //This return will be a &quot;retfie fast&quot;, since this is in a #pragma interrupt section</span></p>
<p class="edit_monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8230;&#8230;&#8230;&#8230;&#8230;..</p>
<p>	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INTCONbits.TMR0IE = 0;&nbsp; //disable Timer0 interrupt<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(emulate_mode &amp;&amp; counter_s &gt; 3){&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // seconds on<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; counter_s = 0;<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; emulate_mode = 0;<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }else if (!emulate_mode &amp;&amp; counter_s &gt; 60){&nbsp;&nbsp;&nbsp;&nbsp; //seconds off<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; counter_s = 0;<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; emulate_mode = 1;<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INTCONbits.TMR0IE = 1;</p>
<p>&nbsp;</p>
<p><span class="edit_monospace"><br />
	</span></p>
<p>For full source code see:</p>
<p><a href="http://code.google.com/p/usbthumb/source/browse/#svn/trunk/UsbThumbMousePrank" target="_blank">http://code.google.com/p/usbthumb/source/browse/#svn/trunk/UsbThumbMousePrank</a></p>
<p><strong>UsbThumb is an open-hardware platform, anyone can build their own:</strong></p>
<p><a href="http://code.google.com/p/usbthumb/source/browse/#svn/trunk/Hardware" target="_blank">http://code.google.com/p/usbthumb/source/browse/#svn/trunk/Hardware</a></p>
<p>or pick up a prebuilt SMT version of UsbThumb here: <a href="http://www.gadgetgangster.com/303">http://www.gadgetgangster.com/303</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.starlino.com/usbthumb_mouse_emulator.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
