 
<?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>PocketMagic</title>
	<atom:link href="http://www.pocketmagic.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pocketmagic.net</link>
	<description>Where Technology meets magic</description>
	<lastBuildDate>Wed, 19 Jun 2013 08:53:17 +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>Cartoon yourself using Leptonica</title>
		<link>http://www.pocketmagic.net/2013/06/cartoon-yourself-using-leptonica/</link>
		<comments>http://www.pocketmagic.net/2013/06/cartoon-yourself-using-leptonica/#comments</comments>
		<pubDate>Sat, 15 Jun 2013 16:46:17 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Image processing]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[image processing]]></category>
		<category><![CDATA[leptonica]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=4355</guid>
		<description><![CDATA[Showing how to create a cartoon effect using the image processing library Leptonica ]]></description>
				<content:encoded><![CDATA[<h3>Intro</h3>
<p>I'm a big fan of image processing that I've put to use in various previous projects, related to robotics and artificial vision, such as <a href="http://www.pocketmagic.net/2009/03/robo-evolution-how-to-build-a-better-robot" target="_blank">this one</a>, or for video surveillance and <a href="http://www.pocketmagic.net/2010/08/webcam-surveillance-with-motion-detection-algorithm/" target="_blank">motion detection</a>, but also other work projects.<br />
Image processing is a vast and captivating domain, handling ways of image representation and the transformations that can be applied , for unlimited applications. We can use it to extract characteristics related to the image: shapes (such as  detecting human faces), numbers and text (for OCR purposes), enhancing the visibility, content readability or simply for aesthetic purposes (in photography), we can encode information (cryptography/security), or make a robot follow the user's red jacket. The imagination is the limit.<br />
All the image related operations can consume a lot of processing power, so optimized algorithms taking advantage of the way the image is encoded, and doing low level operations at bit level, must be used. Math is also required as many image transformations use mathematical models that not only need to work correctly, but must be implemented in the most optimum way. </p>
<h3>Leptonica</h3>
<p>Over the time, mostly for academic purposes I've implemented various libraries to handle image processing both for mobile and desktop platforms. But recently I decided to use an open source library, named <a href="http://www.leptonica.com/" target="_blank">Leptonica</a>, and presented as an "a pedagogically-oriented open source site containing software that is broadly useful for image processing and image analysis applications." A few days after using it I couldn't go without it. Not only it offers a robust interface to the basics: various file formats, loading and saving images, supporting and converting from multiple representation systems, but it implements powerful primitives to allow almost any possible transformation on an image. It is open source and so it exposes the internal secrets to anyone willing ot customize the code or to push the performance even further. And talking about performance , it is doing great: bit-wise operations, mathematically improved algorithms, to minimize the work load and do the job in the shortest time.</p>
<h3>A sample</h3>
<p>As per the article's title, the plan is to implement a simple cartoon transformation effect, using leptonica, on a regular picture. Well not quite regular, as I chose a beautiful lady for the viewer's delight.</p>
<table cellspacing="2" cellpadding="0" border="1">
<tr>
<td><center><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/06/girl_with_roses.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/06/girl_with_roses-199x300.jpg" alt="girl_with_roses" width="199" height="300" class="alignnone size-medium wp-image-4356" /></a><br />
Step 1</center></td>
<td><center><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/06/leptonica_cartoonizer_01_gray.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/06/leptonica_cartoonizer_01_gray-199x300.jpg" alt="leptonica_cartoonizer_01_gray" width="199" height="300" class="alignnone size-medium wp-image-4358" /></a><br />
Step 2</center></td>
<td><center><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/06/leptonica_cartoonizer_02_edges.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/06/leptonica_cartoonizer_02_edges-199x300.jpg" alt="leptonica_cartoonizer_02_edges" width="199" height="300" class="alignnone size-medium wp-image-4360" /></a><br />
Step 3</center></td>
</tr>
<tr>
<td><center><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/06/leptonica_cartoonizer_03_edges_inverted.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/06/leptonica_cartoonizer_03_edges_inverted-199x300.jpg" alt="leptonica_cartoonizer_03_edges_inverted" width="199" height="300" class="alignnone size-medium wp-image-4361" /></a><br />
Step 4</center>
</td>
<td><center><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/06/leptonica_cartoonizer_04_blur.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/06/leptonica_cartoonizer_04_blur-199x300.jpg" alt="leptonica_cartoonizer_04_blur" width="199" height="300" class="alignnone size-medium wp-image-4362" /></a><br />
Step 5</center></p>
<td><center><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/06/leptonica_cartoonizer_05_cartoon.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/06/leptonica_cartoonizer_05_cartoon-199x300.jpg" alt="leptonica_cartoonizer_05_cartoon" width="199" height="300" class="alignnone size-medium wp-image-4363" /></a><br />
Step 6</center>
</td>
</tr>
</table>
<p><b>Step 1: loading the original image</b>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">PIX *pixSrcImg = pixRead<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;girl_with_roses.jpg&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></pre>
<p><b>Step 2: convert to grayscale, taking the maximum deviation into account</b></p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">PIX *pixGrayMM = pixConvertRGBToGrayMinMax<span style="color: #66cc66;">&#40;</span>pixSrcImg, L_CHOOSE_MAX<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pixWrite<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;leptonica_cartoonizer_01_gray.jpg&quot;</span>, pixGrayMM, IFF_JFIF_JPEG<span style="color: #66cc66;">&#41;</span>;</div></li></ol></pre>
<p><b>Step 3: perform edge detect</b></p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">PIX *pixEdges = pixEdgeFilter<span style="color: #66cc66;">&#40;</span>pixGrayMM,  L_ALL_EDGES<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pixWrite<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;leptonica_cartoonizer_02_edges.jpg&quot;</span>, pixEdges, IFF_JFIF_JPEG<span style="color: #66cc66;">&#41;</span>;</div></li></ol></pre>
<p><b>Step 4: invert the edges</b></p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">PIX *pixEdgesInverted = pixInvert<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">NULL</span>, pixEdges<span style="color: #66cc66;">&#41;</span>; </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pixWrite<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;leptonica_cartoonizer_03_edges_inverted.jpg&quot;</span>, pixEdgesInverted, IFF_JFIF_JPEG<span style="color: #66cc66;">&#41;</span>;</div></li></ol></pre>
<p><b>Step 5: blur the inverted edges, to reduce the roughness a little bit</b></p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">PIX *pixBlur = pixBlur5<span style="color: #66cc66;">&#40;</span>pixEdgesInverted<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pixWrite<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;leptonica_cartoonizer_04_blur.jpg&quot;</span>, pixBlur, IFF_JFIF_JPEG<span style="color: #66cc66;">&#41;</span>;</div></li></ol></pre>
<p><b>Step 6: combine the last result with the original image, using a factor (150, can be changed)</b></p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">PIX *pixCartoon = pixBlendHardLight<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">NULL</span>,  pixSrcImg, pixBlur,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span> ,<span style="color: #cc66cc;">150</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pixWrite<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;leptonica_cartoonizer_05_cartoon.jpg&quot;</span>, pixCartoon, IFF_JFIF_JPEG<span style="color: #66cc66;">&#41;</span>;</div></li></ol></pre>
<p><b>Here's the result:</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/06/cartoon-yourself-girl-with-roses.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/06/cartoon-yourself-girl-with-roses.jpg" alt="cartoon yourself girl with roses" width="800" height="602" class="alignnone size-full wp-image-4383" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/06/cartoon-yourself-using-leptonica/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A 3D Carousel View for Android</title>
		<link>http://www.pocketmagic.net/2013/06/a-3d-carousel-view-for-android/</link>
		<comments>http://www.pocketmagic.net/2013/06/a-3d-carousel-view-for-android/#comments</comments>
		<pubDate>Thu, 13 Jun 2013 18:52:25 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[carousel]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[custom control]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=4330</guid>
		<description><![CDATA[Create a beautiful custom 3D carousel view, to give your Android user interfaces a modern look. Sample code included under GPL v2.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.pocketmagic.net/wp-content/uploads/2013/06/android_carousel_gallery_view_01.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/06/android_carousel_gallery_view_01.jpg" alt="android_carousel_gallery_view_01" width="800" height="500" class="alignnone size-full wp-image-4341" /></a><br />
Data controls take various forms, one of the mostly used being the listview. With the emerging "finger friendly" technologies, various controls have been developed to take advantage of easier data browsing. Android natively supports the Gallery view:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/06/galleryview.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/06/galleryview.jpg" alt="galleryview" width="800" height="480" class="alignnone size-full wp-image-4332" /></a><br />
But that looks a bit "unfinished" at least. It is, however, possible to extend the Gallery view, and handle the way each item is created and shown, as Neil Davies did, in his excellent <a href="http://www.inter-fuser.com/2010/02/android-coverflow-widget-v2.html" target="_blank">CoverFlow Example tutorial</a>.<br />
I pushed things a bit further to offer the following:<br />
- circular list: we'll never get to the end, as the last item is linked to the first, as in a circular list. Browsing the items will let the content coming, continuously and regardless of the number of actual items.<br />
- nice shadow effect: each item's image is prolonged with a little shadow gradient at the bottom<br />
- memory optimizations: we only create the shadow effect for the items in view, and not for the entire carousel structure, which can get very big. I had no issues in loading close to 2500 items in my view, and the animation, movement and memory status were all ok!<br />
- scalable items, that will look ok , regardless of Android device screen size<br />
- custom items, composed of an image and a text label<br />
- filtering , as part of the attached carousel adapter structure, optimized for fast searches in large data sets<br />
All in one a whole new concept that behaves with the same fluency regardless of the number of data items.</p>
<p>The code is composed of 4 major parts, each set in a separate class file.<br />
<b>1: CarouselView.java</b><br />
It extends the Gallery class, to create our custom carousel view. In it's constructor it exposes:
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">setStaticTransformationsEnabled</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></pre>
<p> that allows us to handle the transformation of each item displayed, based on it's distance to the center: we want to rotate the items, as they get away from the center:</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/**</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;* {@inheritDoc}</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;*</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;* @see #setStaticTransformationsEnabled(boolean) </span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;*/</span> </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">boolean</span> getChildStaticTransformation<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AView+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">View</span></a> child, Transformation t<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	CarouselViewItem s = <span style="color: #66cc66;">&#40;</span>CarouselViewItem<span style="color: #66cc66;">&#41;</span>child;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">final</span> <span style="color: #993333;">int</span> childCenter = s.<span style="color: #006600;">getLeft</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> + s.<span style="color: #006600;">getMaxW</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>/<span style="color: #cc66cc;">2</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">final</span> <span style="color: #993333;">int</span> childWidth = s.<span style="color: #006600;">getMaxW</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #993333;">int</span> rotationAngle = <span style="color: #cc66cc;">0</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	t.<span style="color: #006600;">clear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	t.<span style="color: #006600;">setTransformationType</span><span style="color: #66cc66;">&#40;</span>Transformation.<span style="color: #006600;">TYPE_MATRIX</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>childCenter == mCoveflowCenter<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		transformImageBitmap<span style="color: #66cc66;">&#40;</span>s, t, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>      </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		rotationAngle = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">float</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>mCoveflowCenter - childCenter<span style="color: #66cc66;">&#41;</span>/ childWidth<span style="color: #66cc66;">&#41;</span> *  mMaxRotationAngle<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AMath+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Math</span></a>.<span style="color: #006600;">abs</span><span style="color: #66cc66;">&#40;</span>rotationAngle<span style="color: #66cc66;">&#41;</span> &gt; mMaxRotationAngle<span style="color: #66cc66;">&#41;</span> </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			rotationAngle = <span style="color: #66cc66;">&#40;</span>rotationAngle &lt; <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> ? -mMaxRotationAngle : mMaxRotationAngle;   </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		transformImageBitmap<span style="color: #66cc66;">&#40;</span>s, t, rotationAngle<span style="color: #66cc66;">&#41;</span>;         </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span>     </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">true</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #808080; font-style: italic;">/**</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; * Transform the Image Bitmap by the Angle passed </span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; * 0 for center item</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; * @param imageView ImageView the ImageView whose bitmap we want to rotate</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; * @param t transformation </span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; * @param rotationAngle the Angle by which to rotate the Bitmap</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #993333;">void</span> transformImageBitmap<span style="color: #66cc66;">&#40;</span>CarouselViewItem s, Transformation t, <span style="color: #993333;">int</span> rotationAngle<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>            </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 mCamera.<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 <span style="color: #000000; font-weight: bold;">final</span> Matrix imageMatrix = t.<span style="color: #006600;">getMatrix</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #993333;">int</span> imageWidth = s.<span style="color: #006600;">getMaxW</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #993333;">int</span> imageHeight = s.<span style="color: #006600;">getMaxH</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #993333;">int</span> rotation = <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AMath+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Math</span></a>.<span style="color: #006600;">abs</span><span style="color: #66cc66;">&#40;</span>rotationAngle<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 <span style="color: #808080; font-style: italic;">//As the angle of the view gets less, zoom in     </span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 <span style="color: #993333;">float</span> zoomAmount = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">float</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>rotation * <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 mCamera.<span style="color: #006600;">translate</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>.0f, <span style="color: #cc66cc;">0</span>.0f, zoomAmount<span style="color: #66cc66;">&#41;</span>;          </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 mCamera.<span style="color: #006600;">rotateY</span><span style="color: #66cc66;">&#40;</span>rotationAngle<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 mCamera.<span style="color: #006600;">getMatrix</span><span style="color: #66cc66;">&#40;</span>imageMatrix<span style="color: #66cc66;">&#41;</span>;               </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 imageMatrix.<span style="color: #006600;">preTranslate</span><span style="color: #66cc66;">&#40;</span>-<span style="color: #66cc66;">&#40;</span>imageWidth/<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>, -<span style="color: #66cc66;">&#40;</span>imageHeight/<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 imageMatrix.<span style="color: #006600;">postTranslate</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>imageWidth/<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #66cc66;">&#40;</span>imageHeight/<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 mCamera.<span style="color: #006600;">restore</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p><b>2: CarouselViewItem.java</b><br />
Is a class that defines one custom item, in this case a scalable image view with a text label at the bottom. Nothing fancy, just a class extending relativelayout with two views inside.</p>
<p><b>3: CarouselDataItem.java</b><br />
The data we store for one item. We'll use this to populate our custom adapter, fill in data, and for further processing, eg. for filtering or for handling clicks on items.</p>
<p><b>4: CarouselViewAdapter.java</b><br />
The custom view, as an extension to BaseAdapter. The getView method is essential: we get the item attached CarouselDataItem data, we use it to load the image from the disk, we transform the image by making a nice reflection effect and then create the corresponding CarouselViewItem object.<br />
The advantage is that we do this on the fly, only for the displayed items. By doing so, we can show thousands of items in our Carousel view.<br />
The reflection effect looks even better on the white-gray gradient set as background for the parent container.</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AView+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">View</span></a> getView<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> position, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AView+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">View</span></a> convertView, ViewGroup parent<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 <span style="color: #808080; font-style: italic;">// empty items</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>mDocus.<span style="color: #006600;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> ==<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		 Bitmap empty = BitmapFactory.<span style="color: #006600;">decodeResource</span><span style="color: #66cc66;">&#40;</span>mContext.<span style="color: #006600;">getResources</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, R.<span style="color: #006600;">drawable</span>.<span style="color: #006600;">empty</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		 Bitmap reflection = createReflectedImage<span style="color: #66cc66;">&#40;</span>empty<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		 empty.<span style="color: #006600;">recycle</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		 CarouselViewItem scaIv = <span style="color: #000000; font-weight: bold;">new</span> CarouselViewItem<span style="color: #66cc66;">&#40;</span>mContext, reflection, <span style="color: #ff0000;">&quot;empty doc&quot;</span>, m_w, m_h<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		 <span style="color: #000000; font-weight: bold;">return</span> scaIv; <span style="color: #808080; font-style: italic;">//fix divide by zero on filtering</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 <span style="color: #808080; font-style: italic;">// we got content</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>position &gt;= mDocus.<span style="color: #006600;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		 position = position % mDocus.<span style="color: #006600;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 <span style="color: #66cc66;">&#125;</span> </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 Bitmap originalImage = BitmapFactory.<span style="color: #006600;">decodeFile</span><span style="color: #66cc66;">&#40;</span>mDocus.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>position<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getImgPath</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 Bitmap reflection = createReflectedImage<span style="color: #66cc66;">&#40;</span>originalImage<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>originalImage != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		 originalImage.<span style="color: #006600;">recycle</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 CarouselViewItem scaIv = <span style="color: #000000; font-weight: bold;">new</span> CarouselViewItem<span style="color: #66cc66;">&#40;</span>mContext, reflection, mDocus.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>position<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getDocText</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, m_w, m_h<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	 <span style="color: #000000; font-weight: bold;">return</span> scaIv;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #66cc66;">&#125;</span> </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>This class is also important for offering the filter option (the search box at the top). The idea here is that the adapter is the one that must identify the data we apply the sorting option to. In this case it is the text string attached to each item as the item name.</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> Filter getFilter<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> Filter<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		@Override</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #000000; font-weight: bold;">protected</span> FilterResults performFiltering<span style="color: #66cc66;">&#40;</span>CharSequence constraint<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #000000; font-weight: bold;">final</span> FilterResults oReturn = <span style="color: #000000; font-weight: bold;">new</span> FilterResults<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #808080; font-style: italic;">//final CarouselDataItem[] mDocus;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #000000; font-weight: bold;">final</span> ArrayList&lt;CarouselDataItem&gt; results = <span style="color: #000000; font-weight: bold;">new</span> ArrayList&lt;CarouselDataItem&gt;<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>mDocusOrig == <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> mDocusOrig = mDocus;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>constraint != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>mDocusOrig != <span style="color: #000000; font-weight: bold;">null</span> &amp;&amp; mDocusOrig.<span style="color: #006600;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> &gt; <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">					<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> CarouselDataItem g : mDocusOrig<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">						<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>g.<span style="color: #006600;">getDocText</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">								.<span style="color: #006600;">contains</span><span style="color: #66cc66;">&#40;</span>constraint.<span style="color: #006600;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">							results.<span style="color: #006600;">add</span><span style="color: #66cc66;">&#40;</span>g<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">					<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				oReturn.<span style="color: #006600;">values</span> = results;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #000000; font-weight: bold;">return</span> oReturn;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		@SuppressWarnings<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;unchecked&quot;</span><span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		@Override</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">void</span> publishResults<span style="color: #66cc66;">&#40;</span>CharSequence constraint,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				FilterResults results<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			mDocus = <span style="color: #66cc66;">&#40;</span>ArrayList&lt;CarouselDataItem&gt;<span style="color: #66cc66;">&#41;</span> results.<span style="color: #006600;">values</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			notifyDataSetChanged<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> notifyDataSetChanged<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006600;">notifyDataSetChanged</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #808080; font-style: italic;">//notifyChanged = true;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>Creating the Carousel view is easy. We need to create the control itself, and then populate it by attaching the custom adapter, filled with our data. This logic is done in MainActivity.java:</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// copy images from assets to sdcard</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">AppUtils.<span style="color: #006600;">AssetFileCopy</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, <span style="color: #ff0000;">&quot;/mnt/sdcard/plasma1.png&quot;</span>, <span style="color: #ff0000;">&quot;plasma1.png&quot;</span>, <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">AppUtils.<span style="color: #006600;">AssetFileCopy</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, <span style="color: #ff0000;">&quot;/mnt/sdcard/plasma2.png&quot;</span>, <span style="color: #ff0000;">&quot;plasma2.png&quot;</span>, <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">AppUtils.<span style="color: #006600;">AssetFileCopy</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, <span style="color: #ff0000;">&quot;/mnt/sdcard/plasma3.png&quot;</span>, <span style="color: #ff0000;">&quot;plasma3.png&quot;</span>, <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">AppUtils.<span style="color: #006600;">AssetFileCopy</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, <span style="color: #ff0000;">&quot;/mnt/sdcard/plasma4.png&quot;</span>, <span style="color: #ff0000;">&quot;plasma4.png&quot;</span>, <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//Create carousel view documents</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ArrayList&lt;CarouselDataItem&gt; Docus = <span style="color: #000000; font-weight: bold;">new</span> ArrayList&lt;CarouselDataItem&gt;<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> i=<span style="color: #cc66cc;">0</span>;i&lt;<span style="color: #cc66cc;">1000</span>;i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	CarouselDataItem docu;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>i%<span style="color: #cc66cc;">4</span>==<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> docu = <span style="color: #000000; font-weight: bold;">new</span> CarouselDataItem<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/mnt/sdcard/plasma1.png&quot;</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #ff0000;">&quot;First Image &quot;</span>+i<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>i%<span style="color: #cc66cc;">4</span>==<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> docu = <span style="color: #000000; font-weight: bold;">new</span> CarouselDataItem<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/mnt/sdcard/plasma2.png&quot;</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #ff0000;">&quot;Second Image &quot;</span>+i<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>i%<span style="color: #cc66cc;">4</span>==<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> docu = <span style="color: #000000; font-weight: bold;">new</span> CarouselDataItem<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/mnt/sdcard/plasma3.png&quot;</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #ff0000;">&quot;Third Image &quot;</span>+i<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">else</span> docu = <span style="color: #000000; font-weight: bold;">new</span> CarouselDataItem<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/mnt/sdcard/plasma4.png&quot;</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #ff0000;">&quot;4th Image &quot;</span>+i<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	Docus.<span style="color: #006600;">add</span><span style="color: #66cc66;">&#40;</span>docu<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span>  </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>Creating the control itself:</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// create the carousel</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">CarouselView coverFlow = <span style="color: #000000; font-weight: bold;">new</span> CarouselView<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// create adapter and specify device independent items size (scaling)</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// for more details see: http://www.pocketmagic.net/2013/04/how-to-scale-an-android-ui-on-multiple-screens/</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">m_carouselAdapter =  <span style="color: #000000; font-weight: bold;">new</span> CarouselViewAdapter<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>,Docus, m_Inst.<span style="color: #006600;">Scale</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">400</span><span style="color: #66cc66;">&#41;</span>,m_Inst.<span style="color: #006600;">Scale</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">300</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">coverFlow.<span style="color: #006600;">setAdapter</span><span style="color: #66cc66;">&#40;</span>m_carouselAdapter<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">coverFlow.<span style="color: #006600;">setSpacing</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">-1</span>*m_Inst.<span style="color: #006600;">Scale</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">150</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">coverFlow.<span style="color: #006600;">setSelection</span><span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AInteger+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Integer</span></a>.<span style="color: #006600;">MAX_VALUE</span> / <span style="color: #cc66cc;">2</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">coverFlow.<span style="color: #006600;">setAnimationDuration</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1000</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">coverFlow.<span style="color: #006600;">setOnItemSelectedListener</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>OnItemSelectedListener<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">AppUtils.<span style="color: #006600;">AddView</span><span style="color: #66cc66;">&#40;</span>panel, coverFlow, LayoutParams.<span style="color: #006600;">FILL_PARENT</span>,LayoutParams.<span style="color: #006600;">WRAP_CONTENT</span>, </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #993333;">int</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#123;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #993333;">int</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#123;</span>RelativeLayout.<span style="color: #006600;">CENTER_IN_PARENT</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#125;</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #cc66cc;">-1</span>, <span style="color: #cc66cc;">-1</span><span style="color: #66cc66;">&#41;</span>; </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>The setOnItemSelectedListener will catch the click-on-items events. There's a toast message informing the user what was just clicked on:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/06/android_carousel_gallery_view_02.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/06/android_carousel_gallery_view_02.jpg" alt="android_carousel_gallery_view_02" width="800" height="500" class="alignnone size-full wp-image-4342" /></a></p>
<p>The filter also works great, simply adding a text in the edittext at the top, will call the onTextChanged callback, and give the string to the custom adapter filter:</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> onTextChanged<span style="color: #66cc66;">&#40;</span>CharSequence s, <span style="color: #993333;">int</span> start, <span style="color: #993333;">int</span> before, <span style="color: #993333;">int</span> count<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	m_carouselAdapter.<span style="color: #006600;">getFilter</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">filter</span><span style="color: #66cc66;">&#40;</span>s.<span style="color: #006600;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span>  </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>The case of no results (after filtering is also handled), where a custom image is displayed, and the "empty doc" text as the label:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/06/android_carousel_gallery_view_03.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/06/android_carousel_gallery_view_03.jpg" alt="android_carousel_gallery_view_03" width="800" height="500" class="alignnone size-full wp-image-4343" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/06/android_carousel_gallery_view_05.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/06/android_carousel_gallery_view_05.jpg" alt="android_carousel_gallery_view_05" width="800" height="500" class="alignnone size-full wp-image-4344" /></a></p>
<p>The code is released under GPL v2.0 license and can be downloaded below. For any questions feel free to use comments section.<br />
Download source code <a href="http://www.pocketmagic.net/wp-content/uploads/2013/06/3DCarousel.zip">here</a>, or on <a href="http://code.google.com/p/android-3d-carousel-view/" target="_blank">Google code</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/06/a-3d-carousel-view-for-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android tiled background</title>
		<link>http://www.pocketmagic.net/2013/06/android-tiled-background/</link>
		<comments>http://www.pocketmagic.net/2013/06/android-tiled-background/#comments</comments>
		<pubDate>Thu, 13 Jun 2013 12:52:44 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=4323</guid>
		<description><![CDATA[Learn how to create a simple tiled background for Android applications using Java code.]]></description>
				<content:encoded><![CDATA[<p>When creating background panels for various Android applications, we can use a static image that would <a href="http://www.pocketmagic.net/2013/04/how-to-scale-an-android-ui-on-multiple-screens/" target="_blank">scale or stretch</a> or multiple images for multiple screen sizes, but we can also use a tiny image and repeat it on both axes for a tiled background.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/06/android_tiled_background.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/06/android_tiled_background.jpg" alt="android_tiled_background" width="640" height="480" class="alignnone size-full wp-image-4324" /></a><br />
As I am not a big fan of using XML static UI resources for Android development, my approach uses Java entirely. Place a small image to be used for our repeating background, such as this one:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/06/background_pattern.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/06/background_pattern-300x300.jpg" alt="background_pattern" width="300" height="300" class="alignnone size-medium wp-image-4325" /></a><br />
It can be any image, but you'll want the margins to match when the image gets repeated on horizontal and vertical axes.<br />
Next, in your main activity, create a layout, load the image, set it to repeat, and add it as layout background. </p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// create tiled background</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Bitmap bmp = BitmapFactory.<span style="color: #006600;">decodeResource</span><span style="color: #66cc66;">&#40;</span>getResources<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, R.<span style="color: #006600;">drawable</span>.<span style="color: #006600;">background_pattern</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">BitmapDrawable bitmapDrawable = <span style="color: #000000; font-weight: bold;">new</span> BitmapDrawable<span style="color: #66cc66;">&#40;</span>bmp<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">bitmapDrawable.<span style="color: #006600;">setTileModeXY</span><span style="color: #66cc66;">&#40;</span>android.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">Shader</span>.<span style="color: #006600;">TileMode</span>.<span style="color: #006600;">REPEAT</span>, android.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">Shader</span>.<span style="color: #006600;">TileMode</span>.<span style="color: #006600;">REPEAT</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>To set it as layout background, use:</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// create main panel</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">RelativeLayout panel = <span style="color: #000000; font-weight: bold;">new</span> RelativeLayout<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">panel.<span style="color: #006600;">setLayoutParams</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> LayoutParams<span style="color: #66cc66;">&#40;</span>LayoutParams.<span style="color: #006600;">FILL_PARENT</span>,LayoutParams.<span style="color: #006600;">FILL_PARENT</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">panel.<span style="color: #006600;">setBackgroundDrawable</span><span style="color: #66cc66;">&#40;</span>bitmapDrawable<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>Voila!<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/06/android_background_tile_repeat_image.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/06/android_background_tile_repeat_image.jpg" alt="android_background_tile_repeat_image" width="640" height="400" class="alignnone size-full wp-image-4326" /></a></p>
<p>Sample code is available here:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/06/BackgroundTile.zip">BackgroundTile</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/06/android-tiled-background/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tube: 258-B Amperex rectifier</title>
		<link>http://www.pocketmagic.net/2013/05/tube-258-b-amperex-rectifier/</link>
		<comments>http://www.pocketmagic.net/2013/05/tube-258-b-amperex-rectifier/#comments</comments>
		<pubDate>Sat, 25 May 2013 13:21:42 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Tubes]]></category>
		<category><![CDATA[258-B]]></category>
		<category><![CDATA[258B]]></category>
		<category><![CDATA[rectifier]]></category>
		<category><![CDATA[tubes]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=4270</guid>
		<description><![CDATA[The Amperex 258-B is a half-wave Mercury-Vapor rectifier tube used in power supplies.]]></description>
				<content:encoded><![CDATA[<p><b>Pictures:</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/amperex-258-b-rectifier-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/amperex-258-b-rectifier-1-300x199.jpg" alt="amperex 258-b rectifier 1" width="300" height="199" class="alignnone size-medium wp-image-4271" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/amperex-258-b-rectifier-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/amperex-258-b-rectifier-2-300x199.jpg" alt="amperex 258-b rectifier 2" width="300" height="199" class="alignnone size-medium wp-image-4272" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/amperex-258-b-rectifier-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/amperex-258-b-rectifier-3-300x199.jpg" alt="amperex 258-b rectifier 3" width="300" height="199" class="alignnone size-medium wp-image-4273" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/amperex-258-b-rectifier-4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/amperex-258-b-rectifier-4-300x199.jpg" alt="amperex 258-b rectifier 4" width="300" height="199" class="alignnone size-medium wp-image-4274" /></a></p>
<p><b>Details:</b><br />
The Amperex 258-B is a half-wave Mercury-Vapor rectifier tube used in power supplies. Identical to CV2594.<br />
Filament 	Vf 2.5 Volts / If: 7.5 Ampere / -: Direct /<br />
Description 	7.5KV PIV, 640mA. Bi-pin version of 249B.<br />
Amperex, Continental, Hytron, Taylor and WE known manufacturers.<br />
Literature 	Taschenbuch zum Röhren-Codex 1948/49<br />
- - Manufacturers Literature<br />
Tube Lore, Sibley, USA 1996 </p>
<p><b>Datasheet:</b><br />
n/a</p>
<p><b>Links:</b><br />
<a href="http://www.radiomuseum.org/tubes/tube_258b.html" target="_blank">258-B on Radiomuseum</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/05/tube-258-b-amperex-rectifier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tube: GP-5 (ГП-5)</title>
		<link>http://www.pocketmagic.net/2013/05/tube-gp-5-%d0%b3%d0%bf-5/</link>
		<comments>http://www.pocketmagic.net/2013/05/tube-gp-5-%d0%b3%d0%bf-5/#comments</comments>
		<pubDate>Sat, 25 May 2013 13:07:01 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Tubes]]></category>
		<category><![CDATA[GP-5]]></category>
		<category><![CDATA[GP5]]></category>
		<category><![CDATA[shunt]]></category>
		<category><![CDATA[tubes]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=4265</guid>
		<description><![CDATA[The Svetlana GP-5 (ГП-5) is a glass-envelope beam power triode intended for use as a shunt regulator or pulse modulator in high-voltage systems.]]></description>
				<content:encoded><![CDATA[<p><b>Pictures:</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/tube-gp-5-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/tube-gp-5-1-199x300.jpg" alt="tube gp-5 1" width="199" height="300" class="alignnone size-medium wp-image-4266" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/tube-gp-5-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/tube-gp-5-2-199x300.jpg" alt="tube gp-5 2" width="199" height="300" class="alignnone size-medium wp-image-4267" /></a></p>
<p><b>Details:</b><br />
The Svetlana GP-5 (ГП-5) is a glass-envelope beam power triode intended for use as a shunt regulator or pulse modulator in high-voltage systems. It features anode operating voltage of 30 kV and a plate dissipation of 37.5 watts. Originally intended for color-TV voltage stabilization, the GP-5 is similar to the Telefunken ED500 and may be used to retrofit equipment which uses the American type 6BK4 or other high-voltage beam triodes.<br />
Military equipment with "OTK" mark. Near equivalent: ED500 and 6BK4. The tube is manufactured by the Svetlana, St. Peterburg, Russia. </p>
<p><b>Datasheet:</b><br />
General characteristics:<br />
Name: GP5<br />
Cathode: oxide-coated, unipotential<br />
Voltage (AC or DC), V: 6.3 (± 0.6)<br />
Current, mA: 210 (± 20)<br />
Heater-cathode voltage, peak, V: ±200<br />
Amplification factor (nominal): 2750<br />
Transconductance (nominal), uS: 700<br />
Interelectrode capacitances (typical), with cathode grounded:<br />
- Input 4.0 pF<br />
- Output 1.5 pF<br />
- Feedback 0.1 pF</p>
<p>Mechanical characteristics:<br />
Base standard magnoval, glass button<br />
Socket Svetlana SK509 or similar<br />
Anode cap approx. 3/8 in (9 mm) diameter<br />
Anode connector same as 6BK4 or 807<br />
Operating position Any (vertical for convection cooling)<br />
Nominal dimensions:<br />
- Height of glass envelope 100 mm (3 7/8 in)<br />
- Diameter of glass envelope 46 mm (1 3/4 in)<br />
- Overall height 125 mm (4 7/8 in.)<br />
Net weight: 115g</p>
<p>Maximum ratings:<br />
Anode voltage: 30KV<br />
Anode dissipation: 37.5W<br />
Anode current, continuous: 2mA<br />
Grid voltage: -450V<br />
Maximum grid-circuit resistance: 3 MOhms<br />
Envelope temperature: 250C</p>
<p><b>Links:</b><br />
<a href="http://www.radiomuseum.org/tubes/tube_gp5.html" target="_blank">Radiomuseum</a><br />
<a href="http://www.rutubes.com/index.php?productID=524" target="_blank">Russian tubes</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/05/tube-gp-5-%d0%b3%d0%bf-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Coil Winding machine counter with Atmega8 and Reed relay</title>
		<link>http://www.pocketmagic.net/2013/05/coil-winding-machine-counter-with-atmega8-and-reed-relay/</link>
		<comments>http://www.pocketmagic.net/2013/05/coil-winding-machine-counter-with-atmega8-and-reed-relay/#comments</comments>
		<pubDate>Sat, 25 May 2013 11:00:05 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[5110]]></category>
		<category><![CDATA[atmega8]]></category>
		<category><![CDATA[coil winding machine]]></category>
		<category><![CDATA[HD44780]]></category>
		<category><![CDATA[lcd]]></category>
		<category><![CDATA[microcontrollers]]></category>
		<category><![CDATA[nokia]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=4248</guid>
		<description><![CDATA[A digital counter with a nice LCD display that supports both incrementing and decrementing. Good for various purposes, in this case as a display to a coil winding machine.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.elforum.ro/memberlist.php?mode=viewprofile&u=4728" target="_blank">Ovidiu </a>asked me to build a digital counter for his new project, a coil winding machine. Here is what I came up with:<br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/7j5D7wPT2Dw" frameborder="0" allowfullscreen></iframe></p>
<h3>Variant 1 : Atmega8 + Nokia 5110 LCD + 3V power supply</h3>
<p>I am using an Atmega8-8PU (configured for 8MHz with external crystal), <a href="http://www.pocketmagic.net/2013/04/atmega8-and-nokia-5110-lcd/" target="_blank">a Nokia 5110 lcd</a>, and a transistor to handle the pulses from a reed relay. A 3.3V regulator provides the voltage for the entire circuit.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/reed-digital-counter-atmega2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/reed-digital-counter-atmega2.jpg" alt="reed digital counter atmega2" width="800" height="391" class="alignnone size-full wp-image-4252" /></a></p>
<p>Everything has been mounted on a test board, including the headers for: ISP programmer (<a href="http://www.pocketmagic.net/2012/05/cheap-avr-usb-programmer/" target="_blank">USBAsp</a>), the <a href="http://www.pocketmagic.net/2013/04/atmega8-and-nokia-5110-lcd/" target="_blank">5110 Nokia LCD</a>, the power supply (5V in, fed to the 3.3V regulator), the Reed relay connector, the reset button connector and another 2 pins connector, used to read the polarity of coil winding machine's motor, so we know we either increment or decrement the counter.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/reed_counter_atmega_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/reed_counter_atmega_1-150x150.jpg" alt="reed_counter_atmega_1" width="150" height="150" class="alignnone size-thumbnail wp-image-4253" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/reed_counter_atmega_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/reed_counter_atmega_2-150x150.jpg" alt="reed_counter_atmega_2" width="150" height="150" class="alignnone size-thumbnail wp-image-4254" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/reed_counter_atmega_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/reed_counter_atmega_3-150x150.jpg" alt="reed_counter_atmega_3" width="150" height="150" class="alignnone size-thumbnail wp-image-4255" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/reed_counter_atmega_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/reed_counter_atmega_4-150x150.jpg" alt="reed_counter_atmega_4" width="150" height="150" class="alignnone size-thumbnail wp-image-4256" /></a><br />
There are a few connectors:<br />
J1: is for the power supply. The circuit takes 5V, that get into the L7833 for 3.3V output used by the atmega8 uC and the LCD.<br />
J2: is the LCD connector, going to the Nokia 5110LCD.<br />
J3: goes to the reed relay. This is the place we generate pulses for the microcontroller to count.<br />
J4: is the polarity connector. It must be connected in parallel on the coil winding machine's motor. It was designed for a 12V motor (but this can be changed by adjusting the voltage dividers formed by R3-R4 and R5-R6, so they take in the motor voltage, and output not more than 5V). If the motor is connected in normal polarity, we will read PD0 high, if the motor is in inverse polarity, we'll have PD1 high. This info is used in the code to either increment or decrement the counter.<br />
J5: is just a simple momentary switch. When pressed, will reset the counter to zero.<br />
ISP connector: is a 10 pin connector used with the USBAsp AVR programmer.</p>
<p><b>Circuit diagram:</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/digital-counter-reed-switch-circuit-diagram.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/digital-counter-reed-switch-circuit-diagram-300x168.png" alt="digital counter reed switch circuit diagram" width="300" height="168" class="alignnone size-medium wp-image-4259" /></a></p>
<p><b><a href="http://www.pocketmagic.net/2013/03/how-to-set-the-avr-fusebits/" target="_blank">Fuse bits</a>:</b><br />
External 8MHz crystal. The settings are:</p>
<pre class="c"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">avrdude -p atmega8 -c usbasp -U lfuse:w:0xff:m 	-U hfuse:w:0xc9:m 	</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p><b>Source code:</b><br />
You can download and use the source code, under the Apache license, <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/atmega-reed-digital-counter.zip">here</a>.<br />
<br><br />
<br><br />
<br></p>
<h3>Variant 2 : Atmega8 + 2x16 HD44780 Character LCD + 5V power supply</h3>
<p>Some of my readers asked for a custom variant, that uses a 2x16 HD44780 LCD (or a 1x16 smaller variant). These displays require a 5V voltage supply, so here is variant 2 of the digital counter, modified to support these requirements.</p>
<p><b>2x16 LCD Circuit Diagram:</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/digital-counter-reed-switch-circuit-diagram-with-2x16LCD.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/digital-counter-reed-switch-circuit-diagram-with-2x16LCD-300x181.png" alt="digital counter reed switch circuit diagram with 2x16LCD" width="300" height="181" class="alignnone size-medium wp-image-4279" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/HD44780_1_16_connector.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/HD44780_1_16_connector-300x225.jpg" alt="HD44780_1_16_connector" width="300" height="225" class="alignnone size-medium wp-image-4284" /></a></p>
<p><b>Hex file, SCH and source code:</b><br />
Can be downloaded here: <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/atmega-reed-digital-counter-2x16LCD.zip">atmega reed digital counter 2x16LCD</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/05/coil-winding-machine-counter-with-atmega8-and-reed-relay/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Developing for Blackberry 10</title>
		<link>http://www.pocketmagic.net/2013/05/developing-for-blackberry-10/</link>
		<comments>http://www.pocketmagic.net/2013/05/developing-for-blackberry-10/#comments</comments>
		<pubDate>Sun, 19 May 2013 10:09:59 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=4212</guid>
		<description><![CDATA[A short insight on how to get started with developing for the new Blackberry 10, using dynamically created controls.]]></description>
				<content:encoded><![CDATA[<h3>Introduction</h3>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td><a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/blackberry_bb_10.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/blackberry_bb_10-300x275.jpg" alt="blackberry_bb_10" width="300" height="275" class="alignnone size-medium wp-image-4215" /></a></td>
<td>In a world dominated by Android and iOS, how hard is it for another mobile platform, be it one bearing the glory of the past, to reconquer the market shares it once had? It's all about marketing, a bit of luck, but from my point of view (not generally applicable, see how iOS started), the technology involved - the actual value resulting from the time and effort invested in making something better.<br />
Blackberry has reinvented itself in a new, fierce competitor with its latest release, the Blackberry 10. The handsets running the new OS are impressive: huge 768 x 1280 pixel screens, 8Mega pixel camera (with geotagging and face detection), 2GB of Ram memory and a Dual-core 1.5 GHz Krait processor. A beast in terms of hardware capabilities but also <a href="http://www.pocketmagic.net/2009/02/developing-for-blackberry-introduction/">a huge step forward</a>.</td>
</tr>
</table>
<h3>Installing the tools</h3>
<p>The technology also refers to the software available, and the software dedicated to developers to make even more apps for the platform. Here I was surprised to find new changes, as compared to <a href="http://www.pocketmagic.net/2012/01/developing-for-blackberry-part-2">my previous experience</a> with these devices.<br />
Installing the new development tools is easy, it is a customized IDE based on Eclipse, the installer does everything, including requesting the code signing information (the developer account and all resources, including the signing keys are all free). To start, go <a href="http://developer.blackberry.com/native/download/">here</a>.<br />
Once installed, you can go to File->New Project to start your own development work, or File->New->Example to pick one of the tens of samples available.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/bb_ide_01.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/bb_ide_01.jpg" alt="bb_ide_01" width="779" height="342" class="alignnone size-full wp-image-4219" /></a></p>
<h3>A simple hello World application</h3>
<p>When starting a new Blackberry 10 project, the wizard gives us several choices:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/bb_ide_02.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/bb_ide_02.jpg" alt="bb_ide_02" width="639" height="387" class="alignnone size-full wp-image-4220" /></a><br />
BlackBerry Native SDK provides APIs to access some of the low level/core functionality of the device, ranging from events, to screens, audio, sensors, network etc. Use the Native SDK when you need direct access to the hardware. The Cascades SDK is a UI toolkit built upon the Qt toolkit. It provides you with a common set of UI controls, with a common look and feel. A good choice for building User interfaces.<br />
Cascades rely on a static QML file. My common practice is to build the interface dynamically: it can get more complicated at the cost of code readability, but it gives total control over the interface, during the runtime (conditional creation/deletion of various UI elements, eg.serial key field only if the software is not registered, etc). So instead of presenting a QML based Hello World interface, I'll show you how to create the equivalent, using only C++ code.</p>
<pre class="cpp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ApplicationUI::<span style="color: #00eeff;">ApplicationUI</span><span style="color: #000000;">&#40;</span>bb::<span style="color: #00eeff;">cascades</span>::<span style="color: #00eeff;">Application</span> *app<span style="color: #000000;">&#41;</span>: QObject<span style="color: #000000;">&#40;</span>app<span style="color: #000000;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// create root object for the UI</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	Page *page = <span style="color: #0000dd;">new</span> Page<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// set created root object as a scene</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	app-&gt;setScene<span style="color: #000000;">&#40;</span>page<span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> 	Container* pContainer = <span style="color: #0000dd;">new</span> Container<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	page-&gt;setContent<span style="color: #000000;">&#40;</span>pContainer<span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// create top text field</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	m_tf = <span style="color: #0000dd;">new</span> TextField<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	m_tf-&gt;setText<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Status&quot;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	pContainer-&gt;add<span style="color: #000000;">&#40;</span>m_tf<span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// Position button 1 horizontally centered of the container</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	Button* pButton1 = Button::<span style="color: #00eeff;">create</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #00eeff;">text</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Button1&quot;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	pButton1-&gt;setHorizontalAlignment<span style="color: #000000;">&#40;</span>HorizontalAlignment::<span style="color: #00eeff;">Center</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// catch click events</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	connect<span style="color: #000000;">&#40;</span>pButton1, <span style="color: #0000ff;">SIGNAL</span><span style="color: #000000;">&#40;</span>clicked<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>, <span style="color: #0000dd;">this</span>, SLOT<span style="color: #000000;">&#40;</span>onButton1Clicked<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// add button to container</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	pContainer-&gt;add<span style="color: #000000;">&#40;</span> pButton1 <span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// Position button 2 horizontally centered of the container</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	Button* pButton2 = Button::<span style="color: #00eeff;">create</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #00eeff;">text</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Button2&quot;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	pButton2-&gt;setHorizontalAlignment<span style="color: #000000;">&#40;</span>HorizontalAlignment::<span style="color: #00eeff;">Center</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	connect<span style="color: #000000;">&#40;</span>pButton2, <span style="color: #0000ff;">SIGNAL</span><span style="color: #000000;">&#40;</span>clicked<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>, <span style="color: #0000dd;">this</span>, SLOT<span style="color: #000000;">&#40;</span>onButton2Clicked<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// add button to container</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	pContainer-&gt;add<span style="color: #000000;">&#40;</span> pButton2 <span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// create a text label</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	QString labelText = <span style="color: #666666;">&quot;Hello World! www.pocketmagic.net&quot;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	Label *label = <span style="color: #0000dd;">new</span> Label<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	label-&gt;setText<span style="color: #000000;">&#40;</span>labelText<span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	pContainer-&gt;add<span style="color: #000000;">&#40;</span> label <span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// create an image view</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	ImageView* imageView1 = <span style="color: #0000dd;">new</span> ImageView<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	imageView1-&gt;setImage<span style="color: #000000;">&#40;</span>Image<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;asset:///logosymbol.png&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	imageView1-&gt;setHorizontalAlignment<span style="color: #000000;">&#40;</span>HorizontalAlignment::<span style="color: #00eeff;">Center</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	pContainer-&gt;add<span style="color: #000000;">&#40;</span> imageView1 <span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>The Slots for the two buttons, have to be defined in aplicationui.hpp as following:</p>
<pre class="cpp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">public</span> slots:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">void</span> onButton1Clicked<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">void</span> onButton2Clicked<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>The debug function with output to Console in the Eclipse IDE, can be defined in main.cpp:</p>
<pre lang=cpp">
...
void myMessageOutput(QtMsgType type, const char* msg){
               fprintf(stdout, "%s\n", msg);
               fflush(stdout);
}

Q_DECL_EXPORT int main(int argc, char **argv)
{
    // this is where the server is started etc
    Application app(argc, argv);

    qInstallMsgHandler(myMessageOutput);
    ...
</pre>
<p>To set some of the button's fields separately, you can also create it by using:</p>
<pre class="cpp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">QString buttonText = <span style="color: #666666;">&quot;myText&quot;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    Button *button2 = <span style="color: #0000dd;">new</span> Button<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    button2-&gt;setText<span style="color: #000000;">&#40;</span>buttonText<span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    button2-&gt;setImage<span style="color: #000000;">&#40;</span>Image<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;asset:///image.png&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>Where image.png is a png image file, placed in your project's assets folder.</p>
<p>Here is the result of running the program above, both on landscape and portrait:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/blackberry_z10_hello_world_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/blackberry_z10_hello_world_1-300x180.jpg" alt="blackberry_z10_hello_world_1" width="300" height="180" class="alignnone size-medium wp-image-4223" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/blackberry_z10_hello_world_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/blackberry_z10_hello_world_2-180x300.jpg" alt="blackberry_z10_hello_world_2" width="180" height="300" class="alignnone size-medium wp-image-4224" /></a></p>
<p>The code is available for <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/HelloWorld.zip">download</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/05/developing-for-blackberry-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Victoreen CDV-717 Remote Gamma Survey dosimeter</title>
		<link>http://www.pocketmagic.net/2013/05/victoreen-cdv-717-remote-gamma-survey-dosimeter/</link>
		<comments>http://www.pocketmagic.net/2013/05/victoreen-cdv-717-remote-gamma-survey-dosimeter/#comments</comments>
		<pubDate>Thu, 16 May 2013 11:15:41 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[High Voltage]]></category>
		<category><![CDATA[Nuclear]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[cdv717]]></category>
		<category><![CDATA[dosimeter]]></category>
		<category><![CDATA[dosimetry]]></category>
		<category><![CDATA[ion chamber]]></category>
		<category><![CDATA[ionization chamber]]></category>
		<category><![CDATA[Victoreen]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=4192</guid>
		<description><![CDATA[The CDV-717 is a very high-range gamma radiation ionization chamber detecting instrument, manufactured by Victoreen back in 1964.]]></description>
				<content:encoded><![CDATA[<p>The CD V-717 was designed for use in fallout monitoring stations, having the exact same operating characteristics as the CD V-715 but with an added feature - a removable bottom with a 7.5 meters extension cable. The detector element (ion-chamber) is mounted inside the removable bottom, allowing the placement of the detector element outside of the shelter area while the metering section of the metering unit would remain inside of the shelter area connected to the detector with the long cable. Because of the extension cable container, the unit is considerable bigger in size than the <a href="http://www.pocketmagic.net/2010/07/victoreen-cdv700-6b-mod-audiobnc-connector/" target="_blank">CDV-700</a>.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_717_ion_chamber_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_717_ion_chamber_1-150x150.jpg" alt="cdv_717_ion_chamber_1" width="150" height="150" class="alignnone size-thumbnail wp-image-4193" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_717_ion_chamber_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_717_ion_chamber_2-150x150.jpg" alt="cdv_717_ion_chamber_2" width="150" height="150" class="alignnone size-thumbnail wp-image-4194" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_717_ion_chamber_6.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_717_ion_chamber_6-150x150.jpg" alt="cdv_717_ion_chamber_6" width="150" height="150" class="alignnone size-thumbnail wp-image-4195" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_717_ion_chamber_8.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_717_ion_chamber_8-150x150.jpg" alt="cdv_717_ion_chamber_8" width="150" height="150" class="alignnone size-thumbnail wp-image-4196" /></a><br />
The CD V-717 is a very high-range gamma radiation detecting instrument, that uses a ion chamber (so not a Geiger counter!). It was designed for use by radiological monitors for the major part of their operation in the period following an attack, and intended for surface monitoring survey (although could be use for aerial measurements as well). The ranges of this instrument are 0-0.5, 0-5, 0-50 and 0-500 roentgens/hour. A popular joke says this device indicates how dead you already are. When properly calibrated, the response of this instrument is within the range of plus or minus 20 percent of the true gamma radiation dose from a Co60 or Cs137 radioactive source.</p>
<p>The detector element is a ionization chamber,  that consists of a gas-filled chamber with two electrodes; known as anode and cathode. The electrodes in the CDV-717 are in the form of a cylinder arrangement with a co-axially located internal anode wire. A voltage potential is applied between the electrodes to create an electric field in the fill gas. When gas between the electrodes is ionized by incident ionizing radiation, Ion-pairs are created and the resultant positive ions and dissociated electrons move to the electrodes of the opposite polarity under the influence of the electric field. This generates an ionization current which is measured by an electrometer circuit. The electrometer must be capable of measuring the very small output current which is in the region of femtoamperes to picoamperes, depending on the chamber design, radiation dose and applied voltage.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_717_ion_chamber_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_717_ion_chamber_3-150x150.jpg" alt="cdv_717_ion_chamber_3" width="150" height="150" class="alignnone size-thumbnail wp-image-4197" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_717_ion_chamber_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_717_ion_chamber_4-150x150.jpg" alt="cdv_717_ion_chamber_4" width="150" height="150" class="alignnone size-thumbnail wp-image-4198" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_717_ion_chamber_5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_717_ion_chamber_5-150x150.jpg" alt="cdv_717_ion_chamber_5" width="150" height="150" class="alignnone size-thumbnail wp-image-4199" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_717_ion_chamber_7.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_717_ion_chamber_7-150x150.jpg" alt="cdv_717_ion_chamber_7" width="150" height="150" class="alignnone size-thumbnail wp-image-4200" /></a></p>
<p>There is a manual available online <a href="http://www.orau.org/ptp/Library/cdv/victor717-1.pdf" target="_blank">here</a> and more resources on the civildefensemuseum <a href="http://www.civildefensemuseum.com/cdmuseum2/radkits/cdv717.html" target="_blank">website</a> or on <a href="http://www.orau.org/ptp/collection/civildefense/cdv717.htm" target="_blank">orau.org</a>. Some additional details on the ionization chambers can be read <a href="http://en.wikipedia.org/wiki/Ionization_chamber" target="_blank">here</a>.</p>
<p>The circuit diagram:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv717_circuit_diagram.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv717_circuit_diagram-252x300.jpg" alt="cdv717_circuit_diagram" width="252" height="300" class="alignnone size-medium wp-image-4204" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/05/victoreen-cdv-717-remote-gamma-survey-dosimeter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CDV-742 Dosimeter and CDV-750 Dosimeter Charger</title>
		<link>http://www.pocketmagic.net/2013/05/cdv-742-dosimeter-and-cdv-750-dosimeter-charger/</link>
		<comments>http://www.pocketmagic.net/2013/05/cdv-742-dosimeter-and-cdv-750-dosimeter-charger/#comments</comments>
		<pubDate>Thu, 16 May 2013 10:13:10 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[High Voltage]]></category>
		<category><![CDATA[Nuclear]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[cdv742]]></category>
		<category><![CDATA[cdv750]]></category>
		<category><![CDATA[dosimeter]]></category>
		<category><![CDATA[dosimetry]]></category>
		<category><![CDATA[electrostatic]]></category>
		<category><![CDATA[gamma]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=4168</guid>
		<description><![CDATA[The CDV-750-5b Dosimeter Charger is a self contained battery-operated instrument.]]></description>
				<content:encoded><![CDATA[<p>The primary purpose of the Model CD V-750 was to charge civil defense dosimeters (CD V-138, 730, 740, and 742). By charge, we mean adjust the dosimeter so that the quartz fiber, visible through the eyepiece as a fine line running vertically across the scale,  is set at zero.  The CD V-750 could also be used to read the dosimeters if insufficient light was available - quite possible in an emergency situation.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_750_742_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_750_742_1-150x150.jpg" alt="cdv_750_742_1" width="150" height="150" class="alignnone size-thumbnail wp-image-4169" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_750_742_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_750_742_2-150x150.jpg" alt="cdv_750_742_2" width="150" height="150" class="alignnone size-thumbnail wp-image-4170" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_750_742_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_750_742_3-150x150.jpg" alt="cdv_750_742_3" width="150" height="150" class="alignnone size-thumbnail wp-image-4171" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_750_742_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_750_742_4-150x150.jpg" alt="cdv_750_742_4" width="150" height="150" class="alignnone size-thumbnail wp-image-4172" /></a><br />
The key features of the CD V-750 were the charging contact (protected by a dust cap attached to the case via a bead chain) and the control knob for adjusting the charge.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_750_742_5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_750_742_5-150x150.jpg" alt="cdv_750_742_5" width="150" height="150" class="alignnone size-thumbnail wp-image-4173" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_750_742_6.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_750_742_6-150x150.jpg" alt="cdv_750_742_6" width="150" height="150" class="alignnone size-thumbnail wp-image-4174" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_750_742_7.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_750_742_7-150x150.jpg" alt="cdv_750_742_7" width="150" height="150" class="alignnone size-thumbnail wp-image-4175" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_750_742_8.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_750_742_8-150x150.jpg" alt="cdv_750_742_8" width="150" height="150" class="alignnone size-thumbnail wp-image-4176" /></a><br />
The model I have and that can be seen in the pictures above is 5b. Earlier models had a lever that pushed towards the lower left was used to provide the charge (The mechanical energy generated by pumping the lever is converted into electrical energy. Those units also had a battery, but only to power the light used to illuminate the dosimeter scale). The 5b and newer units use the battery energy for the charge as well, with a small invertor that boosts the 1.5V from the D cell battery to aprox 57Volts.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv-750-schematic.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv-750-schematic.jpg" alt="cdv-750-schematic" width="500" height="312" class="alignnone size-full wp-image-4178" /></a></p>
<p>The CDV-742 Radiological Dosimeters are electrostatic devices used for measuring an<br />
accumulated dose (over a period of time) of radiation. The civil defense dosimeters are a standard dosimeter design. This same type of dosimeter would be used anywhere people would have to measure their accumulated radiation dose. The electrostatic type of dosimeter is charged with a dosimeter charger (pictured above). This charger, charges the inner chamber of the dosimeter tube with a high voltage charge which zeros the dosimeters hair like crystal in the viewing scale. When ionizing gamma radiation passes through the dosimeter it discharges it causing the hair like crystal to move up scale resulting in a reading of the accumulated dose received by the dosimeter.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/old_CDV750_1b.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/old_CDV750_1b-150x150.jpg" alt="OLYMPUS DIGITAL CAMERA" width="150" height="150" class="alignnone size-thumbnail wp-image-4181" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/old_CDV750_2b.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/old_CDV750_2b-150x150.jpg" alt="old_CDV750_2b" width="150" height="150" class="alignnone size-thumbnail wp-image-4182" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/old_CDV750_3b.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/old_CDV750_3b-150x150.jpg" alt="old_CDV750_3b" width="150" height="150" class="alignnone size-thumbnail wp-image-4183" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/old_CDV750_4b.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/old_CDV750_4b-150x150.jpg" alt="OLYMPUS DIGITAL CAMERA" width="150" height="150" class="alignnone size-thumbnail wp-image-4184" /></a></p>
<p>The inside of a dosimeter pen contains a capacitor (charged with the charger/CDV-750), an electroscope (the quartz fibre), lenses to focus the light to allow observations via the eyepiece and finally a scale (working as an overlay on top of the quartz fibre shadow):<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv742_components.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv742_components.jpg" alt="cdv742_components" width="638" height="259" class="alignnone size-full wp-image-4187" /></a><br />
And yet more in-detail diagrams:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/dosimeter1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/dosimeter1-180x300.jpg" alt="dosimeter1" width="180" height="300" class="alignnone size-medium wp-image-4189" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/dosimeter2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/dosimeter2-216x300.jpg" alt="dosimeter2" width="216" height="300" class="alignnone size-medium wp-image-4190" /></a></p>
<p>Resources:<br />
<a href="http://www.orau.org/ptp/collection/civildefense/cdv750.htm">[1] orau.org</a><br />
<a href="http://www.michigancivildefense.com/cdv750.html">[2] michigancivildefense.com </a><br />
<a href="http://www.civildefensemuseum.com/cdmuseum2/radkits/dose.html">[3] civildefensemuseum.com</a><br />
<a href="http://www.vaughns-1-pagers.com/science/cdv-750-charger.htm">[4] vaughns-1-pagers.com</a><br />
<a href="http://www.hosfelt.com/en-us/dept_55.html">[5] hosfelt.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/05/cdv-742-dosimeter-and-cdv-750-dosimeter-charger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Repairing a Victoreen CDV-700 6B Dosimeter</title>
		<link>http://www.pocketmagic.net/2013/05/repairing-a-victoreen-cdv700-6b-dosimeter/</link>
		<comments>http://www.pocketmagic.net/2013/05/repairing-a-victoreen-cdv700-6b-dosimeter/#comments</comments>
		<pubDate>Thu, 16 May 2013 09:12:04 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[High Voltage]]></category>
		<category><![CDATA[Nuclear]]></category>
		<category><![CDATA[cdv700]]></category>
		<category><![CDATA[dosimeter]]></category>
		<category><![CDATA[failure]]></category>
		<category><![CDATA[geiger counter]]></category>
		<category><![CDATA[repair]]></category>
		<category><![CDATA[Victoreen]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=4146</guid>
		<description><![CDATA[Fixing a CDV700 dosimeter can be difficult because original replacement components are not an easy find. ]]></description>
				<content:encoded><![CDATA[<p>CD-V700 radiation survey meter is a sensitive low-range instrument that can be used to measure gamma radiation and detect beta radiation. I own a functional vintage CDV700 unit, that I've presented <a href="http://www.pocketmagic.net/2010/07/victoreen-cdv700-6b-mod-audiobnc-connector/">here</a>. Functional, at least until it decided to stop working for no apparent reason.</p>
<p>Checking everything step by step, I saw the following:<br />
1. The oscillator works<br />
2. Only 100V output, after the rectifier diode<br />
Here is the circuit diagram:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv700_circuit_diagram.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv700_circuit_diagram-212x300.jpg" alt="cdv700_circuit_diagram" width="212" height="300" class="alignnone size-medium wp-image-4149" /></a><br />
I changed the two caps right after the diode. The issue remains. Disconnecting the diode's positive end, shows 900+ volts, but when connected in the circuit, I barely can get 200V, and the funny thing is the unit was operational last time I've used it. I then changed the second transistor (the one handling the headset and the dial) (PNP) to a generic PNP and also changed the selenium diode to a 14KV 10mA modern one. No luck.<br />
Thanks to the <a href="http://tech.groups.yahoo.com/group/CDV700CLUB/message/40498">CDV700CLUB group</a>, I got some excellent suggestions on what to try next, but most of that I checked already to no avail: Bad regulator, leaky hv cap, bad probe cable, bad geiger tube.<br />
As <a href="http://tech.groups.yahoo.com/group/CDV700CLUB/message/40508">disklog </a>suggested, the problem might be failure of the T1 transformer, resulting in the defects that I have observed/measured. So I would either need to rewind the transformer or find a replacement (which is a bit complicated for such old designs).</p>
<p>Doug was so kind to help me on this matter, and sent me not one but two CDV700 circuit boards and some additional components. Thanks Doug!<br />
Given this nice donation, getting my CDV700 operational again was so easy. I replaced the entire board with one received from him:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_700_6b_repair_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_700_6b_repair_1-150x150.jpg" alt="cdv_700_6b_repair_1" width="150" height="150" class="alignnone size-thumbnail wp-image-4156" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_700_6b_repair_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_700_6b_repair_2-150x150.jpg" alt="cdv_700_6b_repair_2" width="150" height="150" class="alignnone size-thumbnail wp-image-4157" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_700_6b_repair_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_700_6b_repair_3-150x150.jpg" alt="cdv_700_6b_repair_3" width="150" height="150" class="alignnone size-thumbnail wp-image-4158" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_700_6b_repair_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_700_6b_repair_4-150x150.jpg" alt="cdv_700_6b_repair_4" width="150" height="150" class="alignnone size-thumbnail wp-image-4159" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_700_6b_repair_5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_700_6b_repair_5-150x150.jpg" alt="cdv_700_6b_repair_5" width="150" height="150" class="alignnone size-thumbnail wp-image-4160" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_700_6b_repair_6.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_700_6b_repair_6-150x150.jpg" alt="cdv_700_6b_repair_6" width="150" height="150" class="alignnone size-thumbnail wp-image-4161" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_700_6b_repair_7.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_700_6b_repair_7-150x150.jpg" alt="cdv_700_6b_repair_7" width="150" height="150" class="alignnone size-thumbnail wp-image-4162" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_700_6b_repair_8.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/cdv_700_6b_repair_8-150x150.jpg" alt="cdv_700_6b_repair_8" width="150" height="150" class="alignnone size-thumbnail wp-image-4163" /></a></p>
<p>It worked from the first try!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/05/repairing-a-victoreen-cdv700-6b-dosimeter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tube: 1B40</title>
		<link>http://www.pocketmagic.net/2013/05/tube-1b40/</link>
		<comments>http://www.pocketmagic.net/2013/05/tube-1b40/#comments</comments>
		<pubDate>Thu, 09 May 2013 10:24:57 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Tubes]]></category>
		<category><![CDATA[1B40]]></category>
		<category><![CDATA[radar]]></category>
		<category><![CDATA[tubes]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=4133</guid>
		<description><![CDATA[External Cavity tube, 1KW at 1075 to 1096MHz.]]></description>
				<content:encoded><![CDATA[<p><b>Pictures:</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/pocketmagic.net_1B40_tube_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/pocketmagic.net_1B40_tube_1-150x150.jpg" alt="pocketmagic.net_1B40_tube_1" width="150" height="150" class="alignnone size-thumbnail wp-image-4134" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/pocketmagic.net_1B40_tube_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/pocketmagic.net_1B40_tube_2-150x150.jpg" alt="pocketmagic.net_1B40_tube_2" width="150" height="150" class="alignnone size-thumbnail wp-image-4135" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/pocketmagic.net_1B40_tube_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/pocketmagic.net_1B40_tube_3-150x150.jpg" alt="pocketmagic.net_1B40_tube_3" width="150" height="150" class="alignnone size-thumbnail wp-image-4136" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/pocketmagic.net_1B40_tube_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/pocketmagic.net_1B40_tube_4-150x150.jpg" alt="pocketmagic.net_1B40_tube_4" width="150" height="150" class="alignnone size-thumbnail wp-image-4137" /></a></p>
<p><b>Details:</b><br />
External Cavity, 1KW at 1075 to 1096MHz. 'Electrodeless' discharge: the tube has the ground ring and a keep-alive electrode connection in the base. Made by Bomac and Sylvania.   It measures 38x20mm (12mm across glass).</p>
<p><b>Datasheet:</b><br />
n/a</p>
<p><b>Links:</b><br />
<a href="http://www.radiomuseum.org/tubes/tube_1b40.html">Radiomuseum</a><br />
<a href="http://www.tubecollector.org/1b40.htm">Tubecollector</a><br />
<a href="http://www.edelpro.com/DiskSealVacuumTubes/body.html">Disk seal vacuum tubes</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/05/tube-1b40/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tube: USN-5J29</title>
		<link>http://www.pocketmagic.net/2013/05/tube-usn-5j29/</link>
		<comments>http://www.pocketmagic.net/2013/05/tube-usn-5j29/#comments</comments>
		<pubDate>Wed, 08 May 2013 17:48:12 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Tubes]]></category>
		<category><![CDATA[5J29]]></category>
		<category><![CDATA[cyclotron]]></category>
		<category><![CDATA[magnetron]]></category>
		<category><![CDATA[radar]]></category>
		<category><![CDATA[radar jammer]]></category>
		<category><![CDATA[tubes]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=4121</guid>
		<description><![CDATA[ 5J29 is a split anode magnetron. This device is water cooled, the water flowing round the metal loop.]]></description>
				<content:encoded><![CDATA[<p><b>Pictures:</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/pocketmagic.net_tube_5J29_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/pocketmagic.net_tube_5J29_1-150x150.jpg" alt="pocketmagic.net_tube_5J29_1" width="150" height="150" class="alignnone size-thumbnail wp-image-4122" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/pocketmagic.net_tube_5J29_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/pocketmagic.net_tube_5J29_2-150x150.jpg" alt="pocketmagic.net_tube_5J29_2" width="150" height="150" class="alignnone size-thumbnail wp-image-4123" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/pocketmagic.net_tube_5J29_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/pocketmagic.net_tube_5J29_3-150x150.jpg" alt="pocketmagic.net_tube_5J29_3" width="150" height="150" class="alignnone size-thumbnail wp-image-4124" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/pocketmagic.net_tube_5J29_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/pocketmagic.net_tube_5J29_4-150x150.jpg" alt="pocketmagic.net_tube_5J29_4" width="150" height="150" class="alignnone size-thumbnail wp-image-4125" /></a></p>
<p><b>Details:</b><br />
5J29 is a split anode magnetron. This device is water cooled, the water flowing round the metal loop.<br />
Identical to: 	5J29 = CV3842 = ZP579<br />
Filament: 	Vf 2.2 Volts / If: 35 Ampere / -: Direct /<br />
Description: 	External magnet, split-anode, glass body CW magnetron; 350 to 770MHz; 75 to 150W out. Liquid-cooled through the anode tubular pins and the internal loop, part of the tuning line resonator.<br />
450mA max at 2500V, 1500 gauss flux density. Used in the AN/APT-4 jammer. 'Confidential' etched on the glass.  </p>
<p>The 5J29 is an unusual device, a water-cooled split anode magnetron, used primarily in the AN/APT-4 radar jammer. Unlike a conventional multicavity magnetron, the 5J29 is effectively a miniature cyclotron accelerator. The 5J29 is best known as a GE product; the second-source FTR version is much rarer. The 5J29 operates at frequencies between 350 and 770MHz.</p>
<p><b>The AN/APT-4 Radar Jammer</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/5J29_AN-APT-4_jammer.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/5J29_AN-APT-4_jammer.jpg" alt="5J29_AN-APT-4_jammer" width="800" height="382" class="alignnone size-full wp-image-4128" /></a><br />
"This jammer, code named Broadloom I, was the first to use one of the techniques feverishly explored in the middle of the war to raise power outputs at VHF and UHF frequencies. Faced with the inability to use conventional triodes and tetrodes at power levels of more than 20 or 30 watts output, this transmitter was designed to use an early 1930s development - a split anode magnetron - to obtain 150W CW output from about 140 MHz to almost 800 MHz. They used two different tubes to cover this frequency range , along with an impressive amount of hardware devoted to the care and feeding of this simple(!) one tube transmitter. These tubes differed from the more familiar cavity magnetrons used for pulse radar work in that they used an external resonant LC circuit, sometimes called a tank, to provide an impressive tuning range.</p>
<p>Composed of three separate packages - left to right a power supply, an AM modulator using a pair of 813 PA tubes, and the transmitter - this prototype set by Stromberg Carlson had a production run of only 100 sets.</p>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/AN-APT-4a.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/AN-APT-4a-150x150.jpg" alt="The modulator" width="150" height="150" class="alignnone size-thumbnail wp-image-4130" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/AN-APT-4b.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/AN-APT-4b-150x150.jpg" alt="The transmitter" width="150" height="150" class="alignnone size-thumbnail wp-image-4131" /></a><br />
GE was selected to manufacture the final product, and there are small changes between this rare example and the later GE set that had an initial production of 2,092 sets. Below is a photo of the interior of the GE transmitter, showing the long tuning cavity and coaxial line stretcher "trombone" used to get the frequency down to its surprising low end of 2 meters.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/05/AN-APT-4_jammer2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/05/AN-APT-4_jammer2-150x150.jpg" alt="AN-APT-4_jammer2" width="150" height="150" class="alignnone size-thumbnail wp-image-4129" /></a><br />
There was a serious filament "back heating" problem that plagued the early developers (analogous to thermal runaway in a transistor circuit), Initial operation with the split anode tube ran into an impractically short lifetime of less than 30 hours for the tube. It seems that you have essentially a miniature cyclotron at work in the tube, and especially at frequencies below about 150MHz, electron leakage from the anodes bombarding the glass seals was causing the early failure. Eventually, the simple addition of washers and nuts above the seals deflected the electrons from the seals enough to make the tubes last ten times as long. Even so, there is an impressive amount of heat to be carried away from an operating tube, and this package is filled with electric motors to accomplish that task - three blowers (two to blow air through the glycol cooled radiator used to keep the tube temperature down), as well as a coolant pump at lower left. The recirculation method depended on which of the two magnetrons was used. The lower frequency magnetron at left below required coaxial brass tubes to circulate pure glycol deep into each anode of the magnetron, recovering the hot fluid coming back out in the outer brass tube. The higher frequency tube had a continuous loop through the tube, so circulation wasn't quite so difficult a problem and could recover more heat in operation. Changing magnetron types on the Stromberg Carlson prototype required turning a valve 90 degrees, while the later GE set accomplished the same thing through the tube attachments. Below is a closeup of both tubes - a 5J30 on the left and 5J29 on the right. " Source [4]</p>
<p><b>Datasheet:</b><br />
n/a</p>
<p><b>Links:</b><br />
[1] <a href="http://www.radiomuseum.org/tubes/tube_5j29.html" target="_blank">Radiomuseum</a><br />
[2] <a href="http://www.decadecounter.com/vta/tubepage.php?item=20" target="_blank">The Vintage Technology association</a><br />
[3] <a href="http://www.tubecollector.org/5j29.htm" target="_blank">Tubecollector</a><br />
[4] <a href="http://aafradio.org/countermeasures/AN-APT-4_jammer.htm" target="_blank">Magnetron Jammers</a><br />
[5] <a href="http://www.ibiblio.org/hyperwar/USN/ref/RADELEVEN/#tdy" target="_blank">TDY-1 Radar Jamming system</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/05/tube-usn-5j29/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to make metallic sodium</title>
		<link>http://www.pocketmagic.net/2013/04/how-to-make-metallic-sodium/</link>
		<comments>http://www.pocketmagic.net/2013/04/how-to-make-metallic-sodium/#comments</comments>
		<pubDate>Sat, 27 Apr 2013 13:19:48 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[diy]]></category>
		<category><![CDATA[electrolysis]]></category>
		<category><![CDATA[metallic]]></category>
		<category><![CDATA[molten]]></category>
		<category><![CDATA[sodium]]></category>
		<category><![CDATA[sodium hydroxide]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=4069</guid>
		<description><![CDATA[Electrolysis of molten sodium hydroxide at  318 °C .]]></description>
				<content:encoded><![CDATA[<p>Sodium is a chemical element with the symbol Na (from Latin: natrium) in the periodic table and atomic number 11. It is a soft, silvery-white, highly reactive metal and is a member of the alkali metals; its only stable isotope is 23Na. The free metal does not occur in nature, but instead must be prepared from its compounds; it was first isolated by Humphry Davy in 1807 by the electrolysis of sodium hydroxide.</p>
<p>Given its extraordinary chemical reactivity, there are multiple applications for this substance. Preparing it via electrolysis is the easiest way to go, however we need to use a molten sodium hydroxide electrolyte, as the resulting sodium would react with the water in an aqueous solution. Not that hard to do, as NaOH melts at 318 °C . The temperature is reasonably low to allow the separation of the resulting sodium without spontaneous ignition in air, but extra caution must be exercised as the chemicals involved are highly caustic, especially at high temperatures.<br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/3TJYmSuFX4c" frameborder="0" allowfullscreen></iframe><br />
I used a ceramic electrolysis container with two steel electrodes. Carbon rods doesn't go to well. The power supply was my trusty <a href="http://www.pocketmagic.net/2010/02/variable-0-30v-20a-regulated-power-supply-using-lm317/">variable regulated DC supply</a>, and most of the time I used 7-10V. To melt the sodium hydroxide I used a butane torch: melting is necessary to get the electrolysis going , but then the flowing current will keep the NaOH in molten state and the torch is not required anymore.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/sodium_electrolysis_diagram.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/sodium_electrolysis_diagram.jpg" alt="sodium_electrolysis_diagram" width="428" height="420" class="alignnone size-full wp-image-4071" /></a></p>
<p>In the laboratory, with carefully controlled conditions, sodium metal can be isolated from the electrolysis of the molten monohydrate in a low temperature version of the Castner process, according to the following reaction:</p>
<p>    4 NaOH·H2O(l) → 4 Na(l) + O2(g) + 6 H2O(g)</p>
<p>The monohydrate does not need to be heated in order to melt, as the process produces enough heat due to ohmic heating. However, it must be initiated with a small quantity of liquid water to create an electrically conductive electrolyte. As the system's temperature increases, the monohydrate will start to melt at about 65 °C as stated above. Only when the temperature reaches about 100 °C can sodium be isolated. Below this temperature, the water produced will react with the sodium: above this point, any water formed will be driven off in the vapour phase, creating an essentially anhydrous reaction. While this process has some advantages over other electrolytic processes, it is not preferred by most chemists because a marginal quantity of sodium produced boils at the electrode interface. </p>
<p>If temperature is too high, part of the sodium will dissolve in the molten NaOH, as shown in the video (the black substance surrounding the metallic sodium spheres). Also the electrodes should be some space apart to prevent short-circuit due to the liquid sodium getting mixed in the electrolyte.<br />
NaCl might be a good alternative, but at the high temperature needed to melt it, handling sodium is more problematic.</p>
<p>Eye protection is an absolute must, as the chemicals involved will quickly burn through skin!</p>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/metallic_sodium_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/metallic_sodium_1-150x150.jpg" alt="metallic_sodium_1" width="150" height="150" class="alignnone size-thumbnail wp-image-4073" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/metallic_sodium_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/metallic_sodium_2-150x150.jpg" alt="metallic_sodium_2" width="150" height="150" class="alignnone size-thumbnail wp-image-4074" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/metallic_sodium_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/metallic_sodium_3-150x150.jpg" alt="metallic_sodium_3" width="150" height="150" class="alignnone size-thumbnail wp-image-4075" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/metallic_sodium_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/metallic_sodium_4-150x150.jpg" alt="metallic_sodium_4" width="150" height="150" class="alignnone size-thumbnail wp-image-4076" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/metallic_sodium_5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/metallic_sodium_5-150x150.jpg" alt="metallic_sodium_5" width="150" height="150" class="alignnone size-thumbnail wp-image-4077" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/metallic_sodium_6.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/metallic_sodium_6-150x150.jpg" alt="metallic_sodium_6" width="150" height="150" class="alignnone size-thumbnail wp-image-4078" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/metallic_sodium_7.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/metallic_sodium_7-150x150.jpg" alt="metallic_sodium_7" width="150" height="150" class="alignnone size-thumbnail wp-image-4079" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/metallic_sodium_8.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/metallic_sodium_8-150x150.jpg" alt="metallic_sodium_8" width="150" height="150" class="alignnone size-thumbnail wp-image-4080" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/04/how-to-make-metallic-sodium/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to scale an Android UI on multiple screens</title>
		<link>http://www.pocketmagic.net/2013/04/how-to-scale-an-android-ui-on-multiple-screens/</link>
		<comments>http://www.pocketmagic.net/2013/04/how-to-scale-an-android-ui-on-multiple-screens/#comments</comments>
		<pubDate>Mon, 15 Apr 2013 16:34:24 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[bitmap]]></category>
		<category><![CDATA[drawable]]></category>
		<category><![CDATA[ImageView]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[scale]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=4042</guid>
		<description><![CDATA[Learn how to scale an user interface to maintain the same aspect ratio, while running the same code on various Android devices.]]></description>
				<content:encoded><![CDATA[<p>We have to admit that being an open source platform , used by so many manufactures on so many different devices is not exactly an advantage for Android, when we talk about application development with supporting multiple screen sizes. But this is nothing new. There is an article on the Android.com, discussing a few programming tips, in <a href="http://developer.android.com/guide/practices/screens_support.html">"Supporting multiple Screens"</a>.</p>
<p>Besides the multitude of screen densities, that can be handled satisfactory by using the DPI approach, there are also very big differences in screen resolutions, especially when comparing phones with tablets.<br />
Creating a separate layout xml file might be a painful experience, not to mention that that are times when we simply want to scale the same interface, to maintain its look and consistency when running on a phone, but also when running on a tablet. So, here is the question:</p>
<h3>How to scale an Android User Interface on multiple screens?</h3>
<p>Let's start with an example: two android devices, a tablet (MDPI, 1280x800 pixels) and a phone (HDPI, 960x540). The sample code shows an image, centered on the screen. The image is provided in res/drawable-mdpi and res/drawable-hdpi. Here are the two variants:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/scaletest.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/scaletest.png" alt="scaletest" width="48" height="48" class="alignnone size-full wp-image-4043" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/scaletest1.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/scaletest1.png" alt="scaletest" width="72" height="72" class="alignnone size-medium wp-image-4044" /></a><br />
The tablet picks up the 48x48 one, and the phone the 72x72 one, as expected, based on their DPIs. The code to draw the image is simple:</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> onCreate<span style="color: #66cc66;">&#40;</span>Bundle savedInstanceState<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006600;">onCreate</span><span style="color: #66cc66;">&#40;</span>savedInstanceState<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        RelativeLayout panel = <span style="color: #000000; font-weight: bold;">new</span> RelativeLayout<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        setContentView<span style="color: #66cc66;">&#40;</span>panel<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        ImageView iv = <span style="color: #000000; font-weight: bold;">new</span> ImageView<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        iv.<span style="color: #006600;">setImageResource</span><span style="color: #66cc66;">&#40;</span>R.<span style="color: #006600;">drawable</span>.<span style="color: #006600;">scaletest</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        RelativeLayout.<span style="color: #006600;">LayoutParams</span> lpv = <span style="color: #000000; font-weight: bold;">new</span> RelativeLayout.<span style="color: #006600;">LayoutParams</span><span style="color: #66cc66;">&#40;</span>LayoutParams.<span style="color: #006600;">WRAP_CONTENT</span>, LayoutParams.<span style="color: #006600;">WRAP_CONTENT</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        lpv.<span style="color: #006600;">addRule</span><span style="color: #66cc66;">&#40;</span>RelativeLayout.<span style="color: #006600;">CENTER_IN_PARENT</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        panel.<span style="color: #006600;">addView</span><span style="color: #66cc66;">&#40;</span>iv, lpv<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>Here are screen captures showing the result, and a real photo. The real photo shows that the DPI is correctly taken into account, and the image appears of having the same size on these different density screens:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/android_imageview_scale_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/android_imageview_scale_1-300x187.jpg" alt="android_imageview_scale_1" width="300" height="187" class="alignnone size-medium wp-image-4045" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/android_imageview_scale_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/android_imageview_scale_2-300x168.jpg" alt="android_imageview_scale_2" width="300" height="168" class="alignnone size-medium wp-image-4046" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/android_imageview_scale_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/android_imageview_scale_3-300x170.jpg" alt="android_imageview_scale_3" width="300" height="170" class="alignnone size-medium wp-image-4047" /></a></p>
<p>Now let's assume we are designing a single interface layout in Photoshop: we place some given size buttons, some given size images, and all in one, the entire interface is designed to fit a certain <b>aspect ratio</b>. How can we have that fit into the two screens used as examples above?</p>
<p>Well, for a start, if we go for full sized/no titlebar and no statusbar option:</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">requestWindowFeature<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AWindow+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Window</span></a>.<span style="color: #006600;">FEATURE_NO_TITLE</span><span style="color: #66cc66;">&#41;</span>;				</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">getWindow<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">setFlags</span><span style="color: #66cc66;">&#40;</span>WindowManager.<span style="color: #006600;">LayoutParams</span>.<span style="color: #006600;">FLAG_FULLSCREEN</span>,WindowManager.<span style="color: #006600;">LayoutParams</span>.<span style="color: #006600;">FLAG_FULLSCREEN</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>then the tablet has (in landscape mode) a screen ratio of 1280/752=80:47 (because the bottom tablet bar also uses space, out of the total 1280x800 screen size) while the phone has 960/540=16:9. Both interfaces should be on landscape, so if we design our interface layout to be of 960x640 pixels, we'll need to scale the height (640) to match the tablet's screen height, and so for the phone's screen height. Using this scaling factor, we then resize the width as well, and our interface designed for 960:640 will get: 1128x752 (scale factor 1.175, padding horizontal: 76pixels) on the tablet, and 810x540 (scale factor 0.84375. padding horizontal: 75pixels):<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/android_scaled_gui_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/android_scaled_gui_1-300x187.jpg" alt="android_scaled_gui_1" width="300" height="187" class="alignnone size-medium wp-image-4051" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/android_scaled_gui_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/android_scaled_gui_2-300x168.jpg" alt="android_scaled_gui_2" width="300" height="168" class="alignnone size-medium wp-image-4052" /></a></p>
<p>So what we can do at this step is design the entire interface to match 960x640 pixels, then put all images in drawable-nodpi (so we always get constant size bitmaps), and scale everything on screen according to our scaling factor, <b>m_fFrameS</b>:</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@Override <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> onCreate<span style="color: #66cc66;">&#40;</span>Bundle savedInstanceState<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006600;">onCreate</span><span style="color: #66cc66;">&#40;</span>savedInstanceState<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        requestWindowFeature<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AWindow+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Window</span></a>.<span style="color: #006600;">FEATURE_NO_TITLE</span><span style="color: #66cc66;">&#41;</span>;				</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        getWindow<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">setFlags</span><span style="color: #66cc66;">&#40;</span>WindowManager.<span style="color: #006600;">LayoutParams</span>.<span style="color: #006600;">FLAG_FULLSCREEN</span>,WindowManager.<span style="color: #006600;">LayoutParams</span>.<span style="color: #006600;">FLAG_FULLSCREEN</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        RelativeLayout panel = <span style="color: #000000; font-weight: bold;">new</span> RelativeLayout<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        setContentView<span style="color: #66cc66;">&#40;</span>panel<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #808080; font-style: italic;">/*ImageView iv = new ImageView(this);</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;       iv.setImageResource(R.drawable.scaletest);</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;       RelativeLayout.LayoutParams lpv = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;       lpv.addRule(RelativeLayout.CENTER_IN_PARENT);</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;       panel.addView(iv, lpv);*/</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        DisplayMetrics dm = <span style="color: #000000; font-weight: bold;">new</span> DisplayMetrics<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		getWindowManager<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getDefaultDisplay</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getMetrics</span><span style="color: #66cc66;">&#40;</span>dm<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #993333;">int</span> m_nTotalW = dm.<span style="color: #006600;">widthPixels</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #993333;">int</span>  m_nTotalH = dm.<span style="color: #006600;">heightPixels</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #808080; font-style: italic;">// scale factor</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #993333;">float</span> m_fFrameS = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">float</span><span style="color: #66cc66;">&#41;</span>m_nTotalH / <span style="color: #cc66cc;">640</span>.0f;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #808080; font-style: italic;">// compute our frame</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #993333;">int</span> m_nFrameW = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">960</span>.0f * m_fFrameS<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #993333;">int</span> m_nFrameH = m_nTotalH;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #808080; font-style: italic;">// compute padding for our frame inside the total screen size</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #993333;">int</span> m_nPaddingY = <span style="color: #cc66cc;">0</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #993333;">int</span> m_nPaddingX = <span style="color: #66cc66;">&#40;</span>m_nTotalW - m_nFrameW<span style="color: #66cc66;">&#41;</span> / <span style="color: #cc66cc;">2</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        Log.<span style="color: #006600;">d</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;ScaleTest&quot;</span>, <span style="color: #ff0000;">&quot;Total:&quot;</span>+m_nTotalW + <span style="color: #ff0000;">&quot;x&quot;</span>+m_nTotalH+ <span style="color: #ff0000;">&quot; Scale:&quot;</span>+m_fFrameS+<span style="color: #ff0000;">&quot; Frame:&quot;</span>+m_nFrameW+<span style="color: #ff0000;">&quot;x&quot;</span>+m_nFrameH + <span style="color: #ff0000;">&quot; Padding:&quot;</span>+m_nPaddingX+<span style="color: #ff0000;">&quot;x&quot;</span>+m_nPaddingY<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        RelativeLayout frame = <span style="color: #000000; font-weight: bold;">new</span> RelativeLayout<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        frame.<span style="color: #006600;">setBackgroundColor</span><span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AColor+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">GRAY</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        RelativeLayout.<span style="color: #006600;">LayoutParams</span> lpv = <span style="color: #000000; font-weight: bold;">new</span> RelativeLayout.<span style="color: #006600;">LayoutParams</span><span style="color: #66cc66;">&#40;</span>m_nFrameW, m_nFrameH<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        lpv.<span style="color: #006600;">leftMargin</span> = m_nPaddingX ;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        lpv.<span style="color: #006600;">topMargin</span> = m_nPaddingY;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        panel.<span style="color: #006600;">addView</span><span style="color: #66cc66;">&#40;</span>frame, lpv<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<h3>Scaling method 1: scaling the drawables</h3>
<p>As you can see , we are more interested in preserving our interface's coordinates, and graphical elements intact, then of actually having our buttons have the exact length in centimeters between various devices (not really important).  To continue, let's use another example, where we design a complete 960x640 user interface (the floral brown background), and we have one single imageview (the purple flower), placed at some exact coordinates. We want this interface to be drawn exactly the same way, when running the code on various devices:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/background_ui.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/background_ui-300x203.jpg" alt="background_ui" width="300" height="203" class="alignnone size-medium wp-image-4054" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/flower_ui.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/flower_ui.jpg" alt="flower_ui" width="231" height="192" class="alignnone size-medium wp-image-4055" /></a><br />
The coordinates for the imageview are given by the cyan guidelines. We save the two images (<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/background_ui_android.jpg">background</a>, <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/flower_ui.jpg">flower</a>) in /res/drawable-nodpi . To load them we use:</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> Bitmap getScaledBitmap<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AContext+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Context</span></a> context, <span style="color: #993333;">float</span> scalex, <span style="color: #993333;">float</span> scaley, <span style="color: #993333;">int</span> id<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	Bitmap bitmap = BitmapFactory.<span style="color: #006600;">decodeResource</span><span style="color: #66cc66;">&#40;</span>context.<span style="color: #006600;">getResources</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, id<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	Matrix matrix = <span style="color: #000000; font-weight: bold;">new</span> Matrix<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	matrix.<span style="color: #006600;">postScale</span><span style="color: #66cc66;">&#40;</span>scalex, scaley<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	matrix.<span style="color: #006600;">postRotate</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	Bitmap scaled =  Bitmap.<span style="color: #006600;">createBitmap</span><span style="color: #66cc66;">&#40;</span>bitmap, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, bitmap.<span style="color: #006600;">getWidth</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, bitmap.<span style="color: #006600;">getHeight</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, matrix, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	bitmap.<span style="color: #006600;">recycle</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">return</span> scaled;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> Drawable getScaledDrawable<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AContext+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Context</span></a> context, <span style="color: #993333;">float</span> scalex, <span style="color: #993333;">float</span> scaley, <span style="color: #993333;">int</span> id<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> BitmapDrawable<span style="color: #66cc66;">&#40;</span>context.<span style="color: #006600;">getResources</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, getScaledBitmap<span style="color: #66cc66;">&#40;</span>context, scalex, scaley, id<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>And then the code to display the background and the image is:</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">       frame.<span style="color: #006600;">setBackgroundDrawable</span><span style="color: #66cc66;">&#40;</span>getResources<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getDrawable</span><span style="color: #66cc66;">&#40;</span>R.<span style="color: #006600;">drawable</span>.<span style="color: #006600;">background_ui_android</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        ImageView iv = <span style="color: #000000; font-weight: bold;">new</span> ImageView<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        iv.<span style="color: #006600;">setImageDrawable</span><span style="color: #66cc66;">&#40;</span>getScaledDrawable<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        		m_fFrameS, m_fFrameS, <span style="color: #808080; font-style: italic;">// same scaling factor on horizontal and on vertical </span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        		R.<span style="color: #006600;">drawable</span>.<span style="color: #006600;">flower_ui</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        lpv = <span style="color: #000000; font-weight: bold;">new</span> RelativeLayout.<span style="color: #006600;">LayoutParams</span><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        		Scale<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">231</span>,m_fFrameS<span style="color: #66cc66;">&#41;</span>, Scale<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">192</span>, m_fFrameS<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        lpv.<span style="color: #006600;">leftMargin</span> =  Scale<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">410</span>,m_fFrameS<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        lpv.<span style="color: #006600;">topMargin</span> = Scale<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">239</span>,m_fFrameS<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        frame.<span style="color: #006600;">addView</span><span style="color: #66cc66;">&#40;</span>iv, lpv<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>And here is the result: tablet vs phone:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/android_scaled_imageview_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/android_scaled_imageview_1-300x187.jpg" alt="android_scaled_imageview_1" width="300" height="187" class="alignnone size-medium wp-image-4058" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/android_scaled_imageview_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/android_scaled_imageview_2-300x168.jpg" alt="android_scaled_imageview_2" width="300" height="168" class="alignnone size-medium wp-image-4059" /></a><br />
As you can see, the images are perfectly scaled, aspect ratio matched, on two different android devices.<br />
Sample code available here: <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/ScalingTest_1.zip">ScalingTest_1</a></p>
<h3>Scaling method 2: scaling the Views</h3>
<p>The first approach was to scale the drawables we feed to the views. Let's try instead, to create custom views of exactly the same we provide, while their content scales automatically. We'll be needing a custom ImageView, so we'll just extend the class.<br />
The trick is to override the onMeasure method:</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ScalableImageView <span style="color: #000000; font-weight: bold;">extends</span> ImageView <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #993333;">int</span> m_w, m_h;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">public</span> ScalableImageView<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AContext+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Context</span></a> context, <span style="color: #993333;">int</span> w, <span style="color: #993333;">int</span> h<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #66cc66;">&#40;</span>context<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		m_w = w; m_h = h;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	@Override </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">void</span> onMeasure<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> widthMeasureSpec, <span style="color: #993333;">int</span> heightMeasureSpec<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006600;">onMeasure</span><span style="color: #66cc66;">&#40;</span>widthMeasureSpec, heightMeasureSpec<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">setMeasuredDimension</span><span style="color: #66cc66;">&#40;</span>m_w, m_h<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>And the result is very much the same, but without having to allocate memory for the scaled drawable, as in example 1:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/android_scaled_imageview_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/android_scaled_imageview_1-300x187.jpg" alt="android_scaled_imageview_1" width="300" height="187" class="alignnone size-medium wp-image-4058" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/android_scaled_imageview_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/android_scaled_imageview_2-300x168.jpg" alt="android_scaled_imageview_2" width="300" height="168" class="alignnone size-medium wp-image-4059" /></a><br />
The code: <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/ScalingTest_2.zip">ScalingTest_2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/04/how-to-scale-an-android-ui-on-multiple-screens/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Atmega8 and Nokia 5110 LCD</title>
		<link>http://www.pocketmagic.net/2013/04/atmega8-and-nokia-5110-lcd/</link>
		<comments>http://www.pocketmagic.net/2013/04/atmega8-and-nokia-5110-lcd/#comments</comments>
		<pubDate>Mon, 08 Apr 2013 16:03:05 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[3110]]></category>
		<category><![CDATA[5110]]></category>
		<category><![CDATA[atmega8]]></category>
		<category><![CDATA[lcd]]></category>
		<category><![CDATA[LCD library]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[microcontrollers]]></category>
		<category><![CDATA[nokia]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=4016</guid>
		<description><![CDATA[A C++ Library for AVR microcontrollers that allows easy connectivity to  the Nokia 3110/5110 graphical LCDs.]]></description>
				<content:encoded><![CDATA[<p>The 5110 LCD is a graphical 84x48 pixels monochrome display.<br />
It features a modest Backlight illumination, that can be blue or white. It only needs 3V to run, and it is 5V signal tolerant (not the backlight, so be careful, the leds need 3V max!) Its cost is also low, making it an excellent choice for DIY projects.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/nokia_5110_lcd_atmega_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/nokia_5110_lcd_atmega_1-300x199.jpg" alt="nokia_5110_lcd_atmega_1" width="300" height="199" class="alignnone size-medium wp-image-4017" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/nokia_5110_lcd_atmega_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/nokia_5110_lcd_atmega_2-300x199.jpg" alt="nokia_5110_lcd_atmega_2" width="300" height="199" class="alignnone size-medium wp-image-4018" /></a></p>
<p>To connect it to an Atmega8, you can use the following diagram:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/atmega8_nokia5110.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/atmega8_nokia5110-300x206.jpg" alt="atmega8_nokia5110" width="300" height="206" class="alignnone size-medium wp-image-4019" /></a></p>
<p>The code, written as a C++ class, allows you to output text or draw pixels, position anywhere on the screen, or even draw images. The initialization function  is highly flexible, allowing you to specify the pins allocated for the LCD, on the fly:</p>
<pre class="cpp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">// define the 5 LCD Data pins: SCE, RST, DC, DATA, CLK</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">lcd.<span style="color: #00eeff;">lcd_init</span><span style="color: #000000;">&#40;</span>&amp;PORTB, PB0, &amp;PORTB, PB1, &amp;PORTB, PB2, &amp;PORTB, PB3, &amp;PORTB, PB4<span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">while</span> <span style="color: #000000;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// image demo</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	lcd.<span style="color: #00eeff;">printPictureOnLCD</span><span style="color: #000000;">&#40;</span>introScreen<span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	_delay_ms<span style="color: #000000;">&#40;</span><span style="color: #0000dd;">2000</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	lcd.<span style="color: #00eeff;">lcd_clear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// goto and char demo</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #0000ff;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #0000ff;">int</span> i=<span style="color: #0000dd;">0</span>;i&lt;<span style="color: #0000dd;">14</span>;i++<span style="color: #000000;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #0000ff;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #0000ff;">int</span> j=<span style="color: #0000dd;">0</span>;j&lt;<span style="color: #0000dd;">6</span>;j++<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			lcd.<span style="color: #00eeff;">lcd_goto_xy</span><span style="color: #000000;">&#40;</span>i,j<span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			lcd.<span style="color: #00eeff;">lcd_chr</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">'0'</span> + <span style="color: #000000;">&#40;</span>i + j<span style="color: #000000;">&#41;</span> % <span style="color: #0000dd;">10</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			_delay_ms<span style="color: #000000;">&#40;</span><span style="color: #0000dd;">10</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #000000;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	_delay_ms<span style="color: #000000;">&#40;</span><span style="color: #0000dd;">2000</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	lcd.<span style="color: #00eeff;">lcd_clear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// formatted string demo</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #0000ff;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #0000ff;">int</span> i=<span style="color: #0000dd;">10</span>;i&gt;<span style="color: #0000dd;">0</span>;i--<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		lcd.<span style="color: #00eeff;">lcd_goto_xy</span><span style="color: #000000;">&#40;</span><span style="color: #0000dd;">0</span>,<span style="color: #0000dd;">1</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		lcd.<span style="color: #00eeff;">lcd_string_format</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;   00.00.%02d   <span style="color: #666666; font-weight: bold;">\n</span>  pocketmagic <span style="color: #666666; font-weight: bold;">\n</span>     .net     &quot;</span>, i<span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		_delay_ms<span style="color: #000000;">&#40;</span><span style="color: #0000dd;">200</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	_delay_ms<span style="color: #000000;">&#40;</span><span style="color: #0000dd;">2000</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	lcd.<span style="color: #00eeff;">lcd_clear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// draw a chart</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #0000ff;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #0000ff;">int</span> i=<span style="color: #0000dd;">0</span>;i&lt;<span style="color: #0000dd;">84</span>;i++<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #0000ff;">int</span> f = <span style="color: #000000;">&#40;</span>i * i<span style="color: #000000;">&#41;</span> % <span style="color: #0000dd;">48</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		lcd.<span style="color: #00eeff;">drawPixel</span><span style="color: #000000;">&#40;</span>i,<span style="color: #0000dd;">0</span>, <span style="color: #0000dd;">1</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		lcd.<span style="color: #00eeff;">drawPixel</span><span style="color: #000000;">&#40;</span>i, f, <span style="color: #0000dd;">1</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	_delay_ms<span style="color: #000000;">&#40;</span><span style="color: #0000dd;">2000</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	lcd.<span style="color: #00eeff;">lcd_clear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span>	</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>Here is the result of the code above:<br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/dKK_svHlBS8" frameborder="0" allowfullscreen></iframe></p>
<p>A few pictures:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/nokia_5110_lcd_atmega_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/nokia_5110_lcd_atmega_3-150x150.jpg" alt="nokia_5110_lcd_atmega_3" width="150" height="150" class="alignnone size-thumbnail wp-image-4026" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/nokia_5110_lcd_atmega_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/nokia_5110_lcd_atmega_4-150x150.jpg" alt="nokia_5110_lcd_atmega_4" width="150" height="150" class="alignnone size-thumbnail wp-image-4027" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/nokia_5110_lcd_atmega_5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/nokia_5110_lcd_atmega_5-150x150.jpg" alt="nokia_5110_lcd_atmega_5" width="150" height="150" class="alignnone size-thumbnail wp-image-4028" /></a></p>
<p>The image data with the two cats, available in introscreen.h, has been generated out of a monochrome, 84x48 pixels BMP, using the <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/LCDAssistant.zip">LCDAssistant</a> software, by Radoslaw Kwiecien.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/assistant.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/assistant-300x239.png" alt="assistant" width="300" height="239" class="alignnone size-medium wp-image-4022" /></a></p>
<p>The code is available as open source, licensed under GPL v2:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/lcd_5110.zip">lcd_5110</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/04/atmega8-and-nokia-5110-lcd/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Detecting an ultrasonic beacon</title>
		<link>http://www.pocketmagic.net/2013/04/detecting-an-ultrasonic-beacon/</link>
		<comments>http://www.pocketmagic.net/2013/04/detecting-an-ultrasonic-beacon/#comments</comments>
		<pubDate>Sun, 07 Apr 2013 14:24:33 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[40KHz]]></category>
		<category><![CDATA[barrier]]></category>
		<category><![CDATA[beacon]]></category>
		<category><![CDATA[ultrasonic]]></category>
		<category><![CDATA[ultrasound]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3951</guid>
		<description><![CDATA[How to build an ultrasound beacon and the corresponding receiver.]]></description>
				<content:encoded><![CDATA[<p>An ultrasonic beacon and a ultrasonic receiver is very similar to a beam barrier circuit, the only difference is we don't sound an alarm when an object breaks the ultrasonic path, but instead we try to locate the ultrasonic beacon by moving the receiver. This can be useful in robotics, when we use ultrasounds to detect a target (which in fact is the beacon itself).<br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/Vg7-wyq0DtQ" frameborder="0" allowfullscreen></iframe><br />
To generate or detect ultrasounds, we'll use "40KHZ Ultrasonic Transducer Sensors":<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic-tranducers.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic-tranducers.jpg" alt="ultrasonic tranducers" width="726" height="350" class="alignnone size-full wp-image-3953" /></a><br />
For the emitter (the beacon itself), all we need is an oscillator set for a 35-45KHz frequency. We can achieve this using a 555 timer, a microcontroller and PWM, or discrete components. The simple the better, even though  we lack some control over the signal shape:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic-transmitter.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic-transmitter-300x168.jpg" alt="ultrasonic-transmitter" width="300" height="168" class="alignnone size-medium wp-image-3954" /></a><br />
The receiver is two amplifying transistors and a detector diode:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic-receiver.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic-receiver-300x163.jpg" alt="ultrasonic-receiver" width="300" height="163" class="alignnone size-medium wp-image-3955" /></a></p>
<p>The signal shape at the emitter:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/ads00015.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/ads00015.jpg" alt="ads00015" width="480" height="234" class="alignnone size-full wp-image-3957" /></a></p>
<p>The signal at the receiver, just before the diode:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/ads00016.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/ads00016.jpg" alt="ads00016" width="480" height="234" class="alignnone size-full wp-image-3958" /></a></p>
<p>The range is excellent, at about 4 meters, the receiver was returning more than 100mV, for the detected signal, while at less than 1 meter it was putting out 4 V. The emission cone's angle is almost 40 degrees wide. An excellent module for robotics!</p>
<p><b>Update:</b> And speaking about robots, here are some neat ultrasonic detector modules, built for the differential <a href="http://www.pocketmagic.net/2013/02/android-controlled-robot-part-2/">rover robot</a> I'm currently working on.<br />
These modules can be hooked up to a microcontroller's ADC port, and will return distance dependent voltages. So not only you can use them to spot the direction the sound is coming from, but you can also estimate the distance. The output is via the "signal" pin, which will provide approximately 0..5V depending on the power level of the detected ultrasonic signal.<br />
I built two, as I need differential data to be able to pinpoint the source beacon easier.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic_beacon_receiver_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic_beacon_receiver_1-300x199.jpg" alt="ultrasonic_beacon_receiver_1" width="300" height="199" class="alignnone size-medium wp-image-3997" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic_beacon_receiver_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic_beacon_receiver_2-300x199.jpg" alt="ultrasonic_beacon_receiver_2" width="300" height="199" class="alignnone size-medium wp-image-3998" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic_beacon_receiver_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic_beacon_receiver_3-300x199.jpg" alt="ultrasonic_beacon_receiver_3" width="300" height="199" class="alignnone size-medium wp-image-3999" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic_beacon_receiver_5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic_beacon_receiver_5-300x199.jpg" alt="ultrasonic_beacon_receiver_5" width="300" height="199" class="alignnone size-medium wp-image-4001" /></a></p>
<p><b>Circuit diagram and PCB layout</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic_circuit.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic_circuit-300x138.png" alt="ultrasonic_circuit" width="300" height="138" class="alignnone size-medium wp-image-4002" /></a><br />
Eagle PCB layout available here: <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic_beacon_receiver.zip">ultrasonic_beacon_receiver</a></p>
<p>Resources:<br />
<a href="http://www.electroschematics.com/5144/ultrasonic-beam-barrier/" target="_blank">Ultrasonic Barrier</a><br />
<a href="http://www.micro-examples.com/public/microex-navig/doc/090-ultrasonic-ranger.html" target="_blank">A cheap ultrasonic range finder</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/04/detecting-an-ultrasonic-beacon/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Virtual Reality App Controls Real household objects</title>
		<link>http://www.pocketmagic.net/2013/04/virtual-reality-app-controls-real-household-objects/</link>
		<comments>http://www.pocketmagic.net/2013/04/virtual-reality-app-controls-real-household-objects/#comments</comments>
		<pubDate>Wed, 03 Apr 2013 11:25:48 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[electronic]]></category>
		<category><![CDATA[equipment]]></category>
		<category><![CDATA[Ethernet]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[virtual]]></category>
		<category><![CDATA[virtual reality]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3936</guid>
		<description><![CDATA[You can use your smartphone (android/iphone) to control electrical equipment inside your home. See how.]]></description>
				<content:encoded><![CDATA[<p>I have designed a hardware interface to control real electronic devices by using a virtual reality clone.<br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/3hOVfSG1x0Q" frameborder="0" allowfullscreen></iframe></p>
<p>A few pictures with the construction itself:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/virtual-reality-controller-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/virtual-reality-controller-1-150x150.jpg" alt="virtual reality controller 1" width="150" height="150" class="alignnone size-thumbnail wp-image-3937" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/virtual-reality-controller-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/virtual-reality-controller-2-150x150.jpg" alt="virtual reality controller 2" width="150" height="150" class="alignnone size-thumbnail wp-image-3938" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/virtual-reality-controller-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/virtual-reality-controller-3-150x150.jpg" alt="virtual reality controller 3" width="150" height="150" class="alignnone size-thumbnail wp-image-3939" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/virtual-reality-controller-4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/virtual-reality-controller-4-150x150.jpg" alt="virtual reality controller 4" width="150" height="150" class="alignnone size-thumbnail wp-image-3940" /></a></p>
<p>Opens a world of possibilities, doesn't it?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/04/virtual-reality-app-controls-real-household-objects/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dual H-Bridge for controlling two motors</title>
		<link>http://www.pocketmagic.net/2013/03/dual-h-bridge-for-controlling-two-motors/</link>
		<comments>http://www.pocketmagic.net/2013/03/dual-h-bridge-for-controlling-two-motors/#comments</comments>
		<pubDate>Wed, 27 Mar 2013 12:30:08 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Robotics]]></category>
		<category><![CDATA[H-bridge]]></category>
		<category><![CDATA[h-brige]]></category>
		<category><![CDATA[microcontrollers]]></category>
		<category><![CDATA[robot]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3899</guid>
		<description><![CDATA[Build a dual H-bridge board to control two motors. ]]></description>
				<content:encoded><![CDATA[<p>For the A4WD1 Robot platform project presented <a href="http://www.pocketmagic.net/?p=3665" target="_blank">here</a>, I decided to skip the Sabertooth 2X12 R/C Regenerative Dual Channel Motor Controller, and build a dual H-Bridge board to control the motors. The reason I did this was because the Sabertooth requires a UART connection, and I had none available.<br />
An H-bridge is an electronic circuit which enables a voltage to be applied across a load in either direction.<br />
One single H-Bridge can be used to control a DC motor. By applying voltage in either direction (+/- or -/+) that is reversing the polarity, we can have the motor run forward or backward.<br />
The robot I'm currently working on uses a differential system, so there are two sets of motors that can run both forward (and the robot goes forward), backward (resulting in backward movement) or one moves forward and the other backward that would make the robot turn (either left or right). To control the both sets, a dual h-bridge board was required. This design is based on my previous h-bridge, available <a href="http://www.pocketmagic.net/2009/03/a-simple-h-bridge-design/" target="_blank">here</a>. </p>
<h3>Pictures</h3>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_01.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_01-150x150.jpg" alt="dual_hbridge_motor_controller_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3900" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_02.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_02-150x150.jpg" alt="dual_hbridge_motor_controller_02" width="150" height="150" class="alignnone size-thumbnail wp-image-3901" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_03.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_03-150x150.jpg" alt="dual_hbridge_motor_controller_03" width="150" height="150" class="alignnone size-thumbnail wp-image-3902" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_04.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_04-150x150.jpg" alt="dual_hbridge_motor_controller_04" width="150" height="150" class="alignnone size-thumbnail wp-image-3903" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_05.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_05-150x150.jpg" alt="dual_hbridge_motor_controller_05" width="150" height="150" class="alignnone size-thumbnail wp-image-3904" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_06.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_06-150x150.jpg" alt="dual_hbridge_motor_controller_06" width="150" height="150" class="alignnone size-thumbnail wp-image-3905" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_07.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_07-150x150.jpg" alt="dual_hbridge_motor_controller_07" width="150" height="150" class="alignnone size-thumbnail wp-image-3906" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_08.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_08-150x150.jpg" alt="dual_hbridge_motor_controller_08" width="150" height="150" class="alignnone size-thumbnail wp-image-3907" /></a></p>
<h3>A quick test:</h3>
<p><iframe width="800" height="450" src="http://www.youtube.com/embed/miao-Yv_xWo" frameborder="0" allowfullscreen></iframe></p>
<h3>Circuit diagram:</h3>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/hbridge-pcb.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/hbridge-pcb-300x165.png" alt="hbridge-pcb" width="300" height="165" class="alignnone size-medium wp-image-3910" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/hbridge-sch.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/hbridge-sch-300x241.png" alt="hbridge-sch" width="300" height="241" class="alignnone size-medium wp-image-3911" /></a><br />
PCB available here: <a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/hbridge.zip">hbridge</a></p>
<h3>H-Bridge can limit the motor current</h3>
<p>Resistors R1, R2, R5 and R6 can be used to control the amount of current available to the motors. Using the default 1K value, there might not be enough current to allow steering (turning around while standing by using the differential system):<br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/tGv_UcVcR5o" frameborder="0" allowfullscreen></iframe></p>
<p><b>Changing the resistors to lower 150 Ohm values, produces a completely different result: more current is available to the motors, expressed in higher torque and the steering movement is successfully executed:</b><br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/E69Mn7fu4PI" frameborder="0" allowfullscreen></iframe><br />
So keep this in mind when building your own. Controlling the current is a great feature to use when we want to limit the amount of current available to the load. We can use it to avoid overheating or for other applications.<br />
But for this particular construction, the motors need the extra current to allow turning the robot correctly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/03/dual-h-bridge-for-controlling-two-motors/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to set the AVR Fusebits</title>
		<link>http://www.pocketmagic.net/2013/03/how-to-set-the-avr-fusebits/</link>
		<comments>http://www.pocketmagic.net/2013/03/how-to-set-the-avr-fusebits/#comments</comments>
		<pubDate>Mon, 11 Mar 2013 14:10:39 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[atmega128]]></category>
		<category><![CDATA[atmega168]]></category>
		<category><![CDATA[atmega328p]]></category>
		<category><![CDATA[atmega8]]></category>
		<category><![CDATA[atmel]]></category>
		<category><![CDATA[avr]]></category>
		<category><![CDATA[fusebit doctor]]></category>
		<category><![CDATA[fusebits]]></category>
		<category><![CDATA[microcontrollers]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3861</guid>
		<description><![CDATA[Learn how to set your atmega to work with various external crystals, program the fusebits, and build a fusebit doctor to revive your AVRs, in case you wrote the wrong settings .]]></description>
				<content:encoded><![CDATA[<p>For most of my <a href="http://www.pocketmagic.net/tag/microcontrollers/" target="_blank">microcontroller </a>related projects, I try to describe everything in detail, but I just realized I didn't pay enough attention to showing how to set the fusebits to make the AVRs work with various external crystals, 8MHz, 16MHz, etc. I mostly work with mega microcontrollers (atmega8, atmega16, atmega128, atmega168, atmega328p) but the information in this article applies to all the other AVR microcontrollers.</p>
<h3>Hardware tools</h3>
<p>To set the fusebits you can use the same tool you use to write the .hex. In my case, this is <a href="http://www.pocketmagic.net/2012/05/cheap-avr-usb-programmer/" target="_blank">my trusty USBAsp USB programmer</a>, that works great!</p>
<h3>Software tools</h3>
<p>Here things get a bit more complicated. On one hand you need the software that works with USBAsp, but on the other hand you need to correctly compute the fusebit values that will be programmed in your AVR.<br />
For the first I use <a href="http://winavr.sourceforge.net/" target="_blank">Winavr</a>.  If working with a command prompt line tool seems complicated to you, consider using alternatives such as <a href="http://extremeelectronics.co.in/software/extreme-burner-avr-1-3-beta-test/" target="_blank">Extreme burner</a>.<br />
For computing the fusebits, there are quite a few online webpages that help you achieve the goal in easy steps: <a href="http://www.engbedded.com/fusecalc/" target="_blank">here</a> or <a href="http://www.frank-zhao.com/fusecalc/" target="_blank">here </a>. Any of these two will do. Accessing one of these pages, you must select the AVR you need to program the fusebits for , then several tables with apparently complicated settings show up:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/fusecalc_engbedded.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/fusecalc_engbedded-275x300.png" alt="fusecalc_engbedded" height="193" class="alignnone size-medium wp-image-3871" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/fusecalc_frankzao.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/fusecalc_frankzao-300x193.png" alt="fusecalc_frankzao" width="300" height="193" class="alignnone size-medium wp-image-3872" /></a><br />
To help you get going, here are a few details you  should know:<br />
<b>Clock selection</b><br />
This controls how the chip is clocked. The drop down menu shows a big list of options, but reading those carefully you'll quickly see they all mention the Clock Source and the Clock Startup. Wrong clock settings can make your AVR unusable. If this happens, see the <a href="#fusebitdoctor">Fusebit doctor</a> below, to learn how to reset the fuses and "revive" your AVR.<br />
The <b>Clock Source</b> contains the following:<br />
External Clock, Internal 8MHz clock, Internal 4MHz clock, Internal 128KHz clock, External Crystal (0.4-0.9 MHz), External Crystal (0.9MHz - 3.0MHz), External Crystal (3.0MHz - 8.0MHz) or External Crystal (8.0MHz +)<br />
The <b>Clock Startup</b> can be one of the following:<br />
14CK + 0 ms, 14CK + 4 ms, 14CK + 65 ms.<br />
<b>External Clock</b> means that a square wave is being input into the CLOCK-IN pin by using a clock generating chip. This is uncommon and usually you won't be needing it.<br />
<b>Internal Clock</b> sets the avr to use the internal oscillator that is not very precise but good for most projects that don't have fine timing requirements. You should know that this clock varies with temperature and the power supply voltage. You can chose from a 8MHz, 4MHz or 128KHz clock. The 128KHz clock is for very low power applications where the low speed helps conserve power. By using the internal clock, you don't need to wire up a crystal so we can use the XTAL1 and XTAL2 pins for various other purposes.<br />
<b>External Crystal</b> option is used when you need a special clock rate, like 8MHz or 12MHz or a high precision clock that will not vary with temperature or power supply voltage fluctuations. In this case you need to connect an external crystal or oscillator.<br />
The <b>Startup Time</b> is a short delay, used to pause the clock for the given time, the very first time the power is applied. To be on the safe side, go with the longest setting 14CK + 65ms unless you know for a fact your settings must be different.<br />
<b>Clock Output</b> (available for some AVRs only) produces a square wave of the same frequency of the clock input (internal, external, crystal, etc) on a given pin (D2, B0, etc). This is useful if you're debugging the clock rate, or if you want to use the clock to drive another chip.<br />
<b>Clock Divide</b> (available for some AVRs only), causes the chip to divide the clock rate by 8. So if the clock source is set to Internal 8MHz and you have this fuse set, then you'll really be running at 1MHz. By default, this is turned on.<br />
<b>Reset Disable</b>, turns the Reset pin into a normal pin instead of a special pin (as it is set by default). If this fuse is enabled (Reset Disabled), you won't be able to program the chip using ISP anymore. Be careful about this option, and never set it on, unless you really need the one extra pin.  If you set this fuse in error and you can't access your AVR anymore, see the <a href="#fusebitdoctor">Fusebit doctor</a>, to learn how to reset the fuses and "revive" your avr.<br />
<b>Brown-out Detect</b> fuses set the voltage threshold for the Brownout protection circuitry on. A "brown-out" happens when the voltage drops and your clock radio may stop working: the power voltage is too low to run reliably at the predefined. ex: ATtiny2313 can run as fast at 20MHz but only if the supply voltage is between 4.5V and 5.5V. If the voltage decreases below 4.5V, the AVR may behave erratically, erasing or overwriting the RAM and EEPROM,  it may also start running random piece of the flash program, all in one an action with unpredictable results, nothing you would want your hardware to do. To keep it under control, set the brownout voltage to 4.3V. If the voltage goes below this threshold, the chip will turn off until the voltage returns. It will then reset and start over. If the chip is meant to run at 5V, set the brown-out to 4.3V. If the chip can run as low as 3.3V you can set the brown-out to 1.8V. If the chip is a 'low voltage compatible' chip such as the attiny2313V (which can run as low as 1.8V if its clocked at 4MHz or less) then you can set the brownout to 1.8V. You can read more in the datasheet.<br />
By default, this option is disabled. If your AVR uses a bootloader or the EEPROM, you must set the BOD for safety!<br />
<b>SPI programming (SPIEN fuse)</b>, if this fuse is not enabled, the part must be programmed using high-voltage, and the SPI interface will not be usable (so no USBASP for you). Be careful about disabling this fuse, as without a high voltage programmer, your AVR might become unusable. Also see the <a href="#fusebitdoctor">Fusebit doctor</a> below, to learn how to reset the fuses and "revive" your avr.</p>
<p>As a result of carefully choosing the FUSEBIT Settings, you get several numbers in HEX, representing the LOW FUSE, the HIGH FUSE, and for some AVRs the EXTENDED FUSE.<br />
To set them with AVRDUDE (WinAVR) or Extreme Burner, see the examples below:</p>
<h3>Examples</h3>
<p><b>ATMega8 default settings</b>: 1MHz internal oscillator<br />
<b>avrdude Syntax:</b></p>
<pre class="cpp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">avrdude -p atmega8 -c usbasp -U lfuse:w:0xE1:m 	-U hfuse:w:0xD9:m</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p><b>Extreme burner</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/extreme_burner_default_fuses.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/extreme_burner_default_fuses-150x150.jpg" alt="extreme_burner_default_fuses" width="150" height="150" class="alignnone size-thumbnail wp-image-3876" /></a><br />
<b>As you can see the lfuse and hfuse numbers are the same (0xE1 and 0xD9). To save on article length, and increase readability, I will only show the AVRdude settings, while you can easily insert those numbers in Extreme Burner for the same results.</b></p>
<p><b>ATMega8 8MHz external crystal</b></p>
<pre class="cpp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">avrdude -p atmega8 -c usbasp -U lfuse:w:0xDC:m -U hfuse:w:0xD9:m</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p><b>ATMega8 16MHz external crystal</b></p>
<pre class="cpp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">avrdude -p atmega8 -c usbasp -U lfuse:w:0xFF:m -U hfuse:w:0xC9:m</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p><b>ATMega128 default</b></p>
<pre class="cpp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">avrdude -p atmega128 -c usbasp -U lfuse:w:0xE1:m -U hfuse:w:0x99:m</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p><b>ATMega128 16MHz external crystal fuses</b></p>
<pre class="cpp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">avrdude -p atmega128 -c usbasp -U lfuse:w:0xFF:m -U hfuse:w:0x89:m</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p><b>ATMega168 default fuses, 1MHz internal oscillator</b></p>
<pre class="cpp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">avrdude -p atmega168 -c usbasp -U lfuse:w:0x62:m -U hfuse:w:0xDF:m -U efuse:w:0x1:m -U lock:w:0xFF:m</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p><b>ATMega168 16MHz external crystal fuses</b></p>
<pre class="cpp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">avrdude -p atmega168 -c usbasp -U lfuse:w:0xdf:m -U hfuse:w:0xDF:m -U efuse:w:0xF9:m -U lock:w:0xFF:m</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p><b>ATMega328p default fuses, 1MHz internal oscillator</b></p>
<pre class="cpp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">avrdude -p atmega328p -c usbasp -U lfuse:w:0x62:m -U hfuse:w:0xD9:m -U efuse:w:0x7:m -U lock:w:0xFF:m </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p><b>ATMega328p 3-8MHz external crystal</b></p>
<pre class="cpp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">avrdude -p atmega328p -c usbasp -U lfuse:w:0xdc:m -U hfuse:w:0xDF:m -U efuse:w:0xFF:m -U lock:w:0xFF:m </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p><b>ATMega328p 16MHz external crystal fusebits settings</b></p>
<pre class="cpp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">avrdude -p atmega328p -c usbasp -U lfuse:w:0xdf:m -U hfuse:w:0xDF:m -U efuse:w:0xF9:m -U lock:w:0xFF:m </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p><a name="fusebitdoctor"></a></p>
<h3>Fusebit doctor</h3>
<p>The fusebit doctor, designed by <a href="http://mdiy.pl/atmega-fusebit-doctor-hvpp/?lang=en" target="_blank">manekinen</a>, is a device for repairing dead ATmega and ATtiny family AVRs by writing the default, correct fusebits. Most common causes for dead AVRs, are wrong clock source settings (CKSEL fusebits), disabled SPI programming (SPIEN fuse) or disabled reset pin (RSTDISBL fuse). This circuit uses the parallel and serial high-voltage programming method: HVPP = high voltage parallel programming and HVSP = high voltage serial programming.<br />
Manekinen's device come with a database of supported chip, stored in the board's main microcontroller, that is used to recognize the faulty chips, and restore their original settings. To do this, we only need to place them in the correct socket and press the START button. So easy. As all project resources have been kindly provided by the author, I built my own board to repair some of my faulty chips.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/avr_fusebit_doctor_01.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/avr_fusebit_doctor_01-150x150.jpg" alt="avr_fusebit_doctor_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3878" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/avr_fusebit_doctor_02.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/avr_fusebit_doctor_02-150x150.jpg" alt="avr_fusebit_doctor_02" width="150" height="150" class="alignnone size-thumbnail wp-image-3879" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/avr_fusebit_doctor_03.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/avr_fusebit_doctor_03-150x150.jpg" alt="avr_fusebit_doctor_03" width="150" height="150" class="alignnone size-thumbnail wp-image-3880" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/avr_fusebit_doctor_04.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/avr_fusebit_doctor_04-150x150.jpg" alt="avr_fusebit_doctor_04" width="150" height="150" class="alignnone size-thumbnail wp-image-3881" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/avr_fusebit_doctor_05.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/avr_fusebit_doctor_05-150x150.jpg" alt="avr_fusebit_doctor_05" width="150" height="150" class="alignnone size-thumbnail wp-image-3882" /></a></p>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/avr_fusebit_doctor_06.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/avr_fusebit_doctor_06-150x150.jpg" alt="avr_fusebit_doctor_06" width="150" height="150" class="alignnone size-thumbnail wp-image-3883" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/avr_fusebit_doctor_07.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/avr_fusebit_doctor_07-150x150.jpg" alt="avr_fusebit_doctor_07" width="150" height="150" class="alignnone size-thumbnail wp-image-3884" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/avr_fusebit_doctor_08.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/avr_fusebit_doctor_08-150x150.jpg" alt="avr_fusebit_doctor_08" width="150" height="150" class="alignnone size-thumbnail wp-image-3885" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/avr_fusebit_doctor_09.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/avr_fusebit_doctor_09-150x150.jpg" alt="avr_fusebit_doctor_09" width="150" height="150" class="alignnone size-thumbnail wp-image-3886" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/avr_fusebit_doctor_10.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/avr_fusebit_doctor_10-150x150.jpg" alt="avr_fusebit_doctor_10" width="150" height="150" class="alignnone size-thumbnail wp-image-3887" /></a></p>
<p>One of my atmega328p's had faulty fusebit settings, because of some complications while writing its firmware. To revive it , I put it in the AVR Doctor's socket, and pressed the START button. Almost instantly the GREEN Led turned on, and the "patient" was cured. So simple. </p>
<p>PCB, Schematics and firmware available <a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/update11-30.04.2011.zip">here</a> or <a href="http://mdiy.pl/atmega-fusebit-doctor-hvpp/?lang=en" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/03/how-to-set-the-avr-fusebits/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>NMEA GPS Library for AVR Microcontrollers</title>
		<link>http://www.pocketmagic.net/2013/02/nmea-gps-library-for-avr-microcontrollers/</link>
		<comments>http://www.pocketmagic.net/2013/02/nmea-gps-library-for-avr-microcontrollers/#comments</comments>
		<pubDate>Mon, 25 Feb 2013 19:11:31 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[74HC164]]></category>
		<category><![CDATA[74LS164]]></category>
		<category><![CDATA[atmega128]]></category>
		<category><![CDATA[atmega8]]></category>
		<category><![CDATA[GPS]]></category>
		<category><![CDATA[GPS library]]></category>
		<category><![CDATA[HD44780]]></category>
		<category><![CDATA[lcd]]></category>
		<category><![CDATA[LCD library]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[microcontrollers]]></category>
		<category><![CDATA[NMEA]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[optimized]]></category>
		<category><![CDATA[parser]]></category>
		<category><![CDATA[serial LCD]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3821</guid>
		<description><![CDATA[An open source library that allows you to use a NMEA GPS Module with an AVR Microcontroller. UART Communication and NMEA Parser is included.]]></description>
				<content:encoded><![CDATA[<p>Recently I have developed a GPS NMEA Parser for an embedded system using the ATMega128 microcontroller, and decided to pack everything together as <b>a GPS open source library for AVR Microcontrollers</b>. The code is <b>highly optimized</b> to load the microprocessor as low as possible (both in terms of storage and CPU load), so the serial data is parsed as it gets in, without using redundant data structures or operations.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/atmega128_nmea_gps_library_0.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/atmega128_nmea_gps_library_0-300x199.jpg" alt="atmega128_nmea_gps_library_0" width="300" height="199" class="alignnone size-medium wp-image-3825" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/atmega128_nmea_gps_library_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/atmega128_nmea_gps_library_1-300x199.jpg" alt="atmega128_nmea_gps_library_1" width="300" height="199" class="alignnone size-medium wp-image-3826" /></a></p>
<h3>Short Intro. NMEA Sentences</h3>
<p>Most GPS Modules output serial data, using the RX TX pins, and the UART protocol. The data itself is in the NMEA format, a CSV (comma separated value) format with predefined keywords. One such set of NMEA CSV values, that starts with $ and ends with EOL, is called a [b]NMEA sentence[/b].<br />
The NMEA sentence is a comma separated list of values which contains information on a single GPS reading. There are a number of sentence types, each with its own, variable number of values, as defined by the NMEA protocol, such as the GPRMC (Recommended minimum specific GPS/Transit data) sentence, the GPGGA (Global Positioning System Fix Data) or the GPGSV (GPS Satellites in view) just to name a few. See this <a href="http://home.mira.net/~gnb/gps/nmea.html">page </a>for more details on the NMEA sentences.</p>
<h3>More details</h3>
<p>The library consists of two files, nmea.cpp and nmea.h defining a C++ class, named NMEA. The GPS data is provided to a instance of this class (an object) using the feed function <b>int fusedata(char c);</b> . As you can see this function takes one char, and must be called each time serial data is received from the GPS module.<br />
For AVR - GPS communication, I wrote another handy piece of code, an UART library allowing both polling based and interrupt based information exchange. As this is written as a C++ class (uart.cpp and uart.h), you'll be able to instantiate any number of objects, providing only the UART ports you are planning to use. For the Atmega128 this is extremely useful as this chip supports two UART gateways: uart0 (rx0/tx0) on pins PE0+PE1 and uart1 (rx1/tx1) on PD2+PD3. I hooked the GPS up to uart0, and for uart1 I connected an UART Bluetooth module. This proved extremely useful for debugging my code, while implementing this NMEA parser library, as there were many situations that required careful analysis of the algorithm and its results (string parsing, string cutting, etc). Connecting the Bluetooth module to the PC, a simple terminal application such as <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">Putty </a>can be used to visualize strings received from the microcontroller board:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/gps_nmea_1.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/gps_nmea_1-261x300.png" alt="gps_nmea_1"  height="208" class="alignnone size-medium wp-image-3838" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/gps_nmea_2.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/gps_nmea_2-300x208.png" alt="gps_nmea_2" width="300" height="208" class="alignnone size-medium wp-image-3839" /></a><br />
With only two objects, we can handle both the GPS and the Bluetooth modules easy:</p>
<pre class="cpp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">UART	uart0, <span style="color: #ff0000;">// gps module</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	uart1; <span style="color: #ff0000;">// bluetooth module</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">//USART0 RX interrupt this code is executed when we recieve a character</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ISR<span style="color: #000000;">&#40;</span>USART0_RX_vect<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #0000ff;">volatile</span> <span style="color: #0000ff;">char</span> c = UDR0; <span style="color: #ff0000;">//Read the value out of the UART buffer</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	nmea.<span style="color: #00eeff;">fusedata</span><span style="color: #000000;">&#40;</span>c<span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">//USART1 RX interrupt this code is executed when we recieve a character</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ISR<span style="color: #000000;">&#40;</span>USART1_RX_vect<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #0000ff;">volatile</span> <span style="color: #0000ff;">char</span> c = UDR1; <span style="color: #ff0000;">//Read the value out of the UART buffer</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span>c == <span style="color: #666666;">'1'</span><span style="color: #000000;">&#41;</span> _delay_ms<span style="color: #000000;">&#40;</span><span style="color: #0000dd;">10000</span><span style="color: #000000;">&#41;</span>; <span style="color: #ff0000;">// pause execution when we send char '1' for debugging</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">// init serial link</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">uart0.<span style="color: #00eeff;">Init</span><span style="color: #000000;">&#40;</span><span style="color: #0000dd;">0</span>,<span style="color: #0000dd;">4800</span>, <span style="color: #0000ff;">true</span><span style="color: #000000;">&#41;</span>; <span style="color: #ff0000;">//uart0: GPS</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">uart1.<span style="color: #00eeff;">Init</span><span style="color: #000000;">&#40;</span><span style="color: #0000dd;">1</span>,<span style="color: #0000dd;">9600</span>, <span style="color: #0000ff;">true</span><span style="color: #000000;">&#41;</span>; <span style="color: #ff0000;">//uart1: Bluetooth</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>The serial data is assembled on the fly, without using any redundant buffers. When a sentence is complete (one that starts with $, ending in EOL), all processing is done on this temporary buffer that we've built: checksum computation, extracting sentence "words" (the CSV values), and so on.<br />
When a new sentence is fully assembled using the <b>fusedata</b> function, the code calls <b>parsedata</b>. This function in turn, splits the sentences and interprets the data. Here is part of the parser function, handling both the $GPRMC NMEA sentence:</p>
<pre class="cpp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">/* $GPGGA</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">	* $GPGGA,hhmmss.ss,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx*hh</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">	* ex: $GPGGA,230600.501,4543.8895,N,02112.7238,E,1,03,3.3,96.7,M,39.0,M,,0000*6A,</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">	*</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">	* WORDS:</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">	*  1    = UTC of Position</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">	*  2    = Latitude</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">	*  3    = N or S</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">	*  4    = Longitude</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">	*  5    = E or W</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">	*  6    = GPS quality indicator (0=invalid; 1=GPS fix; 2=Diff. GPS fix)</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">	*  7    = Number of satellites in use [not those in view]</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">	*  8    = Horizontal dilution of position</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">	*  9    = Antenna altitude above/below mean sea level (geoid)</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">	*  10   = Meters  (Antenna height unit)</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">	*  11   = Geoidal separation (Diff. between WGS-84 earth ellipsoid and mean sea level.  </span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">	*      -geoid is below WGS-84 ellipsoid)</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">	*  12   = Meters  (Units of geoidal separation)</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">	*  13   = Age in seconds since last update from diff. reference station</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">	*  14   = Diff. reference station ID#</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">	*  15   = Checksum</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">	*/</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span>mstrcmp<span style="color: #000000;">&#40;</span>tmp_words<span style="color: #000000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #000000;">&#93;</span>, <span style="color: #666666;">&quot;$GPGGA&quot;</span><span style="color: #000000;">&#41;</span> == <span style="color: #0000dd;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// Check GPS Fix: 0=no fix, 1=GPS fix, 2=Dif. GPS fix</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span>tmp_words<span style="color: #000000;">&#91;</span><span style="color: #0000dd;">6</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #000000;">&#93;</span> == <span style="color: #666666;">'0'</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #ff0000;">// clear data</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		res_fLatitude = <span style="color: #0000dd;">0</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		res_fLongitude = <span style="color: #0000dd;">0</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		m_bFlagDataReady = <span style="color: #0000ff;">false</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #0000ff;">return</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000;">&#125;</span>			</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// parse time</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	res_nUTCHour = digit2dec<span style="color: #000000;">&#40;</span>tmp_words<span style="color: #000000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span> * <span style="color: #0000dd;">10</span> + digit2dec<span style="color: #000000;">&#40;</span>tmp_words<span style="color: #000000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	res_nUTCMin = digit2dec<span style="color: #000000;">&#40;</span>tmp_words<span style="color: #000000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span> * <span style="color: #0000dd;">10</span> + digit2dec<span style="color: #000000;">&#40;</span>tmp_words<span style="color: #000000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	res_nUTCSec = digit2dec<span style="color: #000000;">&#40;</span>tmp_words<span style="color: #000000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #0000dd;">4</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span> * <span style="color: #0000dd;">10</span> + digit2dec<span style="color: #000000;">&#40;</span>tmp_words<span style="color: #000000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #0000dd;">5</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// parse latitude and longitude in NMEA format</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	res_fLatitude = string2float<span style="color: #000000;">&#40;</span>tmp_words<span style="color: #000000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	res_fLongitude = string2float<span style="color: #000000;">&#40;</span>tmp_words<span style="color: #000000;">&#91;</span><span style="color: #0000dd;">4</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// get decimal format</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span>tmp_words<span style="color: #000000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #000000;">&#93;</span> == <span style="color: #666666;">'S'</span><span style="color: #000000;">&#41;</span> res_fLatitude  *= <span style="color: #0000dd;">-1.0</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span>tmp_words<span style="color: #000000;">&#91;</span><span style="color: #0000dd;">5</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #000000;">&#93;</span> == <span style="color: #666666;">'W'</span><span style="color: #000000;">&#41;</span> res_fLongitude *= <span style="color: #0000dd;">-1.0</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #0000ff;">float</span> degrees = trunc<span style="color: #000000;">&#40;</span>res_fLatitude / <span style="color: #0000dd;">100</span>.0f<span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #0000ff;">float</span> minutes = res_fLatitude - <span style="color: #000000;">&#40;</span>degrees * <span style="color: #0000dd;">100</span>.0f<span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	res_fLatitude = degrees + minutes / <span style="color: #0000dd;">60</span>.0f;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	degrees = trunc<span style="color: #000000;">&#40;</span>res_fLongitude / <span style="color: #0000dd;">100</span>.0f<span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	minutes = res_fLongitude - <span style="color: #000000;">&#40;</span>degrees * <span style="color: #0000dd;">100</span>.0f<span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	res_fLongitude = degrees + minutes / <span style="color: #0000dd;">60</span>.0f;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// parse number of satellites</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	res_nSatellitesUsed = <span style="color: #000000;">&#40;</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&#41;</span>string2float<span style="color: #000000;">&#40;</span>tmp_words<span style="color: #000000;">&#91;</span><span style="color: #0000dd;">7</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// parse altitude</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	res_fAltitude = string2float<span style="color: #000000;">&#40;</span>tmp_words<span style="color: #000000;">&#91;</span><span style="color: #0000dd;">9</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// data ready</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	m_bFlagDataReady = <span style="color: #0000ff;">true</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>See the entire code for a better understanding of the logic implied. After parsing, the data is sent to the LCD:</p>
<pre class="cpp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">lcd.<span style="color: #00eeff;">lcd_cursor_home</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span>nmea.<span style="color: #00eeff;">isdataready</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// use index to change display on every iteration: easy way to show more content on a small screen</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span>i%<span style="color: #0000dd;">2</span> == <span style="color: #0000dd;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #ff0000;">// show latitude, number of sats, longitude, altitude</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		lcd.<span style="color: #00eeff;">lcd_string_format</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;%f SATs:%d    <span style="color: #666666; font-weight: bold;">\n</span>%f A:%dm    &quot;</span>, </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		 nmea.<span style="color: #00eeff;">getLatitude</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, nmea.<span style="color: #00eeff;">getSatellites</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> 		 nmea.<span style="color: #00eeff;">getLongitude</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, <span style="color: #000000;">&#40;</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&#41;</span>nmea.<span style="color: #00eeff;">getAltitude</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #000000;">&#123;</span> <span style="color: #ff0000;">//show speed, bearing, time and date</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		lcd.<span style="color: #00eeff;">lcd_string_format</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;S:%2.2f B:%2.2f    <span style="color: #666666; font-weight: bold;">\n</span>%02d:%02d %02d-%02d-%02d    &quot;</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		 nmea.<span style="color: #00eeff;">getSpeed</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, nmea.<span style="color: #00eeff;">getBearing</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		 nmea.<span style="color: #00eeff;">getHour</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>,nmea.<span style="color: #00eeff;">getMinute</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		 nmea.<span style="color: #00eeff;">getDay</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>,nmea.<span style="color: #00eeff;">getMonth</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>,nmea.<span style="color: #00eeff;">getYear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000;">&#125;</span>				 </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #000000;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	lcd.<span style="color: #00eeff;">lcd_string</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Waiting for GPS  <span style="color: #666666; font-weight: bold;">\n</span>fix. No Data.       &quot;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>The code above uses an index (i) to show more content on the tiny 2x16 LCD. First we show latitude, number of satellites used, longitude and altitude (in meters) and on the next iteration we show speed, bearing UTC time and UTC date. As you can see we call <b>isdataready()</b> function first, to make sure we have a GPS fix and valid data.</p>
<h3>Conversions</h3>
<p>To represent the coordinates, NMEA uses DM.MM, (degrees, minutes, decimal minutes) followed by N or S for latitude, and E or W for longitude. Example sentence:<br />
$GPRMC,230558.501,A,4543.8901,N,02112.7219,E,1.50,181.47,230213,,,A*66,<br />
The GPS Library code converts latitude & longitude obtained from NMEA's GPGGA or GPRMC to decimal:</p>
<pre class="cpp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">// parse latitude and longitude in NMEA format</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">res_fLatitude = string2float<span style="color: #000000;">&#40;</span>tmp_words<span style="color: #000000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">res_fLongitude = string2float<span style="color: #000000;">&#40;</span>tmp_words<span style="color: #000000;">&#91;</span><span style="color: #0000dd;">5</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">// get decimal format</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span>tmp_words<span style="color: #000000;">&#91;</span><span style="color: #0000dd;">4</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #000000;">&#93;</span> == <span style="color: #666666;">'S'</span><span style="color: #000000;">&#41;</span> res_fLatitude  *= <span style="color: #0000dd;">-1.0</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span>tmp_words<span style="color: #000000;">&#91;</span><span style="color: #0000dd;">6</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #000000;">&#93;</span> == <span style="color: #666666;">'W'</span><span style="color: #000000;">&#41;</span> res_fLongitude *= <span style="color: #0000dd;">-1.0</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">float</span> degrees = trunc<span style="color: #000000;">&#40;</span>res_fLatitude / <span style="color: #0000dd;">100</span>.0f<span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">float</span> minutes = res_fLatitude - <span style="color: #000000;">&#40;</span>degrees * <span style="color: #0000dd;">100</span>.0f<span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">res_fLatitude = degrees + minutes / <span style="color: #0000dd;">60</span>.0f;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">degrees = trunc<span style="color: #000000;">&#40;</span>res_fLongitude / <span style="color: #0000dd;">100</span>.0f<span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">minutes = res_fLongitude - <span style="color: #000000;">&#40;</span>degrees * <span style="color: #0000dd;">100</span>.0f<span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">res_fLongitude = degrees + minutes / <span style="color: #0000dd;">60</span>.0f;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>Speed, as returned by GPRMC is in knots/hour. The knot (pronounced not) is a unit of speed equal to one nautical mile (1.852 km) per hour. So to get the speed in km/h we do:</p>
<pre class="cpp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">res_fSpeed = string2float<span style="color: #000000;">&#40;</span>tmp_words<span style="color: #000000;">&#91;</span><span style="color: #0000dd;">7</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">res_fSpeed /= <span style="color: #0000dd;">1.852</span>; <span style="color: #ff0000;">// convert to km/h</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>The rest is straight forward, but in case you have any questions, feel free o use the comments form below.</p>
<p><iframe width="800" height="450" src="http://www.youtube.com/embed/TCCFnY8f6Og" frameborder="0" allowfullscreen></iframe></p>
<p>Notes:<br />
The LCD is connected using only three wires, using a shift register, as explained <a href="http://www.pocketmagic.net/2013/02/atmega128-and-hd44780-lcd-using-3-wires-with-the-74hc164/">here</a>. The pins used are visible in the code:</p>
<pre class="cpp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">lcd.<span style="color: #00eeff;">Init</span><span style="color: #000000;">&#40;</span>&amp;PORTC,PC0,	<span style="color: #ff0000;">// data/rs</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> &amp;PORTC, PC1,	<span style="color: #ff0000;">// clk</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> &amp;PORTC, PC2<span style="color: #000000;">&#41;</span>;  <span style="color: #ff0000;">// lcd e</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<h3>License</h3>
<p>This library is free software, licensed under GPL v2; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.<br />
For other licensing options, feel free to contact me.</p>
<p>Code available <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/board128.zip">here</a>, and on Google Code <a href="https://code.google.com/p/avr-nmea-gps-library/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/02/nmea-gps-library-for-avr-microcontrollers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ATMega128 and HD44780 LCD using 3 Wires with the 74HC164</title>
		<link>http://www.pocketmagic.net/2013/02/atmega128-and-hd44780-lcd-using-3-wires-with-the-74hc164/</link>
		<comments>http://www.pocketmagic.net/2013/02/atmega128-and-hd44780-lcd-using-3-wires-with-the-74hc164/#comments</comments>
		<pubDate>Thu, 21 Feb 2013 13:44:35 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Robotics]]></category>
		<category><![CDATA[2x16]]></category>
		<category><![CDATA[3 wires]]></category>
		<category><![CDATA[4x20]]></category>
		<category><![CDATA[74HC164]]></category>
		<category><![CDATA[74LS164]]></category>
		<category><![CDATA[atmega128]]></category>
		<category><![CDATA[atmega8]]></category>
		<category><![CDATA[HD44780]]></category>
		<category><![CDATA[lcd]]></category>
		<category><![CDATA[LCD library]]></category>
		<category><![CDATA[microcontrollers]]></category>
		<category><![CDATA[serial LCD]]></category>
		<category><![CDATA[shift register]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3785</guid>
		<description><![CDATA[Learn how to transform your HD44780 LCD into a easy to use, serial LCD, that you can connect to your microcontroller using only 3 wires! It's time to save a few pins, and expand your project's functionality!]]></description>
				<content:encoded><![CDATA[<p>Using LCDs in my microcontroller projects is nothing new for me. Back in 2009 I was putting together my very first code library to display content on a 2x16 LCD hooked up to a ATMega8. The original article is still available <a href="http://www.pocketmagic.net/2009/02/atmega8-and-2x16-hd44780-lcd/">here</a>.</p>
<p>For the <a href="http://www.pocketmagic.net/2013/02/android-controlled-robot-part-2/">Android Controlled robot project</a>,  I've decided I'll be needing an LCD, to show various parameters and make debugging easier. In the end it will also be useful to show content to the user on various topics, like low battery, or GPS coordinates.</p>
<p><b>So</b>, here is an improved version of the HD44780 LCD library code.</p>
<h3>1. Classic 4Bit HD44780 code: using 6 wires to connect the LCD</h3>
<p>To save a few pins, I've connected the LCD in 4 bit mode. We are only using D4,D5,D6 and D7. Also RS and E. So 6 pins are used on the microcontroller. The Atmega128 has plenty IO pins, still if you need to optimize, see the next paragraph, where I used a 74HC164 to serialize the LCD data and use only 3 pins.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/atmega128_lcd_6wires_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/atmega128_lcd_6wires_1-300x199.jpg" alt="atmega128_lcd_6wires_1" width="300" height="199" class="alignnone size-medium wp-image-3789" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/atmega128_lcd_6wires_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/atmega128_lcd_6wires_2-300x199.jpg" alt="atmega128_lcd_6wires_2" width="300" height="199" class="alignnone size-medium wp-image-3790" /></a><br />
To use the LCD you need to include the HD44780 library. Then call the init function:</p>
<pre class="cpp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	HD44780 lcd;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// init LCD: RS, E, D4, D5, D6, D7</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	lcd.<span style="color: #00eeff;">lcd_init</span><span style="color: #000000;">&#40;</span>&amp;PORTA,PA6, &amp;PORTA,PA7,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		&amp;PORTA, PA5, &amp;PORTA, PA4, &amp;PORTA, PA3,&amp;PORTA, PA2<span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>As you can see, you need to provide all LCD pins in the function call. This is a very easy way to go, and even allows you to create multiple LCD objects if you want to use more than one display at the same time.<br />
The connections are as follows: RS - PA6, E - PA7, D4 - PA5, D5 - PA4, D6 - PA3, D7 - PA2, but you can change this to any other configuration.<br />
Source code: <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/atmega128_parallel_HD44780_LCD.zip">atmega128_parallel_HD44780_LCD</a></p>
<h3>2. Shift register 74HC164: using only 3 wires to connect to the HD44780 in 8bit mode</h3>
<p>Running the LCD in 8 bit mode, means that we will use all the D0,D1,..D7, RS and E pins. That's a total of 10 wires/pins, and would mean a complete waste of IO pins on a regular microcontroller.<br />
Using a shift register instead, we can cross the boundaries between the parallel and serial worlds. By doing so, it is easy to reduce wire counts, pin use and even help take load off of the cpu by being able to store their data.<br />
For this example, I will used the 74HC164, a 8 bit, serial in parallel out, non latched, shift register.<br />
To better understand this last sentence, here are a few additional details (<a href="http://atmega32-avr.com/the-74hc164-shift-register-and-your-arduino-using-gd74hc164-microcontroller/">source</a>).<br />
<b>First, the name:</b><br />
<b>74</b> — places it as part of the 74xx logic family, and since its logic it cannot directly control very much current  (16-20ma for the entire chip is common), for more current transistors can be used.<br />
<b>HC</b> means its a high speed cmos device and a  low power device that will run from 2 to 5 volts.<br />
<b>164</b> is the model number for this chip, more info is available <a href="http://en.wikipedia.org/wiki/List_of_7400_series_integrated_circuits">here</a>.<br />
<b>"8 bit"</b><br />
A shift register is made up of flip flop circuits, a flip flop is 1 bit of memory, this one has 8 (or 1 byte of memory). Since it is memory, if you do not need to update the register you can just stop “talking” to it and it will remain in whatever state you left it, until you “talk” to it again or reset power.<br />
<b>"serial in parallel out"</b><br />
This means the shift register takes serial data (received from a microcontroller, our atmega128 in this case) and places each bit on the correct output pin. This data processing model only requires 2 wires for total control (one for data, and one for clocking), so you can use 2 digital pins on the microcontroller, and break those 2 out to 8 more digital, parallel outputs.<br />
This fits our purpose perfectly. We want to send the LCD data in a serial mode, using only a few wires, feed it to the 74HC164 that will provide the many parallel connections required by the HD44780.<br />
<b>"non latched"</b><br />
As data enters a shift register via serial, it shows up on the first output pin, when a clock pulse enters in, the first bit shifts over 1 place, creating a scrolling effect on the outputs, for example 00000001 would show up on the outputs as 1, 01, 001, 0001, 00001, 000001, 0000001, 00000001 .<br />
If your talking to other logic devices who are sharing the same clock and not expecting this, it  could cause issues. Latched shift registers have an extra set of memory, so once the data is done entering the register you can flip a switch and show the outputs, but it adds another wire, software, and things to keep up with.</p>
<p>As explained above, it is possible to connect to the HD44780 using only 2 wires, but this complicates the code. To keep everything crystal clear, I opted for a 3 wire interface. One wire for the data, one for the LCD's E pin, and another one for the Clock. The wiring can be see below. 74HC164 Pin 14 is Vcc and is connected to 5V, Pin 7 to GND, and Pin 9 via a 10K pull up resistor to VCC.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/3wire_LCD_Atmega_new_radu.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/3wire_LCD_Atmega_new_radu-300x153.png" alt="3wire_LCD_Atmega_new_radu" width="300" height="153" class="alignnone size-medium wp-image-3810" /></a></p>
<p>Similar to the first paragraph, the code encapsulates the HD44780 functionality in a class, where the init function takes the ports and pins used to connect the device. This way you can hook up multiple LCD's to your microcontroller, if required by your application.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/atmega128_lcd_3wires_74HC164_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/atmega128_lcd_3wires_74HC164_1-300x199.jpg" alt="atmega128_lcd_3wires_74HC164_1" width="300" height="199" class="alignnone size-medium wp-image-3799" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/atmega128_lcd_3wires_74HC164_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/atmega128_lcd_3wires_74HC164_2-300x199.jpg" alt="atmega128_lcd_3wires_74HC164_2" width="300" height="199" class="alignnone size-medium wp-image-3800" /></a><br />
The last photo shows the three wires (gray, white, yellow) used to control the LCD. Now this sure saves a few pins, considering the LCD is connected in 8 bit mode!<br />
The code is configured to use the following pins: RS/DATA - PA0, CLK - PA1, LCD E - PA2, but you can change it as you like.<br />
Download the 3 Wires, 74HC164 code: <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/atmega128_3Wire_74HC164_HD44780_LCD.zip">atmega128_3Wire_74HC164_HD44780_LCD</a></p>
<p>A big thank you goes to the following articles:<br />
<a href="http://atmega32-avr.com/the-74hc164-shift-register-and-your-arduino-using-gd74hc164-microcontroller/">The 74HC164 Shift Register and your Arduino using GD74HC164 microcontroller</a><br />
<a href="http://www.micahcarrick.com/avr-3-wire-hd44780-lcd-interface-avr-gcc.html">AVR 3-Wire HD44780 LCD Interface (avr-gcc)</a><br />
<a href="http://code.google.com/p/arduinoshiftreglcd/">arduinoshiftreglcd</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/02/atmega128-and-hd44780-lcd-using-3-wires-with-the-74hc164/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The Hyacinth &#8211; a timelapse video</title>
		<link>http://www.pocketmagic.net/2013/02/the-hyacinth-a-timelapse-video/</link>
		<comments>http://www.pocketmagic.net/2013/02/the-hyacinth-a-timelapse-video/#comments</comments>
		<pubDate>Wed, 13 Feb 2013 23:05:30 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[camera]]></category>
		<category><![CDATA[hyacinth]]></category>
		<category><![CDATA[intervalometer]]></category>
		<category><![CDATA[timelapse]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3735</guid>
		<description><![CDATA[A timelapse video of a Hyacinth opening into flower!]]></description>
				<content:encoded><![CDATA[<p>Using a camera, an external flash (to control shadow projection), radio triggers, and an intervalometer for shooting photos automatically, here's a timelapse video where each frame is taken at a 15 minutes interval. The subject - three beautiful hyacinths, spreading an incredible smell while the flowers grow.</p>
<p><iframe width="800" height="450" src="http://www.youtube.com/embed/_O8bO74h94c" frameborder="0" allowfullscreen></iframe></p>
<p>A total of 200 frames, taken at a 15minutes interval. The setup is simple:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/hyacinthus_timelapse.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/hyacinthus_timelapse.jpg" alt="hyacinthus_timelapse" width="800" height="400" class="alignnone size-full wp-image-3737" /></a></p>
<p>And here is the Hyacinth, after the photo shooting session was over, with most of its flowers open. Beautiful, isn't it?<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/hyacinthus_flowers.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/hyacinthus_flowers.jpg" alt="hyacinthus_flowers" width="800" height="451" class="alignnone size-full wp-image-3739" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/02/the-hyacinth-a-timelapse-video/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microscope photos: White and Blue Mold</title>
		<link>http://www.pocketmagic.net/2013/02/microscope-photos-white-and-blue-mold/</link>
		<comments>http://www.pocketmagic.net/2013/02/microscope-photos-white-and-blue-mold/#comments</comments>
		<pubDate>Wed, 13 Feb 2013 20:52:59 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Optics]]></category>
		<category><![CDATA[Photography]]></category>
		<category><![CDATA[1000X]]></category>
		<category><![CDATA[bausch and lomb]]></category>
		<category><![CDATA[blue mold]]></category>
		<category><![CDATA[cells]]></category>
		<category><![CDATA[magnification]]></category>
		<category><![CDATA[microscope]]></category>
		<category><![CDATA[onion skin cells]]></category>
		<category><![CDATA[optic]]></category>
		<category><![CDATA[optical]]></category>
		<category><![CDATA[phase contrast]]></category>
		<category><![CDATA[white mold]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3727</guid>
		<description><![CDATA[White and blue mold as seen under the microscope, magnified up to 1000 (one thousand) times!]]></description>
				<content:encoded><![CDATA[<p>Here are some more pictures taken with my <a href="http://www.pocketmagic.net/2012/08/bausch-and-lomb-microscope/">Bausch and Lomb Microscope</a>.</p>
<p><b>White mold microscope photos</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/1layers.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/1layers-150x150.jpg" alt="1layers" width="150" height="150" class="alignnone size-thumbnail wp-image-3728" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/2layers.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/2layers-150x150.jpg" alt="2layers" width="150" height="150" class="alignnone size-thumbnail wp-image-3729" /></a></p>
<p><b>Blue mold microscope photos</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/blue-mold-under-microscope-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/blue-mold-under-microscope-1-150x150.jpg" alt="blue mold under microscope 1" width="150" height="150" class="alignnone size-thumbnail wp-image-3730" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/blue-mold-under-microscope-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/blue-mold-under-microscope-2-150x150.jpg" alt="blue mold under microscope 2" width="150" height="150" class="alignnone size-thumbnail wp-image-3731" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/blue-mold-under-microscope-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/blue-mold-under-microscope-3-150x150.jpg" alt="blue mold under microscope 3" width="150" height="150" class="alignnone size-thumbnail wp-image-3732" /></a></p>
<p>For more microscope pictures see <a href="http://www.pocketmagic.net/2012/08/bausch-and-lomb-microscope/">this article</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/02/microscope-photos-white-and-blue-mold/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building a robot – Part 2</title>
		<link>http://www.pocketmagic.net/2013/02/android-controlled-robot-part-2/</link>
		<comments>http://www.pocketmagic.net/2013/02/android-controlled-robot-part-2/#comments</comments>
		<pubDate>Thu, 07 Feb 2013 15:56:34 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Robotics]]></category>
		<category><![CDATA[A4WD1]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[atmega128]]></category>
		<category><![CDATA[bluetooth]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[H-bridge]]></category>
		<category><![CDATA[lynxmotion]]></category>
		<category><![CDATA[microcontrollers]]></category>
		<category><![CDATA[robot]]></category>
		<category><![CDATA[Sabertooth]]></category>
		<category><![CDATA[uart]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3665</guid>
		<description><![CDATA[Building an autonomous robot using a rover platform and advanced electronics is not an easy job. Kevin asked me to build a robot that would follow its user. A companion, very much like a robo-dog. See the project log here.]]></description>
				<content:encoded><![CDATA[<p><b>Featured on Hack A Day, check it out <a href="http://hackaday.com/2013/05/28/wireless-rover-with-android-control" target="_blank">here</a>!</b></p>
<p>My friend Kevin, contacted me for building an <b>advanced autonomous companion robot</b>. The final goal is  to have to robot following its user. This is the construction log page, with more content added as the project moves on. As this project continues what I have shown in <a href="http://www.pocketmagic.net/2010/11/android-controlled-robot-via-bluetooth-part-1/">a previous article</a>, you can see this post a a follow-up, named as Part2.</p>
<p><a name="130121"></a></p>
<h3>1. January 21, 2013</h3>
<p>Kevin carefully prepared everything for the long trip, and the package with the hardware components got here today. For the new robot I will drop my previous <a href="http://www.pocketmagic.net/2009/07/another-differential-robot-platform/">Ara robotic rover platform</a>, in favor of the neat <a href="http://www.lynxmotion.com/c-111-no-electronics-kit.aspx">A4WD1 from Lynxmotion</a>. Essentially this is a similar differential control rover platform, using 4 geared motors of 200RPM 37mm diameter, one for each wheel (<a href="http://www.lynxmotion.com/p-93-gear-head-motor-12vdc-301-200rpm-6mm-shaft.aspx" target="_blank">HN-GH12-2217</a>).<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-1-150x150.jpg" alt="android autonomous companion robot 1" width="150" height="150" class="alignnone size-thumbnail wp-image-3666" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-2-150x150.jpg" alt="android autonomous companion robot 2" width="150" height="150" class="alignnone size-thumbnail wp-image-3667" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-3-150x150.jpg" alt="android autonomous companion robot 3" width="150" height="150" class="alignnone size-thumbnail wp-image-3668" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-4-150x150.jpg" alt="android autonomous companion robot 4" width="150" height="150" class="alignnone size-thumbnail wp-image-3669" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-5-150x150.jpg" alt="android autonomous companion robot 5" width="150" height="150" class="alignnone size-thumbnail wp-image-3670" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-6.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-6-150x150.jpg" alt="android autonomous companion robot 6" width="150" height="150" class="alignnone size-thumbnail wp-image-3671" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-8.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-8-150x150.jpg" alt="android autonomous companion robot 8" width="150" height="150" class="alignnone size-thumbnail wp-image-3673" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-7.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-7-150x150.jpg" alt="android autonomous companion robot 7" width="150" height="150" class="alignnone size-thumbnail wp-image-3672" /></a><br />
Putting the rover together was easy except for the tires which required a little Vaseline. The robot's central processing unit will be an <a href="http://www.atmel.com/devices/atmega128.aspx">Atmega128 microcontroller</a> and not the <a href="http://www.lynxmotion.com/p-468-basic-atom-pro-28-pin.aspx">Lynxmotion's BASIC Atom Pro 28 Pin</a> (which also requires the custom "<a href="http://www.lynxmotion.com/p-252-bot-board-ii.aspx">bot board II</a>"). <b>Atmega128 wins</b> here  with its 128KB flash memory, 16MHz max operating frequency and a multitude of IO ports, while the Basic atom pro can only provide 32K of Program Space and a limited operating frequency (Not to mention the costs, Lynxmotion products are also very expensive).<br />
The motors are to be driven via a <a href="http://www.lynxmotion.com/p-563-sabertooth-2x12-rc-regenerative-dual-channel-motor-controller.aspx">Sabertooth 2X12 R/C Regenerative Dual Channel Motor Controller</a> . I am yet to see how well this performs when compared to <a href="http://www.pocketmagic.net/2009/03/a-simple-h-bridge-design/" target="_blank">my simple H-Bridge</a> that I used before. The battery is a <a href="http://www.lynxmotion.com/p-727-120-volt-ni-mh-2800mah-battery-pack.aspx" target="_blank">generous 12V 2800mAh</a> from Lynxmotion.</p>
<p><a name="130206"></a></p>
<h3>2. February 06, 2013</h3>
<p>The rover's bottom is a thin black plexiglass sheet, that looks great but can't sustain much weight. In this case, the battery seemed a bit too heavy for the bottom sheet, especially considering high speed movements over rough terrain. So I had to build a battery holder using some steel. Hope I won't get to replace all the original rover by the end of this project <img src='http://www.pocketmagic.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  . But this is what perfectionists usually do.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-09.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-09-150x150.jpg" alt="android autonomous companion robot 09" width="150" height="150" class="alignnone size-thumbnail wp-image-3681" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-10.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-10-150x150.jpg" alt="android autonomous companion robot 10" width="150" height="150" class="alignnone size-thumbnail wp-image-3682" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-11.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-11-150x150.jpg" alt="android autonomous companion robot 11" width="150" height="150" class="alignnone size-thumbnail wp-image-3683" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-12.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-12-150x150.jpg" alt="android autonomous companion robot 12" width="150" height="150" class="alignnone size-thumbnail wp-image-3684" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-13.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-13-150x150.jpg" alt="android autonomous companion robot 13" width="150" height="150" class="alignnone size-thumbnail wp-image-3685" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-14.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-14-150x150.jpg" alt="android autonomous companion robot 14" width="150" height="150" class="alignnone size-thumbnail wp-image-3686" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-15.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-15-150x150.jpg" alt="android autonomous companion robot 15" width="150" height="150" class="alignnone size-thumbnail wp-image-3687" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-16.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-16-150x150.jpg" alt="android autonomous companion robot 16" width="150" height="150" class="alignnone size-thumbnail wp-image-3688" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-17.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-17-150x150.jpg" alt="android autonomous companion robot 17" width="150" height="150" class="alignnone size-thumbnail wp-image-3689" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-18.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-autonomous-companion-robot-18-150x150.jpg" alt="android autonomous companion robot 18" width="150" height="150" class="alignnone size-thumbnail wp-image-3690" /></a><br />
The steel support is placed longitudinally at the bottom, fixed in screws. This can be used to support other components as well, as I drilled multiple holes for that. Two U-shape holders have been fitted using rivets, this way I got no difference in level, and no sharp points to puncture the battery to be placed in this support:<br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/_ofCZeySrFw" frameborder="0" allowfullscreen></iframe><br />
The prominent ends have been leveled with a metal file. The U-shaped holders got some little plastic spacers, made from PVC plastic heated and bended in a convenient angle. With the battery in place, here is the first motor test:<br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/wcqFQ1Kbahg" frameborder="0" allowfullscreen></iframe></p>
<p><a name="130212"></a></p>
<h3>3. February 12, 2013</h3>
<p>The Atmega128 board got a power supply, for both 5V and 3V. The latter is for the Bluetooth module and one of the GPS modules.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/building-a-robot-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/building-a-robot-1-150x150.jpg" alt="building a robot 1" width="150" height="150" class="alignnone size-thumbnail wp-image-3723" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/building-a-robot-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/building-a-robot-2-150x150.jpg" alt="building a robot 2" width="150" height="150" class="alignnone size-thumbnail wp-image-3724" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/building-a-robot-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/building-a-robot-3-150x150.jpg" alt="building a robot 3" width="150" height="150" class="alignnone size-thumbnail wp-image-3725" /></a><br />
The power supply consists of a high efficiency DC-DC converter built using the LM2596 IC. There are plenty of such converters available on Ebay for just a few bucks. I replaced the pot with a fixed 1KO resistor, so the converter would put out a fixed 5V voltage. The 3V is obtained using two L78L33 's. The power boards where fixed to the Atmega128 board.</p>
<p><a name="130218"></a></p>
<h3>4. February 18, 2013</h3>
<p>New Atmega128 board, with pin connectors including power and gnd to make connections easier.  The microcontroller board has been mounted to the robot's platform. The Sabertooth 2X12 has also been mounted. Thick wires link the h-bridge and the motors.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robodog-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robodog-1-150x150.jpg" alt="android robodog 1" width="150" height="150" class="alignnone size-thumbnail wp-image-3843" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robodog-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robodog-3-150x150.jpg" alt="android robodog 3" width="150" height="150" class="alignnone size-thumbnail wp-image-3844" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robodog-4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robodog-4-150x150.jpg" alt="android robodog 4" width="150" height="150" class="alignnone size-thumbnail wp-image-3845" /></a></p>
<p><a name="130225"></a></p>
<h3>5. February 25, 2013</h3>
<p>I finished the top board, exposing the bluetooth UART module and the <a href="https://www.sparkfun.com/products/465">NMEA GPS module</a>. This will be mounted outside the robot's body, to make sure the modules get maximum radio signal. An LCD is to provide vital information such as battery levels and other diagnosis messages.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robodog-top-board-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robodog-top-board-1-150x150.jpg" alt="android robodog top board 1" width="150" height="150" class="alignnone size-thumbnail wp-image-3847" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robodog-top-board-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robodog-top-board-2-150x150.jpg" alt="android robodog top board 2" width="150" height="150" class="alignnone size-thumbnail wp-image-3848" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robodog-top-board-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robodog-top-board-3-150x150.jpg" alt="android robodog top board 3" width="150" height="150" class="alignnone size-thumbnail wp-image-3849" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robodog-top-board-4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robodog-top-board-4-150x150.jpg" alt="android robodog top board 4" width="150" height="150" class="alignnone size-thumbnail wp-image-3850" /></a><br />
And with these last modules, I had to write a considerable amount of software. And this is only the beginning of the long road ahead:<br />
- <a href="http://www.pocketmagic.net/2013/02/atmega128-and-hd44780-lcd-using-3-wires-with-the-74hc164">HD44780 LCD code</a> . The LCD uses only 3 wires to connect to the Atmega128, using a shift register, 74HC164, to save a few IO pins.<br />
- <a href="http://www.pocketmagic.net/2013/02/nmea-gps-library-for-avr-microcontrollers/">UART code</a>, to handle data from the UART Bluetooth module and the UART GPS Module.<br />
- <a href="http://www.pocketmagic.net/2013/02/nmea-gps-library-for-avr-microcontrollers/">GPS NMEA Parser</a>, highly optimized to save memory and processing power. Also available on Google code, <a href="https://code.google.com/p/avr-nmea-gps-library/">here</a>.<br />
And the first problems didn't wait too long to show up. It appears the bluetooth module's RF creates some kind of interference that reduces the GPS signal. As a result, having the Bluetooth module on, I can barely get a GPS fix. When the signal is good (8 satellites in use), turning the bluetooth module on will reduce the signal (3-4 satellites). Here is a demo to show this defect. The red jumper wire is used to power on/off the Bluetooth module. The "sats" value displayed on the LCD is the number of fixed satellites.<br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/AuTCimWoxMQ" frameborder="0" allowfullscreen></iframe><br />
So to bypass the issue, I'll need to rework the top-board and move the Bluetooth module at some distance from the GPS module. I was not aware of such a design requirement. </p>
<p><a name="130327"></a></p>
<h3>6. March 27, 2013</h3>
<p>The <a href="http://www.lynxmotion.com/p-563-sabertooth-2x12-rc-regenerative-dual-channel-motor-controller.aspx">Sabertooth 2X12 R/C Regenerative Dual Channel Motor Controller</a> needs to be hooked up to an UART port. On the microcontroller board I have no free UART port available, so to simplify I plan to use a dual H-Bridge built from scratch. You can see the Dual H-Bridge <a href="http://www.pocketmagic.net/?p=3899" target="_blank">here</a>.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_01.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_01-150x150.jpg" alt="dual_hbridge_motor_controller_08" width="150" height="150" class="alignnone size-thumbnail wp-image-3907" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_04.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_04-150x150.jpg" alt="dual_hbridge_motor_controller_08" width="150" height="150" class="alignnone size-thumbnail wp-image-3907" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_05.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_05-150x150.jpg" alt="dual_hbridge_motor_controller_08" width="150" height="150" class="alignnone size-thumbnail wp-image-3907" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_07.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/03/dual_hbridge_motor_controller_07-150x150.jpg" alt="dual_hbridge_motor_controller_08" width="150" height="150" class="alignnone size-thumbnail wp-image-3907" /></a><br />
Schematics and PCB available in the<a href="http://www.pocketmagic.net/?p=3899" target="_blank"> Dual H-Bridge article</a>.<br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/miao-Yv_xWo" frameborder="0" allowfullscreen></iframe><br />
The LCD has been mounted inside the chassis, must admit it looks perfect this way: low profile, high tires, black paint, and that blue electric LCD light. All combined with a highly energetic movement.</p>
<p><a name="130328"></a></p>
<h3>7. March 28, 2013</h3>
<p>Following the successful dual HBridge integration, I added the Bluetooth UART module, and wrote a software for Android OS, to allow me to control the robot by using the phone. Here's a demo video:<br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/R6vbkIuUhjs" frameborder="0" allowfullscreen></iframe><br />
And a few pictures to show the final robot shape:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robot-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robot-1-150x150.jpg" alt="android robot 1" width="150" height="150" class="alignnone size-thumbnail wp-image-3944" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robot-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robot-2-150x150.jpg" alt="android robot 2" width="150" height="150" class="alignnone size-thumbnail wp-image-3945" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robot-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robot-3-150x150.jpg" alt="android robot 3" width="150" height="150" class="alignnone size-thumbnail wp-image-3946" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robot-4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/android-robot-4-150x150.jpg" alt="android robot 4" width="150" height="150" class="alignnone size-thumbnail wp-image-3947" /></a><br />
Next thing to do is to make the robot follow the user, AUTOMATICALLY! I'm currently considering two options, one involves using the GPS Module, send the coordinates via bluetooth to user's mobile phone that also has GPS and can then inform the robot where it needs to go, the second option would be to use some kind of beacons, the user would carry in his/her hand (or pocket), and the robot would detect those and follow the signal. </p>
<p><a name="130408"></a></p>
<h3>8. April 08, 2013</h3>
<p>As I've shown above, the purpose of this robot is to follow its user, and I imagined two instruments for implementing that:</p>
<p>1) a global localization method, using GPS. The PROs are that we can place a GPS module on the robot, and the user can have a mobile phone with its own GPS module. The phone can establish a connection to the robot using Bluetooth, and send the user coordinates periodically. Then the robot can calculate the path it needs to run, to get in close proximity of the user, and follow him/her. Sounds good, but the CONs are bad: first, the GPS errors are too big to allow us to make the robot follow the user; it would rather jump like a crazy monkey all around the user, and this is the best scenario. Another issue is also the GPS signal which is poor or unavailable indoors.<br />
If we place a stationary GPS receiver, here's how the GPS coordinates look like:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/gps_errors.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/gps_errors-300x298.jpg" alt="gps_errors" width="300" height="298" class="alignnone size-medium wp-image-4005" /></a><br />
As you can see, despite the fact our GPS receiver is stationary, the localization data we receive has a tolerance of a few meters or even tens of meters, placing us on a disc surrounding the real position. This is inappropriate for the purpose of this work, so I have decided to find different means of robot positioning and orientation; this number -2- below:</p>
<p>2) The local method will use a closed system for localization, formed of only the robot itself, the user, and a signaling beacon. Normally the user will carry a signaling beacon (ultrasonic, infrared, radio, etc), which the robot will "see" and follow. Easy to say, doing it is of course much harder, as we need a smooth robot movement, so a lot of error compensation and fuzzy logic must be involved.<br />
Recently I made some excellent progress using ultrasounds as a transmission method, to create a simple beacon detector. You can read more on it <a href="http://www.pocketmagic.net/2013/04/detecting-an-ultrasonic-beacon/">here</a>.<br />
The user needs to carry this tiny, low power ultrasonic beacon which the robot should be able to "hear" and use the signal to navigate to the target, and follow it.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_beacon_receiver_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_beacon_receiver_2-150x150.jpg" alt="ultrasonic_beacon_receiver_2" width="150" height="150" class="alignnone size-thumbnail wp-image-4006" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_beacon_receiver_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_beacon_receiver_3-150x150.jpg" alt="ultrasonic_beacon_receiver_3" width="150" height="150" class="alignnone size-thumbnail wp-image-4007" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_beacon_receiver_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_beacon_receiver_4-150x150.jpg" alt="ultrasonic_beacon_receiver_4" width="150" height="150" class="alignnone size-thumbnail wp-image-4008" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_beacon_receiver_5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_beacon_receiver_5-150x150.jpg" alt="ultrasonic_beacon_receiver_5" width="150" height="150" class="alignnone size-thumbnail wp-image-4009" /></a><br />
These wonderful modules will not only return a signal when ultrasounds are detected, but the output amplitude is directly proportional with the actual distance to the beacon. So we'll know both where the beacon is, and how far.<br />
Given these tools, there are several ways of implementing the working mechanism:<br />
a) using a single ultrasonic receiver, placed in front of the robot: the rover will need to rotate until it detects a maximum level of signal. Then it should move forward until the detected signal reaches a given threshold (so it will not hit the user, but stop right before him/her). It doesn't really work well, as the software gets overcomplicated and the results are not as good as expected.<br />
b) similar to a), but use a servo motor to rotate the ultrasonic sensor instead of rotating the entire robot. When the maximum signal is detected, the robot should turn towards the source, and begin moving forward . It still doesn't solve many of the issues found with a)<br />
c) using two ultrasonic receivers, placed some space apart, in the frontal part of the rover. Now we can make differential measurements, so it's easy to know from which part is the signal coming from, as the corresponding sensor will have higher readings. The robot can now directly turn towards the beacon, and follow the forward direction while the two sensors give approximately similar readings. If the right sensor output increases, then it means the robot needs to turn right, to face the beacon and continue moving forward. Same case for left. A similar approach has been used in a project by <a href="http://ese.wustl.edu/ContentFiles/Research/UndergraduateResearch/CompletedProjects/WebPages/sp10/Wiens/web/index.html">Andrew Wiens </a>:<br />
<iframe width="480" height="360" src="http://www.youtube.com/embed/tgytAJmJmgM" frameborder="0" allowfullscreen></iframe><br />
d) using more than two sensors, ideally 8, placed at 45 degrees in a radial disposition. This would pinpoint the source more accurately, and reduce the time needed to find the beacon. Still, to simplify, I plan to go for the differential measurements presented at c) . </p>
<p>The ultrasonic sensors already return an output signal which is a function of the distance to the beacon / user. This can be used to measure the distance. If greater accuracy is required, we can involve infrared light in the process:<br />
- the beacon sends a set of 38KHz modulated Infrared pulses marking moment of time t0<br />
- the beacon immediately sends out the ultrasonic pulses<br />
- the receiver which is a few meters from the beacon, receives the infrared pulses practically instantaneously and knows the time is t0 (using a TSOPXX38)<br />
- the receiver registers the incoming ultrasonic pulses at the time t1, where t1>t0. By using the speed of sound in air, we can get the exact distance to the beacon.<br />
All in one we use light to signal the start for counting, and we stop when the ultrasonic waves reach the destination.<br />
More on this <a href="http://www.convict.lu/htm/rob/ir_us.htm" target="_blank">here</a>, <a href="http://www.convict.lu/Jeunes/beacon.htm" target="_blank">here</a> or <a href="http://books.google.ro/books?id=wSmJjIZzwR8C&pg=PA28&lpg=PA28&dq=infrared+ultrasound+beacon&source=bl&ots=dVhT5eVPwr&sig=J8SFmWyZVTlDHqSEK1e4CI1nwWg&hl=en&sa=X&ei=4LliUaXiDcGotAbn8YHYAg&ved=0CFAQ6AEwBA#v=onepage&q=infrared%20ultrasound%20beacon&f=false" target="_blank">here</a>.</p>
<p><a name="130409"></a></p>
<h3>9. April 09, 2013</h3>
<p>Using the ultrasonic sensors differential readings (with sensors placed in front, at angles of aprox. 15 degrees of the longitudinal axis), I got some excellent results: the robot is able to follow me, and keep track of my speed, and orientation:<br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/9d8HmCxB158" frameborder="0" allowfullscreen></iframe><br />
The algorithm compares the readings from the two sensors and decides whether to turn left (if left sensor return higher readings), right or to move forward (if the output of the two sensors is similar).<br />
There are some remaining issues:<br />
- if the robot approaches a wall, and the beacon signal is coming from the back, it will reflect in the wall and confuse the robot<br />
- no detection capabilities for signal coming from any other direction, other than the front<br />
To solve these issues, three more ultrasonic receiver boards are needed, namely one for back, and one for each of the sides.  Also the movement is a bit shaky, and this can also be improved by changes in the robot's software code. More to follow soon.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasound_guided_robot_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasound_guided_robot_1-300x199.jpg" alt="ultrasound_guided_robot_1" width="300" height="199" class="alignnone size-medium wp-image-4031" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasound_guided_robot_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasound_guided_robot_2-300x199.jpg" alt="ultrasound_guided_robot_2" width="300" height="199" class="alignnone size-medium wp-image-4032" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasound_guided_robot_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasound_guided_robot_3-300x199.jpg" alt="ultrasound_guided_robot_3" width="300" height="199" class="alignnone size-medium wp-image-4033" /></a><br />
I built some nice PCBs for the ultrasonic sensors, and provided more details on Detecting an ultrasonic beacon, <a href="http://www.pocketmagic.net/2013/04/detecting-an-ultrasonic-beacon/" target="_blank">here</a>.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic_beacon_receiver_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic_beacon_receiver_1-150x150.jpg" alt="ultrasonic_beacon_receiver_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3997" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic_beacon_receiver_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic_beacon_receiver_2-150x150.jpg" alt="ultrasonic_beacon_receiver_2" width="150" height="150" class="alignnone size-thumbnail wp-image-3998" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic_beacon_receiver_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic_beacon_receiver_3-150x150.jpg" alt="ultrasonic_beacon_receiver_3" width="150" height="150" class="alignnone size-thumbnail wp-image-3999" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic_beacon_receiver_5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/04/ultrasonic_beacon_receiver_5-150x150.jpg" alt="ultrasonic_beacon_receiver_5" width="150" height="150" class="alignnone size-thumbnail wp-image-4001" /></a></p>
<p><a name="130410"></a></p>
<h3>10. April 10, 2013</h3>
<p>I built a total of 5 ultrasonic receivers, that are to be placed two in the front, one at the back and two on each side.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_detectors_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_detectors_1-150x150.jpg"  /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_detectors_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_detectors_2-150x150.jpg"  /></a><br />
The idea is to have the robot turn around facing the ultrasonic signal, and then to make it follow the source using the two frontal sensors. The differential readings will help us decide whether to adjust the direction for left or right.<br />
Using some PVC pipes, I built some nice and robust plastic enclosures, by heating and pressing the plastic to get the desired shapes:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_enclosure_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_enclosure_1-150x150.jpg" alt="ultrasonic_enclosure_1" width="150" height="150" class="alignnone size-thumbnail wp-image-4085" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_enclosure_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_enclosure_2-150x150.jpg" alt="ultrasonic_enclosure_2" width="150" height="150" class="alignnone size-thumbnail wp-image-4086" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_enclosure_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_enclosure_3-150x150.jpg" alt="ultrasonic_enclosure_3" width="150" height="150" class="alignnone size-thumbnail wp-image-4087" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_enclosure_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_enclosure_4-150x150.jpg" alt="ultrasonic_enclosure_4" width="150" height="150" class="alignnone size-thumbnail wp-image-4088" /></a><br />
The result looks great:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/robot_sensors_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/robot_sensors_1-150x150.jpg" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/robot_sensors_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/robot_sensors_2-150x150.jpg" /></a><br />
For some uber-coolness factor, I decided to add frontal white lights and back position red lights, controllable from the software (on/off). The frontal side now also houses a nice Sharp 2y0a infrared sensor, that will help avoid hitting any obstacles. So now the robot is capable to hear and see its surroundings. Love how it looks:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/robot_cool_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/robot_cool_1-150x150.jpg" alt="robot_cool_1" width="150" height="150" class="alignnone size-thumbnail wp-image-4092" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/robot_cool_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/robot_cool_2-150x150.jpg" alt="robot_cool_2" width="150" height="150" class="alignnone size-thumbnail wp-image-4093" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/robot_cool_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/robot_cool_4-150x150.jpg" alt="robot_cool_4" width="150" height="150" class="alignnone size-thumbnail wp-image-4095" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/robot_cool_5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/robot_cool_5-150x150.jpg" alt="robot_cool_5" width="150" height="150" class="alignnone size-thumbnail wp-image-4096" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/robot_cool_6.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/robot_cool_6-150x150.jpg" alt="robot_cool_6" width="150" height="150" class="alignnone size-thumbnail wp-image-4097" /></a></p>
<p><a name="130501"></a></p>
<h3>11. May 01, 2013</h3>
<p>Time has come to build the TX ultrasonic beacon. This time I wanted to try something new, so here is my first PCB for SMD components:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_beacon_40KHz_NE556_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_beacon_40KHz_NE556_1-150x150.jpg" alt="ultrasonic_beacon_40KHz_NE556_1" width="150" height="150" class="alignnone size-thumbnail wp-image-4106" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_beacon_40KHz_NE556_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_beacon_40KHz_NE556_2-150x150.jpg" alt="ultrasonic_beacon_40KHz_NE556_2" width="150" height="150" class="alignnone size-thumbnail wp-image-4107" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_beacon_40KHz_NE556_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_beacon_40KHz_NE556_3-150x150.jpg" alt="ultrasonic_beacon_40KHz_NE556_3" width="150" height="150" class="alignnone size-thumbnail wp-image-4108" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_beacon_40KHz_NE556_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/ultrasonic_beacon_40KHz_NE556_4-150x150.jpg" alt="ultrasonic_beacon_40KHz_NE556_4" width="150" height="150" class="alignnone size-thumbnail wp-image-4109" /></a><br />
It uses a NE556, dual timer, and is configured to emit short bursts of 40KHz pulses. You can see the circuit here:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/556_diagram.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/556_diagram-150x150.png" alt="556_diagram" width="150" height="150" class="alignnone size-thumbnail wp-image-4110" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/556_smd_pcb.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/556_smd_pcb-150x150.png" alt="556_smd_pcb" width="150" height="150" class="alignnone size-thumbnail wp-image-4111" /></a><br />
Eagle file also available, <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/beacon-TX.zip">beacon TX</a>.<br />
A case was also needed, to enclose the 9V battery as well, and make it comfortable for holding it in the hand. The final results looks like this:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/tx_beacon_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/tx_beacon_1-150x150.jpg" alt="tx_beacon_1" width="150" height="150" class="alignnone size-thumbnail wp-image-4114" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/tx_beacon_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/tx_beacon_2-150x150.jpg" alt="tx_beacon_2" width="150" height="150" class="alignnone size-thumbnail wp-image-4115" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/02/tx_beacon_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/02/tx_beacon_3-150x150.jpg" alt="tx_beacon_3" width="150" height="150" class="alignnone size-thumbnail wp-image-4116" /></a></p>
<p><a name="130503"></a></p>
<h3>12. May 03, 2013</h3>
<p>This project finally comes to an end, so I recorded two demo videos to show the robot following me, outdoors. A few modifications in software are likely to be done, but all in one, the work is pretty much complete:<br />
<b>Demo 1:</b><br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/omh-m_DDcfw" frameborder="0" allowfullscreen></iframe></p>
<p><b>Demo 2:</b><br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/ECS1E6e6xes" frameborder="0" allowfullscreen></iframe></p>
<p><a name="130522"></a></p>
<h3>13. May 22, 2013</h3>
<p>As I am a perfectionist with all that I build, I couldn't stay away and had to make this robot even better. So I did two things:<br />
1) For the autonomous, human following software: I improved the ultrasonic detection algorithm, and the movement logic: Now the robot will follow its user more precisely, and the speed will vary with the detected signal: if the robots sees the user at a greater distance, will engage with a greater speed. If closer to the user, will proceed with smaller steps. The calculations are not linear, so I used some time to get the best formula. In the end I'm quite pleased, we can see some nice improvements when compared to previous two videos - so here are two new demos:<br />
<b>Demo 3:</b><br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/UuYxDldQtn4" frameborder="0" allowfullscreen></iframe></p>
<p><b>Demo 4:</b><br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/J-oJVs9jrak" frameborder="0" allowfullscreen></iframe></p>
<p>2) For the remote control software, where the user controls the robot using a phone, the rover now reports its frontal sensor readings (that show the proximity in centimeters to any detected obstacle), to the smartphone. So the movement commands go from phone to robot, and the sensor readings go the opposite way, from robot to phone. The Android software now allows the user to turn the lights on and off, and using the frontal distance sensor, a red line is drawn, showing the proximity to an obstacle. The robot can be controlled this way - without actually seeing what it is heading for, as this simple radar will be enough to get a clear path. Here is another demo:<br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/1ZRPEJxP-IY" frameborder="0" allowfullscreen></iframe></p>
<p>3) When bluetooth is connected, the robot will ignore any ultrasonic signals from its beacon. So better separates the two modes of operation discussed above.</p>
<h3>Resources:</h3>
<p><a href="http://books.google.ro/books?id=wSmJjIZzwR8C&source=gbs_navlinks_s" target="_blank">Mechanisms for Combining Infrared and Ultrasound Signals for Indoor Wireless localization</a><br />
<a href="http://www.convict.lu/htm/rob/ir_us.htm" target="_blank">Infrared / Ultrasonic beacon</a><br />
<a href="http://ese.wustl.edu/ContentFiles/Research/UndergraduateResearch/CompletedProjects/WebPages/sp10/Wiens/web/overview.html" target="_blank">Ultrasonic Source Localization</a><br />
<a href="http://www.doc.ic.ac.uk/~nd/surprise_97/journal/vol1/jmd/" target="_blank">Mobile Robot Navigation</a><br />
<a href="http://www.learnstuff.com/learn-about-gps/" target="_blank">Learn about GPS</a><br />
Robo-Dog on <a href="http://hackaday.com/2013/05/28/wireless-rover-with-android-control" target="_blank">Hack A Day</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/02/android-controlled-robot-part-2/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>uRADMonitor &#8211; Unusual Background Radiation Reports</title>
		<link>http://www.pocketmagic.net/2013/01/uradmonitor-unusual-background-radiation-reports/</link>
		<comments>http://www.pocketmagic.net/2013/01/uradmonitor-unusual-background-radiation-reports/#comments</comments>
		<pubDate>Thu, 31 Jan 2013 18:52:05 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Nuclear]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[abnormal]]></category>
		<category><![CDATA[atypical]]></category>
		<category><![CDATA[automated]]></category>
		<category><![CDATA[barometric pressure]]></category>
		<category><![CDATA[dosimeter]]></category>
		<category><![CDATA[environmental radiation surveillance]]></category>
		<category><![CDATA[geiger counter]]></category>
		<category><![CDATA[geiger muller]]></category>
		<category><![CDATA[humidity]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[radiation]]></category>
		<category><![CDATA[radiation data]]></category>
		<category><![CDATA[radiation monitor]]></category>
		<category><![CDATA[SBM-19]]></category>
		<category><![CDATA[sensors]]></category>
		<category><![CDATA[temperature]]></category>
		<category><![CDATA[uradmonitor]]></category>
		<category><![CDATA[weather station]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3615</guid>
		<description><![CDATA[This page has been created to report unusual activity (radiation, temperature, humidity, luminosity, barometric pressure), as recorded by the uRADMonitor, including all the debug data to support the results. I cannot guarantee the measurement precision, I merely present the data recorded by the instruments.]]></description>
				<content:encoded><![CDATA[<p><a name="en"></a><img src="http://pocketmagic.net/en.gif"> uRADMonitor is a network connected monitoring station, focused on continuous Environmental Radiation Surveillance, located in Timisoara, Romania. This capability is delivered by a digital dosimeter constructed around the highly sensitive Geiger Muller tube SBM-19. It has been completed in October 20, 2012, and it is running ever since, collecting data. Construction details, and real time data, are available <a href="http://www.pocketmagic.net/2012/10/uradmonitor-online-remote-radiation-monitoring-station/">here</a>.<br />
This additional page, has been created to report unusual activity, as recorded by the uRADMonitor, including all the debug data to support the results. I cannot guarantee the measurement precision, I merely present the data recorded by the instruments. Feedback among readers is welcome, please use the comments section.<br />
<a name="ro"></a><img src="http://pocketmagic.net/ro.gif"> uRADMonitor e o statie de monitorizare a fondului de radiatii, in Timisoara, Romania. Elementul de detectie a radiatiei ionizante consta intr-un tub Geiger Muller SBM-19, si un numarator digital. Aparatul a fost pus in functiune in 20 Octombrie 2012, si de atunci funtioneaza neintrerupt, colectand rezultatele masuratorilor. Detalii tehnice de constructie, dar si grafice in timp real, pe baza datelor colectate, sunt disponibile <a href="http://www.pocketmagic.net/2012/10/uradmonitor-online-remote-radiation-monitoring-station/">aici (in engleza)</a> si <a href="http://www.pocketmagic.net/2012/10/statie-de-monitorizare-a-fondului-de-radiatii-gamma-in-timisoara/">aici (in romana)</a>.<br />
Acest nou articol a fost creat pentru a raporta masuratori atipice, asa cum au fost ele inregistrate de uRADMonitor, incluzand toate datele de depanare software (debug). Nu pot sa garantez acuratetea acestor rezultate, le prezint doar asa cum au fost inregistrate de uRADMonitor. Feedback din partea cititorilor este bine venit, in sectiunea de comentarii a paginii.</p>
<p><a name="130131"></a></p>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td valign="middle"><img src="http://www.pocketmagic.net/attention.gif"></td>
<td valign="middle">
<h3>01. January 31, 2013</h3>
</td>
</tr>
</table>
<p>Time interval: 18:11:08 - 18:17:07 (Bucharest timezone, GMT+2)<br />
Atypical measurement: <b>radiation level</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/atypical_radiation_cpm_13_01_31.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/atypical_radiation_cpm_13_01_31-300x150.png" alt="atypical_radiation_cpm_13_01_31" width="300" height="150" class="alignnone size-medium wp-image-3616" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/13_01_31_maxres.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/13_01_31_maxres-300x150.png" alt="13_01_31_maxres" width="300" height="150" class="alignnone size-medium wp-image-3745" /></a><br />
Measure units: cpm (counts per minute, as related to Geiger tube SBM-19)<br />
Measurement resolution: 1 minute<br />
Max value recorded: <b>3781</b><br />
Typical average value for the last 2 months: <b>81</b><br />
<b>Relevant Debug data:</b><code><br />
T_RO:31.Jan.2013 18:10:09,T_UC:19:15:0,ID:1,VOL:400,DUTY:69,T1:9.50,T2:8.40,H2:73.70,L3:0,T4:8.00,P4:100401,CPM:70<br />
T_RO:31.Jan.2013 18:11:08,T_UC:19:16:0,ID:1,VOL:399,DUTY:69,T1:9.50,T2:8.40,H2:74.20,L3:0,T4:8.00,P4:100401,CPM:2292<br />
<b>T_RO:31.Jan.2013 18:12:08,T_UC:19:17:0,ID:1,VOL:399,DUTY:69,T1:9.50,T2:8.40,H2:74.50,L3:0,T4:8.00,P4:100406,CPM:3781</b><br />
T_RO:31.Jan.2013 18:13:07,T_UC:19:18:0,ID:1,VOL:401,DUTY:69,T1:9.50,T2:8.40,H2:74.40,L3:0,T4:8.00,P4:100408,CPM:3148<br />
T_RO:31.Jan.2013 18:14:07,T_UC:19:19:0,ID:1,VOL:400,DUTY:69,T1:9.50,T2:8.40,H2:76.20,L3:0,T4:8.00,P4:100410,CPM:3027<br />
T_RO:31.Jan.2013 18:15:07,T_UC:19:20:0,ID:1,VOL:400,DUTY:69,T1:9.50,T2:8.40,H2:75.50,L3:0,T4:8.00,P4:100414,CPM:3012<br />
T_RO:31.Jan.2013 18:16:08,T_UC:19:21:0,ID:1,VOL:402,DUTY:71,T1:10.00,T2:8.40,H2:75.30,L3:0,T4:8.00,P4:100410,CPM:2997<br />
T_RO:31.Jan.2013 18:17:07,T_UC:19:22:0,ID:1,VOL:399,DUTY:69,T1:10.00,T2:8.40,H2:76.60,L3:0,T4:8.00,P4:100409,CPM:264<br />
T_RO:31.Jan.2013 18:18:07,T_UC:19:23:0,ID:1,VOL:399,DUTY:69,T1:10.00,T2:8.40,H2:75.40,L3:0,T4:8.00,P4:100414,CPM:90 </code><br />
<b>Legend:</b><code><br />
T_RO: Event timestamp, indicating real date and time in Timisoara, Romania<br />
T_UC: internal uRADMonitor time<br />
VOL: voltage on Geiger tube, SBM-19<br />
DUTY: the duty cycle driving the 400V inverter in thousand percents<br />
T1: measured temperature on sensor 1 (DS18B20) in degrees Celsius<br />
T2: measured temperature on sensor 2 (DHT22) in degrees Celsius<br />
H2: measured humidity on sensor 2 (DHT22) in relative nits<br />
L3: measured luminosity on photodiode sensor 3 in relative units<br />
T4: measured temperature on sensor 4 (BMP085) in degrees Celsius<br />
P4: measured barometric pressure on sensor 4 (BMP085) in Pascals<br />
CPM: measure radiation level on Geiger tube SBM-19, in counts per minute</code><br />
<b>Comments:</b><br />
All system's parameters indicate the uRADMonitor is functioning in normal parameters.<br />
The tube voltage is in normal parameters (400V +-5V).<br />
All other measurements indicate typical values.<br />
Persistence: none, radiation abnormal readings lasted for only 6 minutes, than the data gets back to normal/typical levels.<br />
System malfunction probability:  none / highly improbable.</p>
<p><a name="130208"></a></p>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td valign="middle"><img src="http://www.pocketmagic.net/attention.gif"></td>
<td valign="middle">
<h3>02. February 08, 2013</h3>
</td>
</tr>
</table>
<p>Time interval: 00:26:43 - 00:33:42 (Bucharest timezone, GMT+2)<br />
Atypical measurement: <b>radiation level</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/atypical_radiation_cpm_13_02_08.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/atypical_radiation_cpm_13_02_08-300x150.png" alt="atypical_radiation_cpm_13_02_08" width="300" height="150" class="alignnone size-medium wp-image-3703" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/13_02_08_maxres.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/13_02_08_maxres-300x150.png" alt="13_02_08_maxres" width="300" height="150" class="alignnone size-medium wp-image-3746" /></a><br />
Measure units: cpm (counts per minute, as related to Geiger tube SBM-19)<br />
Measurement resolution: 1 minute<br />
Max value recorded: <b>5175</b><br />
Typical average value for the last 2 months: <b>81</b><br />
<b>Relevant Debug data:</b><code><br />
T_RO:08.Feb.2013 00:25:43,T_UC:12:46:0,ID:1,VOL:400,DUTY:69,T1:4.50,T2:3.20,H2:91.90,L3:0,T4:3.00,P4:99285,CPM:81<br />
T_RO:08.Feb.2013 00:26:43,T_UC:12:47:0,ID:1,VOL:400,DUTY:69,T1:4.50,T2:3.20,H2:91.90,L3:0,T4:3.00,P4:99295,CPM:3444<br />
<b>T_RO:08.Feb.2013 00:27:42,T_UC:12:48:0,ID:1,VOL:400,DUTY:69,T1:5.00,T2:3.30,H2:91.50,L3:0,T4:3.00,P4:99297,CPM:5175</b><br />
T_RO:08.Feb.2013 00:28:42,T_UC:12:49:0,ID:1,VOL:400,DUTY:69,T1:4.50,T2:3.30,H2:92.00,L3:0,T4:3.00,P4:99291,CPM:4056<br />
T_RO:08.Feb.2013 00:29:42,T_UC:12:50:0,ID:1,VOL:399,DUTY:69,T1:4.50,T2:3.40,H2:91.10,L3:0,T4:3.00,P4:99296,CPM:3868<br />
T_RO:08.Feb.2013 00:30:42,T_UC:12:51:0,ID:1,VOL:399,DUTY:69,T1:4.50,T2:3.40,H2:90.60,L3:0,T4:3.00,P4:99307,CPM:3502<br />
T_RO:08.Feb.2013 00:31:42,T_UC:12:52:0,ID:1,VOL:399,DUTY:69,T1:5.00,T2:3.40,H2:91.60,L3:0,T4:3.00,P4:99300,CPM:3354<br />
T_RO:08.Feb.2013 00:32:42,T_UC:12:53:0,ID:1,VOL:400,DUTY:69,T1:4.50,T2:3.40,H2:92.30,L3:0,T4:3.00,P4:99295,CPM:3326<br />
T_RO:08.Feb.2013 00:33:42,T_UC:12:54:0,ID:1,VOL:399,DUTY:69,T1:4.50,T2:3.40,H2:92.10,L3:0,T4:3.00,P4:99290,CPM:1955<br />
T_RO:08.Feb.2013 00:34:42,T_UC:12:55:0,ID:1,VOL:399,DUTY:69,T1:4.50,T2:3.40,H2:91.20,L3:0,T4:3.00,P4:99318,CPM:86  </code><br />
<b>Legend:</b>see above.<br />
<b>Comments:</b><br />
All system's parameters indicate the uRADMonitor is functioning in normal parameters.</p>
<p><a name="130215"></a></p>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td valign="middle"><img src="http://www.pocketmagic.net/attention.gif"></td>
<td valign="middle">
<h3>03. February 15, 2013</h3>
</td>
</tr>
</table>
<p>Time interval:  21:52:44 - 21:57:44 (Bucharest timezone, GMT+2)<br />
Atypical measurement: <b>radiation level</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/atypical_radiation_cpm_13_02_15.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/atypical_radiation_cpm_13_02_15-300x150.png" alt="atypical_radiation_cpm_13_02_15" width="300" height="150" class="alignnone size-medium wp-image-3743" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/13_02_15_maxres.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/13_02_15_maxres-300x150.png" alt="13_02_15_maxres" width="300" height="150" class="alignnone size-medium wp-image-3747" /></a><br />
Measure units: cpm (counts per minute, as related to Geiger tube SBM-19)<br />
Measurement resolution: 1 minute<br />
Max value recorded: <b>5849</b><br />
Typical average value for the last 2 months: <b>81</b><br />
<b>Relevant Debug data:</b><code><br />
T_RO:15.Feb.2013 21:51:44,T_UC:2:41:0,ID:1,VOL:399,DUTY:70,T1:8.00,T2:6.60,H2:99.90,L3:0,T4:6.00,P4:100607,CPM:89<br />
T_RO:15.Feb.2013 21:52:44,T_UC:2:42:0,ID:1,VOL:399,DUTY:70,T1:8.00,T2:6.60,H2:99.90,L3:0,T4:6.00,P4:100591,CPM:3521<br />
<b>T_RO:15.Feb.2013 21:53:44,T_UC:2:43:0,ID:1,VOL:399,DUTY:70,T1:8.00,T2:6.60,H2:99.90,L3:0,T4:6.00,P4:100597,CPM:5849</b><br />
T_RO:15.Feb.2013 21:54:44,T_UC:2:44:0,ID:1,VOL:399,DUTY:71,T1:8.00,T2:6.50,H2:99.90,L3:0,T4:6.00,P4:100577,CPM:5591<br />
T_RO:15.Feb.2013 21:56:44,T_UC:2:46:0,ID:1,VOL:399,DUTY:70,T1:8.00,T2:6.50,H2:99.90,L3:0,T4:6.00,P4:100586,CPM:1927<br />
T_RO:15.Feb.2013 21:57:44,T_UC:2:47:0,ID:1,VOL:399,DUTY:71,T1:8.00,T2:6.60,H2:99.90,L3:0,T4:6.00,P4:100571,CPM:72 </code><br />
<b>Legend:</b> see above.<br />
<b>Comments:</b><br />
All system's parameters indicate the uRADMonitor is functioning in normal parameters.</p>
<p><a name="130219"></a></p>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td valign="middle"><img src="http://www.pocketmagic.net/attention.gif"></td>
<td valign="middle">
<h3>04. February 19, 2013</h3>
</td>
</tr>
</table>
<p>Time interval:  00:57:20 - 00:58:20 (Bucharest timezone, GMT+2)<br />
Atypical measurement: <b>radiation level</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/2013_02_19_cpm.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/2013_02_19_cpm-300x150.png" alt="2013_02_19_cpm" width="300" height="150" class="alignnone size-medium wp-image-3755" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/13_02_19_bigres_cpm.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/13_02_19_bigres_cpm-300x150.png" alt="13_02_19_bigres_cpm" width="300" height="150" class="alignnone size-medium wp-image-3756" /></a><br />
Measure units: cpm (counts per minute, as related to Geiger tube SBM-19)<br />
Measurement resolution: 1 minute<br />
Max value recorded: <b>2875</b><br />
Typical average value for the last 2 months: <b>81</b><br />
<b>Relevant Debug data:</b><code><br />
T_RO:19.Feb.2013 00:56:20,T_UC:14:11:0,ID:1,VOL:376,DUTY:52,T1:4.00,T2:2.60,H2:85.10,L3:0,T4:2.00,P4:100628,CPM:72<br />
T_RO:19.Feb.2013 00:57:20,T_UC:14:12:0,ID:1,VOL:382,DUTY:53,T1:4.00,T2:2.60,H2:86.40,L3:0,T4:2.00,P4:100612,CPM:2139<br />
<b>T_RO:19.Feb.2013 00:58:20,T_UC:14:13:0,ID:1,VOL:373,DUTY:52,T1:4.00,T2:2.60,H2:85.00,L3:0,T4:2.00,P4:100615,CPM:2875</b><br />
T_RO:19.Feb.2013 00:59:20,T_UC:14:14:0,ID:1,VOL:364,DUTY:48,T1:4.00,T2:2.60,H2:85.50,L3:0,T4:2.00,P4:100611,CPM:83 </code><br />
<b>Legend:</b> see above.<br />
<b>Comments:</b><br />
All system's parameters indicate the uRADMonitor is functioning in normal parameters. Tube is currently operating on 375V.</p>
<p><a name="130220"></a></p>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td valign="middle"><img src="http://www.pocketmagic.net/attention.gif"></td>
<td valign="middle">
<h3>05. February 20, 2013</h3>
</td>
</tr>
</table>
<p>Time interval:  20:35:49 - 20:40:49 (Bucharest timezone, GMT+2)<br />
Atypical measurement: <b>radiation level</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/13_02_20_cpm.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/13_02_20_cpm-300x150.png" alt="13_02_20_cpm" width="300" height="150" class="alignnone size-medium wp-image-3773" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/13_02_20_cpmbig.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/13_02_20_cpmbig-300x150.png" alt="13_02_20_cpmbig" width="300" height="150" class="alignnone size-medium wp-image-3774" /></a><br />
Measure units: cpm (counts per minute, as related to Geiger tube SBM-19)<br />
Measurement resolution: 1 minute<br />
Max value recorded: <b>3893</b><br />
Typical average value for the last 2 months: <b>81</b><br />
<b>Relevant Debug data:</b><code><br />
T_RO:20.Feb.2013 20:34:49,T_UC:7:38:0,ID:1,VOL:374,DUTY:50,T1:7.00,T2:5.60,H2:68.70,L3:0,T4:5.00,P4:100443,CPM:82<br />
T_RO:20.Feb.2013 20:35:49,T_UC:7:39:0,ID:1,VOL:375,DUTY:50,T1:6.50,T2:5.60,H2:69.00,L3:0,T4:5.00,P4:100431,CPM:1205<br />
<b>T_RO:20.Feb.2013 20:36:49,T_UC:7:40:0,ID:1,VOL:378,DUTY:51,T1:7.00,T2:5.60,H2:69.40,L3:0,T4:5.00,P4:100441,CPM:3893</b><br />
T_RO:20.Feb.2013 20:37:49,T_UC:7:41:0,ID:1,VOL:375,DUTY:50,T1:7.00,T2:5.60,H2:69.90,L3:0,T4:5.00,P4:100436,CPM:3321<br />
T_RO:20.Feb.2013 20:38:49,T_UC:7:42:0,ID:1,VOL:375,DUTY:50,T1:7.00,T2:5.60,H2:70.40,L3:0,T4:5.00,P4:100440,CPM:3117<br />
T_RO:20.Feb.2013 20:39:49,T_UC:7:43:0,ID:1,VOL:375,DUTY:50,T1:6.50,T2:5.60,H2:69.80,L3:0,T4:5.00,P4:100436,CPM:301<br />
T_RO:20.Feb.2013 20:40:49,T_UC:7:44:0,ID:1,VOL:374,DUTY:50,T1:6.50,T2:5.70,H2:70.20,L3:0,T4:5.00,P4:100436,CPM:102<br />
T_RO:20.Feb.2013 20:41:49,T_UC:7:45:0,ID:1,VOL:375,DUTY:50,T1:7.00,T2:5.60,H2:69.40,L3:0,T4:5.00,P4:100442,CPM:60 </code><br />
<b>Legend:</b> see above.<br />
<b>Comments:</b><br />
All system's parameters indicate the uRADMonitor is functioning in normal parameters. Tube voltage has been reduced to 375V.</p>
<p><a name="130222"></a></p>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td valign="middle"><img src="http://www.pocketmagic.net/attention.gif"></td>
<td valign="middle">
<h3>06. February 22, 2013</h3>
</td>
</tr>
</table>
<p>Time interval:   22:25:12 - 22:37:12 (Bucharest timezone, GMT+2)<br />
Atypical measurement: <b>radiation level</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/2013_02_22_cpm.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/2013_02_22_cpm-300x150.png" alt="2013_02_22_cpm" width="300" height="150" class="alignnone size-medium wp-image-3812" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/2013_02_22_bigcpm.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/2013_02_22_bigcpm-300x150.png" alt="2013_02_22_bigcpm" width="300" height="150" class="alignnone size-medium wp-image-3813" /></a><br />
Measure units: cpm (counts per minute, as related to Geiger tube SBM-19)<br />
Measurement resolution: 1 minute<br />
Max value recorded: <b>4812</b><br />
Typical average value for the last 2 months: <b>81</b><br />
<b>Relevant Debug data:</b><code><br />
T_RO:22.Feb.2013 22:24:12,T_UC:9:29:0,ID:1,VOL:375,DUTY:56,T1:6.00,T2:4.30,H2:99.90,L3:0,T4:3.00,P4:99621,CPM:95<br />
T_RO:22.Feb.2013 22:25:12,T_UC:9:30:0,ID:1,VOL:375,DUTY:56,T1:6.00,T2:4.30,H2:99.90,L3:0,T4:3.00,P4:99627,CPM:850<br />
<b>T_RO:22.Feb.2013 22:26:12,T_UC:9:31:0,ID:1,VOL:375,DUTY:56,T1:6.00,T2:4.40,H2:99.90,L3:0,T4:3.00,P4:99631,CPM:4812</b><br />
T_RO:22.Feb.2013 22:27:12,T_UC:9:32:0,ID:1,VOL:375,DUTY:55,T1:6.00,T2:4.40,H2:99.90,L3:0,T4:3.00,P4:99635,CPM:3643<br />
T_RO:22.Feb.2013 22:28:12,T_UC:9:33:0,ID:1,VOL:375,DUTY:55,T1:6.50,T2:4.40,H2:99.90,L3:0,T4:4.00,P4:99640,CPM:3337<br />
T_RO:22.Feb.2013 22:29:12,T_UC:9:34:0,ID:1,VOL:375,DUTY:56,T1:6.50,T2:4.50,H2:99.90,L3:0,T4:4.00,P4:99629,CPM:3158<br />
T_RO:22.Feb.2013 22:30:12,T_UC:9:35:0,ID:1,VOL:375,DUTY:55,T1:6.00,T2:4.50,H2:99.90,L3:0,T4:4.00,P4:99624,CPM:3102<br />
T_RO:22.Feb.2013 22:31:12,T_UC:9:36:0,ID:1,VOL:375,DUTY:56,T1:6.00,T2:4.50,H2:99.90,L3:0,T4:4.00,P4:99629,CPM:3081<br />
T_RO:22.Feb.2013 22:32:12,T_UC:9:37:0,ID:1,VOL:375,DUTY:56,T1:6.00,T2:4.50,H2:99.90,L3:0,T4:4.00,P4:99630,CPM:3031<br />
T_RO:22.Feb.2013 22:33:12,T_UC:9:38:0,ID:1,VOL:375,DUTY:55,T1:6.00,T2:4.50,H2:99.90,L3:0,T4:4.00,P4:99623,CPM:3155<br />
T_RO:22.Feb.2013 22:34:12,T_UC:9:39:0,ID:1,VOL:376,DUTY:56,T1:6.00,T2:4.50,H2:99.90,L3:0,T4:4.00,P4:99620,CPM:3121<br />
T_RO:22.Feb.2013 22:35:12,T_UC:9:40:0,ID:1,VOL:375,DUTY:55,T1:6.00,T2:4.50,H2:99.90,L3:0,T4:4.00,P4:99624,CPM:3105<br />
T_RO:22.Feb.2013 22:36:12,T_UC:9:41:0,ID:1,VOL:375,DUTY:56,T1:6.00,T2:4.50,H2:99.90,L3:0,T4:4.00,P4:99624,CPM:3094<br />
T_RO:22.Feb.2013 22:37:12,T_UC:9:42:0,ID:1,VOL:375,DUTY:56,T1:6.00,T2:4.50,H2:99.90,L3:0,T4:4.00,P4:99629,CPM:2433<br />
T_RO:22.Feb.2013 22:38:12,T_UC:9:43:0,ID:1,VOL:375,DUTY:55,T1:6.00,T2:4.50,H2:99.90,L3:0,T4:4.00,P4:99631,CPM:89 </code><br />
<b>Legend:</b> see above.<br />
<b>Comments:</b><br />
All system's parameters indicate the uRADMonitor is functioning in normal parameters. Tube voltage has been set to 376V</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/01/uradmonitor-unusual-background-radiation-reports/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Programmatically Injecting Events on Android &#8211; Part 2</title>
		<link>http://www.pocketmagic.net/2013/01/programmatically-injecting-events-on-android-part-2/</link>
		<comments>http://www.pocketmagic.net/2013/01/programmatically-injecting-events-on-android-part-2/#comments</comments>
		<pubDate>Wed, 30 Jan 2013 14:12:49 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[/dev/input/]]></category>
		<category><![CDATA[Inject Keys]]></category>
		<category><![CDATA[Instrumentation]]></category>
		<category><![CDATA[IWindowManager]]></category>
		<category><![CDATA[jni]]></category>
		<category><![CDATA[MotionEvent]]></category>
		<category><![CDATA[Mouse Events]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[root]]></category>
		<category><![CDATA[ServiceManager]]></category>
		<category><![CDATA[Touch Events]]></category>
		<category><![CDATA[WindowManager]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3527</guid>
		<description><![CDATA[A JNI Library for Android, to inject keys and touches but also listen for incoming input events to and from all applications, available as Open Source under GPL.]]></description>
				<content:encoded><![CDATA[<p>Our smartphones are capable of some impressive processing power, quickly replacing much of what we used the desktop PC for, in the past: mainly document management and communication. But there's always a balance between functionality and security, and Google's Android decided to opt mostly in favor of the latter, leaving out critical functionality on purpose, such as injecting keys or touch events to a third party process.<br />
While this seems unimportant to the regular user, this is fundamentally crucial for developing "also regular" applications such as: remote administration (like VNC, teamviewer, remote control), for application test tools, or for applications aiming to improve the smartphone control for persons with disabilities (using the chair joystick to control the Android phone). Another example here, is the option to create a custom mouse pointer on top of your Android screen, for application control purposes, as presented <a href="http://www.pocketmagic.net/2012/07/android-overlay-cursor">here</a>, that also needs to be able to inject the touch events when the user clicks.<br />
Not to mention various automation tasks, hacks & mods but in the end is all about the freedom given to the development community. The Android platform makers should come up with some better solutions.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/header_android_inject_events.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/header_android_inject_events.jpg" alt="header_android_inject_events" width="800" height="311" class="alignnone size-full wp-image-3550" /></a></p>
<h3>Introduction</h3>
<p>In <a href="http://www.pocketmagic.net/2012/04/injecting-events-programatically-on-android/">part 1</a> of this article I have indicated three ways of injecting events on the Android platform:<br />
<b>Method 1</b>: Using internal APIs, mainly relying on the WindowManager and the two APIs: injectPointerEvent and injectKeyEvent</li>
<p><b>Method 2</b>: Using an instrumentation object</li>
<p><b>Method 3</b>: Direct event injection to /dev/input/eventX </li>
<p>While the first two rely on the dreaded  INJECT_EVENTS permission, available only to platform makers, and have suffered great changes in the last OS versions, the third method is at the moment of writing this article the best bet for properly injecting events on Android.</p>
<p>The /dev/input/eventX are event input nodes, part of the linux platform beneath Android. Normally their permissions are set so only the Owner and its Group can read and write from/top these files. There are no permissions set for Other, and there is where our code is situated, since it is not owner of the linux input event nodes, nor member of the Owner group:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/android_input_event_nodes.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/android_input_event_nodes.png" alt="android_input_event_nodes" width="639" height="136" class="alignnone size-full wp-image-3529" /></a></p>
<p>So to be able to use method 3, and to directly interface to the input event nodes, we need to be able to alter the permissions, in order to set the Other permission bit to Read (if we want to intercept input event data) or Write (if we want to push events, as indicated in the article's title: <b>Injecting events</b>). The best way to go is to set the bit to allow +rw (read and write) , using the chmod native command:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/android_input_event_nodes_chmod.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/android_input_event_nodes_chmod.png" alt="android_input_event_nodes_chmod" width="630" height="143" class="alignnone size-full wp-image-3530" /></a><br />
Without root access, this fails, with "operation not permitted". So here is the point where we can only proceed if we are using a Rooted Android phone. Everything else shown in this article will work without root, but for changing the permissions we need root, and there's no way around it. A bit frustrating, considering we are talking about such a tiny information segment. More on linux filesystem permissions, <a href="http://www.cyberciti.biz/faq/how-linux-file-permissions-work/">here</a>.</p>
<p>Once the input event nodes are set to allow both reading and writing, we can open them as regular files, and read the content or write our own content, to intercept events or inject our own keys or touch events. The format accepted by the input event node files is:</p>
<pre class="c"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">struct</span> input_event <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #993333;">struct</span> timeval time;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">short</span> type;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">short</span> code;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> value;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* type and code are values defined in linux/input.h. </span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;* For example, type might be EV_REL for relative  moment of a mouse, </span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;* or EV_KEY for a keypress, and code is the keycode, or REL_X or ABS_X for a mouse.</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;* The linux/input.h is part of the Android NDK</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;*/</span></div></li></ol></pre>
<p>Make sure to read more on this topic, for a better understanding. A nice article is available on <a href="http://www.linuxjournal.com/article/6429">Linux Journal</a>.</p>
<p>By popular demand on my two previous articles: <a href="http://www.pocketmagic.net/2012/04/injecting-events-programatically-on-android/">Programmatically Injecting Events on Android – Part 1</a>  and  <a href="http://www.pocketmagic.net/2012/07/android-overlay-cursor">Android Overlay Mouse Cursor</a>, but also to standardize method #3, I have developed a JNI library for Android, to take care of all these details to do what the standard API refuses to do: simple event injection for all your development needs. But it requires root, as explained previously. </p>
<p>The library, named "android-event-injector" is released as Open Source, under GPL, and available on Google code, <a href="http://code.google.com/p/android-event-injector/">here</a>. </p>
<h3>Android Event Injector functionality</h3>
<table cellspacing="10" cellpadding="0" border="0">
<tr>
<td><a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/android_inject_touch_key_event_diagram.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/android_inject_touch_key_event_diagram-150x150.jpg" alt="android_inject_touch_key_event_diagram" width="150" height="150" class="alignnone size-thumbnail wp-image-3534" /></a></td>
<td>
This library uses JNI, and you will need to <a href="http://www.pocketmagic.net/2010/11/android-c-native-development-using-the-ndk-under-windows/">setup Android NDK</a> if you want to change it or compile it.</p>
<p>It uses a low level, native component, that completely handles the input event node interaction: discovering the files (ScanFiles), opening them (OpenDev), Closing/Removing allocated memory (RemoveDev) or getting event node details such as Path and Name. With an open Input Event Node, we can do polling (PollDev, getType, getCode, getValue) or event injection (intSendEvent).</p>
<p>Via JNI, we are handling all this functionality in Java (Events.Java). This class builds multiple instances of the InputDevice class, that correspond to the number of discovered native input event nodes (the number of /dev/input/eventX files). When we open such a file, we use the API call Open(boolean forceOpen):
</td>
</tr>
</table>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/**</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">* function Open : opens an input event node</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">* @param forceOpen will try to set permissions and then reopen if first open attempt fails</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">* @return true if input event node has been opened</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">*/</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">boolean</span> Open<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">boolean</span> forceOpen<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #993333;">int</span> res = OpenDev<span style="color: #66cc66;">&#40;</span>m_nId<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #808080; font-style: italic;">// if opening fails, we might not have the correct permissions, try changing 660 to 666</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>res != <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #808080; font-style: italic;">// possible only if we have root</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>forceOpen &amp;&amp; Shell.<span style="color: #006600;">isSuAvailable</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">      <span style="color: #808080; font-style: italic;">// set new permissions</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">         Shell.<span style="color: #006600;">runCommand</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;chmod 666 &quot;</span>+ m_szPath<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">         <span style="color: #808080; font-style: italic;">// reopen</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">           res = OpenDev<span style="color: #66cc66;">&#40;</span>m_nId<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">       <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  m_szName = getDevName<span style="color: #66cc66;">&#40;</span>m_nId<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  m_bOpen = <span style="color: #66cc66;">&#40;</span>res == <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #808080; font-style: italic;">// debug</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  Log.<span style="color: #006600;">d</span><span style="color: #66cc66;">&#40;</span>LT,  <span style="color: #ff0000;">&quot;Open:&quot;</span>+m_szPath+<span style="color: #ff0000;">&quot; Name:&quot;</span>+m_szName+<span style="color: #ff0000;">&quot; Result:&quot;</span>+m_bOpen<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #808080; font-style: italic;">// done, return</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #000000; font-weight: bold;">return</span> m_bOpen;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>As you can see, at this point we also use <i>chmod</i> to make sure our process can read and write the input event node (/dev/input/eventX file).</p>
<p>If we are successful in opening an event node, we can use it for listening for events (system touch events, key presses, etc), or for injecting events. The code on Google code, exemplifies all these:</p>
<h3>Listening for incoming events</h3>
<p>Here is a simple example on how to use my library, to create a thread that intercepts all system input events and shows them in logcat:</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/**</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">* Starts our event monitor thread that does the data extraction via polling</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">* all data is displayed in the textview, as type-code-value, see input.h in the Android NDK for more details</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">* Monitor output is also sent to Logcat, so make sure you used that as well</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">*/</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> StartEventMonitor<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">m_bMonitorOn = <span style="color: #000000; font-weight: bold;">true</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AThread+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Thread</span></a> b = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AThread+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Thread</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ARunnable+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Runnable</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> run<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span>m_bMonitorOn<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">      <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>InputDevice idev:events.<span style="color: #006600;">m_Devs</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #808080; font-style: italic;">// Open more devices to see their messages</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>idev.<span style="color: #006600;">getOpen</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span> == idev.<span style="color: #006600;">getPollingEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">          <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> line = idev.<span style="color: #006600;">getName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>+</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">              <span style="color: #ff0000;">&quot;:&quot;</span> + idev.<span style="color: #006600;">getSuccessfulPollingType</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>+</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">              <span style="color: #ff0000;">&quot; &quot;</span> + idev.<span style="color: #006600;">getSuccessfulPollingCode</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> + </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">              <span style="color: #ff0000;">&quot; &quot;</span> + idev.<span style="color: #006600;">getSuccessfulPollingValue</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">          Log.<span style="color: #006600;">d</span><span style="color: #66cc66;">&#40;</span>LT, <span style="color: #ff0000;">&quot;Event:&quot;</span>+line<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">          <span style="color: #808080; font-style: italic;">// update textview to show data</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">          <span style="color: #808080; font-style: italic;">//if (idev.getSuccessfulPollingValue() != 0)</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">          m_tvMonitor.<span style="color: #006600;">post</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ARunnable+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Runnable</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> run<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">              m_tvMonitor.<span style="color: #006600;">setText</span><span style="color: #66cc66;">&#40;</span>line<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">          <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">      <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">b.<span style="color: #006600;">start</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;    </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span>  </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>This is very useful when you need to better understand the event structure and the involved values for type,code and value. Make sure you have a look on linux/input.h contents as well, inside your Android NDK folder.</p>
<h3>Injecting events</h3>
<p>Again, input.h is our friend, since it details the event codes we need to use. But you will also want to use the event monitor to be able to write down all the complex events sequence generated by the system when the user touches the screen. Here are a few wrapper functions to serve as a sample:<br />
Home hardware key injection:</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/**</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">* Finds an open device that has a name containing keypad. This probably is the event node associated with the keypad</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">* Its purpose is to handle all hardware Android buttons such as Back, Home, Volume, etc</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">* Key codes are defined in input.h (see NDK) , or use the Event Monitor to see keypad messages</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">* This function sends the HOME key </span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">*/</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> SendHomeKeyToKeypad<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">boolean</span> found = <span style="color: #000000; font-weight: bold;">false</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>InputDevice idev:events.<span style="color: #006600;">m_Devs</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #808080; font-style: italic;">//* Finds an open device that has a name containing keypad. This probably is the keypad associated event node</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>idev.<span style="color: #006600;">getOpen</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; idev.<span style="color: #006600;">getName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">contains</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;keypad&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    idev.<span style="color: #006600;">SendKey</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">102</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// home key down</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    idev.<span style="color: #006600;">SendKey</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">102</span>, <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// home key up</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    found  = <span style="color: #000000; font-weight: bold;">true</span>; <span style="color: #000000; font-weight: bold;">break</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>found == <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  Toast.<span style="color: #006600;">makeText</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, <span style="color: #ff0000;">&quot;Keypad not found.&quot;</span>, Toast.<span style="color: #006600;">LENGTH_SHORT</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>And another example, for injecting touch events:</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//absolute coordinates, on my device they go up to 570x960</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>m_selectedDev!=<span style="color: #cc66cc;">-1</span><span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">   events.<span style="color: #006600;">m_Devs</span>.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>m_selectedDev<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">SendTouchDownAbs</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">155</span>,<span style="color: #cc66cc;">183</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>Don't forget to correctly use the Event input devices. When you open them, you also have access to the Device Name. Make sure you insert key events to the device named "keypad" or "keyboard" and not to the compass or other input devices if you want this to work. Also for touch events, make sure you insert your touches/click events to "touchpad" or "ts". The namings can be different from a device to another, or from a platform to another. Try to develop an algorithm to correctly identify your target before injecting input data.</p>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/android_inject_keys_touches_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/android_inject_keys_touches_4-150x150.jpg" alt="android_inject_keys_touches_4" width="150" height="150" class="alignnone size-thumbnail wp-image-3555" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/android_inject_keys_touches_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/android_inject_keys_touches_3-150x150.jpg" alt="android_inject_keys_touches_3" width="150" height="150" class="alignnone size-thumbnail wp-image-3554" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/android_inject_keys_touches_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/android_inject_keys_touches_2-150x150.jpg" alt="android_inject_keys_touches_2" width="150" height="150" class="alignnone size-thumbnail wp-image-3553" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/android_inject_keys_touches_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/android_inject_keys_touches_1-150x150.jpg" alt="android_inject_keys_touches_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3552" /></a></p>
<h3>Additional resources:</h3>
<p> <a href="http://www.pocketmagic.net/2012/04/injecting-events-programatically-on-android/">Programmatically Injecting Events on Android – Part 1</a><br />
<a href="http://www.pocketmagic.net/2012/07/android-overlay-cursor">Android Overlay Mouse Cursor</a><br />
The code is available on <a href="http://code.google.com/p/android-event-injector/">Google Code</a>, under GPL. Use it only if you understand the terms of Open Source software distributed under GPL.<br />
The library and a sample can be downloaded <a href="http://code.google.com/p/android-event-injector/">here </a>or <a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/EventInjector.zip">EventInjector</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2013/01/programmatically-injecting-events-on-android-part-2/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>Top 10 Radioactive Electronic Tubes</title>
		<link>http://www.pocketmagic.net/2012/12/top-of-radioactive-electronic-tubes/</link>
		<comments>http://www.pocketmagic.net/2012/12/top-of-radioactive-electronic-tubes/#comments</comments>
		<pubDate>Sun, 30 Dec 2012 20:37:58 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[High Voltage]]></category>
		<category><![CDATA[Nuclear]]></category>
		<category><![CDATA[Tubes]]></category>
		<category><![CDATA[11TN40]]></category>
		<category><![CDATA[1B22]]></category>
		<category><![CDATA[1B26]]></category>
		<category><![CDATA[313CD]]></category>
		<category><![CDATA[EII-43-100]]></category>
		<category><![CDATA[Geiger]]></category>
		<category><![CDATA[geiger counter]]></category>
		<category><![CDATA[JAN-346B]]></category>
		<category><![CDATA[JAN-4C35]]></category>
		<category><![CDATA[JAN-8370]]></category>
		<category><![CDATA[MA340]]></category>
		<category><![CDATA[radioactiv]]></category>
		<category><![CDATA[radioactivity]]></category>
		<category><![CDATA[TG-77]]></category>
		<category><![CDATA[tubes]]></category>
		<category><![CDATA[vacuum tube]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3411</guid>
		<description><![CDATA[Some of these tubes contain small quantities of Cesium-137, Cobalt-60, Radium-226, Krypton-85. The radioactive elements have been added to increase the electronic response by improving the internal ionization processes.]]></description>
				<content:encoded><![CDATA[<p>There are some electronic tubes that contain small quantities of radioactive materials to enhance the internal ionization processes. Such tubes have been used in the 20th century mostly in radar technology. Using a Geiger dosimeter, I have created a top of the tubes in my collection, based on their measured activity.<br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/bTyg9hKEooM" frameborder="0" allowfullscreen></iframe><br />
Some of the radioisotopes used in these tubes are Cesium-137, Cobalt-60, Radium-226, Krypton-85. Because of the small quantities involved and the short half-life, Co-60 and Kr-85 can't be detected outside the corresponding tubes, because these devices are old and with the passing time the radioactive atoms have decayed to stable elements.</p>
<p>Being mostly used in RADAR technology, the radioactive elements have been added to increase the electronic response by improving the internal ionization processes.</p>
<p>The film shows the following tubes, in order: 11TN40, MA340, 313CD, JAN-8370, JAN-4C35, TG-77, EII-43-100, JAN-346B, 1B26, 1B22</p>
<h3>11TN40</h3>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/11TN40_tube_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/11TN40_tube_1-150x150.jpg" alt="11TN40_tube_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3413" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/11TN40_tube_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/11TN40_tube_2-150x150.jpg" alt="11TN40_tube_2" width="150" height="150" class="alignnone size-thumbnail wp-image-3414" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/11TN40_tube_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/11TN40_tube_3-150x150.jpg" alt="11TN40_tube_3" width="150" height="150" class="alignnone size-thumbnail wp-image-3415" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/11TN40_tube_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/11TN40_tube_4-150x150.jpg" alt="11TN40_tube_4" width="150" height="150" class="alignnone size-thumbnail wp-image-3416" /></a></p>
<h3>MA340F</h3>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/MA340F_tube_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/MA340F_tube_1-150x150.jpg" alt="MA340F_tube_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3418" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/MA340F_tube_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/MA340F_tube_2-150x150.jpg" alt="MA340F_tube_2" width="150" height="150" class="alignnone size-thumbnail wp-image-3419" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/MA340F_tube_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/MA340F_tube_3-150x150.jpg" alt="MA340F_tube_3" width="150" height="150" class="alignnone size-thumbnail wp-image-3420" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/MA340F_tube_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/MA340F_tube_4-150x150.jpg" alt="MA340F_tube_4" width="150" height="150" class="alignnone size-thumbnail wp-image-3421" /></a></p>
<h3>313CD</h3>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/313CD_tube_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/313CD_tube_1-150x150.jpg" alt="313CD_tube_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3424" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/313CD_tube_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/313CD_tube_2-150x150.jpg" alt="313CD_tube_2" width="150" height="150" class="alignnone size-thumbnail wp-image-3425" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/313CD_tube_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/313CD_tube_3-150x150.jpg" alt="313CD_tube_3" width="150" height="150" class="alignnone size-thumbnail wp-image-3426" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/313CD_tube_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/313CD_tube_4-150x150.jpg" alt="313CD_tube_4" width="150" height="150" class="alignnone size-thumbnail wp-image-3427" /></a></p>
<h3>JAN-8370</h3>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/jan8370_tube_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/jan8370_tube_1-150x150.jpg" alt="jan8370_tube_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3428" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/jan8370_tube_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/jan8370_tube_2-150x150.jpg" alt="jan8370_tube_2" width="150" height="150" class="alignnone size-thumbnail wp-image-3429" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/jan8370_tube_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/jan8370_tube_3-150x150.jpg" alt="jan8370_tube_3" width="150" height="150" class="alignnone size-thumbnail wp-image-3430" /></a></p>
<h3>JAN-4C35</h3>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/jan4c35_tube_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/jan4c35_tube_1-150x150.jpg" alt="jan4c35_tube_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3432" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/jan4c35_tube_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/jan4c35_tube_2-150x150.jpg" alt="jan4c35_tube_2" width="150" height="150" class="alignnone size-thumbnail wp-image-3433" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/jan4c35_tube_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/jan4c35_tube_3-150x150.jpg" alt="jan4c35_tube_3" width="150" height="150" class="alignnone size-thumbnail wp-image-3434" /></a></p>
<h3>SIGNALITE TG-77</h3>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/signalite_tg77_tube_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/signalite_tg77_tube_1-150x150.jpg" alt="signalite_tg77_tube_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3435" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/signalite_tg77_tube_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/signalite_tg77_tube_2-150x150.jpg" alt="signalite_tg77_tube_2" width="150" height="150" class="alignnone size-thumbnail wp-image-3436" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/signalite_tg77_tube_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/signalite_tg77_tube_3-150x150.jpg" alt="signalite_tg77_tube_3" width="150" height="150" class="alignnone size-thumbnail wp-image-3437" /></a></p>
<h3>EII-43-100</h3>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/eii_43_100_tube_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/eii_43_100_tube_1-150x150.jpg" alt="eii_43_100_tube_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3439" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/eii_43_100_tube_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/eii_43_100_tube_2-150x150.jpg" alt="eii_43_100_tube_2" width="150" height="150" class="alignnone size-thumbnail wp-image-3440" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/eii_43_100_tube_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/eii_43_100_tube_3-150x150.jpg" alt="eii_43_100_tube_3" width="150" height="150" class="alignnone size-thumbnail wp-image-3441" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/eii_43_100_tube_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/eii_43_100_tube_4-150x150.jpg" alt="eii_43_100_tube_4" width="150" height="150" class="alignnone size-thumbnail wp-image-3442" /></a></p>
<h3>JAN-346B</h3>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/jan346_tube_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/jan346_tube_1-150x150.jpg" alt="jan346_tube_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3443" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/jan346_tube_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/jan346_tube_2-150x150.jpg" alt="jan346_tube_2" width="150" height="150" class="alignnone size-thumbnail wp-image-3444" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/jan346_tube_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/jan346_tube_3-150x150.jpg" alt="jan346_tube_3" width="150" height="150" class="alignnone size-thumbnail wp-image-3445" /></a></p>
<h3>1B26</h3>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/1b26_tube_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/1b26_tube_1-150x150.jpg" alt="1b26_tube_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3446" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/1b26_tube_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/1b26_tube_2-150x150.jpg" alt="1b26_tube_2" width="150" height="150" class="alignnone size-thumbnail wp-image-3447" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/1b26_tube_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/1b26_tube_3-150x150.jpg" alt="1b26_tube_3" width="150" height="150" class="alignnone size-thumbnail wp-image-3448" /></a></p>
<h3>1B22</h3>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/1b22_tube_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/1b22_tube_1-150x150.jpg" alt="1b22_tube_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3449" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/1b22_tube_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/1b22_tube_2-150x150.jpg" alt="1b22_tube_2" width="150" height="150" class="alignnone size-thumbnail wp-image-3450" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/1b22_tube_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/1b22_tube_3-150x150.jpg" alt="1b22_tube_3" width="150" height="150" class="alignnone size-thumbnail wp-image-3451" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/12/top-of-radioactive-electronic-tubes/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Digital Soldering station ZD937</title>
		<link>http://www.pocketmagic.net/2012/12/digital-soldering-station-zd937/</link>
		<comments>http://www.pocketmagic.net/2012/12/digital-soldering-station-zd937/#comments</comments>
		<pubDate>Tue, 25 Dec 2012 14:42:09 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Optics]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[Christmas]]></category>
		<category><![CDATA[Christmas tree]]></category>
		<category><![CDATA[digital]]></category>
		<category><![CDATA[lcd]]></category>
		<category><![CDATA[leds]]></category>
		<category><![CDATA[light installation]]></category>
		<category><![CDATA[mains]]></category>
		<category><![CDATA[multiple leds]]></category>
		<category><![CDATA[regulated temperature]]></category>
		<category><![CDATA[soldering station]]></category>
		<category><![CDATA[variable temperature]]></category>
		<category><![CDATA[zd-937]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3597</guid>
		<description><![CDATA[A short review on my new Christmas gift, a neat digital soldering station, ZD 937, and a quick light installation that I did with LEDS, running directly on mains , 220V, using the ZD937.]]></description>
				<content:encoded><![CDATA[<p>Santa brought me this little jewel, knowing how much I needed one. Thanks, <a href="http://www.thousandwishes.net">Santa</a>, love my new toy, promise to put it to some good use for the months to come - with the tens of exciting new projects I have in mind.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2013/01/ZD937_digital_soldering_station_pocketmagic.net_.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/ZD937_digital_soldering_station_pocketmagic.net_.jpg" alt="ZD937_digital_soldering_station_pocketmagic.net" width="504" height="428" class="alignnone size-full wp-image-3598" /></a><br />
The ZD937 comes packed with everything you would need from a soldering station, making it an ideal tool for most areas of this field; I plan to use it for all my constructions from now on, saying good bye to my simple soldering iron, that so often burned my components with its unregulated extra hot tip.</p>
<p>The soldering station can regulate temperature in precise discrete steps: 1 degree or 10 degrees per button push up/down, but it can also jump directly to predefined values: 200,300,400 degrees Celsius. There's also a Fahrenheit conversion button, but I don't really need that since we use Celsius here. The values are displayed on its big LCD, and all options are available by the use of large push buttons, making the operation easy and comfortable, allowing the user to focus on the target PCB.</p>
<p>The Soldering Iron is connected to the base via a flexible cable, and the holder is robust, avoiding any accidental burns due to unexpected overturns.</p>
<p>The tips are interchangeable, and I've located multiple providers with good price offers. Here's <a href="http://www.minib2b.com/tips-for-soldering-station-zd-937-p-95240.html">one</a>. Changing the tip is easy, but nevertheless I expect the default one to last for a while.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/zd_937_soldering_station_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/zd_937_soldering_station_1-150x150.jpg" alt="zd_937_soldering_station_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3600" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/zd_937_soldering_station_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/zd_937_soldering_station_2-150x150.jpg" alt="zd_937_soldering_station_3" width="150" height="150" class="alignnone size-thumbnail wp-image-3602" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/zd_937_soldering_station_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/zd_937_soldering_station_3-150x150.jpg" alt="zd_937_soldering_station_3" width="150" height="150" class="alignnone size-thumbnail wp-image-3602" /></a><br />
<b>Specs:</b><br />
Power supply voltage: 110volt (110volt-130volt) /60Hz and 230volt (220volt-240volt) /50Hz<br />
Electric iron Power: 48watt<br />
Equipment power supply fuse:T1 A250volt(50x20mm glass pipe)<br />
Regulating scope of temperature: 150-450<br />
Temperature display:2*31/2grades LCD display, display interval:150-450<br />
Display precision:5%<br />
Allowed use humidity:+5-+40,relative humidity <85%<br />
Atmospheric pressure:600hpa-1000hpa<br />
Case size:210x125x135mm width/height/depth(Without electric iron)<br />
Weight:about 1800grams</p>
<p><b>The spare parts:</b><br />
Spare soldering iron<br />
88-201A 	24V 	48W 	with temperature probe</p>
<p>Spare tip<br />
79-1116 	TIP N1-16 	Hi quality<br />
79-1126 	TIP N1-26<br />
79-1136 	TIP N1-36<br />
79-1146 	TIP N1-46<br />
79-1156 	TIP N1-56</p>
<p>Spare heater<br />
78-201A 	24V 	48W 	88-201A 	with temperature probe</p>
<p>Sponge<br />
79-7301 	57x37mm</p>
<h3>Christmas tree light installation with leds running on mains</h3>
<p>Since it is Christmas which brings some free time, and my wife's favorite Christmas three light installation was broken, I decided to fix it using my new ZD 937. That included changing the original 24V bulbs (hard to find nowadays) to big white leds, running directly on mains (220V). I used this approach:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/led-220V.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/led-220V.jpg" alt="led 220V" width="362" height="304" class="alignnone size-full wp-image-3603" /></a><br />
And mounted everything on a test board, making sure it would fit the original little plastic case connector , that came with this light installation:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/220v_led_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/220v_led_1-150x150.jpg" alt="220v_led_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3604" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/220v_led_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/220v_led_2-150x150.jpg" alt="220v_led_2" width="150" height="150" class="alignnone size-thumbnail wp-image-3605" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/220v_led_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/220v_led_3-150x150.jpg" alt="220v_led_3" width="150" height="150" class="alignnone size-thumbnail wp-image-3606" /></a><br />
After a quick test, everything was ready to go. A lovely result I would say, and nice to know this light installation won't be breaking again, nowhere soon at least, that's for sure.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/diy_light_installation_led_running_on_mains_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/diy_light_installation_led_running_on_mains_1-150x150.jpg" alt="diy_light_installation_led_running_on_mains_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3607" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/diy_light_installation_led_running_on_mains_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/diy_light_installation_led_running_on_mains_2-150x150.jpg" alt="diy_light_installation_led_running_on_mains_2" width="150" height="150" class="alignnone size-thumbnail wp-image-3608" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/diy_light_installation_led_running_on_mains_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/diy_light_installation_led_running_on_mains_3-150x150.jpg" alt="diy_light_installation_led_running_on_mains_3" width="150" height="150" class="alignnone size-thumbnail wp-image-3609" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/diy_light_installation_led_running_on_mains_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/diy_light_installation_led_running_on_mains_4-150x150.jpg" alt="diy_light_installation_led_running_on_mains_4" width="150" height="150" class="alignnone size-thumbnail wp-image-3610" /></a></p>
<h3>Merry Christmas to all of you!</h3>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/12/digital-soldering-station-zd937/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DIY/Homemade Radiation Geiger Dosimeter</title>
		<link>http://www.pocketmagic.net/2012/12/diyhomemade-portable-radiation-dosimeter/</link>
		<comments>http://www.pocketmagic.net/2012/12/diyhomemade-portable-radiation-dosimeter/#comments</comments>
		<pubDate>Sat, 01 Dec 2012 15:01:28 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Nuclear]]></category>
		<category><![CDATA[atmega8]]></category>
		<category><![CDATA[bluetooth]]></category>
		<category><![CDATA[digital]]></category>
		<category><![CDATA[diy]]></category>
		<category><![CDATA[dosimeter]]></category>
		<category><![CDATA[dosimetry]]></category>
		<category><![CDATA[geiger counter]]></category>
		<category><![CDATA[geiger muller]]></category>
		<category><![CDATA[homemade]]></category>
		<category><![CDATA[microcontrollers]]></category>
		<category><![CDATA[SBM-19]]></category>
		<category><![CDATA[SBM-20]]></category>
		<category><![CDATA[STS-1]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3342</guid>
		<description><![CDATA[A digital dosimeter design that can be used with multiple geiger tubes, constructed around the atmega8 microcontroller and a 2x16 LCD. Equipped with a radio Bluetooth module for remote operation.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_dosimeter.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_dosimeter.jpg" alt="geiger counter dosimeter" width="800" height="311" class="alignnone size-full wp-image-3355" /></a><br />
Given all my previous experience with Geiger Counters (see for example my <a href="http://www.pocketmagic.net/?p=3155">uRadMonitor </a>project), I have decided to conceive a portable, easy to build, <strong>radiation dosimeter</strong> . I didn't have much need for yet another dosimeter (with my <a href="http://www.pocketmagic.net/2010/04/radex-rd1706-dosimeter/">Radex 1706</a> or <a href="http://www.pocketmagic.net/2009/12/terra-p-radiation-dosimeter-mks-05/">Terra-P</a>), but I know there are several people not affording a commercial unit, but wanting to have their own radiation measurement tool. So here is this article, giving you just that: an efficient, stable, easy to build construction for all your radiation dosimetry needs.</p>
<h3>Short description</h3>
<p>I started from scratch, designing a complete dosimeter unit around the Atmel Atmega8 microcontroller and a Russian Geiger Muller tube. Here you'll see the CTC-1 tube, for high gamma doses, but the dosimeter can be used with any other tubes such as SBM-20, LND-712 or more sensitive ones such as the<a href="www.pocketmagic.net/?p=2397"> SBM-19</a> or the <a href="www.pocketmagic.net/?p=1216">pancake tube SI-14B</a>. Changing the tube requires changing the software, to adjust the dose conversion calculation. This circuit can be used with almost any geiger tube, as even the inverter's output voltage driving the tube is adjustable in the software.<br />
Here is a video showing a high count rate when using a Si12b tube and Am241 alpha emitter from a smoke detector:<br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/de_A6qBKO0M" frameborder="0" allowfullscreen></iframe></p>
<p>Similar to my <a href="http://pocketmagic.net/?p=3155">uRADMonitor</a>, the micro-controller takes care of everything:<br />
1. Generates a variable duty PWM signal using Timer1, to drive the 400V inverter needed to operate the Geiger tube; The inverter doesn't need a multiplier, as the ferrite's transformer secondary puts out exactly the amount required. The transformer is made on a A22 ferrite core, with 16 turns in the primary and 600 in the secondary.<br />
2. Uses one ADC port to measure the inverter's voltage and adjust the PWM duty cycle for constant output (exactly 400V for stable operation)<br />
3. Counts the time, using Timer0 so we can compute the dose<br />
4. Uses interrupt INT0 to count the pulses produced by the Geiger tube<br />
5. Drives a <a href="www.pocketmagic.net/?p=447">2x16 LCD</a> to output the results.<br />
Some other circuits on the Internet come with improper 400V inverters (some people seem not to be able to design a proper inverter), they are redundant (using 555's and additional components, when the microcontroller can take care of EVERYTHING), use the wrong signal detection/counter circuit, or other small defects that result in wrong measurements. Not to mention the complicated aspect of computing dose in sieverts out of counts per minute.<br />
Given all these wrong designs, my detector tries to fill in some of the gaps. So here is exactly what you need: a stable design, with several improvements made over time, all packed in this nice construction that you can easily replicate. </p>
<h3>Some pictures</h3>
<p>Before getting into the construction details, and the theory involved in my geiger counter, here are some pictures of my construction. I might use them later to point out critical aspects of the construction.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_01.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_01-150x150.jpg" alt="geiger_counter_dosimeter_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3359" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_02.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_02-150x150.jpg" alt="geiger_counter_dosimeter_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3359" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_03.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_03-150x150.jpg" alt="geiger_counter_dosimeter_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3359" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_04.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_04-150x150.jpg" alt="geiger_counter_dosimeter_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3359" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_05.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_05-150x150.jpg" alt="geiger_counter_dosimeter_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3359" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_06.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_06-150x150.jpg" alt="geiger_counter_dosimeter_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3359" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_07.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_07-150x150.jpg" alt="geiger_counter_dosimeter_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3359" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_08.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_08-150x150.jpg" alt="geiger_counter_dosimeter_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3359" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_09.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_09-150x150.jpg" alt="geiger_counter_dosimeter_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3359" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_10.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_10-150x150.jpg" alt="geiger_counter_dosimeter_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3359" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_11.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_11-150x150.jpg" alt="geiger_counter_dosimeter_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3359" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_12.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_12-150x150.jpg" alt="geiger_counter_dosimeter_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3359" /></a></p>
<h3>Building the Ferrite transformer</h3>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger-transformer-coil-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger-transformer-coil-1-150x150.jpg" alt="geiger transformer coil 1" width="150" height="150" class="alignnone size-thumbnail wp-image-4298" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger-transformer-coil-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger-transformer-coil-2-150x150.jpg" alt="geiger transformer coil 2" width="150" height="150" class="alignnone size-thumbnail wp-image-4299" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger-transformer-coil-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger-transformer-coil-3-150x150.jpg" alt="geiger transformer coil 3" width="150" height="150" class="alignnone size-thumbnail wp-image-4300" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger-transformer-coil-4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger-transformer-coil-4-150x150.jpg" alt="geiger transformer coil 4" width="150" height="150" class="alignnone size-thumbnail wp-image-4301" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger-transformer-coil-5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger-transformer-coil-5-150x150.jpg" alt="geiger transformer coil 5" width="150" height="150" class="alignnone size-thumbnail wp-image-4302" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger-transformer-coil-6.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger-transformer-coil-6-150x150.jpg" alt="geiger transformer coil 6" width="150" height="150" class="alignnone size-thumbnail wp-image-4303" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger-transformer-coil-7.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger-transformer-coil-7-150x150.jpg" alt="geiger transformer coil 7" width="150" height="150" class="alignnone size-thumbnail wp-image-4304" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger-transformer-coil-8.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger-transformer-coil-8-150x150.jpg" alt="geiger transformer coil 8" width="150" height="150" class="alignnone size-thumbnail wp-image-4305" /></a></p>
<h3>Building the case</h3>
<p>Once again, I used PVC pipes as a good source of plastic sheets. Here is another case I built for this Geiger dosimeter:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_13.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_13-150x150.jpg" alt="geiger_counter_dosimeter_13" width="150" height="150" class="alignnone size-thumbnail wp-image-3372" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_14.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_14-150x150.jpg" alt="geiger_counter_dosimeter_14" width="150" height="150" class="alignnone size-thumbnail wp-image-3373" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_15.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_15-150x150.jpg" alt="geiger_counter_dosimeter_15" width="150" height="150" class="alignnone size-thumbnail wp-image-3374" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_16.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_16-150x150.jpg" alt="geiger_counter_dosimeter_16" width="150" height="150" class="alignnone size-thumbnail wp-image-3375" /></a></p>
<h3>And the result</h3>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_17.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_17-150x150.jpg" alt="geiger_counter_dosimeter_17" width="150" height="150" class="alignnone size-thumbnail wp-image-3377" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_18.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_18-150x150.jpg" alt="geiger_counter_dosimeter_18" width="150" height="150" class="alignnone size-thumbnail wp-image-3378" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_19.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_19-150x150.jpg" alt="geiger_counter_dosimeter_19" width="150" height="150" class="alignnone size-thumbnail wp-image-3379" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_20.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_dosimeter_20-150x150.jpg" alt="geiger_counter_dosimeter_20" width="150" height="150" class="alignnone size-thumbnail wp-image-3380" /></a></p>
<h3>Construction details</h3>
<p>The circuit diagram can be seen here:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_schematics.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_counter_schematics-300x153.png" alt="geiger_counter_schematics" width="300" height="153" class="alignnone size-medium wp-image-3382" /></a><br />
I had some issues with my first PCB that are now fixed. Here is the final PCB version:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/pcb-1.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/pcb-1-150x150.png" alt="pcb-1" width="150" height="150" class="alignnone size-thumbnail wp-image-3385" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/pcb-2.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/pcb-2-150x150.png" alt="pcb-2" width="150" height="150" class="alignnone size-thumbnail wp-image-3386" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/pcb-3.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/pcb-3-150x150.png" alt="pcb-3" width="150" height="150" class="alignnone size-thumbnail wp-image-3387" /></a></p>
<h3>Battery pack</h3>
<p>Besides using an external power adapter, I added rechargeable batteries to this device so it can operate on independently. 4 AAA NiMH batteries have been packed together using my <a href="www.pocketmagic.net/?p=2518">micro-spot capacitor welder</a>, and inserted in the bottom part of the case.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/battery_pack_welder_01.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/battery_pack_welder_01-150x150.jpg" alt="battery_pack_welder_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3399" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/battery_pack_welder_02.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/battery_pack_welder_02-150x150.jpg" alt="battery_pack_welder_02" width="150" height="150" class="alignnone size-thumbnail wp-image-3400" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/battery_pack_welder_03.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/battery_pack_welder_03-150x150.jpg" alt="battery_pack_welder_03" width="150" height="150" class="alignnone size-thumbnail wp-image-3401" /></a></p>
<h3>Bluetooth Module and remote radiation monitor capabilities - optional</h3>
<p>You might be familiar with the The <a href="http://www.civildefensemuseum.com/cdmuseum2/radkits/cdv717.html">CD V-717</a> that was designed for use in fallout monitoring stations. This detector has a removable bottom with a 25 foot extension cable. The detector element (ion-chamber) is mounted inside the removable bottom. This allows for the placement of the detector element outside of the shelter area while the metering section of the metering unit would remain inside of the shelter area connected to the detector with the 25 foot cable.<br />
In a similar fashion remote operation is possible on my dosimeter, by using... Bluetooth. Hooked to the main microcontroller, there is an UART Bluetooth module packed with its 3.3V regulator. The software running on the atmega8, sends measured dose rate values, via UART (Rx/Tx) to the Bluetooth module.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_dosimeter_bluetooth_pocketmagic.net_.1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_dosimeter_bluetooth_pocketmagic.net_.1-150x150.jpg" alt="geiger_dosimeter_bluetooth_pocketmagic.net.1" width="150" height="150" class="alignnone size-thumbnail wp-image-3514" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_dosimeter_bluetooth_pocketmagic.net_.2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/geiger_dosimeter_bluetooth_pocketmagic.net_.2-150x150.jpg" alt="geiger_dosimeter_bluetooth_pocketmagic.net.2" width="150" height="150" class="alignnone size-thumbnail wp-image-3515" /></a><br />
By doing so, a mobile phone can be used to read the radiation data, from a remote location, without being exposed to what the dosimeter actually measures. Currently I wrote an application for Android phones, that can search nearby bluetooth modules, find the dosimeter, connect to it and display the dose rate, as received via the radio connection. Here is a demo video:<br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/Fd8D6guujIg" frameborder="0" allowfullscreen></iframe><br />
For the Android software, see the bottom of this article.</p>
<h3>Showing the Dosimeter on TVR Timisoara</h3>
<p>Thanks to Andrei Borosovici, I had the chance to discuss this topic on  "Vezi ce-ti doresti" TV Show running on TVR Timisoara. Here is the 14.01.2013 recording, in Romanian:<br />
<iframe width="800" height="600" src="http://www.youtube.com/embed/WXmPR-FNbIg" frameborder="0" allowfullscreen></iframe></p>
<h3>More on Geiger Counters</h3>
<p>Here is a list with must-read resources:<br />
<a href="http://www.pocketmagic.net/?p=3155">uRadMonitor - a Geiger counter radiation monitoring station (v3.3)</a><br />
<a href="http://www.centronic.co.uk/downloads/Geiger_Tube_theory.pdf">Centronic Geiger Muller tubes</a><br />
<a href="http://www.pocketmagic.net/?p=2457">A simple Geiger counter (v3.2)</a></p>
<h3>License</h3>
<p>This work is free software, licensed under GPL v2; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. For other licensing options, feel free to contact me.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/gpl-2.0.txt">License for using my work</a></p>
<h3>HEX Firmware for the Atmega-8</h3>
<p>STS-1 geiger tube: <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/GMD_STS-1.zip">GMD_STS-1</a><br />
SBM-19 geiger tube: <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/GMD_SBM-19.zip">GMD_SBM-19</a><br />
For changing the firmware to make the dosimeter work with other Geiger tubes, contact me.</p>
<h3>Source code and other resources</h3>
<p>Eagle SCH and PCB: <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/urad_dosimeter_3.4.zip">download</a><br />
Dosimeter source code: The code is available on <a href="http://code.google.com/p/geiger-dosimeter-v3-4/">Google Code</a>, under GPL. Use it only if you understand the terms of Open Source software distributed under GPL.<br />
You can also download it <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/Offline-3.4.2.121.A.zip">here</a>.<br />
Optional, if UART Bluetooth module has been added to the dosimeter: <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/DosimeterAndroid.zip">Bluetooth Dosimeter Android Application</a></p>
<h3>Here are some variants created by my readers</h3>
<p><b>DREDD Dosimeter</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/dredd_dosimeter_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/dredd_dosimeter_1-150x150.jpg" alt="dredd_dosimeter_1" width="150" height="150" class="alignnone size-thumbnail wp-image-4293" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/dredd_dosimeter_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/dredd_dosimeter_2-150x150.jpg" alt="dredd_dosimeter_2" width="150" height="150" class="alignnone size-thumbnail wp-image-4294" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/dredd_dosimeter_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/dredd_dosimeter_3-150x150.jpg" alt="dredd_dosimeter_3" width="150" height="150" class="alignnone size-thumbnail wp-image-4295" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/12/dredd_dosimeter_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/12/dredd_dosimeter_4-150x150.jpg" alt="dredd_dosimeter_4" width="150" height="150" class="alignnone size-thumbnail wp-image-4296" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/12/diyhomemade-portable-radiation-dosimeter/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>BMP085 Barometric pressure sensor</title>
		<link>http://www.pocketmagic.net/2012/11/bmp085-barometric-pressure-sensor/</link>
		<comments>http://www.pocketmagic.net/2012/11/bmp085-barometric-pressure-sensor/#comments</comments>
		<pubDate>Sun, 11 Nov 2012 20:19:58 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[altitude]]></category>
		<category><![CDATA[atmega168]]></category>
		<category><![CDATA[atmega328p]]></category>
		<category><![CDATA[atmega8]]></category>
		<category><![CDATA[barometric pressure]]></category>
		<category><![CDATA[bmp085]]></category>
		<category><![CDATA[microcontrollers]]></category>
		<category><![CDATA[pressure]]></category>
		<category><![CDATA[sensor]]></category>
		<category><![CDATA[temperature]]></category>
		<category><![CDATA[temperature sensor]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3333</guid>
		<description><![CDATA[The BMP085 is a compact, low power sensor for reading temperature, barometric pressure and altitude. See it in use with Atmel microprocessors.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/11/barometric_pressure_sensor_bmp085.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/11/barometric_pressure_sensor_bmp085.jpg" alt="" title="barometric_pressure_sensor_bmp085" width="800" height="311" class="alignnone size-full wp-image-3334" /></a><br />
I needed to add pressure reading capabilities to my radiation monitoring station, <a href="http://www.pocketmagic.net/?p=3155">uRadMonitor</a>. For barometric pressure, there aren't many options when it comes to sensors. I stumbled upon the Bosch BMP085 sensor, described as a highly sensitive sensor that can sense differences for each 9cm of an air column. Besides pressure, it also offers temperature data, all packed nicely in a compact module.<br />
The only "problem" is that it provides digital data output, via the i2c bus. My other sensors where not using it, so I had to add the i2c code solely for this sensor, resulting in higher software size.</p>
<p><b>Key features:</b><br />
Pressure range: 300..1100hPa (+9000m ... -500m above sea level)<br />
Supply voltage: 1.8..3.6V (Vdda) 1.62V..3.6V (Vddd)<br />
Low power: 5uA at 1sample/sec in standard mode<br />
Low noise: 0.06hPa (0.5m) in ultra low power mode ; 0.03hPa (0.25m) ultra high resolution mode<br />
Operating temperature: operational in -40..+85°C, with full accuracy in 0..+65°C<br />
Resolution of output data: 1Pa for pressure, 0.1°C for temperature<br />
Complete <a href="http://www.bosch-sensortec.com/content/language1/downloads/BST-BMP085-DS000-05.pdf">datasheet here</a>.</p>
<p>On Earth, standard atmospheric pressure is 101 325 Pa. Meteorological barometric pressure reports typically report atmospheric pressure in hectopascals. More <a href="http://en.wikipedia.org/wiki/Pascal_%28unit%29">here</a>. The BMP085 returns the measured pressure in Pascals and the temperature in degrees Celsius. </p>
<p>The BMP085 is designed to be connected directly to a  microcontroller via the i2c bus. The pressure and temperature data has to be compensated by the calibration data of the EPROM of the BMP085. Reading the calibration done must be done only once, before reading the pressure or temperature data:</p>
<pre class="c"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">void</span> getcalibration<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	uint8_t buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	memset<span style="color: #66cc66;">&#40;</span>buff, <span style="color: #cc66cc;">0</span>, <span style="color: #993333;">sizeof</span><span style="color: #66cc66;">&#40;</span>buff<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #808080; font-style: italic;">//ac1 = read16(BMP085_CAL_AC1);</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	bmp085_readmem<span style="color: #66cc66;">&#40;</span>BMP085_REGAC1, buff, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	ac1 = <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> &lt;&lt;<span style="color: #cc66cc;">8</span> | <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	bmp085_readmem<span style="color: #66cc66;">&#40;</span>BMP085_REGAC2, buff, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	ac2 = <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> &lt;&lt;<span style="color: #cc66cc;">8</span> | <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	bmp085_readmem<span style="color: #66cc66;">&#40;</span>BMP085_REGAC3, buff, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	ac3 = <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> &lt;&lt;<span style="color: #cc66cc;">8</span> | <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	bmp085_readmem<span style="color: #66cc66;">&#40;</span>BMP085_REGAC4, buff, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	ac4 = <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> &lt;&lt;<span style="color: #cc66cc;">8</span> | <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	bmp085_readmem<span style="color: #66cc66;">&#40;</span>BMP085_REGAC5, buff, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	ac5 = <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> &lt;&lt;<span style="color: #cc66cc;">8</span> | <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	bmp085_readmem<span style="color: #66cc66;">&#40;</span>BMP085_REGAC6, buff, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	ac6 = <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> &lt;&lt;<span style="color: #cc66cc;">8</span> | <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	bmp085_readmem<span style="color: #66cc66;">&#40;</span>BMP085_REGB1, buff, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	b1 = <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> &lt;&lt;<span style="color: #cc66cc;">8</span> | <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	bmp085_readmem<span style="color: #66cc66;">&#40;</span>BMP085_REGB2, buff, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	b2 = <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> &lt;&lt;<span style="color: #cc66cc;">8</span> | <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	bmp085_readmem<span style="color: #66cc66;">&#40;</span>BMP085_REGMB, buff, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	mb = <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> &lt;&lt;<span style="color: #cc66cc;">8</span> | <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	bmp085_readmem<span style="color: #66cc66;">&#40;</span>BMP085_REGMC, buff, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	mc = <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> &lt;&lt;<span style="color: #cc66cc;">8</span> | <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	bmp085_readmem<span style="color: #66cc66;">&#40;</span>BMP085_REGMD, buff, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	md = <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> &lt;&lt;<span style="color: #cc66cc;">8</span> | <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>buff<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>I used a BMP085 breakout board, that already has thee 4.7k pull-up resistor on the SDA and SCL pins. </p>
<p>Knowing the pressure it is possible to compute the altitude. A convenient alternative to GPS!</p>
<pre class="c"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// we assume sea level pressure is 101325 Pa</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">float</span> convertAltitude<span style="color: #66cc66;">&#40;</span>int32_t pressure<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span> - pow<span style="color: #66cc66;">&#40;</span>pressure/<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">double</span><span style="color: #66cc66;">&#41;</span><span style="color: #cc66cc;">101325</span>, <span style="color: #cc66cc;">0.1903</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> / <span style="color: #cc66cc;">0.0000225577</span><span style="color: #66cc66;">&#41;</span>;	</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>Here is the code, based on Davide Gironi's work on the BMP085, and the i2c interface originally developed by Peter Fleury.<br />
<a href='http://www.pocketmagic.net/wp-content/uploads/2012/11/BMP085.zip'>BMP085</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/11/bmp085-barometric-pressure-sensor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Temperature and Humidity sensor DHT-22</title>
		<link>http://www.pocketmagic.net/2012/11/temperature-and-humidity-sensor-dht-22/</link>
		<comments>http://www.pocketmagic.net/2012/11/temperature-and-humidity-sensor-dht-22/#comments</comments>
		<pubDate>Fri, 09 Nov 2012 15:47:15 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[atmega8]]></category>
		<category><![CDATA[dht-22]]></category>
		<category><![CDATA[dht22]]></category>
		<category><![CDATA[microcontrollers]]></category>
		<category><![CDATA[pressure]]></category>
		<category><![CDATA[sensor]]></category>
		<category><![CDATA[temperature]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3302</guid>
		<description><![CDATA[DHT-22 is a small size, compact, dual temperature and humidity sensor featuring one-wire connectivity.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/11/header_dht_22.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/11/header_dht_22.jpg" alt="" title="header_dht_22" width="800" height="311" class="alignnone size-full wp-image-3303" /></a><br />
Also known as  RHT-22, RHT-03 and AM2302, the DHT-22 is a small size, compact, dual temperature and humidity sensor. I purchased it to replace the DHT-11 in my <a href="http://www.pocketmagic.net/?p=3155">uRADMonitor </a>radiation monitor station.</p>
<p><b>Specs:</b><br />
Model RHT03<br />
Power supply 3.3-6V DC<br />
Output signal digital signal via MaxDetect 1-wire bus<br />
Sensing element Polymer humidity capacitor<br />
Operating range humidity 0-100%RH; temperature -40~80Celsius<br />
Accuracy humidity +-2%RH(Max +-5%RH); temperature +-0.5Celsius<br />
Resolution or sensitivity humidity 0.1%RH; temperature 0.1Celsius<br />
Repeatability humidity +-1%RH; temperature +-0.2Celsius</p>
<p><b>Datasheet:</b> <a href="http://www.adafruit.com/datasheets/DHT22.pdf">here</a></p>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/11/dht22_atmega8.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/11/dht22_atmega8-300x218.jpg" alt="" title="dht22_atmega8" width="300" height="218" class="alignnone size-medium wp-image-3304" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/11/atmega8_dht22.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/11/atmega8_dht22-300x243.png" alt="" title="atmega8_dht22" width="300" height="243" class="alignnone size-medium wp-image-3305" /></a></p>
<h3>Here are some variants created by my readers</h3>
<p><b>Vanja's DHT22 board</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/11/vanja_dht22.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/11/vanja_dht22-150x150.jpg" alt="vanja_dht22" width="150" height="150" class="alignnone size-thumbnail wp-image-3713" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/11/vanja_dht22-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/11/vanja_dht22-2-150x150.jpg" alt="vanja_dht22-2" width="150" height="150" class="alignnone size-thumbnail wp-image-3714" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/11/DHT22.zip">DHT22 Eagle SCH</a></p>
<p><b>Source code:</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/11/DHT-22_16Mhz.zip">DHT-22, Atmega8 with 16Mhz</a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/11/DHT-22_8Mhz.zip">DHT-22, Atmega8 with 8Mhz</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/11/temperature-and-humidity-sensor-dht-22/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>HC-SR04 Sonar with Atmega8 microcontroller</title>
		<link>http://www.pocketmagic.net/2012/11/hc-sr04-sonar-with-atmega8-microcontroller/</link>
		<comments>http://www.pocketmagic.net/2012/11/hc-sr04-sonar-with-atmega8-microcontroller/#comments</comments>
		<pubDate>Sun, 04 Nov 2012 13:07:55 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[atmega8]]></category>
		<category><![CDATA[atmel]]></category>
		<category><![CDATA[avr]]></category>
		<category><![CDATA[HC-SR04]]></category>
		<category><![CDATA[microcontrollers]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3293</guid>
		<description><![CDATA[Build an ultrasonic sonar for non-contact distance measurements, using an Atmega8 and a HC-SR04]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/11/header.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/11/header.jpg" alt="" title="header" width="800" height="311" class="alignnone size-full wp-image-3296" /></a></p>
<p>The <b>HC-SR04</b> is an Ultrasonic ranging module. It provides 2cm - 400cm non-contact measurement function, the ranging accuracy can reach to 3mm. The module includes the ultrasonic transmitter, receiver and control circuit. </p>
<p><b>The basic principle is:</b><br />
(1) Using IO TRIG Pin, trigger for at least 10us high level signal ,<br />
(2) The Module automatically sends eight 40 kHz and detect whether there is a return signal.<br />
(3) If the ultrasonic signal returns, the time elapsed is used to compute distance, knowing the sound speed in air: Test distance = (high level time×velocity of sound (340M/S) / 2<br />
<b>Datasheet</b>: available <a href="http://www.micropik.com/PDF/HCSR04.pdf">here</a>.<br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/fefG4K14QBo" frameborder="0" allowfullscreen></iframe></p>
<p><b>Circuit diagram:</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/11/circuit_hc_sr04.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/11/circuit_hc_sr04-300x152.png" alt="" title="circuit_hc_sr04" width="300" height="152" class="alignnone size-medium wp-image-3299" /></a></p>
<h3>Here are some variants created by my readers</h3>
<p>Glide built a nice PCB for this sonar. Here are his pics and the eagle files (SCH+PCB)<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/11/sonar-merge-001.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/11/sonar-merge-001-150x150.jpg" alt="sonar merge 001" width="150" height="150" class="alignnone size-thumbnail wp-image-3718" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/11/sonar-merge-002.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/11/sonar-merge-002-150x150.jpg" alt="sonar merge 002" width="150" height="150" class="alignnone size-thumbnail wp-image-3719" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/11/sonar-merge-003.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/11/sonar-merge-003-150x150.jpg" alt="sonar merge 003" width="150" height="150" class="alignnone size-thumbnail wp-image-3720" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/11/glide-sonar-eagle.zip">glide sonar eagle</a></p>
<p><b>Source code:</b><br />
<a href='http://www.pocketmagic.net/wp-content/uploads/2012/11/Sonar-HC_SR04.zip'>Sonar HC_SR04</a><br />
Thanks to <a href="http://www.wzona.info/2012/09/echolokacija-naudojant-hc-sr04.html">wzona</a>. It comes with excellent details, make sure you check it out.</p>
<p>A few pics with the sonar used with a 5110 Nokia graphical LCD. Code for the LCD available <a href="http://www.pocketmagic.net/2013/04/atmega8-and-nokia-5110-lcd/">here</a>.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/11/5110_lcd_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/11/5110_lcd_1-300x199.jpg" alt="5110_lcd_1" width="300" height="199" class="alignnone size-medium wp-image-4037" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/11/5110_lcd_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/11/5110_lcd_2-300x199.jpg" alt="5110_lcd_2" width="300" height="199" class="alignnone size-medium wp-image-4038" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/11/hc-sr04-sonar-with-atmega8-microcontroller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Statie de monitorizare a radiatiei de fond in Timisoara</title>
		<link>http://www.pocketmagic.net/2012/10/statie-de-monitorizare-a-fondului-de-radiatii-gamma-in-timisoara/</link>
		<comments>http://www.pocketmagic.net/2012/10/statie-de-monitorizare-a-fondului-de-radiatii-gamma-in-timisoara/#comments</comments>
		<pubDate>Tue, 30 Oct 2012 15:28:02 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Nuclear]]></category>
		<category><![CDATA[doza radiatii]]></category>
		<category><![CDATA[fond natural]]></category>
		<category><![CDATA[gamma]]></category>
		<category><![CDATA[monitorizare]]></category>
		<category><![CDATA[nivel radiatii]]></category>
		<category><![CDATA[radiatii]]></category>
		<category><![CDATA[radiatii ionizante]]></category>
		<category><![CDATA[radioactiv]]></category>
		<category><![CDATA[radioactivitate]]></category>
		<category><![CDATA[statie]]></category>
		<category><![CDATA[Timisoara]]></category>
		<category><![CDATA[usv/h]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3253</guid>
		<description><![CDATA[Locuiesc in Timisoara, si de curand am terminat o statie de monitorizare a nivelului de radiatii de fond. Cu exceptia catorva institute din tara, care rar dau publice graficele, statia mea e probabil singura alternativa de acest gen, accesibila utilizatorului obisnuit. Acest articol, redactat in romana, prezinta detalii asupra statiei, explica ce este radiatia de fond si cum apare ea,  dar si ilustreaza grafice in timp real.
]]></description>
				<content:encoded><![CDATA[<p><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/header.jpg"><br />
<img src="http://pocketmagic.net/en.gif">For English, <a href="http://www.pocketmagic.net/?p=3155">click here</a>.<br />
<img src="http://pocketmagic.net/ro.gif"><br />
<h3>Introducere</h3>
<p><b>Locuiesc in Timisoara.</b> De curand am terminat o statie de monitorizare a fondului de radiatii, numita uRADMonitor. Statia e montata in exteriorul imobilului, si functioneaza la foc continuu, 24/7, pentru a masura variatii ale fondului de radiatii. <a href="#charts">Mai jos</a> ofer acces public la datele colectate. Variatiile fondului vor putea fi urmarite sub forma de grafice. <b>Debitul dozei ambientale corespunzator fondului natural de radiatii, conform masuratorilor, este de 0.12uSv/h.</b> Acest debit al dozei ambientale poate sa varieze, fara un impact major asupra sanatatii.  Media globala a debitului dozei datorat fondului natural de radiatii este de 0.27uSv/h. Stam mult mai bine decat media.</p>
<p>Pe langa nivelul debitului dozei datorat fondului natural de radiatii, am afisat date de temperatura, umiditate si luminozitate (cat de multa lumina ambientala exista), care se pot dovedi utile pentru cei interesti.</p>
<h3>O scurta prezentare video</h3>
<p><iframe width="800" height="450" src="http://www.youtube.com/embed/cn0CYrqPAmw" frameborder="0" allowfullscreen></iframe></p>
<h3>Ce sunt radiatiile ionizante?</h3>
<p><b>Agentia nucleara si pentru deseuri radioactive din Romania</b>, are un excelent ghid introductiv, care poate fi citit la sectiunea <a href="http://www.agentianucleara.ro/?page_id=68">"Despre radioactivitate"</a>. Va recomand sa il lecturati pentru o mai buna intelegere a celor discutate aici.</p>
<p>De la inceput vreau sa clarific ca statia masoara radiatii ionizante, parte a fondului natural.<br />
Radiatiile ionizante produc ionizari, procese electro-chimice in care substantele implicate sunt modificate. Raportate la corpul nostru, aceste procese pot fi nocive, pentru ca ionizarile pot provoca distrugeri la nivelul celulelor, inclusiv modificari ale lanturilor de ADN.<br />
Dar asa a fost de cand e lumea, si ne-am adaptat conditiilor de pe Pamanat. In permanenta celulele afectate sunt reparate sau inlocuite.<br />
O problema devine cresterea nivelului de radiatii peste limitele acceptate, cum se intampla in cazul accidentelor nucleare (Cernobal, Fukushima, etc). Daca corpul nostru e bombardat de o doza prea mare de radiatii , distrugerea cauzata poate fi ireversibila.<br />
Pe langa proprietatile ionizante, unele tipuri de radiatii, cum sunt radiatiile gamma, sint radiatii puternic penetrante.  Ele pot patrunde in interiorul corpului unam, putind in acest fel produce ionizari, nu doar la nivelul pielii ci si in interiorul corpului.</p>
<p>Radiatiile electromagnetice, cum sunt cele emise de antenele de telecomunicatii (telefonie, televiziune, radio), nu sunt ionizante. Nu exista date care sa lege expunerea la radiatiile electromagnetice de probleme de sanatate.</p>
<p>Radiatiile ultraviolete sunt ionizante, dar au putere de penetrare mica, energia lor fiind mica. Dar pot afecta pielea si ochii, si pot cauza boli grave cum e cancerul de piele sau distrugeri ale retinei.</p>
<p>Asadar pe aceasta pagina veti putea vizualiza nivelul radiatiilor in Timisoara, asa cum e masurat de statia pe care am construit-o. <b>Datele sunt pur informative, si nu pot sa garantez acuratetea lor, proiectul fiind realizat in regim de amator, dar cu o pregatire rezonabila in fiecare din tehnologiile implicate.</b></p>
<h3>De unde apare radiatia de fond?</h3>
<p>Cu precadere din doua surse: cosmice si terestre.<br />
<b>Radiatia cosmica</b> include ioni si nuclei grei proveniti din afara Sistemului Solar. Acestia ne bombardeaza direct, sau interactioneaza cu elemente din atmosfera pentru a produce jerbe de radiatii secundare: raze X, particule alpha, protoni, electroni, neutroni, etc. Compusi secundari se formeaza si prin transmutarea elementelor din atmosfera in radioizotopi sub influenta razelor cosmice, care la randul lor vor fi surse secundare de emisie.<br />
Componenta de radiatie cosmica contine si particule expulzate de catre furtunile solare, particule neincarcate electric ce pot trece de centurile Van Allen.<br />
<b>Sursele terestre</b> includ radioizotopii aflati in natura (elemente radioactive), cum sunt uraniul, toriul, dar si unii izotopi ai potasiului si carbonului. Elementele radioactive naturale, terestre, se dezintegreaza in timp, dezintegrari, care in final duc la elemente stabile, ne-radioactive. Uraniul 238 se dezintegreaza in Radiu 226, care la randul lui trece in Radon 222. Acesta din urma e un gaz care ajunge in atmosfera si la randul lui se dezintegreaza in alte elemente. Toate dezintegrarile se produc cu emisii de radiatii. </p>
<p>Exista si radiatia de fond produsa prin mijloace artificiale, adica produsa de om, care provine din teste nucleare (in special cele deasupra solului), arderea in cantitati mari a carbunelui care duce la concentrarea in cenusa a materialelor radioactive naturale (Uraniu, Toriu si Radon),  industria chimica care introduce in circuitul natural aceleasi produse, prin prelucrarea materiei prime cu continut de U sau Th, eliberarea in atmosfrea de tritiu si C-14 de catre reactoarele nucleare in functionare normala  sau accidente nucleare (Cernobal, Fukushima).</p>
<p>Toate aceste fenomene contribuie la fondul natural de radiatii.</p>
<p><a name="charts"></a></p>
<h3>Grafice in timp real, pentu Timisoara</h3>
<p>Cu exceptia catorva institute din tara, care rar dau publice graficele privind fondul de radiatie, statia mea e probabil singura alternativa de acest gen, disponibila utilizatorului obisnuit.<br />
Iata grafice realizate cu date culese in ultimele 7 zile, cu o integrare de 3 ore. Integrarea se refera la cumularea mai multor valori citite, intr-o valoare medie, pentru a observa mai usor si mai corect tendinta de evolutie. Graficele prezinta numele si unitatea de masura in partea de sus, si data, ora si valoarea, in partea de jos:<br />
<img src="http://www.pocketmagic.net/attention.gif"><img src="http://www.pocketmagic.net/en.gif">Atypical data has been logged <a href="http://www.pocketmagic.net/2013/01/uradmonitor-unusual-background-radiation-reports/#en">here</a> <img src="http://www.pocketmagic.net/attention.gif"><img src="http://www.pocketmagic.net/ro.gif">Variatiile atipice sunt centralizate <a href="http://www.pocketmagic.net/2013/01/uradmonitor-unusual-background-radiation-reports/#ro">aici</a><br />
<img src="http://www.pocketmagic.net/uradmonitor/public.php?param=usvh&interval=7&integration=3&size=large"><br />
<img src="http://www.pocketmagic.net/uradmonitor/public.php?param=temp1&interval=7&integration=3&size=large"><br />
<img src="http://www.pocketmagic.net/uradmonitor/public.php?param=humi&interval=7&integration=3&size=large"><br />
<img src="http://www.pocketmagic.net/uradmonitor/public.php?param=lumi&interval=7&integration=3&size=large"></p>
<h3>Grafice pe ultimele 30 de zile</h3>
<p>Am introdus <b>grafice pe ultimele 30 de zile</b>. Sunt prea mari pentru a le introduce ca poza, asa ca va rog dati click pe linkurile de mai jos. Integrarea e calculata la 3 ore. Daca aveti nevoie de rezolutii mai fine, puteti sa-mi spuneti. Nu uitati, aparatul a fost pus in functiune in data de 20 Octombrie, la publicarea acestui articol nu existau inca 30 de zile de inregistrari.<br />
<a href="http://www.pocketmagic.net/uradmonitor/public.php?param=usvh&interval=30&integration=3&size=xxlarge">Radiatia in Sievert/Ora</a><br />
<a href="http://www.pocketmagic.net/uradmonitor/public.php?param=cpm&interval=30&integration=3&size=xxlarge">Radiatia in CPM (numar de pulsuri detectate/minut)</a><br />
<a href="http://www.pocketmagic.net/uradmonitor/public.php?param=temp1&interval=30&integration=3&size=xxlarge">Temperatura in grade Celsius</a><br />
<a href="http://www.pocketmagic.net/uradmonitor/public.php?param=humi&interval=30&integration=3&size=xxlarge">Umiditatea relativa in procente</a><br />
<a href="http://www.pocketmagic.net/uradmonitor/public.php?param=lumi&interval=30&integration=3&size=xxlarge">Luminozitatea relativa in procente la mie</a></p>
<h3>Alte resurse</h3>
<p>Pagina proiectului <b>uRADMonitor</b> e accesibila <a href="http://uradmonitor.pocketmagic.net">aici</a>.<br />
Detaliile de constructie, inclusiv schema electronica, pot fi accesate <a href="http://www.pocketmagic.net/?p=2457">aici</a>.<br />
Pentru intrebari sau alte detalii, va stau la dispozitie, puteti folosi sectiunea de comentarii de mai jos.<br />
<br><br />
<b>Noiembrie 16, 2012</b><br />
Am raspuns invitatiei lui <a href="http://www.facebook.com/andrei.borosovici?ref=ts&fref=ts">Andrei Borosovici</a>, si astfel am participat la emisiunea lui, pe TVR3 , unde am avut ocazia sa prezint, in linii mari, detalii din spatele acestui proiect:<br />
<iframe width="800" height="600" src="http://www.youtube.com/embed/OhuANUFjQc8" frameborder="0" allowfullscreen></iframe><br />
<br><br />
<b>Decembrie 7, 2012</b><br />
Proiectul a facut atentia celor de la Hack a Day, unde a stat azi pe prima pagina. Articolul in engleza, poate fi citit <a href="http://hackaday.com/2012/12/07/online-radiation-monitoring-station/">aici</a>.<br />
<br><br />
<img src="http://pocketmagic.net/en.gif">For English, <a href="http://www.pocketmagic.net/?p=3155">click here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/10/statie-de-monitorizare-a-fondului-de-radiatii-gamma-in-timisoara/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>uRADMonitor &#8211; Online Radiation monitoring station</title>
		<link>http://www.pocketmagic.net/2012/10/uradmonitor-online-remote-radiation-monitoring-station/</link>
		<comments>http://www.pocketmagic.net/2012/10/uradmonitor-online-remote-radiation-monitoring-station/#comments</comments>
		<pubDate>Sun, 21 Oct 2012 19:20:46 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Nuclear]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[automated]]></category>
		<category><![CDATA[barometric pressure]]></category>
		<category><![CDATA[dosimeter]]></category>
		<category><![CDATA[environmental radiation surveillance]]></category>
		<category><![CDATA[geiger counter]]></category>
		<category><![CDATA[geiger muller]]></category>
		<category><![CDATA[humidity]]></category>
		<category><![CDATA[microcontrollers]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[radiation]]></category>
		<category><![CDATA[radiation data]]></category>
		<category><![CDATA[radiation monitor]]></category>
		<category><![CDATA[SBM-19]]></category>
		<category><![CDATA[sensors]]></category>
		<category><![CDATA[temperature]]></category>
		<category><![CDATA[weather station]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3155</guid>
		<description><![CDATA[I've developed the uRADMonitor as an Environmental Radiation Surveillance automated monitoring device. Data is gathered in real time, 24/7, and is exported via the Internet to a database online. The data is available in customizable charts for analysis.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/header.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/header.jpg" alt="" title="header" width="800" height="311" class="alignnone size-full wp-image-3172" /></a><br />
<img src="http://pocketmagic.net/ro.gif">Pentru limba romana, <a href="http://www.pocketmagic.net/?p=3253">click aici</a><br />
<img src="http://pocketmagic.net/en.gif"><b>uRADMonitor</b> is a network connected monitoring station, focused on continuous Environmental Radiation Surveillance. This capability is delivered by a digital dosimeter constructed around the highly sensitive Geiger Muller tube <a href="http://www.pocketmagic.net/?p=2397">SBM-19</a>. Additional sensors gather real time data on temperature , humidity and sky luminosity. </p>
<table cellspacing="15" cellpadding="0" border="0">
<tr>
<td valign="top">
<iframe width="300" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?q=45.755906,21.229692&amp;num=1&amp;t=h&amp;ie=UTF8&amp;ll=45.75387,21.23683&amp;spn=0.017966,0.025749&amp;z=14&amp;output=embed"></iframe><br /><small><a href="https://maps.google.com/maps?q=45.755906,21.229692&amp;num=1&amp;t=h&amp;ie=UTF8&amp;ll=45.75387,21.23683&amp;spn=0.017966,0.025749&amp;z=14&amp;source=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small><br>Location of uRadMonitor #1</td>
<td>&nbsp;&nbsp;</td>
<td valign="top">
<b>Construction details</b> and a few words on Geiger Tube Theory and radiation detection can be found <a href="http://www.pocketmagic.net/?p=2457">in my Geiger Counter article, V3</a>. I consider it a must read for any Geiger counter enthusiast, willing to start the long road of building this device.<br />
<br><b>This project requires knowledge</b> of various technical fields: general electronics (basic circuits, soldering), microcontroller hardware (timers, counters, interrupts, firmware development), C programming (for the microcontroller), basic atomic physics and Geiger theory, signal processing (for optimal amplification of pulses and detection on rising edge), Ethernet protocols (ARP, ICMP, TCP/IP), SQL databases (for storing data on server side) and PHP programming (for developing the data post-processing scripts: charts, export, etc). But the tool is well worth the effort since it works as a data gathering/logger tool, allowing research in the field of radiation such as identifying connections between various parameters (radiation in the first minutes of the falling rain, etc). It is also an automated guardian able to identify the slightest changes in normal radiation levels, 24/7.
</td>
</tr>
</table>
<h3>uRADMonitor demo video in English,  "Invisible Enemy - Radiation":</h3>
<p><iframe width="800" height="450" src="http://www.youtube.com/embed/O4cqDWPrW50" frameborder="0" allowfullscreen></iframe><br />
There is also a Romanian version of the film, <a href="http://www.youtube.com/watch?v=cn0CYrqPAmw">here</a>.</p>
<p><br><br />
<a name="charts"></a></p>
<h3>Graphs built in <b>real time</b> with uRADMonitor data. Time is GMT+3 (Europe/Timisoara):</h3>
<p><img src="http://www.pocketmagic.net/attention.gif"><img src="http://www.pocketmagic.net/en.gif">Atypical data has been logged <a href="http://www.pocketmagic.net/2013/01/uradmonitor-unusual-background-radiation-reports/#en">here</a> <img src="http://www.pocketmagic.net/attention.gif"><img src="http://www.pocketmagic.net/ro.gif">Variatiile atipice sunt centralizate <a href="http://www.pocketmagic.net/2013/01/uradmonitor-unusual-background-radiation-reports/#ro">aici</a></p>
<p><!-- REAL time charts follow --><br />
<b>Background radiation</b><br />
<img src="http://www.pocketmagic.net/uradmonitor/public.php?param=cpm&size=large"><br />
<img src="http://www.pocketmagic.net/uradmonitor/public.php?param=usvh&size=large"><br />
<b>*** Note:</b> The dose in uSv/h is only an estimation extrapolated from the CPM readings, based on geiger tube characteristics (SBM-19).<br />
<b>Temperature</b><br />
<img src="http://www.pocketmagic.net/uradmonitor/public.php?param=temp1&size=large"><br />
<img src="http://www.pocketmagic.net/uradmonitor/public.php?param=temp2&size=large"><br />
<img src="http://www.pocketmagic.net/uradmonitor/public.php?param=temp3&size=large"><br />
<b>Humidity</b><br />
<img src="http://www.pocketmagic.net/uradmonitor/public.php?param=humi&size=large"><br />
<b>Barometric pressure</b><br />
<img src="http://www.pocketmagic.net/uradmonitor/public.php?param=pressure&size=large"><br />
<img src="http://www.pocketmagic.net/uradmonitor/public.php?param=mmhg&size=large"><br />
<b>Sky luminosity</b><br />
<img src="http://www.pocketmagic.net/uradmonitor/public.php?param=lumi&size=large"></p>
<h3>How uRADMonitor works</h3>
<p>Several sensors, including a Geiger counter, are connected to a microcontroller (Atmega168). A network interface chip (enc28j60) provides an Ethernet interface. Data from sensors is collected on a one minute interval and exported online to the server (pocketmagic.net). Using PHP and SQL, the data is stored and post processed, so users connecting via a webbrowser can access various charts, <b>in real time</b>.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uRadMonitor_online_radiation_monitor.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uRadMonitor_online_radiation_monitor.jpg" alt="" title="uRadMonitor_online_radiation_monitor" width="800" height="800" class="alignnone size-full wp-image-3196" /></a></p>
<h3>Data access</h3>
<p>Currently I provide a simple interface to access the data collected by uRADMonitor #1, working in Timisoara, Romania. For server-side optimization reasons, the data is cached. Every time you access the data, you will receive charts not older than 2 minutes!<br />
The data can be accessed as pre-generated charts, of variable parameters, via a HTTP-GET:</p>
<blockquote><p>http://www.pocketmagic.net/uradmonitor/public.php?param=STRING&interval=VALUE&integration=VALUE&size=STRING&gmt=STRING_URL_ENCODED</p></blockquote>
<blockquote><p><b>param</b>: usvh|cpm|temp1|temp2|humi|lumi identifies the data: usvh for radiation in micro sieverts per hour, cpm for radiation in counts per minute, temp1 for temperature sensor #1 (DS1820), temp2 for temperature sensor #2 (DHT-11), humi for humidity sensor (DHT-11), lumi for luminosity sensor<br />
<b>interval</b>: the last number of days data to retrieve. The uRadMonitor #1, started gathering data on October 21, 2012<br />
<b>integration</b>: the average interval in hours. For better observations of the natural background radiation level , you should use a value of 4 (hours).<br />
<b>size</b>: small | medium | large | xlarge<br />
<b>gmt</b>: the gmt for the time coordinates, url encoded (default is Europe/Bucharest)
</p></blockquote>
<p>Try the following examples:<br />
<b>Example 1.</b> The Radiation data on the last 3 days (3x24hours) with an integration average of 4 hours (each point in the chart represents the average of 4 hours of sensors data), with a chart size of 1200x800 pixels, and time displayed with GMT corresponding to London, UK.</p>
<blockquote><p><a href="http://www.pocketmagic.net/uradmonitor/public.php?param=cpm&interval=3&integration=4&size=xlarge&gmt=Europe%2FLondon">http://www.pocketmagic.net/uradmonitor/public.php?param=cpm&interval=3&integration=4&size=xlarge&gmt=Europe%2FLondon</a>
</p></blockquote>
<p><b>Example 2.</b> The temperature data on the last day (1x24hours) with an integration average of 1 hour1 (each point in the chart represents the average of 1 hour of sensors data), with a chart size of 400x250 pixels, and time displayed as US Eastern time.</p>
<blockquote><p><a href="http://www.pocketmagic.net/uradmonitor/public.php?param=temp1&interval=1&integration=1&size=medium&gmt=US%2FEastern">http://www.pocketmagic.net/uradmonitor/public.php?param=temp1&interval=1&integration=1&size=medium&gmt=US%2FEastern</a>
</p></blockquote>
<p><b>Raw data access</b>, containing a huge collection of sensor data, with a 1minute time resolution is also available on request.</p>
<h3>Measuring The Dose</h3>
<p><b>Short Intro</b><br />
If you've seen the above video, you know that radiation cannot be detected with our senses. This is why we had to develop tools to see what our eyes cannot.<br />
A Geiger detector is a device that can sense the presence of ionizing radiation . It is composed of a sealed tube with two electrodes to which a potential difference is applied. A particle entering the tube will initiate a conductive channel between the two, by ionizing the medium inside. When this happens, we can count the pulse, with a counter connected to the tube. The conductive flow needs to be quenched, so the tube gets back to the initial status and it is ready to start detecting again. A special gas is added inside the tube, ex. halogens, that combine with the newly formed ions to neutralize them.</p>
<p><b>Counts per minute (CPM)</b><br />
The number of pulses / time, gives us a new unit for describing the radiation, that we call DOSE. The simplest unit of measure is the CPM , meaning counts per minute. Some tubes are more sensitive than others, so two different tubes will show different CPM readings when placed to the same radioactive source. This means that the CPM value is tube dependent. </p>
<p><b>Non linear answer to energy</b><br />
The Geiger tube's sensitivity can change relative to the incoming radiation's energy. Most tubes show a linear response only above 150keV. This means that a weak source of radiation, of energy below 150keV, will produce false readings on an uncalibrated tube, showing a bigger dose than there actually is. This type of calibration is called "energy response compensation" and it implies placing a thin metal shield, to reduce the intensity of low energy particles. This shield will not interfere with higher energy particles that will pass unaffected, so we can successfully apply the compensation only to the interval of interest, by choosing the shield's geometry (covering the tube partially or completely) or by choosing its thickness.</p>
<p><b>Can we compute the Equivalent dose from CPMs?</b><br />
The CPMs uRADMonitor calculates, are an indication of how much energy is ceded by the radiation to the geiger tube. We call this "the absorbed dose", and it is measured in Gy/h.<br />
Assuming a tube is compensated for energy response, then there is a linear correspondence between CPMs and Gy/h. This function is usually presented in the tube's datasheet in regards to various isotopes such as Co-60 or Cs-137.<br />
If the tube is not compensated, it will  express a higher sensibility mostly for energies below 150keV. We say that the tube's answer to energy is non-linear:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/6993_energy_curve_800.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/6993_energy_curve_800.jpg" alt="" title="6993_energy_curve_800" width="800" height="474" class="alignnone size-full wp-image-3246" /></a></p>
<p>The context for what we do here is extremely important: remember that uRADMonitor measures background radiation. This background is composed of cosmic radiation, of very high energy, and three main terrestrial components of background gammas that are K-40 1462 keV, Bi-214 1760 keV from the U decay series, and Tl-206 from the Th decay series. Smaller contributions to total background come from Pb-212 239 keV, Bi-209 609 keV, Tl-208 908 keV and Bi-214 1120 keV. The most serious non-linearity of energy response in uncompensated GM tubes occurs below 150 keV - and most of that below 100 keV - so none of the background emissions listed above will be seriously affected, nor will the majority of cosmic rays.<br />
The most seriously affected - and, in many ways, the most interesting - part of the background gamma spectrum that will fall within the GM tube's most non-linear energy response region is skyshine - the radiation scattered by the air above both natural and man-made sources like particle accelerators, reactors, and high-level waste dumps. Most skyshine falls below 500 keV, and most of that below 100 keV.<br />
So this means that CPM to Gray/hr conversions, using manufacturers data based on either Cs-137 or Co-60 will not be too inaccurate to be of use across the natural background gamma spectrum. An integration period of four hours should be used for reliable gamma background assessment. (Thanks to Proud Mary, 4HV.org)<br />
Moving from Gy/h to Sv/h is possible due to the Radiation weighting factor, which , for gamma radiation (the main constituent of the background radiation), is 1. 1Sv = 1Gy for gamma.<br />
Bottom line is, that for the restricted case of having the uRADMonitor measure only the small doses involved in the background radiation field, and considering the above mentioned isotopes only, we would computed the dose in Sv/h within a reasonable tolerance. uRADMonitor is not intended as a general purpose Dozimeter.</p>
<h3>Resources</h3>
<p><a href="http://www.qsl.net/k0ff/Skyshine/Skyshine%20Contribution%20to%20Gamma.pdf">Skyshine Contribution to Gamma Ray Background</a><br />
<a href="http://www.nrc.gov/reading-rm/doc-collections/nuregs/staff/sr1501/sr1501.pdf">Background as a Residual Radioactivity Criterion for Decommissioning</a><br />
<a href="http://journals.sfu.ca/coaction/index.php/tellusb/article/download/12552/14322">On the Interpretation of the Diurnal Variation of Cosmic Rays</a><br />
<a href="http://www.centronic.co.uk/downloads/Geiger_Tube_theory.pdf">Centronic Geiger Muller tubes</a></p>
<h3>Indications of commercial dosimeters at the same location</h3>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/radex.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/radex-300x199.jpg" alt="" title="radex" width="300" height="199" class="alignnone size-medium wp-image-3278" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/terrap.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/terrap-300x199.jpg" alt="" title="terrap" width="300" height="199" class="alignnone size-medium wp-image-3279" /></a></p>
<h3>Updates:</h3>
<p>I constantly improve this device by adding new sensors or changing the software. Updates can be tracked on the construction page, <a href="http://www.pocketmagic.net/?p=2457#121020">here</a>.<br />
<br><br />
<b>November 30, 2012</b>:<br />
With uRadMonitor's impact on the local press, I got an invitation to a TV show, where I had the chance to discuss some of the details behind the project. Here is a recording of the transmission on TVR3 (national TV), from 16.11.2012, in Romanian:<br />
<iframe width="800" height="600" src="http://www.youtube.com/embed/OhuANUFjQc8" frameborder="0" allowfullscreen></iframe><br />
<br><br />
<b>December 7, 2012</b><br />
I'm proud to announce this Project is my second work to be featured on <a href="http://hackaday.com/2012/12/07/online-radiation-monitoring-station/">HackAday</a>.</p>
<p><br><br />
<b>December 8, 2012</b><br />
First snow is here.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_snow.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_snow-300x199.jpg" alt="" title="uradmonitor_snow" width="300" height="199" class="alignnone size-medium wp-image-3349" /></a></p>
<p><br><br />
<b>January 31, 2013</b></p>
<table cellspacing="0" cellpadding="5" border="0">
<tr>
<td><img src="http://www.pocketmagic.net/wp-content/uploads/2013/01/atypical_uradmonitor_data-150x150.jpg"></td>
<td>uRADMonitor has been functioning continuously for the last 3 months. I have created a page to present all major atypical variations, that are not caused by technical issues or malfunctions. The page is available <a href="http://www.pocketmagic.net/2013/01/uradmonitor-unusual-background-radiation-reports/">here</a>.
</td>
</tr>
</table>
<p><br><br />
<b>February 16, 2013</b><br />
The recent atypical measurements raised a few questions on the nature of the events: malfunction of the detector (specifically the Geiger Tube due to age) or a legitimate manifestation of a radiation phenomenon.<br />
Some bits of additional info, even if redundant, should share some light on the Geiger detector, as used in the uRADMonitor system. For a start, here is the current circuit diagram:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/33130.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/33130-300x181.png" border="0"></a><br />
The R7 10M anode resistor is a quality component, mounted correctly without fingerprints, dust or humidity. Should this resistor malfunction in any way, one result could be avalanche discharges in the Geiger tube. This resistor has been checked recently and it meets the requirements.<br />
Resistor R5 is used in a voltage divider , by the microcontroller to continuously measure the voltage across the Geiger tube, using one of its ADC (analog to digital) ports. In just a few words, for 400V set on the tube, the voltage divider will return 3.96V ( 400V x 47/(4700+47) ). The micro-controller is set to use a relative voltage of 5V (Vref). The ADC port that measures the tube voltage, has a resolution of 10bits, so for a maximum of 5V on PC3/ADC3, the software would read the max value of 2^10 = 1024. For 4V we would get the proportional value. By doing so, the measurement of the anode voltage is extremely precise.<br />
Should the voltage on tube be lower than the preset threshold (400V), the duty cycle factor of the inverter's PWM is increased, in small steps, until we reach the target voltage (in a given tolerance, initially set to 5V and now changed to 2V). If the voltage on the tube is too high, we do the opposite and decrease the duty factor. In a few words, this is a known regularization mechanism that works well, fact confirmed by the logs, showing several months of constant voltage tube values.<br />
Some time ago, there was an issue with R5: After some use, it "burned" and got interrupted. As a result, the voltage measurement could no longer be done, and the software saw the voltage on tube as being 0. As a result, the duty cycle began to rise, resulting in uncontrolled high voltage generation, way above the tube's safety limits. Luckily, this high voltage also resulted in microcontroller temporarily failure, and so the PWM generation stopped . This in turn, also stopped the dangerous voltage from being applied to the tube (except for the first few miliseconds). R5 has been replaced with a better quality resistor.<br />
I was recommended the following useful resources:<br />
1. <a href="http://www.dtic.mil/dtic/tr/fulltext/u2/746267.pdf">An investigation into the causes of short lifetimes of geiger-muller tubes used in aircraft oil gauging systems</a><br />
2. <a href="http://www.inin.gob.mx/mini_sitios/documentos/MRNI-501D0.pdf">Test Procedure for Geiger-Mueller Radiation Detectors</a><br />
3. <a href="http://www.itcanbeshown.com/NERS315/Lab_4_GM_counting.pdf">Geiger Mueller Counting</a><br />
This valuable resources are a must-read, proving their utility especially for understanding failure causes that can result in avalanche discharges and erroneous readings . Because of the recent atypical radiation measurements recorded by uRADMonitor, I need to evaluate every possibility including a malfunction of the tube.<br />
Test Procedure for Geiger-Mueller Radiation Detectors (2),  proposes a 15% slope as the cut off between good and bad tubes: "In general, the value of the slope must be less than 15 % to consider that the detector is in good conditions." This seems to be a very large figure when you think of really good new GM tubes having plateau slopes of less than 3%.<br />
I ran a few measurements with the current setup. SBM-19's operation interval is 350-475V. For my particular tube, I got unsatisfactory readings for 350V, but good performance in the 375-450V interval, despite its age.<br />
The measurements has been performed during several hours, to acquire sufficient data for computing average values.<br />
Voltage on tube / CPM (with natural background radiation)<br />
349.33 / 65.88<br />
375.64 / 78.62<br />
399.65 / 79.98<br />
424.71 / 80.18<br />
449.51 / 79.68<br />
Complete measurement details in attached PDF document: <a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/sbm_19.pdf">sbm_19</a><br />
To test the tube's performance indicator as presented in "Test Procedure for Geiger-Mueller Radiation Detectors",<br />
I set N1 = 78.62 , V1 = 375.64V , N2 = 79.68 and V2 = 449.51V<br />
For P = 100 * ((N2 - N1)/(V2-V1)) * (100 / ( (N1+N2) / 2)) we get: 1.81060853% a lot lower than the 15% limit proposed in the paper.<br />
The device has been set to 375V (in software), as compared to 400V used from October 2012 until now.</p>
<p><br><br />
<img src="http://pocketmagic.net/ro.gif">Pentru limba romana, <a href="http://www.pocketmagic.net/?p=3253">click aici</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/10/uradmonitor-online-remote-radiation-monitoring-station/feed/</wfw:commentRss>
		<slash:comments>53</slash:comments>
		</item>
		<item>
		<title>DIY/Homemade Geiger Muller Digital Counter V3</title>
		<link>http://www.pocketmagic.net/2012/10/diyhomemade-geiger-counter-2/</link>
		<comments>http://www.pocketmagic.net/2012/10/diyhomemade-geiger-counter-2/#comments</comments>
		<pubDate>Thu, 11 Oct 2012 00:06:58 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[High Voltage]]></category>
		<category><![CDATA[Nuclear]]></category>
		<category><![CDATA[Tubes]]></category>
		<category><![CDATA[BG-08]]></category>
		<category><![CDATA[BG08]]></category>
		<category><![CDATA[dosimeter]]></category>
		<category><![CDATA[dosimetry]]></category>
		<category><![CDATA[G-15H]]></category>
		<category><![CDATA[G-21H]]></category>
		<category><![CDATA[geiger counter]]></category>
		<category><![CDATA[pancake geiger tube]]></category>
		<category><![CDATA[SBM-19]]></category>
		<category><![CDATA[SBM19]]></category>
		<category><![CDATA[sensitive geiger tube]]></category>
		<category><![CDATA[SI-1]]></category>
		<category><![CDATA[SI-12B]]></category>
		<category><![CDATA[SI-14B]]></category>
		<category><![CDATA[SI-22]]></category>
		<category><![CDATA[SI14G]]></category>
		<category><![CDATA[SI22G]]></category>
		<category><![CDATA[STS-1]]></category>
		<category><![CDATA[STS-3]]></category>
		<category><![CDATA[STS-6]]></category>
		<category><![CDATA[STS-8]]></category>
		<category><![CDATA[tubes]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=2457</guid>
		<description><![CDATA[A story of making a DIY Digital Geiger counter circuit, that can be used with several tubes. Add an enc28j60 Ethernet module  and use the data to create graphs available online!]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/header_gm2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/header_gm2.jpg" alt="" title="header_gm2" width="800" height="311" class="alignnone size-full wp-image-2915" /></a><br />
This article is the sum of multiple research results, and it was edited across almost one year. You can use the menu below to jump to the relevant parts, or start reading it in chronological order (newer posts are at the bottom).</p>
<p><b>Progress summary:</b><br />
<a href="#120525">2012-05-25, Geiger Dosimeter (video)</a></p>
<p><b>Digital Geiger Dosimeter:</b><br />
<a href="#120902">2012-09-02, Digital Geiger Dosimeter</a><br />
<a href="#120911">2012-09-11, Update on Atmega8 Timers and Counters</a><br />
<a href="#120915">2012-09-15, Update on Issues with Timer1</a><br />
<a href="#120916">2012-09-16, 400V Inverter Instability Issues fixed</a><br />
<a href="#121011">2012-10-11, Some enc28j60 remarks</a><br />
<a href="#121012">2012-10-12, Atmega168 up and running, first online beta test open</a><br />
<a href="#121018">2012-10-18, Sensor board ready; Signal Capacitor (C7) comparison</a><br />
<a href="#121019">2012-10-19, Device enclosure box ready</a><br />
<a href="#121020">2012-10-20, The results</a><br />
<a href="#121020">2012-11-11, Updates</a></p>
<p><!-- UPDATE --><br />
<a name="120525"></a><br></p>
<h3>May 25, 2012 - Geiger Dosimeter 3.2</h3>
<p>Here's a video featuring version 3.2 of my geiger counter circuit, tested with several tubes:<br />
<iframe width="640" height="360" src="http://www.youtube.com/embed/sJMngwBTXvw" frameborder="0" allowfullscreen></iframe><br />
I did some additional changes to my <a href="http://www.pocketmagic.net/?p=3127">v2.0 simple geiger clicker</a>, to improve it even further. See below the new 3.2 circuit diagram followed by some explanations. The ExpressSCH circuit diagram <a href='http://www.pocketmagic.net/wp-content/uploads/2012/09/express_sch_geiger.zip'>is here</a>.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/01/geiger_counter_32.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/01/geiger_counter_32-300x235.png" alt="" title="geiger_counter_32" width="300" height="235" class="alignnone size-medium wp-image-2718" /></a></p>
<p><b>1. The High voltage supply</b><br />
The goal is to have a counter working at 3V (2xAA batteries) with very little power consumption. This excludes using 555 timers or other fancy ICs. My choice is a feedback based one transistor oscillator. It provides 400V output, for 100mA at 3V.<br />
I am using a ferrite core transformer, 17 turns for primary and 17 for the feedback coil, with 0.2mm CuEm wire. The secondary has 550turns with 0.1mm. The oscillator is operating at a frequency of aprox. 23KHz.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/01/geiger_counter_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/01/geiger_counter_1-150x150.jpg" alt="" title="geiger_counter_1" width="150" height="150" class="alignnone size-thumbnail wp-image-2721" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/01/geiger_counter_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/01/geiger_counter_2-150x150.jpg" alt="" title="geiger_counter_2" width="150" height="150" class="alignnone size-thumbnail wp-image-2722" /></a><br />
The transformer's output is rectified and multiplied by the 3 stages multiplier (10nF 1KV capacitors / BYV26E fast diode).<br />
<b>2. The voltage regulator</b><br />
The geiger tube requires very precise voltages to operate. For this setup, I need to get 400V from this supply, regardless of variations in the input voltage (weak batteries, etc).<br />
This task is achieved by the string of Zeners and the Q2 transistor. When the voltage produced by the multiplier exceeds the Zener threshold , the Q2 transistor opens, and pull down the base of Q1, stopping the oscillation. By doing so, the output voltage remains at a constant level, that equals the Zener threshold. The multiplier must produce a little more than the voltage that triggers the zener string.<br />
<b>3. Connecting the Geiger tube</b><br />
An essential component is the Anode resistor (10M in my circuit). The resistor's minimum value, for any given tube, is specified in the datasheet, but it is a good practice to use a higher value where possible.<br />
The anode resistor is responsible of the following:<br />
- reduces the anode voltage when the tube is conducting. This allows the tube to recover after the discharge. Without this, the tube would conduct continuously and would be destroyed quickly.<br />
- it limits the current flowing through the tube, leading to longer tube life<br />
- it has an effect on the plateau length, a lower value of R1 gives a shorter plateau length [1]</p>
<p>For the pulse signal, there are two connection options: </p>
<table cellspacing="0" cellpadding="5" border="0">
<tr>
<td valign="top">
<b>Anode signal connection</b><br><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/01/anode.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/01/anode.jpg" alt="" title="anode" width="257" height="266" class="alignnone size-full wp-image-2725" /></a><br><br />
This type of connecting is not preferred:<br />
- at switch on, a high voltage transient will be fed to the measuring circuit, resulting in additional protection requirements.<br />
- noise in high voltage rail, will be fed to the measuring circuit via R3.
</td>
<td valign="top">
<b>Cathode signal connection</b><br><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/01/cathode.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/01/cathode.jpg" alt="" title="cathode" width="217" height="227" class="alignnone size-full wp-image-2724" /></a><br><br />
Centronics' "Geiger tube theory" recommends using the cathode connection whenever possible [1]. R2/R1 should be 1/45, taking into account a large value for R1 as explained above (eg. 10M).
</td>
</tr>
</table>
<p><b>4. Measuring circuits</b><br />
With the cathode connection, the measuring circuit's task will be to count and evaluate the positive pulses connected at the cathode resistor R2.<br />
For the circuit v3.2, we will collect the signal, in point A, at the emitter of transistor Q4. Here is how the pulses look like:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/geiger_pulse_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/geiger_pulse_1-300x146.jpg" alt="" title="geiger_pulse_1" width="300" height="146" class="alignnone size-medium wp-image-2897" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/geiger_pulse_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/geiger_pulse_2-300x146.jpg" alt="" title="geiger_pulse_2" width="300" height="146" class="alignnone size-medium wp-image-2898" /></a></p>
<p>I was able to successfully connect it to my<a href="http://www.pocketmagic.net/?p=2445"> CD4026 digital counter</a> , as seen in the video. It works great as a counter showing the individual pulses.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2011/12/2011-12-20-22.39.09.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2011/12/2011-12-20-22.39.09-150x150.jpg"></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/geiger_counter_homemade_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/geiger_counter_homemade_4-150x150.jpg" alt="" title="geiger_counter_homemade_4" width="150" height="150" class="alignnone size-thumbnail wp-image-2907" /></a></p>
<p>The final setup for v3.2:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/geiger_counter_homemade_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/geiger_counter_homemade_1-150x150.jpg" alt="" title="geiger_counter_homemade_1" width="150" height="150" class="alignnone size-thumbnail wp-image-2903" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/geiger_counter_homemade_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/geiger_counter_homemade_2-150x150.jpg" alt="" title="geiger_counter_homemade_2" width="150" height="150" class="alignnone size-thumbnail wp-image-2904" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/geiger_counter_homemade_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/geiger_counter_homemade_3-150x150.jpg" alt="" title="geiger_counter_homemade_3" width="150" height="150" class="alignnone size-thumbnail wp-image-2905" /></a></p>
<p><b>References</b><br />
[1] CENTRONIC , Geiger Muller Tubes, <a href="http://www.centronic.co.uk/downloads/Geiger_Tube_theory.pdf">link</a></p>
<p><!-- UPDATE --><br />
<a name="120902"></a><br></p>
<h3>September 2, 2012 - Digital Geiger Dosimeter v3.3</h3>
<p>For this update, my goal is to go digital. I need to use a microcontroller to take care of everything: regulated high voltage invertor using PWM and ADC voltage feedback, a timer to count seconds, a counter for tube pulses, and finally an Ethernet interface to export data via a network.<br />
The result will be an Internet connected Geiger Counter, collecting various data and provided graphs over large periods of time.<br />
I am planning to use the Atmega8 microcontroller, and push the little program space to its limits.<br />
The Ethernet part is complete, and has been presented <a href="http://www.pocketmagic.net/?p=2866">here</a>: Atmega8 and enc28J60 for Ethernet support.<br />
...<br />
A few hours later, I got a timer and a counter working on the Atmega8, so now I can measure time and also count the pulses coming from the tube . This gives us the dose measured in cpm, sweet first results!<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/DSC_2673.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/DSC_2673-300x199.jpg" alt="" title="DSC_2673" width="300" height="199" class="alignnone size-medium wp-image-2927" /></a><br />
All's left to do is to integrate the HV supply to the uC's circuit, using a simple PWM driver with feedback.</p>
<p><!-- UPDATE --><br />
<a name="120911"></a><br></p>
<h3>September 11, 2012 - Atmega8 Timers and Counters</h3>
<p>I did some progress on the HV inverter needed for the tube. I will have to stick to 400V . The project will be boxed and placed on a remote location outside. From there it will collect data and build various graphs. I have the geiger couter , a temperature sensor, a humidity sensor and a light intensity one. If anyone has other ideas on additional hardware that I should pack in, now it's the right time to say it.</p>
<p>A future project might be having a geiger counter dosimeter with multiple tubes, etc, and a nice LCD display to output the data. Or even some kind of "lab-tool" for testing the tubes.</p>
<p>Multiple pulses happen, and would be good to measure them correctly. This is called discrimination. The following pics show a few such pulses, as recorded with the oscilloscope:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/geiger_pulse_oscilloscope_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/geiger_pulse_oscilloscope_1-150x150.jpg" alt="" title="geiger_pulse_oscilloscope_1" width="150" height="150" class="alignnone size-thumbnail wp-image-2935" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/geiger_pulse_oscilloscope_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/geiger_pulse_oscilloscope_2-150x150.jpg" alt="" title="geiger_pulse_oscilloscope_1" width="150" height="150" class="alignnone size-thumbnail wp-image-2935" /></a><br />
A little update on my progress. I managed to put the microcontroller software together. As I am using an ATMega8, I opted for the following:<br />
- INT0 interrupt to count all incoming pulses on raising edge. I do not have any discriminator yet.<br />
- T0 timer to count passing time. I configured it to generate 1.024ms events, so 976 such events will count for a second.<br />
- T1 timer to generate PWM signal. I got it to accept variable frequency and duty factor. I will probably go for 40KHz to drive a little 2n2222 transistor that pumps the primary of a small ferrite core transformer:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/small_ferrite_core_transformer.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/small_ferrite_core_transformer-150x150.jpg" alt="" title="small_ferrite_core_transformer" width="150" height="150" class="alignnone size-thumbnail wp-image-2937" /></a><br />
I noticed that without any protection, I will get voltage spikes in the microcontroller circuit, measured at PB1, where the PWM signal is provided (spike backs from the ferrite transformer, most likely). So a fast diode, used as snubber was needed across the primary of the small ferrite transformer . See the following images, first without and second with protection:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/geiger_pulse_oscilloscope_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/geiger_pulse_oscilloscope_3-150x150.jpg" alt="" title="geiger_pulse_oscilloscope_3" width="150" height="150" class="alignnone size-thumbnail wp-image-2938" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/geiger_pulse_oscilloscope_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/geiger_pulse_oscilloscope_4-150x150.jpg" alt="" title="geiger_pulse_oscilloscope_3" width="150" height="150" class="alignnone size-thumbnail wp-image-2938" /></a><br />
I still have some issues:<br />
1. I almost used all the program memory available for the atmega8 and still need to code some additional routines. I might be forced to move to a more capable uC. I'll try to optimize and reduce code before I have to do anything like that.<br />
2. There's some interference, between the timer1 PWM, with the ISP interface that handles the Ethernet module:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/atmega_ethernet_geiger_board.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/atmega_ethernet_geiger_board-150x150.jpg" alt="" title="atmega_ethernet_geiger_board" width="150" height="150" class="alignnone size-thumbnail wp-image-2940" /></a><br />
Because of that, the microcontroller hangs at some times. This is extremely annoying considering I need to have this project as a remote box running for large periods of time.<br />
Some of the factors that are causing this:<br />
- bigger duty cycle (timer1's PWM)<br />
- some delays in the software's main loop<br />
- reading ADC ports : I need to read them for sensors, and for checking the inverter voltage. The inverter produces roughly 400V when powered on. The voltage is read using one ADC port. If the voltage is less then required, the duty cycle is increased. If the voltage is bigger then the target set, the duty cycle is decreased. </p>
<p>I will find the cause of this eventually. As it is now, the software opens a TCP/IP socket on port 80 where it exposes some HTML content. So it is a small WEB Server, where you can see some details such as number of times it was accessed, pings received, time since startup, number of counts, CPM, and the dose in uSv/h , estimated for the SBM-19 tube.<br />
Instead of this functionality, which I needed only for testing, the final software needs to work as a client, not a server. After computing all the sensor data locally (including the radiation dose), it will send it online, to a script running on my webpage. So instead of opening a port and waiting for incoming connections, the idea is to have it open a connecting to my server and export the data there. Easy. I believe the timing issues that currently lock my uC from time to time, will be resolved, as having an ongoing connection instead of keeping a port open is better.</p>
<p>Here's a photo showing the software run on a test board, with a LCD hooked up for showing the dose in <b>uSv/h</b> <img src='http://www.pocketmagic.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/atmega8_geiger_counter_lcd.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/atmega8_geiger_counter_lcd-300x199.jpg" alt="" title="atmega8_geiger_counter_lcd" width="300" height="199" class="alignnone size-medium wp-image-2941" /></a></p>
<p><!-- UPDATE --><br />
<a name="120915"></a><br></p>
<h3>September 15, 2012: v3.3.100 - Issues with Timer1</h3>
<p>I decided to set numbers for these updates to help organize it better. So this is 3.3.100.<br />
I've been working on the inverter. It seems I'll be able to have it run in a very wide range of values. This is thanks to a new ferrite core transformer that I made: A22 ferite core (it is really small, 1cm diameter), 16 turns primary with 0.2mm wire, and 600 turns secondary with 0.1mm wire. It is driven by a PN2222A generic transistor, using the 5V rail.<br />
The output is fully rectified using 4 fast diodes set in a bridge. No multiplier required! <img src='http://www.pocketmagic.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I made some tests with various frequencies. Here are some results, yellow/CH1 is at the PB1 pin, while cyan/CH2 is the inverter output:</p>
<p>40KHZ, duty:16% 396V, duty:35% 792V<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/11.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/11-300x146.jpg" alt="" title="1" width="300" height="146" class="alignnone size-medium wp-image-2964" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/21.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/21-300x146.jpg" alt="" title="2" width="300" height="146" class="alignnone size-medium wp-image-2965" /></a></p>
<p>20KHz, duty:10% 396V, duty:15% 616V<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/31.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/31-300x146.jpg" alt="" title="3" width="300" height="146" class="alignnone size-medium wp-image-2967" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/4-300x146.jpg" alt="" title="4" width="300" height="146" class="alignnone size-medium wp-image-2968" /></a></p>
<p>10KHz, duty:1% 200V, duty:16% 768V<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/5-300x146.jpg" alt="" title="5" width="300" height="146" class="alignnone size-medium wp-image-2969" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/6.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/6-300x146.jpg" alt="" title="6" width="300" height="146" class="alignnone size-medium wp-image-2970" /></a></p>
<p>I will probably choose a 20KHz frequency to set it out of the audible spectrum. The driving signal seems a little distorted, as I am still getting some spike backs from the ferrite transformer. I should fix this as well.</p>
<p>I'm still having issues when using the enc28J60 code together with the Timer1 PWM code. So either I have the Ethernet interface, either I have the PWM signal for the HV inverter. Sometimes it works, but not very stable. Here is the current circuit diagram, version 3.3.100:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/digital_geiger_counter_atmega8_v3.3.100.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/digital_geiger_counter_atmega8_v3.3.100-300x189.jpg" alt="" title="digital_geiger_counter_atmega8_v3.3.100" width="300" height="189" class="alignnone size-medium wp-image-2971" /></a></p>
<p>I got some interesting results, and good news on the same time. Using a 8x prescalling when setting the Timer1 PWM, seems to allow the code to work together with the enc28j60, as expected. So this seems a good starting point, too bad I don't know the exact cause of these issues. Code for enc28j60 is rather complex , already.</p>
<p><!-- UPDATE --><br />
<a name="120916"></a><br></p>
<h3>September 16, 2012 - v3.3.101 - 400V Inverter Instability Issues fixed</h3>
<p>I finally fixed the instability problems, the network module / PWM interference, and most of the issues I've mentioned before.<br />
The problem was improper filtering in two key points:<br />
1. The inverter's driver needed a little protection from those spike backs. For this I used two resistors at the inverter's driver base , and a little choke between the transformer's primary and the positive rail. This solved the spike backs, CH1/yellow at PB1, CH2/cyan inverter output:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/ADS00046.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/ADS00046-300x146.jpg" alt="" title="ADS00046" width="300" height="146" class="alignnone size-medium wp-image-2974" /></a><br />
Notice the PWM waveform still seems a little shaky at the top.<br />
2. Voltage regulators (5V and the 3.3V), needed a few electrolytic caps<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/ADS00047.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/ADS00047-300x146.jpg" alt="" title="ADS00047" width="300" height="146" class="alignnone size-medium wp-image-2975" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/ADS00048.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/ADS00048-300x146.jpg" alt="" title="ADS00048" width="300" height="146" class="alignnone size-medium wp-image-2976" /></a><br />
Now the PWM looks much better (have a quick look to the previous oscilloscope screens), and the circuit performs as expected, seems like the Ethernet module was greatly influenced by all the variations and improper filtering.<br />
Here is the new schematic, v3.3.101:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/digital_geiger_counter_atmega8_v3.3.101.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/digital_geiger_counter_atmega8_v3.3.101-300x189.jpg" alt="" title="digital_geiger_counter_atmega8_v3.3.101" width="300" height="189" class="alignnone size-medium wp-image-2973" /></a><br />
This works great, finally! I am able to adjust the duty cycle and get perfectly regulated high voltage needed for the geiger tube. The voltage feedback reading with ADC will be used to adjust the duty cycle automatically: increase it if voltage is less than 400V (or any other target voltage), or decrease it to lower the output voltage, if more than 400V is being generated.<br />
Compared to V3.2, the ripple is almost zero! See the two photos below:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/ripple_geiger_counter_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/ripple_geiger_counter_1-300x146.jpg" alt="" title="ripple_geiger_counter_1" width="300" height="146" class="alignnone size-medium wp-image-3240" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/ripple_geiger_counter_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/ripple_geiger_counter_2-300x146.jpg" alt="" title="ripple_geiger_counter_1" width="300" height="146" class="alignnone size-medium wp-image-3240" /></a><br />
The first, shows my version 3.2 inverter output, that uses a NPN oscillating transistor in an Armstrong oscillator, and a feedback mechanism constructed with zenner diodes set for 400V, that triggers an oscillator-blocking second transistor. Illustrated as trace for CH1 - yellow, set for 400V.<br />
The second shows the output in 3.3, fully rectified and produced by a a precisely calculated PWM signal. See the CH2, cyan trace, set for 350V. That was only for testing, as the feedback mechanism now sets the voltage for 400V.</p>
<p><!-- UPDATE --><br />
<a name="121011"></a><br></p>
<h3>October 11, 2012 - Some enc28j60 remarks</h3>
<p>For now just a few observations:<br />
The ENC28J60 will work without the 74LS125N buffer just fine, assuming you don't have other devices connected over SPI. This simplifies things a bit. I also did minor changes on the ENC28J60 code and now the stability is much improved. Can be seen <a href="http://www.pocketmagic.net/?p=2866#121011">here</a>.<br />
Now a bigger problem is that I've consumed most of ATmega8's flash memory, and still need to do some additional programing. This forces me to move one step higher , to the <a href="http://www.atmel.com/devices/atmega168.aspx">Atmega168</a> microcontroller, featuring 16KB of flash memory, instead of <a href="http://www.atmel.com/devices/atmega8.aspx">ATmega8</a>'s 8KB.<br />
Still , it will be possible to use the Atmega8 for a standalone dosimeter, with 1 tube, LCD screen, and built in high voltage power supply. But not if we want the ENC28J60 ethernet interface, like for this project.</p>
<p><!-- UPDATE --><br />
<a name="121012"></a><br></p>
<h3>October 12, 2012 - Atmega168 up and running, first online beta test open</h3>
<p>Some news. Got the  new little board up an running, featuring an Atmega168 micocontroller instead of the original Atmega8, because the TCP/IP stack was already consuming 7KB of our Atmega8's 8KB total flash memory. Besides the network stack, I need to drive the HV inverter, check the HV value for regularization, count the time and the pulses, do some logic on those values, and so on... additional programming that would not fit in the Atmega8.</p>
<p>What should have been a simple task, since the 168 has the same pin layout like the Atmega8, ended up as a mess, wasting two days of my time. I will structure the findings and indicate the critical issues, in case others will walk this path.</p>
<p>In the end, it works... not yet in the final form, as I need to build charts and store the data, add sensors, and lots of bells and whistles, BUT, here is how it looks like:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/atmega168_geiger_counter_SBM19.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/atmega168_geiger_counter_SBM19-150x150.jpg" alt="" title="atmega168_geiger_counter_SBM19" width="150" height="150" class="alignnone size-thumbnail wp-image-3041" /></a><br />
The software computes a CPM value based on a 5seconds time constant and displays the corresponding Sieverts/Hour dose in regards to the <a href="http://www.pocketmagic.net/?p=2397">SBM-19 Geiger tube</a> characteristics.</p>
<p>The board is currently up and running for a stability test, and can be accessed over the internet, <a href="http://www.pocketmagic.net/?p=3155">here (edit: test ended)</a>. Give it a run, and let me know what you think!</p>
<p>Issues migrating from Atmega8 to Atmega168:<br />
1. Atmega168 will not work with enc28J60, unless you use PB2 for CS. Atmega8 did not have this issue, which cost me two days to figure out. If PB2 is not used, the Atmega168 will hang in enc28j60Init, when doing the first enc28j60WriteOp, because the  waitspi(); never gets to finish.<br />
2. Keep the code inside interrupt callbacks light: the T0 interrupt was computing some time related values, but also reading the ADC port for voltage regularization. This crashed my uC until I moved the ADC reading code to the main loop.<br />
3. Keep the strings to a minimum, since the RAM is extremely limited. Buffer overflows are hard to debug on a microcontroller. So are the other memory related issues. Double check, triple check or rewrite the code differently.<br />
...</p>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/atmega168_enc28j60_geiger_counter_SBM19-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/atmega168_enc28j60_geiger_counter_SBM19-2-150x150.jpg" alt="" title="atmega168_enc28j60_geiger_counter_SBM19-2" width="150" height="150" class="alignnone size-thumbnail wp-image-3049" /></a><br />
After 2 hours the device is still running with good stability. The absolute CPM given by my background radiation is 90 cpm . A very raw conversion to uSv/h, based on SBM-19 characteristics, would give us 0.18uSv/h.
</td>
<td>
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/atmega168_enc28j60_geiger_counter_SBM19-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/atmega168_enc28j60_geiger_counter_SBM19-3-150x150.jpg" alt="" title="atmega168_enc28j60_geiger_counter_SBM19-3" width="150" height="150" class="alignnone size-thumbnail wp-image-3052" /></a><br />
After 15hours of continuous use, the device is still functioning well. Here is another snapshot of the web interface. What's interesting is the absolute CPM, has dropped significantly. I wonder why.
</td>
</tr>
</table>
<p>Here is the setup so far:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/atmega168_enc28j60_geiger_counter_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/atmega168_enc28j60_geiger_counter_1-150x150.jpg" alt="" title="atmega168_enc28j60_geiger_counter_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3054" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/atmega168_enc28j60_geiger_counter_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/atmega168_enc28j60_geiger_counter_2-150x150.jpg" alt="" title="atmega168_enc28j60_geiger_counter_2" width="150" height="150" class="alignnone size-thumbnail wp-image-3054" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/atmega168_enc28j60_geiger_counter_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/atmega168_enc28j60_geiger_counter_3-150x150.jpg" alt="" title="atmega168_enc28j60_geiger_counter_3" width="150" height="150" class="alignnone size-thumbnail wp-image-3054" /></a><br />
<b>Circuit diagram, v3.3.103</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/atmega168_eth_dosimeter.gif"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/atmega168_eth_dosimeter-300x162.gif" alt="" title="atmega168_eth_dosimeter" width="300" height="162" class="alignnone size-medium wp-image-3094" /></a><br />
The signal is processed by a small preamplifier, with the two transistors 2n5551 and BC558, resulting in a positive pulse of 50-100uSec and 5V amplitude, that is fed to the microcontroller's interrupt INT0 pin: PD2.<br />
<b>Source code:</b><br />
<a href="http://www.pocketmagic.net/?p=3155">3.3.103, available on request</a><br />
...<br />
After 42Hours it is still up and running, so I would say stability has been proven for this circuit, and I will stop this test here:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/atmega_enc28j60_stable_circuit.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/atmega_enc28j60_stable_circuit-150x150.jpg" alt="" title="atmega_enc28j60_stable_circuit" width="150" height="150" class="alignnone size-thumbnail wp-image-3099" /></a><br />
...<br />
<b>Update October 14, 2012</b><br />
Some news: I managed to successfully initiate a Tcp/ip connection from the Geiger counter to a PHP script on this blog. It's late now, but I have everything in place to start exporting data.</p>
<p><!-- UPDATE --><br />
<a name="121018"></a><br></p>
<h3>October 18, 2012 - Sensor board ready; Signal Capacitor (C7) comparison</h3>
<p>I've completed the sensor board:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/sensor_board_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/sensor_board_1-150x150.jpg" alt="" title="sensor_board_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3102" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/sensor_board_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/sensor_board_3-150x150.jpg" alt="" title="sensor_board_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3102" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/sensor_board_7.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/sensor_board_7-150x150.jpg" alt="" title="sensor_board_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3102" /></a></p>
<p>Sensors and microcontroller software are working together. This project was full of obstacles, almost every single step came with bugs and issues, but eventually my determination prevailed.<br />
Finally , here's the data received on my server, comments added after #<br />
id=1 #this is a simple id, in case I will build more of these devices<br />
cip=192.168.2.153 #the local device IP obtained by DHCP - no network config required!<br />
vol=400 #the voltage on tube<br />
duty=74 #7.4% inverter's duty cycle responsible of the 400V produced - used in regularization<br />
pulses=2463 #number of pulses counted since start up<br />
s1t=22 #ds1820 sensor, this is temperature in degrees celsius<br />
s2t=24 #dht11 sensor, temperature in degrees celsius<br />
s2h=75 #dht11 sensor, relative humidity<br />
s3l=19 #photodiode sensor, luminosity<br />
td=0 #number of days since start up<br />
th=0 #number of hours since startup<br />
tm=16 #numer of minutes since startup<br />
ts=41 #seconds from startup<br />
cpm=72 #CPM for the last 5 seconds , just for debugging purposes<br />
<b>Note:</b>absolute CPM would be 2463 / 16.6 ->148 cpm . a bit high I'd say<br />
...<br />
pulses=4166<br />
th=0<br />
tm=38<br />
ts=11<br />
absolute CPM after 38minutes: 109.63 cpm , it is getting closer to expected dose rate.<br />
...<br />
pulses=6323<br />
th=1<br />
tm=4<br />
ts=1<br />
absolute CPM after 1hour: 98cpm</p>
<p>Thanks to Stella on<a href="http://4hv.org/e107_plugins/forum/forum_viewtopic.php?111231.last"> 4HV.org</a>, I've changed the C7 Capacitor (see diagram 3.3.103) to a smaller value. As Stella kindly explained, "The larger the capacitor, the slower will be the rise and fall times of the pulse. I would have expected to see a capacitor of 20 - 100 pF here ", while I've used a huge 20nF capacitor!<br />
This is now changed to a 33pF capacitor, and here is a comparison chart showing the pulse shape/length with three capacitors, while the tube is exposed to natural radiation, to a Am241 source, and to a Cs137 source:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/filter_cap.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/filter_cap-300x150.jpg" alt="" title="filter_cap" width="300" height="150" class="alignnone size-medium wp-image-3106" /></a><br />
The modification will show in the next circuit diagram update.</p>
<p><!-- UPDATE --><br />
<a name="121019"></a><br></p>
<h3>October 19, 2012 - Device enclosure box ready</h3>
<p>Box is ready, completely made of PVC pipe plastic, after transforming a piece of pipe into a sheet and cutting it when heated:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_box_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_box_1-150x150.jpg" alt="" title="remote_geiger_box_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3108" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_box_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_box_2-150x150.jpg" alt="" title="remote_geiger_box_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3108" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_box_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_box_3-150x150.jpg" alt="" title="remote_geiger_box_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3108" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_box_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_box_4-150x150.jpg" alt="" title="remote_geiger_box_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3108" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_box_5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_box_5-150x150.jpg" alt="" title="remote_geiger_box_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3108" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_box_6.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_box_6-150x150.jpg" alt="" title="remote_geiger_box_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3108" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_box_8.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_box_8-150x150.jpg" alt="" title="remote_geiger_box_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3108" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_box_9.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_box_9-150x150.jpg" alt="" title="remote_geiger_box_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3108" /></a><br />
I also created sockets, from the same plastic source, for the geiger tube:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_sockets_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_sockets_1-150x150.jpg" alt="" title="remote_geiger_sockets_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3117" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_sockets_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_sockets_2-150x150.jpg" alt="" title="remote_geiger_sockets_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3117" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_sockets_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_sockets_4-150x150.jpg" alt="" title="remote_geiger_sockets_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3117" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_sockets_5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/remote_geiger_sockets_5-150x150.jpg" alt="" title="remote_geiger_sockets_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3117" /></a><br />
The orange plastic is great, the finished box actually gives the impression of a very good quality plastic / case! Funny considering what  materials I've used.</p>
<p><!-- UPDATE --><br />
<a name="121020"></a><br></p>
<h3>October 20, 2012 - The results </h3>
<p>Final software adjustments have been made. A new SQL database has been configured on pocketmagic.net to receive the data from the online dosimeter. Box has been closed and sealed, then mounted outside my home. Drilling a hole in the outside wall allowed me to install the power and Ethernet cables.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_geiger_dosimeter_0.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_geiger_dosimeter_0-150x150.jpg" alt="" title="uradmonitor_geiger_dosimeter_0" width="150" height="150" class="alignnone size-thumbnail wp-image-3168" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_geiger_dosimeter_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_geiger_dosimeter_1-150x150.jpg" alt="" title="uradmonitor_geiger_dosimeter_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3161" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_geiger_dosimeter_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_geiger_dosimeter_2-150x150.jpg" alt="" title="uradmonitor_geiger_dosimeter_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3161" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_geiger_dosimeter_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_geiger_dosimeter_3-150x150.jpg" alt="" title="uradmonitor_geiger_dosimeter_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3161" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_geiger_dosimeter_35.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_geiger_dosimeter_35-150x150.jpg" alt="" title="uradmonitor_geiger_dosimeter_0" width="150" height="150" class="alignnone size-thumbnail wp-image-3168" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_geiger_dosimeter_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_geiger_dosimeter_4-150x150.jpg" alt="" title="uradmonitor_geiger_dosimeter_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3161" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_geiger_dosimeter_5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_geiger_dosimeter_5-150x150.jpg" alt="" title="uradmonitor_geiger_dosimeter_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3161" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_geiger_dosimeter_6.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_geiger_dosimeter_6-150x150.jpg" alt="" title="uradmonitor_geiger_dosimeter_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3161" /></a></p>
<p><b>Circuit diagram, v3.3.120:</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33120_s.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33120_s-300x200.png" alt="" title="uradmonitor_33120_s" width="300" height="200" class="alignnone size-medium wp-image-3210" /></a></p>
<p><b>Source code:</b><br />
<a href="http://www.pocketmagic.net/?p=3155">3.3.120, available on request</a></p>
<p><b>3.3.110 2:07 PM 10/23/2012</b><br />
<code>SERVER/php:<br />
- final data export script: public.php  . deleted clones<br />
- standardization of export script parameters<br />
- fixed interval: last value shown is last present value<br />
- caching implemented and set to 2 min interval<br />
- fixed bug with displaying last hour in chart<br />
CLIENT/atmega168:<br />
- s2 bug fix, for invalid >100 values<br />
- luminosity computed in percents 0..1000<br />
- time calculation fixed, g_nTimeMilis >= 960<br />
- added isp external connector</code></p>
<p><!-- UPDATE --><br />
<a name="121111"></a><br></p>
<h3>November 11, 2012 - Updates </h3>
<p><b>3.3.121 12:51 PM 10/28/2012</b><br />
<code>SERVER:<br />
- added subdomain uradmonitor.pocketmagic.net<br />
- fixed server downtime chart calculations: missing data time zones are skipped - the graph will simply jump to the next data available.<br />
- added uSv/h<br />
todo: add offline text if no fresh  (>5min) data available<br />
- 3 digits added to values. back to 2 digits.<br />
- added redicted in pocketmagic.net/uradmonitor to uradmonitor.pocketmagic.net<br />
- limits set on the PHP script parameters: 30 for interval and 24 for integration</code></p>
<p><b>3.3.122 2:18 PM 11/02/2012</b><br />
<code>SERVER:<br />
- debug now shows duty cycle too.<br />
CLIENT:<br />
- changed the R5 resistor , as the original burned out (poor chinese quality)<br />
- recalibrated the inverter voltage feedback, by measuring the new R5 value.<br />
- placed safety limits for upper duty cycle percent interval: the burned R5 caused a voltage increase up to 800V!! No other components were harmed.</code></p>
<p><b>3.3.130 2:14 PM 11/11/2012</b><br />
<code>SERVER:<br />
- added new graphs: pressure (bmp085) and temperature 3 (bmp085)<br />
CLIENT:<br />
- dht11 sensor replaced with dht22<br />
- bmp085 sensor added<br />
- new sensor PCB board<br />
- new sensor board sun shield<br />
- additional code for the new sensor and i2c bus connectivity<br />
- atmega168 replaced with atmega328p</code><br />
<b>Photos of 3.3.130 update:</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_01.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_01-150x150.jpg" alt="" title="uradmonitor_33130_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3318" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_02.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_02-150x150.jpg" alt="" title="uradmonitor_33130_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3318" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_03.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_03-150x150.jpg" alt="" title="uradmonitor_33130_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3318" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_04.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_04-150x150.jpg" alt="" title="uradmonitor_33130_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3318" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_05.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_05-150x150.jpg" alt="" title="uradmonitor_33130_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3318" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_06.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_06-150x150.jpg" alt="" title="uradmonitor_33130_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3318" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_07.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_07-150x150.jpg" alt="" title="uradmonitor_33130_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3318" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_08.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_08-150x150.jpg" alt="" title="uradmonitor_33130_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3318" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_09.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_09-150x150.jpg" alt="" title="uradmonitor_33130_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3318" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_10.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_10-150x150.jpg" alt="" title="uradmonitor_33130_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3318" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_11.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/uradmonitor_33130_11-150x150.jpg" alt="" title="uradmonitor_33130_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3318" /></a><br />
<b>Circuit diagram 3.3.130</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/33130.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/33130-300x181.png" alt="" title="33130" width="300" height="181" class="alignnone size-medium wp-image-3330" /></a><br />
<br><br />
<b>3.3.131 6:28PM 12/10/2012</b><br />
<code>SERVER:<br />
CLIENT:<br />
- time computing code updated<br />
- dht22 issues below 0 degrees, because of issues in CRC computation</code><br />
<b>Source code:</b> <a href="http://www.pocketmagic.net/?p=3155">available on request</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/10/diyhomemade-geiger-counter-2/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Temperature Sensors DS18B20 and DHT11 with Atmega8</title>
		<link>http://www.pocketmagic.net/2012/10/atmega8-temperature-sensors-ds18b20-and-dht11/</link>
		<comments>http://www.pocketmagic.net/2012/10/atmega8-temperature-sensors-ds18b20-and-dht11/#comments</comments>
		<pubDate>Sun, 07 Oct 2012 18:28:13 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[atmega8]]></category>
		<category><![CDATA[dht11]]></category>
		<category><![CDATA[digital]]></category>
		<category><![CDATA[ds18b20]]></category>
		<category><![CDATA[microcontrollers]]></category>
		<category><![CDATA[temperature]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3009</guid>
		<description><![CDATA[Use the Atmega8 with two temperature sensors: the DS18B20 and the DHT-11. The latter also offers relative humidity data.]]></description>
				<content:encoded><![CDATA[<p>Both are neat little devices, that can offer useful data to your hardware applications. The DS18B20 comes with better temperature interval and resolution and with more features, but the DHT11 is cheaper and also provides humidity data. Which one is better? It depends on your application. Below see how to use them both, with two small size libraries to keep the program memory to a minimum.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/temperature_sensors.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/temperature_sensors-300x233.jpg" alt="" title="temperature_sensors" width="250" class="alignnone size-medium wp-image-3022" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/ds18b20_dht11_atmega8_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/ds18b20_dht11_atmega8_1-300x284.jpg" alt="" title="ds18b20_dht11_atmega8_1" width="250" class="alignnone size-medium wp-image-3011" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/ds18b20_dht11_atmega8_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/ds18b20_dht11_atmega8_2-300x284.jpg" alt="" title="ds18b20_dht11_atmega8_2" width="250" class="alignnone size-medium wp-image-3012" /></a></p>
<h3>DS18B20 - digital temperature sensor</h3>
<p>My <a href="http://www.pocketmagic.net/?p=473">previous article on the DS18B20</a>, focused on getting only the positive temperature values out of this sensor's Scratchpad. For a better approach the 12 bit data needs to be interpreted correctly, with the most significant bit as the sign bit. This leaves us with 11 bits for the integer temperature part , and 4 bits for the decimal.<br />
A few bitwise operations, and a little bit level surgery, gets the job done.</p>
<pre class="c"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// first 12bits represent the integer temperature</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// the last 4bits represent the fractional temperature</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// I I I I I I I I I I I I F F F F</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//Store temperature integer digits and decimal digits</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">uint16_t integer_bits = temp &gt;&gt; <span style="color: #cc66cc;">4</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		fractional_bits = temp &amp; 0xF;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">int</span> negative = <span style="color: #cc66cc;">0</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>integer_bits &amp; 0x800<span style="color: #66cc66;">&#41;</span> negative = <span style="color: #cc66cc;">1</span>; <span style="color: #808080; font-style: italic;">//the 12th digit is one, representing a negative number</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>Here's a direct conversion using the float data type:</p>
<pre class="c"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">float</span> therm_read_temperature<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #808080; font-style: italic;">//Reset, skip ROM and start temperature conversion</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	therm_reset<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	therm_write_byte<span style="color: #66cc66;">&#40;</span>THERM_CMD_SKIPROM<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	therm_write_byte<span style="color: #66cc66;">&#40;</span>THERM_CMD_CONVERTTEMP<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #808080; font-style: italic;">//Wait until conversion is complete</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span>!therm_read_bit<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #808080; font-style: italic;">//Reset, skip ROM and send command to read Scratchpad</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	therm_reset<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	therm_write_byte<span style="color: #66cc66;">&#40;</span>THERM_CMD_SKIPROM<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	therm_write_byte<span style="color: #66cc66;">&#40;</span>THERM_CMD_RSCRATCHPAD<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	uint8_t l = therm_read_byte<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	uint8_t h = therm_read_byte<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	therm_reset<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #993333;">float</span> temp = <span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span> h &lt;&lt; <span style="color: #cc66cc;">8</span> <span style="color: #66cc66;">&#41;</span> + l <span style="color: #66cc66;">&#41;</span>*<span style="color: #cc66cc;">0.0625</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">return</span> temp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span>				</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>The DS18B20 can do much more than this . See the complete datasheet, <a href="http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf">here</a>.</p>
<h3>DHT11 - cheap digital temperature and humidity sensor</h3>
<p>This Temperature & Humidity Sensor features a temperature & humidity sensor complex with a calibrated digital signal output. It includes a resistive-type humidity measurement component and an NTC temperature measurement component, and connects to a high-performance 8-bit microcontroller, offering excellent quality, fast response, anti-interference ability and cost-effectiveness. Datasheet <a href="http://www.micropik.com/PDF/dht11.pdf">here</a>.<br />
This sensor returns sequences of 5bytes representing the humidity integer value, the temperature, and a checksum. To get the values correctly, precise timing at the 40uS scale is required. </p>
<pre class="c"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// READ OUTPUT - 40 BITS =&gt; 5 BYTES or TIMEOUT</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> i=<span style="color: #cc66cc;">0</span>; i&lt;<span style="color: #cc66cc;">40</span>; i++<span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	loopCnt = <span style="color: #cc66cc;">10000</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span>!<span style="color: #66cc66;">&#40;</span>DHT11_PIN&amp;<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>&lt;&lt;DHT11_DQ<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>loopCnt-- == <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">return</span> DHTLIB_ERROR_TIMEOUT;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> t = micros<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	loopCnt = <span style="color: #cc66cc;">10000</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>DHT11_PIN&amp;<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>&lt;&lt;DHT11_DQ<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">//high</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>loopCnt-- == <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">return</span> DHTLIB_ERROR_TIMEOUT;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>micros<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> - t<span style="color: #66cc66;">&#41;</span> &gt; <span style="color: #cc66cc;">40</span><span style="color: #66cc66;">&#41;</span> bits<span style="color: #66cc66;">&#91;</span>idx<span style="color: #66cc66;">&#93;</span> |= <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span> &lt;&lt; cnt<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>cnt == <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>   <span style="color: #808080; font-style: italic;">// next byte?</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		cnt = <span style="color: #cc66cc;">7</span>;    <span style="color: #808080; font-style: italic;">// restart at MSB</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		idx++;      <span style="color: #808080; font-style: italic;">// next byte!</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">else</span> cnt--;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// WRITE TO RIGHT VARS</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// as bits[1] and bits[3] are always zero they are omitted </span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">*humidity    = bits<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">*temp = bits<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">uint8_t sum = bits<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> + bits<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>bits<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#93;</span> != sum<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">return</span> DHTLIB_ERROR_CHECKSUM;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">return</span> DHTLIB_OK;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p><b>Schematics:</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/ds18b20_dht11_atmega8_3.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/ds18b20_dht11_atmega8_3-300x298.png" alt="" title="ds18b20_dht11_atmega8_3" width="300" height="298" class="alignnone size-medium wp-image-3014" /></a></p>
<p><b>Source code:</b><br />
I have designed the code for an Atmega8 microcontroller. The code is available <a href='http://www.pocketmagic.net/wp-content/uploads/2012/10/TemperatureLCD.zip'>here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/10/atmega8-temperature-sensors-ds18b20-and-dht11/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Vacuum tube tesla coil (VTTC) using Russian GU-81m</title>
		<link>http://www.pocketmagic.net/2012/09/vacuum-tube-tesla-coil-vttc-using-russian-gu-81m/</link>
		<comments>http://www.pocketmagic.net/2012/09/vacuum-tube-tesla-coil-vttc-using-russian-gu-81m/#comments</comments>
		<pubDate>Tue, 25 Sep 2012 22:57:46 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[High Voltage]]></category>
		<category><![CDATA[GU81m]]></category>
		<category><![CDATA[tesla coil]]></category>
		<category><![CDATA[VTTC]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=2988</guid>
		<description><![CDATA[Vasil sent me 3 of his complete tesla coil systems. So here I am rebuilding his GU81m VTTC.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.sciencezero.org/vasil/">Vasil </a>gave me several of his tesla coils, including the GU-81m tesla coil presented <a href="http://www.pocketmagic.net/?p=861">here</a>. Since putting everything together was not a real challenge, I decided to customize some of the builds and change little details just to learn something new. Thanks Vasil, this is a great gift!</p>
<p><b>Project summary:</b><br />
<a href="#120926">2012-09-26, Introduction</a><br />
<a href="#120928">2012-09-28, First test</a><br />
<a href="#130406">2013-04-06, The wooden case</a></p>
<p><!--UPDATE--><br />
<a name="120926"></a><br></p>
<h3>September 26, 2012</h3>
<p>My first target is the GU-81M VTTC, which I'll show in this article. <a href="http://www.sciencezero.org/vasil/teslina/gu81mpage.html">Here </a>is Vasil's original circuit diagram:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_gu81m_mot_doubler.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_gu81m_mot_doubler-300x253.jpg" alt="" title="vttc_gu81m_mot_doubler" width="300" height="253" class="alignnone size-medium wp-image-2989" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_gu81m_vasil.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_gu81m_vasil-237x300.jpg" alt="" title="vttc_gu81m_vasil"  height="253" class="alignnone size-medium wp-image-2990" /></a></p>
<p>I got all the precious components , including the tube, caps, a mot, diodes, even the primary and the secondary coils!<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/vasil_vttc_parts.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/vasil_vttc_parts.jpg" alt="" title="vasil_vttc_parts" width="800" height="600" class="alignnone size-full wp-image-2991" /></a></p>
<p>So here is what I did:</p>
<p>1. The secondary: The coil has been added a few extra turns, so I had to find a way to improve the insulation. I opted for epoxy, with some extra quantity added over the soldering:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_secondary_all.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_secondary_all-150x150.jpg" alt="" title="vttc_secondary_all" width="150" height="150" class="alignnone size-thumbnail wp-image-2992" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_secondary.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_secondary-150x150.jpg" alt="" title="vttc_secondary" width="150" height="150" class="alignnone size-thumbnail wp-image-2993" /></a></p>
<p>2. Grid leakage resistor (R1) new PCB board - 20 x 27Ohm 10W resistors in series, for a total of 540Ohm:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/grid_leakage_resistance_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/grid_leakage_resistance_1-150x150.jpg" alt="" title="grid_leakage_resistance_1" width="150" height="150" class="alignnone size-thumbnail wp-image-2994" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/grid_leakage_resistance_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/grid_leakage_resistance_2-150x150.jpg" alt="" title="grid_leakage_resistance_2" width="150" height="150" class="alignnone size-thumbnail wp-image-2995" /></a></p>
<p>3. Supply filter cap (C3) 6x polypropylene caps 6nF/1600V in series:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_filter_cap.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_filter_cap-150x150.jpg" alt="" title="vttc_filter_cap" width="150" height="150" class="alignnone size-thumbnail wp-image-2996" /></a></p>
<p><!--UPDATE--><br />
<a name="120928"></a><br></p>
<h3>September 28, 2012</h3>
<p>Got it ready for a first test. Unfortunately it didn't work - yet . I probably made a mistake when connecting the feedback coil.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_gu81m_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_gu81m_1-150x150.jpg" alt="" title="vttc_gu81m_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3002" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_gu81m_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_gu81m_2-150x150.jpg" alt="" title="vttc_gu81m_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3002" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_gu81m_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_gu81m_3-150x150.jpg" alt="" title="vttc_gu81m_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3002" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_gu81m_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_gu81m_4-150x150.jpg" alt="" title="vttc_gu81m_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3002" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_gu81m_5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_gu81m_5-150x150.jpg" alt="" title="vttc_gu81m_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3002" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_gu81m_6.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/vttc_gu81m_6-150x150.jpg" alt="" title="vttc_gu81m_1" width="150" height="150" class="alignnone size-thumbnail wp-image-3002" /></a></p>
<p><a name="130406"></a><br></p>
<h3>April 6, 2013</h3>
<p>The wooden case is complete.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/gu81m_tesla_coil_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/gu81m_tesla_coil_2-199x300.jpg" alt="gu81m_tesla_coil_2" width="199" height="300" class="alignnone size-medium wp-image-3992" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/gu81m_tesla_coil_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/gu81m_tesla_coil_3-199x300.jpg" alt="gu81m_tesla_coil_3" width="199" height="300" class="alignnone size-medium wp-image-3993" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/gu81m_tesla_coil_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/gu81m_tesla_coil_4-199x300.jpg" alt="gu81m_tesla_coil_4" width="199" height="300" class="alignnone size-medium wp-image-3994" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/09/vacuum-tube-tesla-coil-vttc-using-russian-gu-81m/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tube: G21-H Geiger Muller</title>
		<link>http://www.pocketmagic.net/2012/09/tube-g21-h-geiger-muller/</link>
		<comments>http://www.pocketmagic.net/2012/09/tube-g21-h-geiger-muller/#comments</comments>
		<pubDate>Sun, 16 Sep 2012 09:16:06 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Tubes]]></category>
		<category><![CDATA[g21h]]></category>
		<category><![CDATA[geiger muller]]></category>
		<category><![CDATA[tubes]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=2955</guid>
		<description><![CDATA[A Geiger Muller tube for Gamma radiation.]]></description>
				<content:encoded><![CDATA[<p><b>Pictures:</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/1-150x150.jpg" alt="" title="1" width="150" height="150" class="alignnone size-thumbnail wp-image-2956" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/2-150x150.jpg" alt="" title="1" width="150" height="150" class="alignnone size-thumbnail wp-image-2956" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/3-150x150.jpg" alt="" title="1" width="150" height="150" class="alignnone size-thumbnail wp-image-2956" /></a><br />
<b>Details:</b><br />
Halogen quenched Geiger Muller Tube, for gamma ray counters, manufactured around 1968 at I.F.A. Romania (Institute of Atomic Physics, Bucuresti, Romania).<br />
It uses 400V, background radiation 110impulses/minute, at the life is guaranteed for 10^9 impulses.<br />
<b>Datasheet:</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/geiger_tube_G21H_IFA.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/geiger_tube_G21H_IFA-300x148.jpg" alt="" title="geiger_tube_G21H_IFA" width="300" height="148" class="alignnone size-medium wp-image-2959" /></a><br />
<b>Links:</b><br />
n/a</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/09/tube-g21-h-geiger-muller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tube: UX-6653</title>
		<link>http://www.pocketmagic.net/2012/09/tube-ux-6653/</link>
		<comments>http://www.pocketmagic.net/2012/09/tube-ux-6653/#comments</comments>
		<pubDate>Wed, 05 Sep 2012 07:32:57 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Tubes]]></category>
		<category><![CDATA[tubes]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=2929</guid>
		<description><![CDATA[A TR Switch tube used in Radar technology, manufactured by Raytheon.]]></description>
				<content:encoded><![CDATA[<p><b>Pictures:</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/ux-6653_raytheon_1.jpg.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/ux-6653_raytheon_1.jpg-150x150.jpg" alt="" title="ux-6653_raytheon_1.jpg" width="150" height="150" class="alignnone size-thumbnail wp-image-2930" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/ux-6653_raytheon_2.jpg.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/ux-6653_raytheon_2.jpg-150x150.jpg" alt="" title="ux-6653_raytheon_1.jpg" width="150" height="150" class="alignnone size-thumbnail wp-image-2930" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/ux-6653_raytheon_3.jpg.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/ux-6653_raytheon_3.jpg-150x150.jpg" alt="" title="ux-6653_raytheon_1.jpg" width="150" height="150" class="alignnone size-thumbnail wp-image-2930" /></a><br />
<b>Details:</b><br />
TR switch in SG radar, about 1941<br />
<b>Datasheet:</b><br />
n/a<br />
<b>Links:</b><br />
<a href="http://www.radiomuseum.org/tubes/tube_ux-6653.html">RadioMuseum</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/09/tube-ux-6653/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tube: EMI9524</title>
		<link>http://www.pocketmagic.net/2012/09/tube-emi9524/</link>
		<comments>http://www.pocketmagic.net/2012/09/tube-emi9524/#comments</comments>
		<pubDate>Sun, 02 Sep 2012 12:55:51 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Tubes]]></category>
		<category><![CDATA[tubes]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=2921</guid>
		<description><![CDATA[A sensitive photomultiplier tube, used in scintillation detectors.]]></description>
				<content:encoded><![CDATA[<p><b>Pictures:</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/emi9524-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/emi9524-1-150x150.jpg" alt="" title="emi9524-1" width="150" height="150" class="alignnone size-thumbnail wp-image-2922" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/emi9524-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/emi9524-2-150x150.jpg" alt="" title="emi9524-2" width="150" height="150" class="alignnone size-thumbnail wp-image-2923" /></a><br />
<b>Details:</b><br />
EMI photomuliplier tube type 9524S (ser no 60678).  14 pin base.<br />
30mm diameter, 112mm long, 11 dynodes, responds to light wavelengths from 320nm to 630nm.<br />
Low dark current, typical sensitivity 50uA/lm, 20.5% peak Q.E.</p>
<p>Lime soda glass window, S-11 type photocatode; 11 dynodes coated with CsSb. 14 pin, B14B base. Intended for scintillation counter applications.<br />
EMI/US, North Hollywood, CA, USA, known manufacturer.  </p>
<p><b>Datasheet:</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/emi9524-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/emi9524-3-150x150.jpg" alt="" title="emi9524-3" width="150" height="150" class="alignnone size-thumbnail wp-image-2924" /></a><br />
<b>Links:</b></p>
<p>http://www.radiomuseum.org/tubes/tube_9524b.html</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/09/tube-emi9524/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tube: ZV1009</title>
		<link>http://www.pocketmagic.net/2012/09/tube-zv1009/</link>
		<comments>http://www.pocketmagic.net/2012/09/tube-zv1009/#comments</comments>
		<pubDate>Sun, 02 Sep 2012 12:31:48 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Tubes]]></category>
		<category><![CDATA[tubes]]></category>
		<category><![CDATA[zv1009]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=2917</guid>
		<description><![CDATA[A klystron capable of up to 6000MHz]]></description>
				<content:encoded><![CDATA[<p><b>Pictures:</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/zv_1009_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/zv_1009_1-150x150.jpg" alt="" title="zv_1009_1" width="150" height="150" class="alignnone size-thumbnail wp-image-2918" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/09/zv_1009_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/09/zv_1009_2-150x150.jpg" alt="" title="zv_1009_2" width="150" height="150" class="alignnone size-thumbnail wp-image-2919" /></a><br />
<b>Details:</b><br />
Metal-ceramic klystron, derived from 6BL6; 1500 to 6000 MHz; can be operated CW, pulsed or FM. Pee-wee 4 pin base; external cavity. Made to Polarad specs under WE patents.<br />
Pin 1 - control electrode, pin 2,4 - heater, pin 3 - cathode; resonator grids to the two rings on the body; reflector to cap.<br />
Filament 	Vf 6.3 Volts / If: 0.68 Ampere / -: Indirect /<br />
<b>Datasheet:</b><br />
n/a<br />
<b>Links:</b><br />
<a href="http://www.radiomuseum.org/tubes/tube_zv1009.html">zv1009</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/09/tube-zv1009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bausch and Lomb Microscope</title>
		<link>http://www.pocketmagic.net/2012/08/bausch-and-lomb-microscope/</link>
		<comments>http://www.pocketmagic.net/2012/08/bausch-and-lomb-microscope/#comments</comments>
		<pubDate>Sat, 04 Aug 2012 12:43:16 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Optics]]></category>
		<category><![CDATA[Photography]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[1000X]]></category>
		<category><![CDATA[bausch and lomb]]></category>
		<category><![CDATA[cells]]></category>
		<category><![CDATA[magnification]]></category>
		<category><![CDATA[microscope]]></category>
		<category><![CDATA[onion skin cells]]></category>
		<category><![CDATA[optic]]></category>
		<category><![CDATA[optical]]></category>
		<category><![CDATA[phase contrast]]></category>
		<category><![CDATA[spider]]></category>
		<category><![CDATA[white mold]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3562</guid>
		<description><![CDATA[Read a post on my new acquisition, a Bauch&#038;Lomb compound binocular microscope, a high quality tool, put to some good use to capture a few micro photographs. It can get up to 1000X with its current optics.]]></description>
				<content:encoded><![CDATA[<p>It's more than twenty years since the last Bausch&Lomb compound microscopes were made. You won't see them equipped with modern features like computer connectivity or the ability to take digital photographs without modification, still for most of the 20th century, Bausch and Lomb compound microscopes were some of the best available for purchase.<br />
Since I'm a curious being, I've for long been fascinated by the unseen micro world, so the microscope was a much desired tool. I've even built some of my own, but the performance was too low to be worth mentioning. Finally I managed to get a nice Bausch&Lomb compound binocular microscope, marked as 31-74-26 .<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-binocular-microscope-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-binocular-microscope-1-150x150.jpg" alt="bausch and lomb binocular microscope 1" width="150" height="150" class="alignnone size-thumbnail wp-image-3564" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-binocular-microscope-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-binocular-microscope-2-150x150.jpg" alt="bausch and lomb binocular microscope 2" width="150" height="150" class="alignnone size-thumbnail wp-image-3565" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-binocular-microscope-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-binocular-microscope-3-150x150.jpg" alt="bausch and lomb binocular microscope 3" width="150" height="150" class="alignnone size-thumbnail wp-image-3566" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-binocular-microscope-4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-binocular-microscope-4-150x150.jpg" alt="bausch and lomb binocular microscope 4" width="150" height="150" class="alignnone size-thumbnail wp-image-3567" /></a></p>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-binocular-microscope-5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-binocular-microscope-5-150x150.jpg" alt="bausch and lomb binocular microscope 5" width="150" height="150" class="alignnone size-thumbnail wp-image-3568" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-binocular-microscope-6.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-binocular-microscope-6-150x150.jpg" alt="bausch and lomb binocular microscope 6" width="150" height="150" class="alignnone size-thumbnail wp-image-3569" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-binocular-microscope-7.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-binocular-microscope-7-150x150.jpg" alt="bausch and lomb binocular microscope 7" width="150" height="150" class="alignnone size-thumbnail wp-image-3570" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-binocular-microscope-8.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-binocular-microscope-8-150x150.jpg" alt="bausch and lomb binocular microscope 8" width="150" height="150" class="alignnone size-thumbnail wp-image-3571" /></a></p>
<h3>Features and specs:</h3>
<p>Model: Galen 3 (?)<br />
Manufacture year: ?<br />
Style: Inclined Binocular<br />
Serial #: 31-74-26<br />
Eyepiece: Wide Field 10X<br />
Nosepiece: Quadruple<br />
Focusing: Coaxial coarse & fine adjustment<br />
Stage: Graduated mechanical stage<br />
Objectives: 4x, 10x, 40x, 100x (oil):  A4/0.10 160/-, A10/0.25 160/-, A40/0.65 160/0.17, A100/1.25 160/0.17 (oil)<br />
Substage: Abbe Condenser 1.25 N.A. with rack & pinion<br />
Light Source: Variable intensity control 6v 20w<br />
Power input: 110V<br />
This unit also features phase contrast accessory however the objectives, while a set of B&L matched objectives, are not optimized for phase contrast.  Abbe condenser, iris diaphragm and variable intensity quartz lamp.  Mechanical stage that is tight and works perfectly. The binocular head has dual diopter adjustments. A few interesting details <a href="http://www.microscopemaster.com/phase-contrast-microscope.html">here </a> and <a href="http://www.microscopemaster.com/compound-light-microscope.html">here</a>.</p>
<h3>Simple mod for 220V power input</h3>
<p>As I got this unit from the USA, it was designed for 110V outlets. I had to change it to take 220V. In it's original form, it came with a 110V / 6V transformer, a voltage adjustable regulator, and a 6V/20W halogen bulb.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-electronics-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-electronics-1-150x150.jpg" alt="bausch and lomb electronics 1" width="150" height="150" class="alignnone size-thumbnail wp-image-3574" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-electronics-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-electronics-2-150x150.jpg" alt="bausch and lomb electronics 2" width="150" height="150" class="alignnone size-thumbnail wp-image-3575" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-electronics-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-electronics-3-150x150.jpg" alt="bausch and lomb electronics 3" width="150" height="150" class="alignnone size-thumbnail wp-image-3576" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-electronics-4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-electronics-4-150x150.jpg" alt="bausch and lomb electronics 4" width="150" height="150" class="alignnone size-thumbnail wp-image-3577" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-electronics-5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-electronics-5-150x150.jpg" alt="bausch and lomb electronics 5" width="150" height="150" class="alignnone size-thumbnail wp-image-3578" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-electronics-6.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-electronics-6-150x150.jpg" alt="bausch and lomb electronics 6" width="150" height="150" class="alignnone size-thumbnail wp-image-3579" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-electronics-7.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-electronics-7-150x150.jpg" alt="bausch and lomb electronics 7" width="150" height="150" class="alignnone size-thumbnail wp-image-3580" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-electronics-8.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/bausch-and-lomb-electronics-8-150x150.jpg" alt="bausch and lomb electronics 8" width="150" height="150" class="alignnone size-thumbnail wp-image-3581" /></a><br />
I only changed the bulb, for a 12V 20W one, and the power plug for 220V European outlets. Powering the unit at 220V will double the transformer's output, in this case 12V. This is a bit hard for the transformer, but it works good. I just need to be careful when adjusting the light to maximum level, as this makes the transformer heat up in a matter of minutes. I might change this electronic setup later.</p>
<h3>First micro photographs</h3>
<p>This microscope doesn't have a digital camera adapter, as explained above. But taking pictures via the eyepiece is not that hard. Having my camera set on manual settings (including the focus) did a decent job:<br />
<b>Onion skin cells</b><br />
The cells of an onion skin are generally rectangular in shape and range in size from 0.25 to 0.4 millimeters in length (250-400 micrometers):<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/040X_onion-skin-cells-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/040X_onion-skin-cells-1-150x150.jpg" alt="040X_onion skin cells 1" width="150" height="150" class="alignnone size-thumbnail wp-image-3583" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/100X_onion-skin-cells-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/100X_onion-skin-cells-2-150x150.jpg" alt="100X_onion skin cells 2" width="150" height="150" class="alignnone size-thumbnail wp-image-3584" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/400X_onion-skin-cells-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/400X_onion-skin-cells-3-150x150.jpg" alt="400X_onion skin cells 3" width="150" height="150" class="alignnone size-thumbnail wp-image-3585" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/400X_onion-skin-cells-4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/400X_onion-skin-cells-4-150x150.jpg" alt="400X_onion skin cells 4" width="150" height="150" class="alignnone size-thumbnail wp-image-3586" /></a></p>
<p><b>White mold formed on grapes</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/100X-white-mold.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/100X-white-mold-150x150.jpg" alt="100X white mold" width="150" height="150" class="alignnone size-thumbnail wp-image-3588" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/400X-white-mold.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/400X-white-mold-150x150.jpg" alt="400X white mold" width="150" height="150" class="alignnone size-thumbnail wp-image-3589" /></a> </p>
<p><b>Live spider (no spider was hurt in the process, but it was hard to focus the little moving guy)</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/spider-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/spider-1-150x150.jpg" alt="spider 1" width="150" height="150" class="alignnone size-thumbnail wp-image-3591" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/spider-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/spider-2-150x150.jpg" alt="spider 2" width="150" height="150" class="alignnone size-thumbnail wp-image-3592" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/spider-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/spider-3-150x150.jpg" alt="spider 3" width="150" height="150" class="alignnone size-thumbnail wp-image-3593" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/08/spider-4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/08/spider-4-150x150.jpg" alt="spider 4" width="150" height="150" class="alignnone size-thumbnail wp-image-3594" /></a></p>
<p>I will post other microphotos from time to time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/08/bausch-and-lomb-microscope/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Atmega8 and enc28J60 for ethernet support</title>
		<link>http://www.pocketmagic.net/2012/07/atmega8-and-enc28j60-for-ethernet-support/</link>
		<comments>http://www.pocketmagic.net/2012/07/atmega8-and-enc28j60-for-ethernet-support/#comments</comments>
		<pubDate>Mon, 30 Jul 2012 21:02:31 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[atmega8]]></category>
		<category><![CDATA[atmel]]></category>
		<category><![CDATA[dht-11]]></category>
		<category><![CDATA[ds18b20]]></category>
		<category><![CDATA[enc28j60]]></category>
		<category><![CDATA[Ethernet]]></category>
		<category><![CDATA[humidity]]></category>
		<category><![CDATA[microcontrollers]]></category>
		<category><![CDATA[tcp/ip]]></category>
		<category><![CDATA[temperature]]></category>
		<category><![CDATA[webserver]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=2866</guid>
		<description><![CDATA[Learn how to create a network interface for your microcontroller projects. Here I have shown an example using the Atmega8 and the enc28j60 . Build a simple Webserver to show sensor data such as temperature or humidity.]]></description>
				<content:encoded><![CDATA[<p>It's not my first time working on microcontrollers and Ethernet interfaces, last time I've used an Arduino board with Ethernet shield for <a href="http://www.pocketmagic.net/?p=484">a voice control application</a>. Now I have to build everything from scratch, and the target microcontroller is an atmega8, so the little program memory must be considered.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/atmega8-enc28j60.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/atmega8-enc28j60.jpg" alt="" title="atmega8 enc28j60" width="800" height="311" class="alignnone size-full wp-image-2870" /></a></p>
<p><b>Progress summary:</b><br />
<a href="#120730">2012-07-30, First setup, using a buffer</a><br />
<a href="#121011">2012-10-11, A simpler variant with no buffers</a><br />
<a href="#121103">2012-11-03, Another simple webserver</a></p>
<p><!--UPDATE--><br />
<a name="120730"></a><br></p>
<h3>July 30, 2012</h3>
<p>My Atmega8 will use an external crystal, and run at 16MHz. It is connected to a 5V supply. The enc28J60 requires 3.3V. The two chips must communicate using the SPI interface.</p>
<p>I found the original project posted on <a href="http://tuxgraphics.com/electronics/200606/article06061.shtml">tuxgraphics </a>. The solution is a good starting point, but it has lots of issues like: no buffering between the microcontroller and the Ethernet chip, microcontroller takes CLK signals from the Ethernet chip, not being able to run at various values, not a chance at 16MHz as I need it.</p>
<p>There are numerous reports of issues caused by the voltage difference in the SPI link. I have decided to use a buffer, as indicated by Mirek, from Poland, <a href="http://www.elektroda.pl/rtvforum/viewtopic.php?t=1644963&highlight=">here</a>. He also sells<a href="http://atnel.pl/karta-sieciowa-ethernet.html"> ready made Ethernet boards</a> that are extremely well built and will save you considerable time for such a project.</p>
<p>The buffer chip is <a href='http://www.pocketmagic.net/wp-content/uploads/2012/07/SN74LS125A.pdf'>SN74LS125A</a>. For the Ethernet chip I purchased a simple board from <a href="http://www.ebay.com/sch/i.html?_trksid=p5197.m570.l1313&_nkw=enc28j60&_sacat=0">Ebay</a>, featuring the enc28J60 chip, the 25MHz crystal, the magnetic ethernet connector, and a few other components:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/enc28j60-board.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/enc28j60-board.jpg" alt="" title="enc28j60 board" width="800" height="311" class="alignnone size-full wp-image-2872" /></a><br />
When the 3.3V are applied and the network cable is connected, the two leds green and yellow should turn on from time to time. I bought two, and both refused to show any led activity. The boards were dead. Looking carefully I've noticed the crystals are soldered improperly and were shorting a few paths of the circuit. Correcting this, solved the problem and the boards were ready for use.<br />
Here is the circuit diagram for these boards:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/enc28j60-board-schematics.pdf"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/ethernet_board-300x195.jpg" alt="" title="ethernet_board" width="300" height="195" class="alignnone size-medium wp-image-2873" /></a><br />
The connector exposes CLKOUT, INT, WOL, SO, SI, SCK, CS, RESET, VCC and GND. I'm currently using only INT,SO,SI,SCK,CS, VCC and GND. The board takes 3.3V so make sure you use a regulator.</p>
<p>Here is how to connect the Ethernet board to the SN74LS125AN buffer. Only INT and SO need to be buffered:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/87_1271699328.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/87_1271699328-300x136.jpg" alt="" title="87_1271699328" width="300" height="136" class="alignnone size-medium wp-image-2877" /></a></p>
<p>Now you are ready to connect it to the Atmega8. SO goes to MISO, SI to MOSI, SCK to SCK, I have connected CS to PB2(SS/OC1B) and INT to PD2 (INT0). </p>
<h3>The software</h3>
<p>The software I've prepared for this article, comes with a minimalistic TCP/IP stack supporting IP, ARP, UDP and TCP, based on the original work of Guido Socher and released under GPL V2 license.<br />
I made it as a simple webserver, to open TCP port 80, so you can connect with your browser but you need to provide a few parameters: http://microcontroller_ip/?cmd=1 . In my sample I've used http://192.168.2.24/?cmd=1 , but you'll need to change the code for a new IP that matches your network settings.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/browser.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/browser.jpg" alt="" title="browser" width="239" height="103" class="alignnone size-full wp-image-2879" /></a><br />
The firmware replies to PINGs which are counted and displayed on the LCD and on the Atmega webpage. The webpage shows the number of times it has been accessed.</p>
<p>Source code:<br />
<a href='http://www.pocketmagic.net/wp-content/uploads/2012/07/ATMegaEth.zip'>ATMegaEth</a></p>
<p><!--UPDATE--><br />
<a name="121011"></a><br></p>
<h3>Update: October 11, 2012</h3>
<p>For a simpler variant, you can skip the buffer and just connect the ENC28J60 module directly to the Atmega8. It will work well, especially if you don't have other devices connected via SPI.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/atmega8_eth_simple.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/atmega8_eth_simple-300x136.jpg" alt="" title="atmega8_eth_simple" width="300" height="136" class="alignnone size-medium wp-image-3030" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/atmega8_temperature_humidity_eth.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/atmega8_temperature_humidity_eth-300x261.jpg" alt="" title="atmega8_temperature_humidity_eth" width="300" height="261" class="alignnone size-medium wp-image-3031" /></a><br />
Here is the software to get this running. It comes as a small WEBSERVER, configured as 192.168.2.24 in code, and supports a DS18B20 temperature sensor connected to the PC4 pin, as well as a DHT-11 temperature and humidity sensor, to show the temperature via the web interface:<br />
<a href='http://www.pocketmagic.net/wp-content/uploads/2012/07/ATmega8_ENC28J60_NOBUFFER_TEMP_WEBSERVER.zip'>ATmega8_ENC28J60_NOBUFFER_TEMP_WEBSERVER</a><br />
The problem is the ENC28J60's mini TCP/IP stack uses a lot of the Atmega8's available flash memory. Aprox.6-7K out of 8K available. This leaves very little room for additional logic.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/atmega8_webserver.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/atmega8_webserver.jpg" alt="" title="atmega8_webserver" width="597" height="273" class="alignnone size-full wp-image-3036" /></a><br />
More on temperature sensors <a href="http://www.pocketmagic.net/?p=3009">here</a>.</p>
<p><!--UPDATE--><br />
<a name="121103"></a><br></p>
<h3>Update: November 03, 2012</h3>
<p>Here is the very basic webserver implementation, featuring only the Ethernet interface, and the minimum software, that runs a local webserver. IP is configured as 192.168.2.24, so take that into account when building your own.<br />
<b>Circuit diagram</b>:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/simple_atmega8_webserver.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/simple_atmega8_webserver.png" alt="" title="simple_atmega8_webserver" width="800" height="389" class="alignnone size-full wp-image-3285" /></a><br />
I tested this on my testboard, nothing fancy:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/enc28j60_board_atmega_s.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/enc28j60_board_atmega_s.jpg" alt="" title="enc28j60_board_atmega_s" width="800" height="531" class="alignnone size-full wp-image-3286" /></a></p>
<p>It works great, here are some images with pings and the web page it exposes:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/ping_atmega8.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/ping_atmega8.jpg" alt="" title="ping_atmega8" width="380"   /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/web_interface_atmega8.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/web_interface_atmega8.jpg" alt="" title="web_interface_atmega8" width="380"/></a></p>
<p>The code is available here:<br />
<a href='http://www.pocketmagic.net/wp-content/uploads/2012/07/webserver_atmega8.zip'>webserver_atmega8</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/07/atmega8-and-enc28j60-for-ethernet-support/feed/</wfw:commentRss>
		<slash:comments>51</slash:comments>
		</item>
		<item>
		<title>Android Overlay Mouse Cursor</title>
		<link>http://www.pocketmagic.net/2012/07/android-overlay-cursor/</link>
		<comments>http://www.pocketmagic.net/2012/07/android-overlay-cursor/#comments</comments>
		<pubDate>Fri, 27 Jul 2012 15:58:53 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Cursor]]></category>
		<category><![CDATA[mouse]]></category>
		<category><![CDATA[Overlay]]></category>
		<category><![CDATA[TYPE_SYSTEM_OVERLAY]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=2853</guid>
		<description><![CDATA[Learn how to create a mouse cursor in Android OS programatically, using Overlay Views.]]></description>
				<content:encoded><![CDATA[<p>For an application developer it is important to have total freedom in shaping the result of his work.<br />
Even if Android OS has been designed without the mouse cursor in mind, there are plenty of situations where a developer needs a cursor on top of other applications installed.</p>
<p>We can draw the cursor at the <a href="http://www.pocketmagic.net/?p=1473">framebuffer </a>level, and while this provides optimum performance, it requires special privileges that regular apps don't have.<br />
The second approach , and the subject of this article, is drawing a cursor using an Overlay.</p>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td><a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/android-mouse-cursor-overlay.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/android-mouse-cursor-overlay-180x300.jpg" alt="" title="android mouse cursor overlay" width="180" height="300" class="alignnone size-medium wp-image-2854" /></a></td>
<td valign="top">
<b>What is an overlay?</b><br />
The SDK defines them as: "Window type: system overlay windows, which need to be displayed on top of everything else. These windows must not take input focus, or they will interfere with the keyguard. "</p>
<p>So what we are about to do is have a small view created, make it show a cursor image, and move it around.<br />
To make things easier, I created a special service class, since the code that displays a cursor would probably be a service , running in the background, and accepting cursor position updates.</p>
<p><b>Sample application</b><br />
You can download the sample application <a href='http://www.pocketmagic.net/wp-content/uploads/2012/07/myCursorOverlay.zip'>here</a>. You can use the code in free or non commercial applications.
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td valign="top">
<b>Details</b><br />
Unless your AndroidManifest.xml contains the SYSTEM_ALERT_WINDOW permission, the code will fail:</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> WindowManager.<span style="color: #006600;">LayoutParams</span> params = <span style="color: #000000; font-weight: bold;">new</span> WindowManager.<span style="color: #006600;">LayoutParams</span><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    WindowManager.<span style="color: #006600;">LayoutParams</span>.<span style="color: #006600;">WRAP_CONTENT</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    WindowManager.<span style="color: #006600;">LayoutParams</span>.<span style="color: #006600;">WRAP_CONTENT</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    WindowManager.<span style="color: #006600;">LayoutParams</span>.<span style="color: #006600;">TYPE_SYSTEM_OVERLAY</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    WindowManager.<span style="color: #006600;">LayoutParams</span>.<span style="color: #006600;">FLAG_NOT_FOCUSABLE</span> | </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">WindowManager.<span style="color: #006600;">LayoutParams</span>.<span style="color: #006600;">FLAG_NOT_TOUCHABLE</span> |</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">WindowManager.<span style="color: #006600;">LayoutParams</span>.<span style="color: #006600;">FLAG_LAYOUT_IN_SCREEN</span>, </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">PixelFormat.<span style="color: #006600;">TRANSLUCENT</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>To make the cursor be able to cover the status bar, and have it's coordinates starting from screen's (0,0) leftmost and topmost point, you will need to specify the .FLAG_LAYOUT_IN_SCREEN flag.
</td>
<td><a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/android-mouse-cursor-overlay-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/android-mouse-cursor-overlay-2-180x300.jpg" alt="" title="android mouse cursor overlay 2" width="180" height="300" class="alignnone size-medium wp-image-2858" /></a></td>
</tr>
</table>
<p>Hope this code proves useful. Looking forward to your comments, questions and feedback,</p>
<h3>Customizing the system's pointer</h3>
<p>It is possible to detect the system mouse coordinates and draw a custom overlay on top of the system mouse cursor. This way we can increase the pointer image size, a very useful enhancement for those that have problems seeing the tiny default cursor. Here is a demo showing a bluetooth mouse cursor and our bigger custom mouse cursor overlay.<br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/XHydpoKq6cw" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/07/android-overlay-cursor/feed/</wfw:commentRss>
		<slash:comments>43</slash:comments>
		</item>
		<item>
		<title>Android default orientation and orientation change events</title>
		<link>http://www.pocketmagic.net/2012/07/android-default-orientation-and-orientation-change-events/</link>
		<comments>http://www.pocketmagic.net/2012/07/android-default-orientation-and-orientation-change-events/#comments</comments>
		<pubDate>Tue, 24 Jul 2012 11:09:01 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[getRotation]]></category>
		<category><![CDATA[orientation]]></category>
		<category><![CDATA[Sensor.TYPE_ORIENTATION]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=2847</guid>
		<description><![CDATA[Find the default orientation on Android devices, and intercept orientation changes even for activities locked in portrait or landscape mode.]]></description>
				<content:encoded><![CDATA[<p>There are times when you want to lock your Activity in Landscape only or Portrait only modes (using AndroidManifest's
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;activity ... <span style="color: #006600;">android</span>:screenOrientation=<span style="color: #ff0000;">&quot;portrait&quot;</span>/&gt;</div></li></ol></pre>
<p> clause or directly from code using
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">setRequestedOrientation<span style="color: #66cc66;">&#40;</span>ActivityInfo.<span style="color: #006600;">SCREEN_ORIENTATION_PORTRAIT</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></pre>
<p>).<br />
But parts of your interface might need to update based on orientation changes (user rotates the device).<br />
The problem is that having your Activity orientation locked,  you won't receive the OnOrientationChanged notification.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/android_screen_orientation_small.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/android_screen_orientation_small.jpg" alt="" title="android_screen_orientation_small" width="800" height="250" class="alignnone size-full wp-image-2850" /></a><br />
To solve this issue you will need to do two things:<br />
1. register for sensor notifications, in this case we'll need the  Sensor.TYPE_ORIENTATION<br />
2. know the device natural orientation (for tablets it is landscape orientation, for phones it is portrait), because the coordinate-system returned by the sensors, is defined relative to the screen of the phone in its default orientation</p>
<p>Here's how to code it:<br />
1. In your Activity class define the following variables:</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//sensors</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">private</span> SensorManager		sensorManager;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #993333;">int</span>	sensor 					= SensorManager.<span style="color: #006600;">SENSOR_ORIENTATION</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">private</span> Sensor 				mySensor;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #993333;">int</span>						m_nOrientation				= <span style="color: #cc66cc;">-1</span>;						<span style="color: #808080; font-style: italic;">// invalid default value</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>2. In your Activity's OnCreate setup your sensor variables :</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #808080; font-style: italic;">// get sensor manager</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        sensorManager = <span style="color: #66cc66;">&#40;</span>SensorManager<span style="color: #66cc66;">&#41;</span> getSystemService<span style="color: #66cc66;">&#40;</span>SENSOR_SERVICE<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #808080; font-style: italic;">// get sensor</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        mySensor = sensorManager.<span style="color: #006600;">getDefaultSensor</span><span style="color: #66cc66;">&#40;</span>Sensor.<span style="color: #006600;">TYPE_ORIENTATION</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>3. In your Activity's OnResume register for sensor notifications, and in OnPause remove them:</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@Override <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> onResume<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006600;">onResume</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>sensorManager!= <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		sensorManager.<span style="color: #006600;">registerListener</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, mySensor, SensorManager.<span style="color: #006600;">SENSOR_DELAY_NORMAL</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@Override <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> onPause<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006600;">onPause</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>sensorManager != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		 sensorManager.<span style="color: #006600;">unregisterListener</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>4. Make the main Activity class implement SensorEventListener, and add the interface methods onAccuracyChanged and onSensorChanged. Add the following code to onSensorChanged:</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@Override</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> onSensorChanged<span style="color: #66cc66;">&#40;</span>SensorEvent event<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #808080; font-style: italic;">// TODO Auto-generated method stub</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">sensor</span>.<span style="color: #006600;">getType</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> == Sensor.<span style="color: #006600;">TYPE_ORIENTATION</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #808080; font-style: italic;">//The coordinate-system is defined relative to the screen of the phone in its default orientation</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	        <span style="color: #993333;">int</span> orientation = <span style="color: #cc66cc;">0</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #993333;">float</span> roll=<span style="color: #cc66cc;">0</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        	<span style="color: #993333;">float</span> pitch=<span style="color: #cc66cc;">0</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">switch</span> <span style="color: #66cc66;">&#40;</span>getWindowManager<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getDefaultDisplay</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getRotation</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>  <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            	<span style="color: #b1b100;">case</span> Surface.<span style="color: #006600;">ROTATION_0</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                	roll=event.<span style="color: #006600;">values</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			pitch=event.<span style="color: #006600;">values</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #000000; font-weight: bold;">break</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">case</span> Surface.<span style="color: #006600;">ROTATION_90</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			roll=event.<span style="color: #006600;">values</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			pitch=-event.<span style="color: #006600;">values</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #000000; font-weight: bold;">break</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">case</span> Surface.<span style="color: #006600;">ROTATION_180</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			roll=-event.<span style="color: #006600;">values</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			pitch=-event.<span style="color: #006600;">values</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #000000; font-weight: bold;">break</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">case</span> Surface.<span style="color: #006600;">ROTATION_270</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			roll=-event.<span style="color: #006600;">values</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			pitch=event.<span style="color: #006600;">values</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #000000; font-weight: bold;">break</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>pitch &gt;= <span style="color: #cc66cc;">-45</span> &amp;&amp; pitch &lt; <span style="color: #cc66cc;">45</span> &amp;&amp; roll &gt;= <span style="color: #cc66cc;">45</span><span style="color: #66cc66;">&#41;</span> orientation = <span style="color: #cc66cc;">0</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>pitch &lt; <span style="color: #cc66cc;">-45</span> &amp;&amp; roll &gt;= <span style="color: #cc66cc;">-45</span> &amp;&amp; roll &lt; <span style="color: #cc66cc;">45</span><span style="color: #66cc66;">&#41;</span> orientation = <span style="color: #cc66cc;">1</span>; </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>pitch &gt;= <span style="color: #cc66cc;">-45</span> &amp;&amp; pitch &lt; <span style="color: #cc66cc;">45</span> &amp;&amp; roll &lt; <span style="color: #cc66cc;">-45</span><span style="color: #66cc66;">&#41;</span> orientation = <span style="color: #cc66cc;">2</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>pitch &gt;= <span style="color: #cc66cc;">45</span> &amp;&amp; roll &gt;= <span style="color: #cc66cc;">-45</span> &amp;&amp; roll &lt; <span style="color: #cc66cc;">45</span> <span style="color: #66cc66;">&#41;</span> orientation = <span style="color: #cc66cc;">3</span>;		</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>m_nOrientation != orientation<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">//orientation changed event</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			m_Inst.<span style="color: #006600;">Debug</span><span style="color: #66cc66;">&#40;</span>LOG_TAG,<span style="color: #ff0000;">&quot;onSensorChanged: orientation:&quot;</span> + orientation<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			m_nOrientation = orientation;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #808080; font-style: italic;">// fire event for new notification, or update your interface here</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>Thanks go to <a href="http://stackoverflow.com/users/264181/diyism">diyism</a>, on stackoverflow.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/07/android-default-orientation-and-orientation-change-events/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bluetooth and iOS &#8211; Use Bluetooth in your iPhone apps</title>
		<link>http://www.pocketmagic.net/2012/07/bluetooth-and-ios-use-bluetooth-in-your-iphone-apps/</link>
		<comments>http://www.pocketmagic.net/2012/07/bluetooth-and-ios-use-bluetooth-in-your-iphone-apps/#comments</comments>
		<pubDate>Mon, 16 Jul 2012 20:31:24 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[BluetoothDevice]]></category>
		<category><![CDATA[bluetoothManager]]></category>
		<category><![CDATA[connect]]></category>
		<category><![CDATA[discover]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[hid]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPod]]></category>
		<category><![CDATA[private api]]></category>
		<category><![CDATA[profiles]]></category>
		<category><![CDATA[services]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[turn bluetooth off]]></category>
		<category><![CDATA[turn bluetooth on]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=2827</guid>
		<description><![CDATA[Learn how to use the BluetoothManager private APIs on iOS / iPhone/ iPod to discover nearby connections, populate a list view with the results, and try to establish a Bluetooth connection to the remote devices.]]></description>
				<content:encoded><![CDATA[<h3>Introduction</h3>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td><a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/ibluetoothze0.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/ibluetoothze0.png" alt="" title="ibluetoothze0" width="226" height="300" class="alignnone size-full wp-image-2829" /></a></td>
<td valign="top">
My past few articles on <a href="http://www.pocketmagic.net/?p=1398">Bluetooth and Android</a> , came with some sample source codes to provide an easier start for those interested in this wireless technology.<br />
Now I'm surprised to see that another successful mobile OS - Apple's iOS - has the same never-ending issues when it comes to a simple development task - writing a bluetooth application. <a href="http://www.pocketmagic.net/?p=2802">Starting with iOS development</a> was easy and straight-forward, but Bluetooth seems to be a no can do. Is it really?<br />
The purpose is to control the Bluetooth Radio: on, off , set it in discoverable mode, discover nearby devices, and establish a RFCOMM connection. Ideally we would also want access to L2CAP and SDP, but for a start let's take it slow.
</td>
</tr>
</table>
<h3>Evaluating the available options</h3>
<p>Here's a list with possible approaches one should consider when wanting to write a BLuetooth application for iPhone. The list is sorted having the better/official choice in mind. Workarounds get to the bottom of the list:<br />
1. Enroll in the made for iPhone/iPod/iPad (MFI) program. Details on costs are not available, but this is not for the small development companies, barely selling a few licenses. <a href="http://stackoverflow.com/questions/3843304/order-of-magnitude-cost-to-ship-an-ios-bluetooth-accessory">Some sources</a> indicate costs depending on project, and starting numbers somewhere at 10K USD.<br />
Not really an option IMO, as the costs involved and trouble getting certified are ridiculously high, for something so basic and simple such as building a Bluetooth application.<br />
2. CoreBluetooth framework, currently usable only with Low Energy Bluetooth 4 devices. Since these are not largely spread this is not really an option. You won't be able to connect to standard headsets, keyboards, or other non-Bluetooth 4 devices. Also at the moment of speaking, the iPhone 4S is the only device capable of LE Bluetooth functionality. Again, not an option.<br />
3. GameKit framework, this allows some basic Bluetooth functionality, such as finding nearby devices and establishing a serial communication link, but it only intended for use between iOS devices. So Android plus iPhone via GameKit is a no go. Remember to thank Apple for making it this way. Or not.<br />
4. Private APIs. There is a BluetoothManager framework, in the private APIs, inside the SDK. This can be used to achieve the proposed task, but you won't get your App approved on Appstore, as private API's is not allowed by Apple. Since this is so convenient, and working so nice, almost like the real thing Apple didn't want to include, I will be using it for this article.<br />
5. Jailbreaking and using Ringwald's BTStack. Jailbreaking = rooting = freedom, probably the best way to go . But this places you so far away from Apple's guidelines, and the Appstore itself. So better decide what your project is all about, and who your users will be.</p>
<h3>iOS BluetoothManager Framework</h3>
<p><b>Installing the Header files</b><br />
Get the 4 .h files from <a href="http://iphone-dev.googlecode.com/svn/branches/include-1.2-sdk/include/BluetoothManager/">here</a> or <a href='http://www.pocketmagic.net/wp-content/uploads/2012/07/iOS-BluetoothManager-Headers.zip'>here</a>.<br />
Browse to your Xcode installation at:<br />
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/PrivateFrameworks/BluetoothManager.framework<br />
Create a new folder, "Headers", and copy the 4 .h files there:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/iOS_bluetooth_01.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/iOS_bluetooth_01-300x272.jpg" alt="" title="iOS_bluetooth_01" width="300" height="272" class="alignnone size-medium wp-image-2837" /></a><br />
<b>Adding the new Framework in Xcode</b><br />
Go to Xcode, click the project in the Navigator, and select "Build Phases". Under "Link binary with Libraries", press the Plus symbol. Select BluetoothManager.framework and click Add.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/iOS_bluetooth_02.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/iOS_bluetooth_02-300x132.png" alt="" title="iOS_bluetooth_02" width="300" height="132" class="alignnone size-medium wp-image-2838" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/iOS_bluetooth_03.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/iOS_bluetooth_03-272x300.png" alt="" title="iOS_bluetooth_03" width="272" height="300" class="alignnone size-medium wp-image-2839" /></a><br />
<b>Using BluetoothManager.framework</b><br />
In your
<pre class="objc"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">viewDidLoad</div></li></ol></pre>
<p> do the following:<br />
1. get an handler to and instance of the BluetoothManager service:</p>
<pre class="objc"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">// setup bluetooth interface</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">btManager = <span style="color: #002200;">&#91;</span>BluetoothManager sharedInstance<span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>2. register for notifications, for Bluetooth radio change (on/off) and for discovering a new device:</p>
<pre class="objc"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #ff0000;">// setup bluetooth notifications</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSNotificationCenter.html"><span style="color: #0000ff;">NSNotificationCenter</span></a> defaultCenter<span style="color: #002200;">&#93;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">     addObserver:self</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">     selector:<span style="color: #0000ff;">@selector</span><span style="color: #002200;">&#40;</span>deviceDiscovered:<span style="color: #002200;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">     name:@<span style="color: #666666;">&quot;BluetoothDeviceDiscoveredNotification&quot;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">     object:<span style="color: #0000ff;">nil</span><span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSNotificationCenter.html"><span style="color: #0000ff;">NSNotificationCenter</span></a> defaultCenter<span style="color: #002200;">&#93;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">     addObserver:self</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">     selector:<span style="color: #0000ff;">@selector</span><span style="color: #002200;">&#40;</span>bluetoothAvailabilityChanged:<span style="color: #002200;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">     name:@<span style="color: #666666;">&quot;BluetoothAvailabilityChangedNotification&quot;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">     object:<span style="color: #0000ff;">nil</span><span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>3. Not needed for the purpose of this app, but it really helped me during development, you can set a notification Observer, and get all system notifications, including the Bluetooth notifications or other unknown notifications. You can later register them as shown at step 2).</p>
<pre class="objc"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #ff0000;">// global notification explorer</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    CFNotificationCenterAddObserver<span style="color: #002200;">&#40;</span>CFNotificationCenterGetLocalCenter<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>, </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                                    <span style="color: #0000ff;">NULL</span>, </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                                    MyCallBack, </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                                    <span style="color: #0000ff;">NULL</span>, </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                                    <span style="color: #0000ff;">NULL</span>,  </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                                    CFNotificationSuspensionBehaviorDeliverImmediately<span style="color: #002200;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>And the callback function is a simple debug logger, outside viewDidLoad:</p>
<pre class="objc"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">// global notification callback</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">void</span> MyCallBack <span style="color: #002200;">&#40;</span>CFNotificationCenterRef center,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                 <span style="color: #0000ff;">void</span> *observer,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                 CFStringRef name,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                 <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">void</span> *object,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                 CFDictionaryRef userInfo<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    NSLog<span style="color: #002200;">&#40;</span>@<span style="color: #666666;">&quot;CFN Name:%@ Data:%@&quot;</span>, name, userInfo<span style="color: #002200;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #002200;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>As I said, this is an extremely useful piece of code.</p>
<p>4. Set the callback for the notifications registered at step 2):</p>
<pre class="objc"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">/* Bluetooth notifications */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">- <span style="color: #002200;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #002200;">&#41;</span>bluetoothAvailabilityChanged:<span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSNotification.html"><span style="color: #0000ff;">NSNotification</span></a> *<span style="color: #002200;">&#41;</span>notification <span style="color: #002200;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    NSLog<span style="color: #002200;">&#40;</span>@<span style="color: #666666;">&quot;NOTIFICATION:bluetoothAvailabilityChanged called. BT State: %d&quot;</span>, <span style="color: #002200;">&#91;</span>btManager enabled<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;     </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #002200;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>And here is the second one, for discovering devices nearby:</p>
<pre class="objc"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">- <span style="color: #002200;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #002200;">&#41;</span>deviceDiscovered:<span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSNotification.html"><span style="color: #0000ff;">NSNotification</span></a> *<span style="color: #002200;">&#41;</span> notification <span style="color: #002200;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    BluetoothDevice *bt = <span style="color: #002200;">&#91;</span>notification object<span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    NSLog<span style="color: #002200;">&#40;</span>@<span style="color: #666666;">&quot;NOTIFICATION:deviceDiscovered: %@ %@&quot;</span>,bt.name, bt.address<span style="color: #002200;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #ff0000;">//create a new list item</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    BTListDevItem *item = <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>BTListDevItem alloc<span style="color: #002200;">&#93;</span> initWithName:bt.name description:bt.address type:<span style="color: #0000dd;">0</span> btdev:bt<span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #ff0000;">//add it to list</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSMutableArray.html"><span style="color: #0000ff;">NSMutableArray</span></a> *tempArray = <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSMutableArray.html"><span style="color: #0000ff;">NSMutableArray</span></a> alloc<span style="color: #002200;">&#93;</span> initWithArray:btDevItems<span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #002200;">&#91;</span>tempArray addObject:<span style="color: #002200;">&#40;</span>item<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    btDevItems = tempArray;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #002200;">&#91;</span>myTableView reloadData<span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #002200;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>As you can see, <b>the incoming notification itself is a newly discovered device, sent in the form of a BluetoothDevice object</b>. To get it correctly I've used :</p>
<pre class="objc"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">BluetoothDevice *bt = <span style="color: #002200;">&#91;</span>notification object<span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>We store the name, the bluetooth address and the pointer to the BluetoothDevice object for later use. The name and address is used to populate the list view:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/IMG_0027.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/IMG_0027-200x300.png" alt="" title="IMG_0027" width="200" height="300" class="alignnone size-medium wp-image-2842" /></a><br />
5. Turn bluetooth on / off . This is easy: we have two buttons, pressing them results in calling one of the following methods:</p>
<pre class="objc"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">/* Interface actions - bt on */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">- <span style="color: #002200;">&#40;</span>IBAction<span style="color: #002200;">&#41;</span>bluetoothON <span style="color: #002200;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    NSLog<span style="color: #002200;">&#40;</span>@<span style="color: #666666;">&quot;bluetoothON called.&quot;</span><span style="color: #002200;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #002200;">&#91;</span>btManager setPowered:YES<span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #002200;">&#91;</span>btManager setEnabled:YES<span style="color: #002200;">&#93;</span>; </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #002200;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">/* Interface actions - bt off */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">- <span style="color: #002200;">&#40;</span>IBAction<span style="color: #002200;">&#41;</span>bluetoothOFF <span style="color: #002200;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    NSLog<span style="color: #002200;">&#40;</span>@<span style="color: #666666;">&quot;bluetoothOFF called.&quot;</span><span style="color: #002200;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #ff0000;">//BluetoothManager *manager = [BluetoothManager sharedInstance];</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #002200;">&#91;</span>btManager setEnabled:NO<span style="color: #002200;">&#93;</span>; </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #002200;">&#91;</span>btManager setPowered:NO<span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #002200;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>6. Triggering bluetooth discovery. I do not enable searching for nearby bluetooth devices by default. Instead, I've added a Scan Button. The logic behind it is as following: check the bluetooth state , if on, start looking for nearby devices (resulting in device found notifications), if bluetooth is off, just throw an error message to inform the user:</p>
<pre class="objc"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">/* Interface actions - scan */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">- <span style="color: #002200;">&#40;</span>IBAction<span style="color: #002200;">&#41;</span>scanButtonAction <span style="color: #002200;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #0000ff;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>btManager enabled<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff0000;">// clear listview</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #002200;">&#91;</span>self clearAllList<span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff0000;">// start scan</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #002200;">&#91;</span>btManager  setDeviceScanningEnabled:YES<span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #002200;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #002200;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        showMessage<span style="color: #002200;">&#40;</span>@<span style="color: #666666;">&quot;Error&quot;</span>, @<span style="color: #666666;">&quot;Turn Bluetooth on first!&quot;</span><span style="color: #002200;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #002200;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #002200;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>7. Establishing a connection<br />
There are two approaches here:<br />
7A. Use BluetoothManager's "connectDevice" method (see BluetoothManager.h) . This method taken a single parameter, a string representing the bluetooth address we need to connect to. For some reason this only worked partially, so I abandoned this method in favor of:<br />
7B. Use BluetoothDevice's "connect" . Remember when we saved a pointer to a BluetoothDevice in the Discovery callback function? Now it's so easy using it!<br />
When the user clicks an item in our list, we do the following:</p>
<pre class="objc"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">- <span style="color: #002200;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #002200;">&#41;</span>tableView:<span style="color: #002200;">&#40;</span>UITableView *<span style="color: #002200;">&#41;</span>tableView didSelectRowAtIndexPath:<span style="color: #002200;">&#40;</span>NSIndexPath *<span style="color: #002200;">&#41;</span>indexPath <span style="color: #002200;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    BTListDevItem *item = <span style="color: #002200;">&#40;</span>BTListDevItem *<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#91;</span>btDevItems objectAtIndex:indexPath.row<span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSString.html"><span style="color: #0000ff;">NSString</span></a> *message = <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSString.html"><span style="color: #0000ff;">NSString</span></a> stringWithFormat:@<span style="color: #666666;">&quot;Device %@ [%@]&quot;</span>, item.name, item.description<span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    showMessage<span style="color: #002200;">&#40;</span>@<span style="color: #666666;">&quot;Connect to:&quot;</span>, message<span style="color: #002200;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #002200;">&#91;</span>self deviceConnect &lt;img src=<span style="color: #666666;">'http://www.pocketmagic.net/wp-includes/images/smilies/icon_sad.gif'</span> alt=<span style="color: #666666;">':('</span> <span style="color: #0000ff;">class</span>=<span style="color: #666666;">'wp-smiley'</span> /&gt;  indexPath.row<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #002200;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>And the deviceConnect function, taking a parameter identifying the index of the device we want to connect to , in our array of devices , is even simpler:</p>
<pre class="objc"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000; font-style: italic;">/* Bluetooth connectivity */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">- <span style="color: #002200;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #002200;">&#41;</span>deviceConnect:<span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>index <span style="color: #002200;">&#123;</span> </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    BTListDevItem *item = <span style="color: #002200;">&#40;</span>BTListDevItem *<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#91;</span>btDevItems objectAtIndex:index<span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    NSLog<span style="color: #002200;">&#40;</span>@<span style="color: #666666;">&quot;deviceConnect to %@&quot;</span>, item.name<span style="color: #002200;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #002200;">&#91;</span>item.btdev connect<span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #002200;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<h3>The connection results</h3>
<p>I've tried to connect to a notebook computer equipped with Bluetooth (named Moon-PC) and to a HID Bluetooth Keyboard (named Celluon). </p>
<p><b>Connecting to the notebook</b><br />
The notebook exposes the following Bluetooth profiles:<br />
Bluetooth File Transfer Service<br />
Bluetooth Information Synchronization Service<br />
Bluetooth Object Push Service<br />
Bluetooth AV Service<br />
Bluetooth Headset Service</p>
<p>The BluetoothDevice.connect() resulted in the following:</p>
<pre class="objc"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #0000dd;">2012</span><span style="color: #0000dd;">-07</span><span style="color: #0000dd;">-16</span> <span style="color: #0000dd;">19</span>:<span style="color: #0000dd;">51</span>:<span style="color: #0000dd;">25.364</span> Bluetooth<span style="color: #002200;">&#91;</span><span style="color: #0000dd;">706</span>:<span style="color: #0000dd;">707</span><span style="color: #002200;">&#93;</span> deviceConnect to MOON-PC</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #0000dd;">2012</span><span style="color: #0000dd;">-07</span><span style="color: #0000dd;">-16</span> <span style="color: #0000dd;">19</span>:<span style="color: #0000dd;">51</span>:<span style="color: #0000dd;">25.366</span> Bluetooth<span style="color: #002200;">&#91;</span><span style="color: #0000dd;">706</span>:<span style="color: #0000dd;">707</span><span style="color: #002200;">&#93;</span> BTM: connecting to device <span style="color: #666666;">&quot;MOON-PC&quot;</span> C4:<span style="color: #0000dd;">46</span>:<span style="color: #0000dd;">19</span>:C6:<span style="color: #0000dd;">39</span>:D1</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #0000dd;">2012</span><span style="color: #0000dd;">-07</span><span style="color: #0000dd;">-16</span> <span style="color: #0000dd;">19</span>:<span style="color: #0000dd;">51</span>:<span style="color: #0000dd;">27.743</span> Bluetooth<span style="color: #002200;">&#91;</span><span style="color: #0000dd;">706</span>:<span style="color: #0000dd;">707</span><span style="color: #002200;">&#93;</span> BTM: attempting to connect to service 0x00000010 on device <span style="color: #666666;">&quot;MOON-PC&quot;</span> C4:<span style="color: #0000dd;">46</span>:<span style="color: #0000dd;">19</span>:C6:<span style="color: #0000dd;">39</span>:D1</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #0000dd;">2012</span><span style="color: #0000dd;">-07</span><span style="color: #0000dd;">-16</span> <span style="color: #0000dd;">19</span>:<span style="color: #0000dd;">51</span>:<span style="color: #0000dd;">27.751</span> Bluetooth<span style="color: #002200;">&#91;</span><span style="color: #0000dd;">706</span>:<span style="color: #0000dd;">707</span><span style="color: #002200;">&#93;</span> BTM: attempting to connect to service 0x00000008 on device <span style="color: #666666;">&quot;MOON-PC&quot;</span> C4:<span style="color: #0000dd;">46</span>:<span style="color: #0000dd;">19</span>:C6:<span style="color: #0000dd;">39</span>:D1</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #0000dd;">2012</span><span style="color: #0000dd;">-07</span><span style="color: #0000dd;">-16</span> <span style="color: #0000dd;">19</span>:<span style="color: #0000dd;">51</span>:<span style="color: #0000dd;">28.994</span> Bluetooth<span style="color: #002200;">&#91;</span><span style="color: #0000dd;">706</span>:<span style="color: #0000dd;">707</span><span style="color: #002200;">&#93;</span> BTM: connection to service 0x00000010 on device <span style="color: #666666;">&quot;MOON-PC&quot;</span> C4:<span style="color: #0000dd;">46</span>:<span style="color: #0000dd;">19</span>:C6:<span style="color: #0000dd;">39</span>:D1 failed with error <span style="color: #0000dd;">305</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #0000dd;">2012</span><span style="color: #0000dd;">-07</span><span style="color: #0000dd;">-16</span> <span style="color: #0000dd;">19</span>:<span style="color: #0000dd;">51</span>:<span style="color: #0000dd;">30.286</span> Bluetooth<span style="color: #002200;">&#91;</span><span style="color: #0000dd;">706</span>:<span style="color: #0000dd;">707</span><span style="color: #002200;">&#93;</span> BTM: connection to service 0x00000008 on device <span style="color: #666666;">&quot;MOON-PC&quot;</span> C4:<span style="color: #0000dd;">46</span>:<span style="color: #0000dd;">19</span>:C6:<span style="color: #0000dd;">39</span>:D1 failed with error <span style="color: #0000dd;">305</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>The Celluon keyboard only exposes the HID profile, and here is the connection result:</p>
<pre class="objc"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #0000dd;">2012</span><span style="color: #0000dd;">-07</span><span style="color: #0000dd;">-16</span> <span style="color: #0000dd;">19</span>:<span style="color: #0000dd;">53</span>:<span style="color: #0000dd;">45.727</span> Bluetooth<span style="color: #002200;">&#91;</span><span style="color: #0000dd;">706</span>:<span style="color: #0000dd;">707</span><span style="color: #002200;">&#93;</span> deviceConnect to Celluon </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #0000dd;">2012</span><span style="color: #0000dd;">-07</span><span style="color: #0000dd;">-16</span> <span style="color: #0000dd;">19</span>:<span style="color: #0000dd;">53</span>:<span style="color: #0000dd;">45.732</span> Bluetooth<span style="color: #002200;">&#91;</span><span style="color: #0000dd;">706</span>:<span style="color: #0000dd;">707</span><span style="color: #002200;">&#93;</span> BTM: connecting to device <span style="color: #666666;">&quot;Celluon &quot;</span> <span style="color: #0000dd;">00</span>:<span style="color: #0000dd;">18</span>:E4:<span style="color: #0000dd;">27</span>:<span style="color: #0000dd;">18</span>:<span style="color: #0000dd;">39</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #0000dd;">2012</span><span style="color: #0000dd;">-07</span><span style="color: #0000dd;">-16</span> <span style="color: #0000dd;">19</span>:<span style="color: #0000dd;">53</span>:<span style="color: #0000dd;">47.204</span> Bluetooth<span style="color: #002200;">&#91;</span><span style="color: #0000dd;">706</span>:<span style="color: #0000dd;">707</span><span style="color: #002200;">&#93;</span> BTM: attempting to connect to service 0x00000020 on device <span style="color: #666666;">&quot;Celluon &quot;</span> <span style="color: #0000dd;">00</span>:<span style="color: #0000dd;">18</span>:E4:<span style="color: #0000dd;">27</span>:<span style="color: #0000dd;">18</span>:<span style="color: #0000dd;">39</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #0000dd;">2012</span><span style="color: #0000dd;">-07</span><span style="color: #0000dd;">-16</span> <span style="color: #0000dd;">19</span>:<span style="color: #0000dd;">53</span>:<span style="color: #0000dd;">47.216</span> Bluetooth<span style="color: #002200;">&#91;</span><span style="color: #0000dd;">706</span>:<span style="color: #0000dd;">707</span><span style="color: #002200;">&#93;</span> BTM: connection to service 0x00000020 on device <span style="color: #666666;">&quot;Celluon &quot;</span> <span style="color: #0000dd;">00</span>:<span style="color: #0000dd;">18</span>:E4:<span style="color: #0000dd;">27</span>:<span style="color: #0000dd;">18</span>:<span style="color: #0000dd;">39</span> failed with error <span style="color: #0000dd;">305</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>It is clear that the BluetoothManager identified 2 of the 5 profiles exported by the notebook, and the HID profile exported by the Celluon keyboard. These profiles seem to be coded with the hex identifiers shown in the debug content: 0x00000010, 0x00000008, 0x00000020</p>
<p>Even if the connection fails, it is a good starting point in investigating how to establish a solid connection, and receive data. Since the services are recognized by the BluetoothManager , it is surely possible to use the existing functionality, and the already implemented protocols. </p>
<p>This research work has been performed on an iPod, running OS 5.1 .</p>
<p>You can use this code or any parts of it, <b>ONLY</b> if you provide a visible link within your work/project/article, to this webpage. If you agree, you can download the complete source code: <a href='http://www.pocketmagic.net/wp-content/uploads/2012/07/Bluetooth-iOS-Code.zip'>Bluetooth iOS Code</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/07/bluetooth-and-ios-use-bluetooth-in-your-iphone-apps/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>Developing for Apple iOS</title>
		<link>http://www.pocketmagic.net/2012/07/developing-for-apple-ios/</link>
		<comments>http://www.pocketmagic.net/2012/07/developing-for-apple-ios/#comments</comments>
		<pubDate>Mon, 16 Jul 2012 18:27:16 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[development tools]]></category>
		<category><![CDATA[hello world]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPod]]></category>
		<category><![CDATA[listview]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=2802</guid>
		<description><![CDATA[A short guide to get started with iOS development. How to build a simple list view.]]></description>
				<content:encoded><![CDATA[<h3>Introduction</h3>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td><a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/Screen-Shot-2012-07-16-at-8.07.03-PM.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/Screen-Shot-2012-07-16-at-8.07.03-PM.png" alt="" title="Screen Shot 2012-07-16 at 8.07.03 PM" width="321" height="393" class="alignnone size-full wp-image-2803" /></a></td>
<td valign="top">
Years after the successful launch of Apple's mobile platform , I accidentally got intersected with this technology. Here are some of my first impressions, and a short tutorial to get you started.</p>
<p>You will need:<br />
- a Mac mini, running Mac OS . I'm currently using a 2011 model, that can boot both Win7 and MacOS. You can see it <a href="http://www.pocketmagic.net/?p=2780"> here</a>.<br />
- a iOS developer account. It is not free, and it costs 99USD/year. You can get one <a href="https://developer.apple.com/programs/ios/">here</a>. </p>
<p>Logging in to the developer account, will give you access to the development tools. Currently available is Xcode 4.3.2 . It is a big download, close to 2GB, but it as a package with everything you need: IDE, SDK and Compiler. This version of Xcode brings the iOS SDK 5.1.<br />
- a test device, unless you are planning to use the Simulator. The test device has many advantages, like speed, and full suite of features working in the real environment like Camera, Bluetooth , Phone, etc , and on top of all, it shows how your software performs on the target it was intended for. It is an optional recommended expense.
</td>
</tr>
</table>
<h3>Installing the tools</h3>
<p>Setting up the tools is straight forward. You just double click the Xcode .dmg file, downloaded from your Developer Account, on Apple's website, than drag the Xcode app to the Applications folder. Unlike the Windows world, this process is considered "Installation" on Mac OS.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/Screen-Shot-2012-07-16-at-8.21.36-PM.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/Screen-Shot-2012-07-16-at-8.21.36-PM.png" alt="" title="Screen Shot 2012-07-16 at 8.21.36 PM" width="500" height="347" class="alignnone size-full wp-image-2808" /></a><br />
Select "Create a new Xcode project", and start by using the built in wizard for your first application. Compile it and have it run on the Simulator.<br />
To run it on an actual device, you'll need to configure your certificates and a provisioning file for your mobile device. There are many good tutorials covering that topic, if you need help. </p>
<h3>Hello world application</h3>
<p>I want to keep it as simple as possible, so I select "Single View application".<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/Screen-Shot-2012-07-16-at-8.32.39-PM.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/Screen-Shot-2012-07-16-at-8.32.39-PM.png" alt="" title="Screen Shot 2012-07-16 at 8.32.39 PM" width="500" height="336" class="alignnone size-full wp-image-2810" /></a><br />
Pressing NEXT asks for some additional details, like Name, Package (company info) etc. Here is what I've used:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/iOS_development_05.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/iOS_development_05.png" alt="" title="iOS_development_05" width="500" height="338" class="alignnone size-full wp-image-2811" /></a><br />
Click NEXT, choose where to save your project, and click Create. Your project template is ready, and you can even run it already!<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/iOS_development_06.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/iOS_development_06-300x218.png" alt="" title="iOS_development_06" width="300" height="218" class="alignnone size-medium wp-image-2812" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/IMG_0030.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/IMG_0030-200x300.png" alt="" title="IMG_0030" width="200" height="300" class="alignnone size-medium wp-image-2813" /></a></p>
<h3>Application architecture</h3>
<p>Coming from the Windows Mobile / Android world, the first step was to establish a few logical links to my previous knowledge.<br />
Looking at the left side of Xcode interface, also called Navigator, you can see the AppDelegate.m and .h and ViewController.m , .h and .xib . The AppDelegate is the entry point for this project, but for this simple Hello World app there is not much to do there. The other three files are responsible for creating your application's "Single view".<br />
The .h is a Header file for declarations, the .m is the implementation file and the .xib is an visual interface builder file. You can use the IDE to add various controls such as buttons , lists or textfields. </p>
<h3>Listviews in iOS</h3>
<p>ListViews are an often used data organizer or display control. I will show you how to add a list view to the Hello World project we created above.</p>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td><a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/iOS_development_07.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/iOS_development_07.png" alt="" title="iOS_development_07" width="257" height="248" class="alignnone size-full wp-image-2815" /></a></td>
<td valign="top">
Among the available controls, accessible by pressing the CUBE symbol in the right part of Xcode's interface (left picture), there is a predefined Table View control. We can use that to create a list view: drag and drop it to the center of the screen, where you see the virtual iOS device. The magnetic placer will adjust the size automatically!
</td>
</tr>
</table>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/iOS_development_08.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/iOS_development_08.png" alt="" title="iOS_development_08" width="600" height="480" class="alignnone size-full wp-image-2816" /></a></p>
<p>To populate this list, we'll need to write some code!<br />
<b>step 1:</b><br />
Open HWViewController.h . You see the following:</p>
<pre class="objc"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #339900;">#import &lt;UIKit/UIKit.h&gt;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">@interface</span> HWViewController : UIViewController</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">@end</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>Change it to:</p>
<pre class="objc"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #339900;">#import &lt;UIKit/UIKit.h&gt;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">@interface</span> HWViewController :  UIViewController &lt;UITableViewDelegate, UITableViewDataSource&gt; <span style="color: #002200;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #ff0000;">// listview attached content array</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSMutableArray.html"><span style="color: #0000ff;">NSMutableArray</span></a> *arrayItems;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #002200;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@property <span style="color: #002200;">&#40;</span>nonatomic, retain<span style="color: #002200;">&#41;</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSMutableArray.html"><span style="color: #0000ff;">NSMutableArray</span></a> *arrayItems;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@property <span style="color: #002200;">&#40;</span>retain, nonatomic<span style="color: #002200;">&#41;</span> IBOutlet UITableView *myTableView;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">@end</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p><b>step 2:</b><br />
Open HWViewController.m . Under
<pre class="objc"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">@implementation</span> HWViewControlle</div></li></ol></pre>
<p> add the following </p>
<pre class="objc"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@synthesize arrayItems, myTableView;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">// build one listview cell</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">- <span style="color: #002200;">&#40;</span>UITableViewCell *<span style="color: #002200;">&#41;</span>tableView:<span style="color: #002200;">&#40;</span>UITableView *<span style="color: #002200;">&#41;</span>tableView cellForRowAtIndexPath:<span style="color: #002200;">&#40;</span>NSIndexPath *<span style="color: #002200;">&#41;</span>indexPath <span style="color: #002200;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #0000ff;">static</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSString.html"><span style="color: #0000ff;">NSString</span></a> *CellIdentifier = @<span style="color: #666666;">&quot;Cell&quot;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    UITableViewCell *cell = <span style="color: #002200;">&#91;</span>tableView dequeueReusableCellWithIdentifier:CellIdentifier<span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #0000ff;">if</span> <span style="color: #002200;">&#40;</span>cell == <span style="color: #0000ff;">nil</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        cell = <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UITableViewCell alloc<span style="color: #002200;">&#93;</span> initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier<span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #002200;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    cell.textLabel.text = <span style="color: #002200;">&#91;</span>arrayItems objectAtIndex:indexPath.row<span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #0000ff;">return</span> cell;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #002200;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">- <span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>tableView:<span style="color: #002200;">&#40;</span>UITableView *<span style="color: #002200;">&#41;</span>tableView numberOfRowsInSection:<span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>section <span style="color: #002200;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #0000ff;">return</span> <span style="color: #002200;">&#91;</span>arrayItems count<span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #002200;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">- <span style="color: #002200;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #002200;">&#41;</span>tableView:<span style="color: #002200;">&#40;</span>UITableView *<span style="color: #002200;">&#41;</span>tableView didSelectRowAtIndexPath:<span style="color: #002200;">&#40;</span>NSIndexPath *<span style="color: #002200;">&#41;</span>indexPath <span style="color: #002200;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSString.html"><span style="color: #0000ff;">NSString</span></a> *item = <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSString.html"><span style="color: #0000ff;">NSString</span></a> *<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#91;</span>arrayItems objectAtIndex:indexPath.row<span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    UIAlertView *Alert = <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIAlertView alloc<span style="color: #002200;">&#93;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                          initWithTitle:@</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                          <span style="color: #666666;">&quot;Hello!&quot;</span> message:item delegate:<span style="color: #0000ff;">nil</span> cancelButtonTitle:@<span style="color: #666666;">&quot;OK&quot;</span> otherButtonTitles:<span style="color: #0000ff;">nil</span><span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #002200;">&#91;</span>Alert show<span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #002200;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">- <span style="color: #002200;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #002200;">&#41;</span>viewDidLoad</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #002200;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #002200;">&#91;</span>super viewDidLoad<span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #ff0000;">// Do any additional setup after loading the view, typically from a nib.</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSMutableArray.html"><span style="color: #0000ff;">NSMutableArray</span></a> *array = <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSMutableArray.html"><span style="color: #0000ff;">NSMutableArray</span></a> alloc<span style="color: #002200;">&#93;</span> initWithObjects:@<span style="color: #666666;">&quot;Radu Motisan&quot;</span>,@<span style="color: #666666;">&quot;Pocketmagic.net&quot;</span>, <span style="color: #0000ff;">nil</span><span style="color: #002200;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    self.arrayItems = array;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #002200;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p><b>step 3:</b><br />
Open HWViewController_iPhone.xib, and click to select the list view. To the right, in the Utilities panel, press the "Connections Inspector" button (last arrow symbol). Under outlets, you'll see "dataSource" and "delegate".</p>
<p>Hold down the Control key, click on the circle at right of "dataSource" , and drag the line over "File's Owner". Do the same for "delegate":<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/iOS_development_09.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/iOS_development_09-300x240.jpg" alt="" title="iOS_development_09" width="300" height="240" class="alignnone size-medium wp-image-2819" /></a><br />
<b>step 4:</b><br />
Compile and RUN the program. You'll get a list view with two lines, clicking any item shows a message box, with the item content:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/IMG_0031.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/IMG_0031-200x300.png" alt="" title="IMG_0031" width="200" height="300" class="alignnone size-medium wp-image-2820" /></a></p>
<h3>Get the sample code here:</h3>
<p><a href='http://www.pocketmagic.net/wp-content/uploads/2012/07/HelloWorld.zip'>HelloWorld</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/07/developing-for-apple-ios/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Capacitor Discharge Microspot Welder / Cutter</title>
		<link>http://www.pocketmagic.net/2012/07/capacitor-discharge-microspot-welder-cutter/</link>
		<comments>http://www.pocketmagic.net/2012/07/capacitor-discharge-microspot-welder-cutter/#comments</comments>
		<pubDate>Sat, 14 Jul 2012 23:36:25 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[atmega16]]></category>
		<category><![CDATA[capacitor]]></category>
		<category><![CDATA[cutter]]></category>
		<category><![CDATA[dual]]></category>
		<category><![CDATA[dual pulse]]></category>
		<category><![CDATA[lcd]]></category>
		<category><![CDATA[LCD library]]></category>
		<category><![CDATA[microcontrollers]]></category>
		<category><![CDATA[microspot]]></category>
		<category><![CDATA[plasma]]></category>
		<category><![CDATA[soldering]]></category>
		<category><![CDATA[supercapacitor]]></category>
		<category><![CDATA[ultracapacitor]]></category>
		<category><![CDATA[welder]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=2518</guid>
		<description><![CDATA[A DIY microspot soldering/welding/cutting device using energy stored in a very large capacitor delivered as precisely calculated pulses to working electrodes.]]></description>
				<content:encoded><![CDATA[<p><b>Featured  on Hack a Day:</b> <a href="http://hackaday.com/2012/03/09/a-capacitive-discharge-weldercutter-for-all-your-lightweight-needs/">see here</a> . Thank you guys!</p>
<p>The circuit diagram and complete source code is available at the bottom of this article. This project is based on <a href="http://www.pittnerovi.com/jiri/hobby/electronics/welder/index.html">Jiri Pittner's welder for the Atmega16</a>, and so the source code (Below) is released under GPL.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-5-150x150.jpg" alt="" title="welder sparks 2" width="150" height="150" class="alignnone size-thumbnail wp-image-2577" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-6.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-6-150x150.jpg" alt="" title="welder sparks 2" width="150" height="150" class="alignnone size-thumbnail wp-image-2577" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-7.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-7-150x150.jpg" alt="" title="welder sparks 2" width="150" height="150" class="alignnone size-thumbnail wp-image-2577" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-8.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-8-150x150.jpg" alt="" title="welder sparks 2" width="150" height="150" class="alignnone size-thumbnail wp-image-2577" /></a><br />
This project took a lot of time to complete. This article is structured on several parts, the bottom containing the final results. The microcontroller source code for the Dual Pulse Welder/Cutter is included at the bottom part of this article.<br />
<iframe width="800" height="450" src="http://www.youtube.com/embed/BVj0Tey3SSM" frameborder="0" allowfullscreen></iframe></p>
<p><b>Progress summary:</b><br />
<a href="#120208">2012-02-08, First tests</a><br />
<a href="#120209">2012-02-09, Choosing the LCD</a><br />
<a href="#120222">2012-02-22, 1,000,000uF Capacitor update</a><br />
<a href="#120301">2012-03-01, Project box</a><br />
<a href="#120303">2012-03-03, Power supply and some innovative electrodes</a><br />
<a href="#120318">2012-03-18, Tungsten electrodes</a><br />
<a href="#120715">2012-07-15, Source code and circuit diagram</a></p>
<p><!--UPDATE--><br />
<a name="120208"></a><br></p>
<h3>Part 1: February 8th, 2012</h3>
<p>I've just completed the first tests of a new challenging project, a <b>pulsed discharge micro spot welder and cutter tool</b>. It stores energy into a huge capacitor bank, and discharges it via two electrodes in the given target, regularly metal foils/sheets. The logic and the precise timing (of the order of micro-seconds) is controlled by an AtMEGA16-16PU microcontroller running at 16MHz. It can be used for <b>spot welding</b> and for <b>plasma cutting</b>.<br />
<iframe width="700" height="386" src="http://www.youtube.com/embed/YKXdRrv1fr8" frameborder="0" allowfullscreen></iframe><br />
The power switch is handled by 5 power mosfets, IRFP2907, set in parallel and driven by a darlington array IC with further transistor amplification. A single mosfet is rated for 75V 209Amps and an extremely low Rds. Do the math for the 5 working together!</p>
<p>Here is one of the construction tests, where I cut a beer can:<br />
<iframe width="700" height="505" src="http://www.youtube.com/embed/teADrSAViXY" frameborder="0" allowfullscreen></iframe></p>
<p>The molten material sticks to the discharge electrodes, making the operation difficult. I plan to try manufacturing them our of Graphite or Tungsten. Let's see which one works best!</p>
<p>This project is work in progress. My capacitors bank is aprox. 60000uFarad, but I need to get close to 1 Farad to have enough energy for correct operation. I will probably use a Car Audio capacitor.</p>
<p>Schematics, Microcontroller software, PCB layout to be added.  Video showing spot welding will follow soon.</p>
<p>Some construction pictures:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_01.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_01-150x150.jpg" alt="" title="capacitor_discharge_welder_01" width="150" height="150" class="alignnone size-thumbnail wp-image-2526" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_02.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_02-150x150.jpg" alt="" title="capacitor_discharge_welder_01" width="150" height="150" class="alignnone size-thumbnail wp-image-2526" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_13.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_13-150x150.jpg" alt="" title="capacitor_discharge_welder_01" width="150" height="150" class="alignnone size-thumbnail wp-image-2526" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_04.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_04-150x150.jpg" alt="" title="capacitor_discharge_welder_01" width="150" height="150" class="alignnone size-thumbnail wp-image-2526" /></a></p>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_05.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_05-150x150.jpg" alt="" title="capacitor_discharge_welder_01" width="150" height="150" class="alignnone size-thumbnail wp-image-2526" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_06.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_06-150x150.jpg" alt="" title="capacitor_discharge_welder_01" width="150" height="150" class="alignnone size-thumbnail wp-image-2526" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_07.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_07-150x150.jpg" alt="" title="capacitor_discharge_welder_01" width="150" height="150" class="alignnone size-thumbnail wp-image-2526" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_08.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_08-150x150.jpg" alt="" title="capacitor_discharge_welder_01" width="150" height="150" class="alignnone size-thumbnail wp-image-2526" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_09.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_09-150x150.jpg" alt="" title="capacitor_discharge_welder_09" width="150" height="150" class="alignnone size-thumbnail wp-image-2526" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_14.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_14-150x150.jpg" alt="" title="capacitor_discharge_welder_01" width="150" height="150" class="alignnone size-thumbnail wp-image-2526" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_11.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_11-150x150.jpg" alt="" title="capacitor_discharge_welder_01" width="150" height="150" class="alignnone size-thumbnail wp-image-2526" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_12.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor_discharge_welder_12-150x150.jpg" alt="" title="capacitor_discharge_welder_01" width="150" height="150" class="alignnone size-thumbnail wp-image-2526" /></a></p>
<p>The tool currently operates in two modes<br />
<b>1) Micro spot soldering</b><br />
A predefined (uC+LCD+controls) high current pulse is delivered to the two electrodes, when the trigger button is pressed. Metal wires or sheets pressed between the electrodes will be soldered.</p>
<p><b>2) Cutting</b><br />
A burst of short pulses are sent to the electrodes to generate plasma and cut thin metal foils.</p>
<p>The pulse duration, repetition rates are configurable. I got best results with pairs of pulses. Duration in the range of tens - a few hundreds of microseconds. For welding, the first pulse melts the material, and the second consolidates the soldering. For cutting the first pulse does the damage, and the second pulse helps to clean the electrode off the molten micro spot.</p>
<p><b>More operating modes can be added, so please give me ideas!</b></p>
<p>TODOs:<br />
- I need to find better electrodes, that do not stick to the material , I'm considering tungsten or graphite. Suggestions?<br />
- bigger capacitor bank: I need more power, and will probably go for a 1Farad Car Audio capacitor . Those Sprague I'm currently using are not enough for ticker sheets.<br />
- finish and publish the software<br />
- publish schematics and PCB layout.</p>
<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/DSC_5058.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/DSC_5058.jpg" alt="" title="DSC_5058" width="700" height="464" class="alignnone size-full wp-image-2519" /></a></p>
<p><!--UPDATE--><br />
<a name="120209"></a><br></p>
<h3>Part 2: February 9th, 2012</h3>
<p>I need to decide what type of LCD to use: the 2 lines HD44780 LCD, or the bigger one, with 4 lines. The code I wrote works with both. The larger one would have the advantage of allowing more text to be displayed. The smaller one is on the other hand more compact, better suited for my small case.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/2012-02-09-14.02.32.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/2012-02-09-14.02.32-150x150.jpg" alt="" title="2012-02-09 14.02.32" width="150" height="150" class="alignnone size-thumbnail wp-image-2545" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/2012-02-09-17.06.06.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/2012-02-09-17.06.06-150x150.jpg" alt="" title="2012-02-09 17.06.06" width="150" height="150" class="alignnone size-thumbnail wp-image-2546" /></a></p>
<p><!--UPDATE--><br />
<a name="120222"></a><br></p>
<h3>Part 3: February 22nd, 2012</h3>
<p>I purchased a suitable capacitor. Finally! It's a Pyramid Royal Blue, CAP160DBL 1.6 Farads . The first thing I did was to dismantle the useless electronic part and the display. By doing so, the new size fits perfectly to my project box. For those complaining that this type of capacitor, when used for car audio systems, doesn't switch off and depletes the car battery, simply unscrew the connectors to take off the display part. You won't be needing that anyway:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/pyramid-16farad-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/pyramid-16farad-1-150x150.jpg" alt="" title="pyramid 16farad 1" width="150" height="150" class="alignnone size-thumbnail wp-image-2548" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/pyramid-16farad-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/pyramid-16farad-2-150x150.jpg" alt="" title="pyramid 16farad 2" width="150" height="150" class="alignnone size-thumbnail wp-image-2549" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/pyramid-16farad-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/pyramid-16farad-3-150x150.jpg" alt="" title="pyramid 16farad 3" width="150" height="150" class="alignnone size-thumbnail wp-image-2550" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/pyramid-16farad-4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/pyramid-16farad-4-150x150.jpg" alt="" title="pyramid 16farad 3" width="150" height="150" class="alignnone size-thumbnail wp-image-2550" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/pyramid-16farad-5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/pyramid-16farad-5-150x150.jpg" alt="" title="pyramid 16farad 3" width="150" height="150" class="alignnone size-thumbnail wp-image-2550" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/pyramid-16farad-6.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/pyramid-16farad-6-150x150.jpg" alt="" title="pyramid 16farad 3" width="150" height="150" class="alignnone size-thumbnail wp-image-2550" /></a><br />
The price for this one was aprox. 55USD from a local shop and this makes it the most expensive component of this entire project, as expected.</p>
<p><!--UPDATE--><br />
<a name="120301"></a><br></p>
<h3>Part 4: March 1st, 2012</h3>
<p>The project box, in the final shape is ready. I had to cut some more wood, but that's an easy task if using the proper tools (I got a nice pendular saw as a gift, last Christmas).<br />
For a quick test I tried using a halogen 12V electronic transformer. That was a waste of time, as those things are unstable, and not working properly (they are barely oscillating):<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor-dual-pulse-welder-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor-dual-pulse-welder-1-150x150.jpg" alt="" title="capacitor dual pulse welder 1" width="150" height="150" class="alignnone size-thumbnail wp-image-2553" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor-dual-pulse-welder-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor-dual-pulse-welder-2-150x150.jpg" alt="" title="capacitor dual pulse welder 2" width="150" height="150" class="alignnone size-thumbnail wp-image-2554" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor-dual-pulse-welder-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/capacitor-dual-pulse-welder-3-150x150.jpg" alt="" title="capacitor dual pulse welder 3" width="150" height="150" class="alignnone size-thumbnail wp-image-2555" /></a><br />
The box exposes the heatsink, a standard PC power connector, and a fuse holder. The big capacitor is mounted on the top, as it looks nice and is too big to fit inside anyway.</p>
<p><!--UPDATE--><br />
<a name="120303"></a><br></p>
<h3>Part 5: March 3rd, 2012</h3>
<p>I resisted the temptation to throw that halogen electronic transformer to the trash. It was such a waste of time! Instead I found a charger, from an old laptop. It is a 90W, 19.5V SMPS supply, with the perfect size for my box. Initial tests shown it is capable of charging the capacitor (with a short initial blackout), and even hold the intense Arc cutting mode power consumption. As this was another Chinese cheapo, some optional components such as filter, capacitors, etc where missing from the PCB, and I added those first. Next I did a heatsink upgrade, to make sure it will run continuously, for as long as I need to use the tool:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/smps-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/smps-1-150x150.jpg" alt="" title="smps 1" width="150" height="150" class="alignnone size-thumbnail wp-image-2556" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/smps-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/smps-2-150x150.jpg" alt="" title="smps 2" width="150" height="150" class="alignnone size-thumbnail wp-image-2557" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/smps-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/smps-3-150x150.jpg" alt="" title="smps 3" width="150" height="150" class="alignnone size-thumbnail wp-image-2558" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/smps-4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/smps-4-150x150.jpg" alt="" title="smps 4" width="150" height="150" class="alignnone size-thumbnail wp-image-2559" /></a><br />
So far this proved to be an excellent choice! My device can now be powered from a 110V-220V outlet.</p>
<p>For the control panel, I needed a few potentiometers and some push buttons. I used a few NOS Russian 47K pots, I got from <a href="http://stores.ebay.com/KW-TUBES">Gintaras Ebay show, KWTUBES</a>. You can get some high quality components there at fair prices.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/kwtubes-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/kwtubes-1-150x150.jpg" alt="" title="kwtubes 1" width="150" height="150" class="alignnone size-thumbnail wp-image-2560" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/kwtubes-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/kwtubes-2-150x150.jpg" alt="" title="kwtubes 2" width="150" height="150" class="alignnone size-thumbnail wp-image-2561" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/kwtubes-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/kwtubes-3-150x150.jpg" alt="" title="kwtubes 3" width="150" height="150" class="alignnone size-thumbnail wp-image-2562" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/kwtubes-4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/kwtubes-4-150x150.jpg" alt="" title="kwtubes 4" width="150" height="150" class="alignnone size-thumbnail wp-image-2563" /></a><br />
Some pins are used to interface with the floating cables coming from the PCB modules. By doing so, I can easily dismantle and re-mantle everything together.</p>
<p>Here's how the setup looks like now:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/setup-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/setup-1-150x150.jpg" alt="" title="setup 1" width="150" height="150" class="alignnone size-thumbnail wp-image-2564" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/setup-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/setup-2-150x150.jpg" alt="" title="setup 2" width="150" height="150" class="alignnone size-thumbnail wp-image-2565" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/setup-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/setup-3-150x150.jpg" alt="" title="setup 3" width="150" height="150" class="alignnone size-thumbnail wp-image-2566" /></a></p>
<p>For the working electrodes I ended up using copper. But not just copper, also a new innovative design: the thick wires are connected to the electrodes using a screw, a screw nut and a washer. The electrode itself is a 10cm metal hollow tube. Inside, copper wire can be inserted, and while working, it can be pulled outside when needed. Exactly like a rotring pencil : the cooper electrodes is eaten while in use, but conveniently can be extracted from within the electrode, or replaced.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/electrodes-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/electrodes-1-150x150.jpg" alt="" title="electrodes 1" width="150" height="150" class="alignnone size-thumbnail wp-image-2567" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/electrodes-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/electrodes-2-150x150.jpg" alt="" title="electrodes 2" width="150" height="150" class="alignnone size-thumbnail wp-image-2568" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/electrodes-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/electrodes-3-150x150.jpg" alt="" title="electrodes 3" width="150" height="150" class="alignnone size-thumbnail wp-image-2569" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/electrodes-4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/electrodes-4-150x150.jpg" alt="" title="electrodes 4" width="150" height="150" class="alignnone size-thumbnail wp-image-2570" /></a><br />
Here's a video showing the working principle:<br />
<iframe width="800" height="437" src="http://www.youtube.com/embed/DuOjaZ-kRa0" frameborder="0" allowfullscreen></iframe><br />
The positive electrode also holds the discharge command push button that can be pressed with one of the fingers.</p>
<p>Finally, here's the completed project:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder_ready-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder_ready-1-150x150.jpg" alt="" title="welder_ready 1" width="150" height="150" class="alignnone size-thumbnail wp-image-2571" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder_ready-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder_ready-2-150x150.jpg" alt="" title="welder_ready 2" width="150" height="150" class="alignnone size-thumbnail wp-image-2572" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder_ready-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder_ready-3-150x150.jpg" alt="" title="welder_ready 3" width="150" height="150" class="alignnone size-thumbnail wp-image-2573" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder_ready-4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder_ready-4-150x150.jpg" alt="" title="welder_ready 4" width="150" height="150" class="alignnone size-thumbnail wp-image-2574" /></a></p>
<p>A few sparks, as recorded in some interesting photos, timing was crucial to get them, but I managed to do that eventually:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-1-150x150.jpg" alt="" title="welder sparks 1" width="150" height="150" class="alignnone size-thumbnail wp-image-2575" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-2-150x150.jpg" alt="" title="welder sparks 2" width="150" height="150" class="alignnone size-thumbnail wp-image-2577" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-3-150x150.jpg" alt="" title="welder sparks 2" width="150" height="150" class="alignnone size-thumbnail wp-image-2577" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-4-150x150.jpg" alt="" title="welder sparks 2" width="150" height="150" class="alignnone size-thumbnail wp-image-2577" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-5-150x150.jpg" alt="" title="welder sparks 2" width="150" height="150" class="alignnone size-thumbnail wp-image-2577" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-6.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-6-150x150.jpg" alt="" title="welder sparks 2" width="150" height="150" class="alignnone size-thumbnail wp-image-2577" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-7.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-7-150x150.jpg" alt="" title="welder sparks 2" width="150" height="150" class="alignnone size-thumbnail wp-image-2577" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-8.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/welder-sparks-8-150x150.jpg" alt="" title="welder sparks 2" width="150" height="150" class="alignnone size-thumbnail wp-image-2577" /></a></p>
<p>The power components are interconnected using thick copper wires. The wires to the electrodes are Copper Litz wire with section are of 16mm^2.<br />
The 1.6F Capacitor that I used, has an ESR of 0.0016 Ohm.</p>
<p><!--UPDATE--><br />
<a name="120318"></a><br></p>
<h3>Part 6: March 18th, 2012</h3>
<p>I recently received a few <a href="http://en.wikipedia.org/wiki/Tungsten_carbide">Tungsten Carbide</a> rods. This excellent material has a high melting point (2,870 °C), it is extremely hard (8.5–9.0 Mohs scale) with low electrical resistivity (~2×10−7 Ohm·m) making it an good electrode material for the Capacitor Welder. I hope to see it solves the molten sticky metal issue I had with copper electrodes.<br />
Results show excellent performance:<br />
<iframe width="800" height="437" src="http://www.youtube.com/embed/PlxrxdKkOWI" frameborder="0" allowfullscreen></iframe><br />
Here is another video:<br />
<iframe width="800" height="437" src="http://www.youtube.com/embed/N5E6qwJgldQ" frameborder="0" allowfullscreen></iframe><br />
After a few minutes of use, some signs of damage are observed on the electrode, but they are minor at least when compared to copper:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/tungsten_carbide-1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/tungsten_carbide-1-150x150.jpg" alt="" title="tungsten_carbide-1" width="150" height="150" class="alignnone size-thumbnail wp-image-2595" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/tungsten_carbide-2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/tungsten_carbide-2-150x150.jpg" alt="" title="tungsten_carbide-1" width="150" height="150" class="alignnone size-thumbnail wp-image-2595" /></a></p>
<p><b>Components used:</b><br />
There were many modules involved in this project, but I will try to mention the most important:<br />
1] 5x IRFP 2907 21USD . <a href="http://www.ebay.com/itm/5-x-IRFP2907-IR-Power-MOSFET-N-Channel-209A-75V-/400223729492">Source</a> . These were used in parallel, on the large heatsink, to switch the capacitor discharge on and off<br />
2] 2x IRF2807 3USD . <a href="http://www.ebay.com/itm/2-x-IRF2807-HEXFET-N-Channel-82A-75V-Free-Shipping-/140675137963">Source</a> . One handles the charging and the other the discharging of the capacitor, to keep it at the predefined voltage level.<br />
3] 1x ULN2803 5USD (10 pieces pack). <a href="www.ebay.com/itm/10-x-ULN2803A-ULN2803-TRANSISTOR-ARRAY-8-NPN-/140587523987">Source</a> . TRANSISTOR ARRAY-8 NPN DARLINGTONS used in the transistor driver board.<br />
4] 1x Atmel ATMega 16-16PU  12USD. <a href="http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=220957477712">Source </a>.<br />
5] 1x 16x2 HD44780 Character LCD 3USD .<a href="http://www.ebay.com/itm/New-1602-16x2-HD44780-Character-LCD-Display-Module-LCM-blue-blacklight-/140716999090"> Source</a> .<br />
6] 1x Power Supply 19.5V 4.5A 13USD . <a href="http://www.ebay.com/itm/19-5V-4-62A-90W-FOR-DELL-STUDIO-1535-PA10-LAPTOP-CHARGER-AC-ADAPTER-7-4-5-0MM-/170801961256">Source</a> .  I had a few of these laptop adapters and it seems they are well fitted for my Capacitor Pulse discharge tool, for both welding and cutting.<br />
7] 1x 1.6F 20V Capacitor 50USD . Source: local car audio shop.<br />
8] 4x 47K Potentiometers 9USD (50 pieces pack). <a href="www.ebay.com/itm/47K-Ohm-0-5W-PCB-panel-mount-linear-taper-pots-50pcs-/380420991296">Source </a>.<br />
9] Other 20USD (16MHz Crystal, connectors, switches, wires, etc)</p>
<p><!--UPDATE--><br />
<a name="120715"></a><br></p>
<h3>Part 7: July 15th, 2012</h3>
<p><b>Schematics:</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/microspot_capacitor_welder.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/microspot_capacitor_welder-300x177.png" alt="" title="microspot_capacitor_welder" width="300" height="177" class="alignnone size-medium wp-image-2793" /></a><br />
The eagle PCH can be downloaded <a href='http://www.pocketmagic.net/wp-content/uploads/2012/02/radu_capacitor_welder_sch.zip'>here</a>.<br />
<b>PCB Layout:</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/02/microspot_capacitor_welder_pcb.png"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/02/microspot_capacitor_welder_pcb-300x189.png" alt="" title="microspot_capacitor_welder_pcb" width="300" height="189" class="alignnone size-medium wp-image-2795" /></a><br />
If you need to print the PCB for your own board, please use <a href='http://www.pocketmagic.net/wp-content/uploads/2012/02/pcb_layout_radu.pdf'>this PDF file</a>.<br />
<b>Software, released under GPL License:</b><br />
Here is my own software implementation, featuring the C++ LCB library that I described in a <a href="http://www.pocketmagic.net/?p=447">previous article</a>:<br />
 <a href='http://www.pocketmagic.net/wp-content/uploads/2012/02/radu_capacitor_welder_source_code.zip'>Hex file and complete source code</a></p>
<p><b>Other resources:</b><br />
You might also want to see Jiri Pittner's welder, presented <a href="http://www.pittnerovi.com/jiri/hobby/electronics/welder/index.html">here</a>.</p>
<p>Looking forward to see your own variants of this cool project! </p>
<h3>Here are some variants created by my readers</h3>
<p>David's capacitor discharge spot welder<br />
David did an excellent job at building this tool, with a very nice case and a pedal as a trigger<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/david_capacitor_discharge_welder_1.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/david_capacitor_discharge_welder_1-150x150.jpg" alt="david_capacitor_discharge_welder_1" width="150" height="150" class="alignnone size-thumbnail wp-image-4314" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/david_capacitor_discharge_welder_2.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/david_capacitor_discharge_welder_2-150x150.jpg" alt="david_capacitor_discharge_welder_2" width="150" height="150" class="alignnone size-thumbnail wp-image-4315" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/david_capacitor_discharge_welder_3.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/david_capacitor_discharge_welder_3-150x150.jpg" alt="david_capacitor_discharge_welder_3" width="150" height="150" class="alignnone size-thumbnail wp-image-4316" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/david_capacitor_discharge_welder_4.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/david_capacitor_discharge_welder_4-150x150.jpg" alt="david_capacitor_discharge_welder_4" width="150" height="150" class="alignnone size-thumbnail wp-image-4317" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/david_capacitor_discharge_welder_5.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/david_capacitor_discharge_welder_5-150x150.jpg" alt="david_capacitor_discharge_welder_5" width="150" height="150" class="alignnone size-thumbnail wp-image-4318" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/david_capacitor_discharge_welder_6.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/david_capacitor_discharge_welder_6-150x150.jpg" alt="david_capacitor_discharge_welder_6" width="150" height="150" class="alignnone size-thumbnail wp-image-4319" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/david_capacitor_discharge_welder_7.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/david_capacitor_discharge_welder_7-150x150.jpg" alt="david_capacitor_discharge_welder_7" width="150" height="150" class="alignnone size-thumbnail wp-image-4320" /></a> <a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/david_capacitor_discharge_welder_8.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/david_capacitor_discharge_welder_8-150x150.jpg" alt="david_capacitor_discharge_welder_8" width="150" height="150" class="alignnone size-thumbnail wp-image-4321" /></a> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/07/capacitor-discharge-microspot-welder-cutter/feed/</wfw:commentRss>
		<slash:comments>88</slash:comments>
		</item>
		<item>
		<title>Mac mini is big enough to blow a full size PC away</title>
		<link>http://www.pocketmagic.net/2012/07/mac-mini-is-big-enough-to-blow-a-full-size-pc-away/</link>
		<comments>http://www.pocketmagic.net/2012/07/mac-mini-is-big-enough-to-blow-a-full-size-pc-away/#comments</comments>
		<pubDate>Sun, 08 Jul 2012 09:29:40 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[Core i5]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[mac mini]]></category>
		<category><![CDATA[Macintosh]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=2780</guid>
		<description><![CDATA[A short review on a Mac Mini that I recently acquired. I plan to use it as my new fixed workstation instead of my older P4 PC.]]></description>
				<content:encoded><![CDATA[<p>Time for me to upgrade my fixed workstation. The previous P4 2.6GHz is still running smooth , thanks to various upgrades it received over time. This time I'm making a bigger step, changing not only the hardware but also the platform, moving to the totally new universe (for me) of the Mac.<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/mac-mini.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/mac-mini.jpg" alt="" title="mac mini" width="800" height="531" class="alignnone size-full wp-image-2781" /></a><br />
The unit I recently acquired, is an entry level Macintosh, namely a Mac Mini, having the following specs:</p>
<li>Manufacturer: Apple</li>
<li>Model: MC816LL/A</li>
<li>Operating System: Mac OS X Lion</li>
<li>Graphics: Radeon HD 6630M with 256MB GDDR5</li>
<li>CPU: Intel Core i5 2nd Gen "Sandy Bridge" 2520M @ 2.50 GHz</li>
<li>RAM: 4GB DDR3 1333 MHz</li>
<li>HDD1: 640 GB SATA  5400 RPM</li>
<li>Built-in speaker</li>
<p>Connectivity:</p>
<li>Ethernet: Gigabit Ethernet 10/100/1000 Mbps</li>
<li>Wireless: Wireless-N 802.11 b/g/n</li>
<li>Bluetooth: Built-in Bluetooth 4.0</li>
<p>The Ports cover everything I need:</p>
<li>Thunderbolt port (up to 10 Gbps)</li>
<li>FireWire 800 port (up to 800 Mbps)</li>
<li>Four USB 2.0 ports (up to 480 Mbps)</li>
<li>HDMI port</li>
<li>SDXC card slot</li>
<li>Gigabit Ethernet port</li>
<li>Audio in/out</li>
<p>More details <a href="http://www.apple.com/macmini/specs.html">here</a>.</p>
<p>Having just little time to try it so far, I already like it a lot, because it is so silent, so compact and small sized, and brings in some serious computing power that is a huge upgrade over what I've used before. Not my pic, but here is a size comparison:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/macmini-finale-jul-2010.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/macmini-finale-jul-2010.jpg" alt="" title="macmini-finale-jul-2010" width="550" height="419" class="alignnone size-full wp-image-2784" /></a></p>
<p>As my monitor doesn't have a HDMI port, I'm using an adapter, made by RocketFish:<br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/07/2343806_sa.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/07/2343806_sa.jpg" alt="" title="2343806_sa" width="361" height="262" class="alignnone size-full wp-image-2785" /></a><br />
You can see the complete specs <a href="http://www.rocketfishproducts.com/products/computer-accessories/RF-AP307.html">here</a>, but you can find it cheaper on Ebay.</p>
<p>For input, I'll be using a <a href="http://www.pocketmagic.net/?p=241">Bluetooth keyboard</a> and a Bluetooth mouse, to take advantage of the Bluetooth connectivity, save some USB ports and get rid of cables.</p>
<p>My plan is to have it run a virtual machine , or <a href="http://support.apple.com/kb/HT1461">Boot Camp</a>, for my previous Windows apps. The power consumption is also a lot lower than my midi-tower PC, so all in one, I'm really excited about this change. Will report back later when I learn more on the software, and the usability.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/07/mac-mini-is-big-enough-to-blow-a-full-size-pc-away/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Atten ADS1102CAL Oscilloscope</title>
		<link>http://www.pocketmagic.net/2012/06/atten-ads1102cal-oscilloscope/</link>
		<comments>http://www.pocketmagic.net/2012/06/atten-ads1102cal-oscilloscope/#comments</comments>
		<pubDate>Sun, 17 Jun 2012 10:28:19 +0000</pubDate>
		<dc:creator>Radu Motisan</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[100Mhz]]></category>
		<category><![CDATA[ADS1102CAL]]></category>
		<category><![CDATA[Atten]]></category>
		<category><![CDATA[manual]]></category>
		<category><![CDATA[oscilloscope]]></category>
		<category><![CDATA[pc software]]></category>
		<category><![CDATA[scope]]></category>

		<guid isPermaLink="false">http://www.pocketmagic.net/?p=3215</guid>
		<description><![CDATA[For my first oscilloscope, I opted for the Atten ADS1102CAL. A few months after, I could say I'm extremely happy choosing this robust device, that does an excellent job on my workbench.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/header_ADS1102CAL_Atten.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/header_ADS1102CAL_Atten.jpg" alt="" title="header_ADS1102CAL_Atten" width="800" height="311" class="alignnone size-full wp-image-3216" /></a><br />
For some time now, the need to have a scope became greater. There were so many projects I could not properly implement, because I didn't have this tool. Finally I came to decide for a digital oscilloscope.</p>
<p><b>ATTEN ADS1102CAL</b> vs <b>Rigol DS1052e</b> were the two options left for considering. Both in the same price range, having a slim design and fancy features such as USB connectors for plugging in a USB Flash and snapshoting the traces (I use that a lot!). The former a 100MHz scope with almost zero reviews (at the time of this article) and the latter limited to 50MHz but with a hack available to boost it to 100MHz and with plenty of feedback, posts and articles from the user community.</p>
<p>Not an easy choice, but I opted for the Atten in the end, assuming it will perform at least as good as the Rigol, and that the lack of reviews is not an indication of its quality. Lucky for me, this assumption was correct.</p>
<p>The ADS1102CAL is a great addon to my workbench, and a valuable tool, that allowed me to push my project further. The <a href="http://www.pocketmagic.net/?p=3155#charts">uRADMonitor </a>would not have been possible without it.</p>
<p><b>Specs ADS1102CAL</b>:<br />
Color TFT LCD display, waveform display is more clear and stable;<br />
• Rich trigger modes: Edge, Pulse, Video, Slope, Alternate;<br />
• Unique digital filter and waveform recorder;<br />
• Pass / Fail function;<br />
• 32 automatic measurements;<br />
• 2 set of reference waveforms, 20 groups of common waveforms, 20 groups of settings within the store / recall; support waveform, set, CSV and bitmap files U disk external storage and recall;<br />
• Manual, tracking, automatic cursor measurement function;<br />
• channel waveform and FFT waveforms at the same time split-screen display;<br />
• Analog channel waveform mesh screen brightness and brightness adjustable;<br />
• pop-up menu display mode, the user operation more flexible, natural;<br />
• rich interface display style: classic, modern, traditional, simple;<br />
• Multilingual interface display, the English online help system;<br />
• Standard interface: USB Host: Support U disk U disk storage and a system through software upgrades; USB Device: support for PictBridge direct printing and PC connection with the remote control; RS-232.</p>
<p><b>Technical Specifications:</b><br />
Bandwidth: 100MHZ<br />
• Channels: Dual Channel + 1 external trigger channel<br />
• The maximum real-time sampling rate: Single 1GSa / S, dual-channel 500MSa / S<br />
• Equivalent Sampling Rate: 50GSa / s<br />
• Memory depth: Single Channel 40K<br />
• Rise time: <.3.5 ns<br />
• Input impedance: 1Mω | | 17pF<br />
• Time base range: 2.5ns/div-50s/div Roll: 100ms-50s/div<br />
• Vertical Sensitivity: 2mv-10v/div (1-2-5 sequence)<br />
• Vertical resolution: 8bit<br />
• Display: TFT 7 è±å¯¸ (178mm) LCD Monitor<br />
Level system<br />
• Real-time sampling rate: 1GSa / s<br />
• Equivalent Sampling Rate: 50GSa / s<br />
• Display Mode: MAIN, WINDOW, WINDOW ZOOM, ROLL, XY<br />
• Time base accuracy: ± 100ppm (any time interval greater than 1ms)<br />
• Horizontal scan range: 2.5nS/DIV - 50S/DIV<br />
• Scan: 100mS/DIV ~ 50S/DIV (1-2.5-5 order)</p>
<p><b>Here are some inside pics taken by a user on another forum:</b><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_01.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_01-150x150.jpg" alt="" title="atten_1102cal_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3218" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_02.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_02-150x150.jpg" alt="" title="atten_1102cal_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3218" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_03.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_03-150x150.jpg" alt="" title="atten_1102cal_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3218" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_04.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_04-150x150.jpg" alt="" title="atten_1102cal_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3218" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_05.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_05-150x150.jpg" alt="" title="atten_1102cal_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3218" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_06.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_06-150x150.jpg" alt="" title="atten_1102cal_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3218" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_07.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_07-150x150.jpg" alt="" title="atten_1102cal_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3218" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_08.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_08-150x150.jpg" alt="" title="atten_1102cal_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3218" /></a><br />
<a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_09.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_09-150x150.jpg" alt="" title="atten_1102cal_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3218" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_10.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_10-150x150.jpg" alt="" title="atten_1102cal_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3218" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_11.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_11-150x150.jpg" alt="" title="atten_1102cal_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3218" /></a><a href="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_12.jpg"><img src="http://www.pocketmagic.net/wp-content/uploads/2012/10/atten_1102cal_12-150x150.jpg" alt="" title="atten_1102cal_01" width="150" height="150" class="alignnone size-thumbnail wp-image-3218" /></a></p>
<p><b>Manual and PC software are available here:</b><br />
<a href="http://www.2shared.com/file/V8K-j45b/atten_Manual_Version_20.html">link</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pocketmagic.net/2012/06/atten-ads1102cal-oscilloscope/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
