<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Over a Cup of Koffee</title>
	
	<link>http://www.randity.com/blog</link>
	<description>tips, tricks and random musings</description>
	<lastBuildDate>Wed, 29 Jul 2009 17:31:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/randity" /><feedburner:info uri="randity" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><item>
		<title>Getting the ATmega8 to run our Program</title>
		<link>http://www.randity.com/blog/2009/07/getting-the-atmega8-to-run/</link>
		<comments>http://www.randity.com/blog/2009/07/getting-the-atmega8-to-run/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 17:31:42 +0000</pubDate>
		<dc:creator>Rahul Pisharody</dc:creator>
				<category><![CDATA[Embedded Development]]></category>
		<category><![CDATA[Hobby]]></category>
		<category><![CDATA[Microcontrollers]]></category>

		<guid isPermaLink="false">http://www.randity.com/blog/?p=125</guid>
		<description><![CDATA[We have seen in the previous articles how to wire up the programmer and how to write a program using C. Here, we see how to actually upload a program onto the device; essentially making the otherwise useless microcontroller to perform a task we intended it to. The process is simple and logical and not much effort is required. For higher end microcontrollers like the Atmega32, debugging interfaces like JTAG are supported via the same utilities mentioned in this post.]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-0996215872406188";
/* 336x280, created 2/25/10 */
google_ad_slot = "3032681584";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p><p><a href="http://www.randity.com/blog/wp-content/uploads/2009/07/usp.JPG" target="_blank"><img class="alignleft" style="margin-left: 10px; margin-right: 10px;" title="Circuit" src="http://www.randity.com/blog/wp-content/uploads/2009/07/usp.JPG" alt="" width="360" height="240" /></a>We saw in our earlier posts, how to wire up the programmer and how to write a C Program. Now, let us see how to compile and download the program onto the device. gcc, as most of you may know, is a cross compiler. A cross compiler is usually used for off target compiling. Thus, a program can be compiled by gcc targeting any platform, not just the host platform. In short, eventhough gcc runs and compiles on a PC, it can be asked to compile for ATmega8. Thus, effectively, we can generate a hex file readable by the device; but not by the PC.</p>
<p>Save the program that we just wrote with a proper filename, say blink.c. To compile the program for the Atmega8 Device,<br />
<code>avr-gcc -mmcu=atmega8 -Os blink.c -o blink.out</code></p>
<p>This generates an object file called <code>blink.out</code> as given in the command line option. Try running this generated file in your PC. The file will generate an error. This is expected, as we compiled the file for ATmega8. Now, the machine code prepared by the compiler have complex structures, making it difficult for a burning program like <code>avrdude</code> to decipher them. Thus we need a way to convert the code into simpler Motorola or Intel hex format. Thus, we need to convert the file we just generated into one of these formats. Well, how do you do it ? Enter <code>avr-objcopy</code>. Issue the following command to convert the machine code into Intel Hex format.</p>
<p><code>avr-objcopy -j .text -j .data -O ihex blink.out blink.hex</code></p>
<p>This converts the complex machine code into readable hexadecimal numbers. One can easily open blink.hex in a editor of his choice to verify the result.</p>
<p>To program the microcontroller, or to upload the firmware, we make use of a nifty little utility called <code>uisp</code>. First, we need to erase the device.<br />
<code>uisp -dlpt=/dev/parport0 --erase -dprog=dapa</code></p>
<p>The above code does a handful of things. First, it tells <code<uisp</code> the port it is using by the <code>-dlpt</code> option. Then it tells the program we need to <code>--erase</code> the device. And lastly, it specifies the method of programming we are using via the <code>-dprog</code> option. Here we are using <code>dapa</code> which means direct parallel access. As soon as this command is executed, the device is erased and ready to accept new firmware. To program the device, use</p>
<p><code>uisp -dlpt=/dev/parport0 --upload if=blink.hex -dprog=dapa -v=3 --hash=32</code></p>
<p>The option <code>-v</code> sets the verbosity level of the output. If all goes well, you will have the microcontroller programmed and executing your program. </p>
<p>And, if you ever want to reset your controller without pushing the reset switch on your board, use<br />
<code>uisp -dprog=dapa</code></p>
<h3  class="related_post_title">Related</h3><ul class="related_post"><li><a href="http://www.randity.com/blog/2009/07/intro-to-avr-gcc/" title="A 101 on avr-gcc">A 101 on avr-gcc</a></li><li><a href="http://www.randity.com/blog/2009/07/programming-atmega8/" title="Programming ATmega8">Programming ATmega8</a></li><li><a href="http://www.randity.com/blog/2009/06/beginning-the-atmega8/" title="Beginning the ATmega8">Beginning the ATmega8</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.randity.com/blog/2009/07/getting-the-atmega8-to-run/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A 101 on avr-gcc</title>
		<link>http://www.randity.com/blog/2009/07/intro-to-avr-gcc/</link>
		<comments>http://www.randity.com/blog/2009/07/intro-to-avr-gcc/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 07:20:50 +0000</pubDate>
		<dc:creator>Rahul Pisharody</dc:creator>
				<category><![CDATA[Embedded Development]]></category>
		<category><![CDATA[Hobby]]></category>
		<category><![CDATA[Microcontrollers]]></category>

		<guid isPermaLink="false">http://www.randity.com/blog/?p=124</guid>
		<description><![CDATA[The GNU/Linux offers a plethora of tools to program the ATmega8 efficiently and quickly. avr-gcc provides a port of the popular gcc compiler. This enables a newbie with basic knowledge in C to program the controller easily without the hassle of learning assembly instructions. Moreover, programming the controller in a middle-level language as opposed to assembly gives higher command over the code, but at a higher program size.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.randity.com/blog/wp-content/uploads/2009/07/gcc.png"><img class="alignleft" title="avr-gcc" src="http://www.randity.com/blog/wp-content/uploads/2009/07/gcc.png" alt="" width="280" height="333" /></a>The GNU/Linux offers a plethora of tools to program the ATmega8 efficiently and quickly. <code>avr-gcc</code> provides a port of the popular <code>gcc</code> compiler. This enables a newbie with basic knowledge in C to program the controller easily without the hassle of learning assembly instructions. Moreover, programming the controller in a middle-level language as opposed to assembly gives higher command over the code, but at a higher program size.</p>
<p>Installing <code>avr-gcc</code> is a breeze in Ubuntu/Debian with proper repositories enabled. It can be installed via Synaptic Package Manager or through command line by issuing the command <code>apt-get install avr-gcc</code>. In addition to the compiler, you also need the libraries which define the specialized functions. The library called <code>avrlibc</code> can be installed in a similar fashion.</p>
<p>Take a look at the <code>man</code> pages to find out the version of <code>avrlibc</code> you are using. Although the past couple of versions are not too different from each other; <code>avrlibc</code> has grown from what it was when it was first introduced in 2002. You will have to download the manual for <code>avrlibc</code> which is available <a rel="nofollow" target="_blank" href="http://savannah.nongnu.org/download/avr-libc/avr-libc-user-manual-1.6.5.pdf.bz2">here</a>.</p>
<p>Let us now try to dissect a small program which blinks an LED; the &#8220;Hello, World&#8221; of microcontrollers.</p>
<div class="c dean_ch" style="white-space: nowrap;">
<span class="co2">#include &lt;avr/io.h&gt;</span><br />
main<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; DDRC <span class="sy0">|=</span> _BV<span class="br0">&#40;</span>PC0<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; TCCR0 <span class="sy0">=</span> _BV<span class="br0">&#40;</span>CS00<span class="br0">&#41;</span> <span class="sy0">|</span> _BV<span class="br0">&#40;</span>CS02<span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">//Clock divided by 1024 mode</span><br />
&nbsp; &nbsp; <span class="kw1">while</span><span class="br0">&#40;</span>1<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; PORTC <span class="sy0">^=</span> _BV<span class="br0">&#40;</span>PC0<span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// toggle PC5</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">while</span><span class="br0">&#40;</span>bit_is_clear<span class="br0">&#40;</span>TIFR<span class="sy0">,</span> TOV0<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; TIFR <span class="sy0">=</span> _BV<span class="br0">&#40;</span>TOV0<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
&nbsp;</div>
<p>The <code>#include</code> directive includes the header file which defines the standard input output functions for the ATmega8. It is not specific to ATmega8, but can be used for a wide range of ATmega Products. It is followed by the <code>main()</code> function which is pretty much how standard C program follows. The variables in capital letters are standard registers of the device as specified in its datasheet. </p>
<p>The <code>DDRC</code> register (or the Data Direction Register, Port C) determines whether a particular pin of the Port should be an output register or an input register. The register is similar to the Tris register in PIC Devices. The difference is that writing a 1 to the pin makes the pin an output as opposed to what in PIC. </p>
<p><code>PC0</code> is the 0th bit of Port C and thus it is numerically equivalent to 0. The macro <code>_BV(X)</code> is equivalent to <code>( 1 << X )</code>. Thus the code <code>_BV(PC0)</code> ultimately evaluates to <code>( 1 << 0)</code> and is written to the <code>DDRC</code> register. To cut a long story short, we just set the bit 0 of the DDRC register, making the pin PC0 an output pin. The macro <code>_BV()</code> is helpful in setting more than one bits without sacrificing code clarity. For example, to make the pins PC5 and PC7 of Port C outputs, one just has to code <code>DDRC |= ( _BV(PC5) | _BV(PC7) );</code> The code word generated is ORed with the <code>DDRC</code> register to save whatever configuration bits the other pins hold. </p>
<p>Next is the <code>TCCR0</code> register. It controls the timer of the ATmega8. By looking at the timer section in the datasheet, one can know which bits to set for each configuration. The bits can then be set using the <code>_BV(X)</code> macro that we encountered earlier. It can also be set by equating the register with the values we generated manually. The preferred method is the usage of macro as it simplifies reading the code.</p>
<p>Since we want to blink the LED an indefinite number of times, we code the LED toggling in an infinite <code>while</code> loop. The operator <code>^</code> is the C XOR operator and it effectively toggles the PC0 bit. The macro <code>bit_is_clear(X, Y)</code> returns true if the Yth bit in the X register is cleared. The register and the bit coded in the program, ie <code>TIFR</code> and <code>TOV0</code> pertains to the timer peripheral of the device. More operational details of the timer can be obtained from the datasheet. Essentially the operation is that on end of timer count, a bit <code>TOV0</code> of the <code>TIFR</code> register is cleared which has to be set to re-enable the timer.</p>
<p>The next post will detail compilation and uploading the program to the device.</p>
<h3  class="related_post_title">Related</h3><ul class="related_post"><li><a href="http://www.randity.com/blog/2009/07/getting-the-atmega8-to-run/" title="Getting the ATmega8 to run our Program">Getting the ATmega8 to run our Program</a></li><li><a href="http://www.randity.com/blog/2009/07/programming-atmega8/" title="Programming ATmega8">Programming ATmega8</a></li><li><a href="http://www.randity.com/blog/2009/06/beginning-the-atmega8/" title="Beginning the ATmega8">Beginning the ATmega8</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.randity.com/blog/2009/07/intro-to-avr-gcc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programming ATmega8</title>
		<link>http://www.randity.com/blog/2009/07/programming-atmega8/</link>
		<comments>http://www.randity.com/blog/2009/07/programming-atmega8/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 04:15:47 +0000</pubDate>
		<dc:creator>Rahul Pisharody</dc:creator>
				<category><![CDATA[Embedded Development]]></category>
		<category><![CDATA[Hobby]]></category>
		<category><![CDATA[Microcontrollers]]></category>

		<guid isPermaLink="false">http://www.randity.com/blog/?p=122</guid>
		<description><![CDATA[No articles on a microcontroller is complete without mentioning how to program the device. Depending on the controller you choose, there are probably a gazillion ways of uploading the firmware. Some are simple nad minimal. Others are complex and extensive. There is always a trade off.]]></description>
			<content:encoded><![CDATA[<p>Its been almost a month since I last visited the <a title="Beginning Development with ATmega8" href="http://www.randity.com/blog/2009/06/beginning-the-atmega8/" target="_blank">ATmega8 I bought the other day</a>. Yet, there it was sitting nicely beneath my PC stand, a bit dusty though. With renewed interest and vigor, I rebooted my attempts. This time, I was ready with all the required components. I left you in the <a href="http://www.randity.com/blog/2009/06/beginning-the-atmega8/" target="_blank">previous article</a> stating that I wired up the programming circuit; but I failed to mention the circuit used. Without further ado, here&#8217;s my programmer circuit.</p>
<div class="wp-caption alignnone" style="width: 380px"><a href="http://www.randity.com/blog/wp-content/uploads/2009/07/ckt.png" target="_blank"><img title="Parallel Programmer Circuit" src="http://www.randity.com/blog/wp-content/uploads/2009/07/ckt.png" alt="" width="370" height="277" /></a><p class="wp-caption-text">Click for a larger version</p></div>
<p>The circuit is simple and the costly parts are the ATmega8 itself and the DB25 connector. The capacitors connected with the crystal (22pF) are used to generate the clock waveforms for the microcontroller to operate. A slightly detailed explanation can be found <a rel="nofollow" target="_blank" title="Capacitors and Crystals" href="http://www.maxim-ic.com/appnotes.cfm/an_pk/2154" target="_blank">here</a>. The values of capacitor to be chosen are dependent on the frequency of Crystal. Most of the microcontrollers provide a look up table in their datasheet to select the capacitor value. Since our application is not terribly time critical, it is good enough if we use capacitors in the near vicinity.</p>
<p>Wire up the circuit on a bread board or a common, general purpose board depending on your choice. Take special care in connecting the ground pins of the parallel connector with the circuit ground. Failing to do this will result in unwanted signals and noise since the signals at two different referral levels are present in the board. With everything in place, it is always a good idea to recheck the wiring and make sure that parallel port connections stays intact.</p>
<p>As for the software part, there a lot of good tools out there to achieve the end job like <a rel="nofollow" target="_blank" title="AVRDUDE Website" href="http://www.nongnu.org/avrdude/" target="_blank">avrdude</a>, <a rel="nofollow" target="_blank" title="SP12" href="http://www.xs4all.nl/~sbolt/e-spider_prog.html" target="_blank">sp12</a> etc. But my favorite is <a rel="nofollow" target="_blank" title="UISP" href="http://www.nongnu.org/uisp/" target="_blank">uisp</a>. If the hardware is all properly wired up, its time to see whether the software detects ATmega8. So fire up a terminal and type in
<div class="bash dean_ch" style="white-space: nowrap;">uisp <span class="re5">-dprog</span>=dapa</div>
<p>If all is well and working properly, you get a notification that </p>
<div class="bash dean_ch" style="white-space: nowrap;">AVR ATmega8 detected</div>
<p>.<br />
In the next post, we will cover programming with <code>avr-gcc</code> and burning with <code>uisp</code></p>
<h3  class="related_post_title">Related</h3><ul class="related_post"><li><a href="http://www.randity.com/blog/2009/07/getting-the-atmega8-to-run/" title="Getting the ATmega8 to run our Program">Getting the ATmega8 to run our Program</a></li><li><a href="http://www.randity.com/blog/2009/07/intro-to-avr-gcc/" title="A 101 on avr-gcc">A 101 on avr-gcc</a></li><li><a href="http://www.randity.com/blog/2009/06/beginning-the-atmega8/" title="Beginning the ATmega8">Beginning the ATmega8</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.randity.com/blog/2009/07/programming-atmega8/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Eclipse</title>
		<link>http://www.randity.com/blog/2009/07/eclipse/</link>
		<comments>http://www.randity.com/blog/2009/07/eclipse/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 13:04:13 +0000</pubDate>
		<dc:creator>Rahul Pisharody</dc:creator>
				<category><![CDATA[Science]]></category>
		<category><![CDATA[Solar Eclipse]]></category>

		<guid isPermaLink="false">http://www.randity.com/blog/?p=119</guid>
		<description><![CDATA[An account of Solar Eclipse of July 22, 2009 with technical details. Also includes the schedule of the next eclipse.]]></description>
			<content:encoded><![CDATA[<p>As even the most ignorant, illiterate creature may have known by now, we have a solar eclipse coming up tomorrow morning. The eclipse will begin in India from approximately, 05:31:13.6 AM and will last upto 07:14:12.6 AM. As we all know, the eclipse is making a buzz around the country; but we, keralites are not so lucky.</p>
<p>The sun be obscured by about 56% at its peek as seen from Kerala. We also have the threat from clouds which may completely screen this magnificent sight. Albeit longest, this isn&#8217;t the last eclipse that can be witnessed in this century. To be exact, the Solar eclipse of July 22 will last 6 minutes and 39 seconds, making it the longest eclipse yet to see  in this century. The longest eclipse of this century was in 1973.<br />
<a href="http://www.randity.com/blog/wp-content/uploads/2009/07/diamond.jpg" target="_blank"><img class="alignleft" style="margin-left: 10px; margin-right: 10px;" title="The Diamond Ring Effect" src="http://www.randity.com/blog/wp-content/uploads/2009/07/diamond.jpg" alt="" width="316" height="282" /></a><br />
In my opinion, we keralites are going to be more blessed by the Eclipse of January 15, 2010. Although the eclipse will not be a total one, the sun will be obscured by about 82%, making it a prominent one. More important, the eclipse happens sometime around 11AM, making it easier to observe and perceive.</p>
<p>Here are a couple of links for both eclipses which contain in detail the duration and visibility of both the eclipses. Both links are for Cochin.<br />
<a rel="nofollow" target="_blank" title="Local Circumstances of the Eclipse of July 22, 2009" href="http://www.eclipse.org.uk/eclipse/0412009/Cochin_India_2009Jul21.png" target="_blank">Local Circumstances of the Eclipse of July 22, 2009</a> and <a rel="nofollow" target="_blank" title="Animation of the July 22 Eclipse as viewed from Cochin" href="http://www.eclipse.org.uk/eclipse/0412009/Cochin_India_2009Jul21_anim.gif" target="_blank">Animation of the Eclipse as viewed from Cochin</a></p>
<p><a rel="nofollow" target="_blank" title="Local Circumstances of the Eclipse of January 15, 2010" href="http://www.eclipse.org.uk/eclipse/0132010/Cochin_India_2010Jan15.png" target="_blank">Local Circumstances of the Eclipse of January 15, 2010</a> and <a rel="nofollow" target="_blank" title="Animation of the January 15, 2010 Eclipse as viewed from Cochin" href="http://www.eclipse.org.uk/eclipse/0132010/Cochin_India_2010Jan15_anim.gif" target="_blank">Animation of the Eclipse as viewed from Cochin</a></p>
<p>With the technical details done, lets get to the fun part. Superstitions. Some of them are my additions and some are I found elsewhere while scouring the World Wide Web. And mind you, apart from being ridiculous, most of them are downright laughable.</p>
<p>1. Do not eat anything tomorrow, as some freak astronomer is of the opinion that eclipse at sunrise is worse than Armageddon.</p>
<p>2. Never do any work during Eclipse (Thats cool !)</p>
<p>3. Avoid eating foods prepared before eclipse !</p>
<p>4. Postpone child births</p>
<p>5. Pregnant Women are to be kept inside a home !</p>
<p>I honestly don&#8217;t know why people still believe such stupidity. Even in this age of Science and Discovery, even in the 4th country to reach the Moon, even in the land of one of the most successful space agencies, these stupidities are tolerated and observed.</p>
<p>Oh, gosh !</p>
<h3  class="related_post_title">Also</h3><ul class="related_post"><li><a href="http://www.randity.com/blog/2009/06/ip-from-command-line/" title="IP from Command Line">IP from Command Line</a></li><li><a href="http://www.randity.com/blog/2009/06/packing-and-unpacking-in-perl/" title="Packing and Unpacking in Perl">Packing and Unpacking in Perl</a></li><li><a href="http://www.randity.com/blog/2009/06/the-clash-of-the-titans/" title="The Clash of the Titans">The Clash of the Titans</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.randity.com/blog/2009/07/eclipse/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Where was I ?</title>
		<link>http://www.randity.com/blog/2009/07/where-was-i/</link>
		<comments>http://www.randity.com/blog/2009/07/where-was-i/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 17:29:26 +0000</pubDate>
		<dc:creator>Rahul Pisharody</dc:creator>
				<category><![CDATA[Family]]></category>

		<guid isPermaLink="false">http://www.randity.com/blog/?p=118</guid>
		<description><![CDATA[An explanation]]></description>
			<content:encoded><![CDATA[<p>I think I owe my readers an apology. I was completely, totally absent for about a month in blogosphere and partially in twitterverse. There were abrupt and sometimes odd tweets flying apart from me. And, obviously, something big was happening. It has passed and I am back.</p>
<p>Meanwhile, a lot of snags hit the ATmega8 development. The major one being the non availability of the components. Family commitments also took a toll on my time and thus the project is currently stalled.</p>
<p>A lot of loose ends lie now to tie up together. I am in the process of rebuilding what I lost.</p>
<h3  class="related_post_title">Also</h3><ul class="related_post"><li><a href="http://www.randity.com/blog/2009/07/getting-the-atmega8-to-run/" title="Getting the ATmega8 to run our Program">Getting the ATmega8 to run our Program</a></li><li><a href="http://www.randity.com/blog/2009/06/the-clash-of-the-titans/" title="The Clash of the Titans">The Clash of the Titans</a></li><li><a href="http://www.randity.com/blog/2009/06/the-palm-gamble/" title="The Palm Gamble">The Palm Gamble</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.randity.com/blog/2009/07/where-was-i/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beginning the ATmega8</title>
		<link>http://www.randity.com/blog/2009/06/beginning-the-atmega8/</link>
		<comments>http://www.randity.com/blog/2009/06/beginning-the-atmega8/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 10:36:14 +0000</pubDate>
		<dc:creator>Rahul Pisharody</dc:creator>
				<category><![CDATA[Embedded Development]]></category>
		<category><![CDATA[Hobby]]></category>
		<category><![CDATA[Microcontrollers]]></category>

		<guid isPermaLink="false">http://www.randity.com/blog/?p=114</guid>
		<description><![CDATA[This is a prologue post for my articles on an embedded system development using the ATmega8 Controller]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.randity.com/blog/wp-content/uploads/2009/06/ATmega8.jpg"><img class="alignleft size-full wp-image-115" title="ATmega8" src="http://www.randity.com/blog/wp-content/uploads/2009/06/ATmega8.jpg" alt="ATmega8" width="240" height="240" /></a>The other day, I decided it was time enough that I loitered around, doing nothing to improve my knowledge or skills at what I am supposed to be good at, Electronics. Oh, well, thats what the world supposes you to be, right ? You know, after getting a B.Tech degree in Electronics, you should at the very least be able to implement a comparator properly. I can, and I have. But thats not the point. I&#8217;ve done nothing related to electronics after I completed my degree. So, on the day of <a href="http://www.randity.com/blog/2009/06/a-day-without-wordpress/">WordPress disaster</a>, I bought all the components required to make my perfect dream.</p>
<p>A line following bot. Before you shun away, let me tell you. A full fledged line follower embodies true spirit of ingenuity and engineering. A true follower is small, agile and does the job clean and fast. I decided to implement one similar to <a rel="nofollow" target="_blank" href="http://elm-chan.org/works/ltc/report.html">ChaN&#8217;s</a>. For a starter, I am not going to make my bot that small, but I wanted to implement the PI(D) controls that he used. I was never really into control systems, and this I believe is a great way to learn more on the topic.</p>
<p>Since I am doing a fast line follower, there should be microcontroller at the helm to do the job. During my engineering life, I have used a lot of <a rel="nofollow" target="_blank" href="http://en.wikipedia.org/wiki/8051">8051</a>s and <a rel="nofollow" target="_blank" href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;nodeId=69">Microchip&#8217;s PIC</a>. I am more familiar with the PIC controller, since I had been using it for almost two years now. The ideal engineer in me found this as the perfect way to do some bit of research. And I needed to setup GNU/Linux as my platform to develop the bot. Thus the equation GNU/Linux + Low Cost resulted in me selecting the AVR&#8217;s famed and praised <a rel="nofollow" target="_blank" href="http://www.atmel.com/products/avr/overview.asp?family_id=607">ATmega8</a>.</p>
<p>I was surprised to learn that Kerala Electricals, Trichur had been offering ATmega line of controllers for a long time. I never found the controller at Ronnie Electronics, M.G. Road, Ernakulam. I first needed to setup the toolchain to program the controller with. This excellent <a rel="nofollow" target="_blank" href="http://pramode.net/articles/lfy/atmega8/pramode.html">article</a> by the Linux Guru Pramod C.E., former alumini of <a rel="nofollow" target="_blank" href="http://www.mec.ac.in/">my college</a> and lecturer at Govt. Engineering College, Trichur helped me a lot. I hit a snag when I was compiling the gcc-3.4.2 package. The avr archiver, <code>avr-ar</code> form binutils package would run, but report a buffer overflow error. Finding no help from forums and user groups, I called up Pramode Sir himself and I was slapped in the face. I mean, not literally, but figuratively speaking.</p>
<p>The toolchain was all the time residing in Ubuntu repos. It was just an <code>apt-get install avr-gcc</code> away. I installed <code>avrlibc</code>, and <code>uisp</code> the same away. With the tools ready, I needed the ATmega8 to do the testing. Away I went to Trichur. Two relatively short bus rides and the hellish long wait of my life, I was back home with the prized ATmega in my hand. Dusted up an old breadboard and wired up the circuit. The soldering iron I have at home is an ancient one. So special care had to be taken while soldering the DB25 connector. I needed to solder properly and at the same time, protect myself from electric shocks and burns.</p>
<h3  class="related_post_title">Related</h3><ul class="related_post"><li><a href="http://www.randity.com/blog/2009/07/getting-the-atmega8-to-run/" title="Getting the ATmega8 to run our Program">Getting the ATmega8 to run our Program</a></li><li><a href="http://www.randity.com/blog/2009/07/intro-to-avr-gcc/" title="A 101 on avr-gcc">A 101 on avr-gcc</a></li><li><a href="http://www.randity.com/blog/2009/07/programming-atmega8/" title="Programming ATmega8">Programming ATmega8</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.randity.com/blog/2009/06/beginning-the-atmega8/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A Day without Wordpress</title>
		<link>http://www.randity.com/blog/2009/06/a-day-without-wordpress/</link>
		<comments>http://www.randity.com/blog/2009/06/a-day-without-wordpress/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 02:15:27 +0000</pubDate>
		<dc:creator>Rahul Pisharody</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://www.randity.com/blog/?p=109</guid>
		<description><![CDATA[WordPress went berserk. The author was not ready to give up and start anew. A face off between the relatively inexperienced author and the tricky WordPress Databases]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-113 alignleft" src="http://www.randity.com/blog/wp-content/uploads/2009/06/Document.jpg" alt="Blank Document" width="223" height="279" />Sometimes the most unfortunate of the events fall upon at the most ill deserved of the times. Frustrated with the waiting, I set out on a maiden voyage to brush up my skills as an Electronics Engineer and pick up quite a few new things along the way. Except for the fact that I had to wait at Kerala Electronics, Trichur for almost a full hour to buy the components during which time, I heard enough of the old Trichur slang, the purchase was fruitful. I even got to spend some quality time over a juice of fresh pineapple with an old, close friend of mine.</p>
<p>When I returned, I immediately started work upon the project, which was a complete success. An unprecedented first time result for me. As I was ready to vent out the day in a blog post, disaster strikes. I decided on changing the <a rel="nofollow" target="_blank" href="http://www.randity.com/blog/">blog</a>&#8217;s <a href="http://www.dailyblogtips.com/studiopress-wordpress-theme-released/">current theme</a> to <a rel="nofollow" target="_blank" href="http://azeeamazeez.com">Azeem Azeez</a>&#8217;s Brilliant and clean <a rel="nofollow" target="_blank" href="http://azeemazeez.com/blogs/white-as-milk">White as Milk</a>. As I was editing the header file from the new theme, I accidently erased a huge part of the file and clicked on update. I know it is too difficult to do one without the other being noticed, but then again euphoria brings about changes in a man&#8217;s attention to details.</p>
<p>And no WordPress.</p>
<p>The database was fine, all tables intact. Nothing had been touched. I was never into databases and MySQL until yesterday. But if I had to get back into business, I had to use phpmyadmin and correct the errors. I first used phpmyadmin&#8217;s default Export command to create a SQL dump of the tables. Next I dropped the tables and reinstalled WordPress. I imported the SQL dump and the SQL Query Windows began to show <a rel="nofollow" target="_blank" href="http://en.wikipedia.org/wiki/Gobbledygook">goobledygook</a>. A missing punctuation, a misplaced quotes and non-existent table values. To top it all, the good old KSEB failed right on time. Impeccable timing.</p>
<p>It was many an hour before the power came back. This time, after a small tweak I applied to the SQL Dump file, I was able to reinstate the tables. And Voila ? Not quite. WordPress was not working again.</p>
<p>I decided to get my hands dirty. I fired up the phpmyadmin and began to view the table entries. I believe the whole problem was a wrong database entry denoting the current theme. I cleared the values for &#8220;current_theme&#8221; and &#8220;recently_edited&#8221;. And as if magic, WordPress was right back on track. No problems with theme or anything. I was a bit surprised at this behaviour.</p>
<p>WordPress, being a blogging application, should have some default theme to resort to incase of a theme failure. Or else, everyone would be wondering what happened to their perfectly customized blog.</p>
<p>Was this my fault ? Or is it WordPress&#8217;s ? Your comments are highly appreciated.</p>
<h3  class="related_post_title">Related</h3><ul class="related_post"><li><a href="http://www.randity.com/blog/2009/06/ip-from-command-line/" title="IP from Command Line">IP from Command Line</a></li><li><a href="http://www.randity.com/blog/2009/06/the-clash-of-the-titans/" title="The Clash of the Titans">The Clash of the Titans</a></li><li><a href="http://www.randity.com/blog/2009/06/bing-searches-google/" title="Bing Searches &#8220;Google&#8221;">Bing Searches &#8220;Google&#8221;</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.randity.com/blog/2009/06/a-day-without-wordpress/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Packing and Unpacking in Perl</title>
		<link>http://www.randity.com/blog/2009/06/packing-and-unpacking-in-perl/</link>
		<comments>http://www.randity.com/blog/2009/06/packing-and-unpacking-in-perl/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 17:46:45 +0000</pubDate>
		<dc:creator>Rahul Pisharody</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://www.randity.com/blog/?p=100</guid>
		<description><![CDATA[Perl's pack/unpack - A quick note]]></description>
			<content:encoded><![CDATA[<p>This post is more to serve as a reminder to myself. Perl has a handy keyword called <code>pack</code> which helps to store a variable in the template specified. <code>pack</code> thus takes two arguments. The first argument is the template and the second argument is the string to be <code>pack</code>ed according to the template.</p>
<p>Now, a <a rel="nofollow" target="_blank" href="http://www.google.co.in/search?hl=en&#038;q=Perl+pack+cheat+lists">search</a> produces lots of links to various Perl <code>pack/unpack</code> cheatlists. And they are all wonderful quick references to an otherwise complicated option set. </p>
<p>I was intrigued by two aspects of the <code>pack/unpack</code> set. One of the cute little tricks I found was by using <code>pack</code>. Ofcourse, they would be elsewhere on the Wide Wide Web(pun intended). But I found these by myself. So explorers who went before me, forgive for this was an accidental discovery. And I hadn&#8217;t known that this was a discovery but a revisit for unbeknownst to the crusaders of other languages, Perl has a lot of accomplices. </p>
<p>The <code>pack</code> Pack :<br />
The follwoing code
<div class="perl dean_ch" style="white-space: nowrap;"><a rel="nofollow" target="_blank" href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <a rel="nofollow" target="_blank" href="http://perldoc.perl.org/functions/ord.html"><span class="kw3">ord</span></a> <a rel="nofollow" target="_blank" href="http://perldoc.perl.org/functions/pack.html"><span class="kw3">pack</span></a> <span class="st0">&quot;b8&quot;</span><span class="sy0">,</span> <span class="nu0">10110</span><span class="sy0">;</span></div>
<p> prints the decimal value of 10110 as evaluated from right to left. I may find uses for it in the future. But the one thing I could do find it well adapted was in obfuscation. Maybe a brilliant JAPH, anyone ?</p>
<p>The <code>unpack</code> Pack:<br />
The following code
<div class="perl dean_ch" style="white-space: nowrap;"><a rel="nofollow" target="_blank" href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <a rel="nofollow" target="_blank" href="http://perldoc.perl.org/functions/unpack.html"><span class="kw3">unpack</span></a> <span class="st0">&quot;C*&quot;</span><span class="sy0">,</span> <span class="st0">&quot;Just&quot;</span><span class="sy0">;</span></div>
<p> prints the decimal value of each character from the string &#8220;Just&#8221;. Apart from obfuscation, the real use of <code>pack/unpack</code> functions is to create easily exchangable data. </p>
<p>As we saw in the earlier example, converting from little-endian to big-endian is a trifle in Perl.</p>
<blockquote><p>If Perl could Perl then Perl would be Perl 6!</p></blockquote>
<h3  class="related_post_title">Related</h3><ul class="related_post"><li><a href="http://www.randity.com/blog/2009/06/a-day-without-wordpress/" title="A Day without Wordpress">A Day without Wordpress</a></li><li><a href="http://www.randity.com/blog/2009/06/the-palm-gamble/" title="The Palm Gamble">The Palm Gamble</a></li><li><a href="http://www.randity.com/blog/2009/06/bash-youtube-downloader/" title="Bash YouTube Downloader">Bash YouTube Downloader</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.randity.com/blog/2009/06/packing-and-unpacking-in-perl/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How Rowling killed Harry</title>
		<link>http://www.randity.com/blog/2009/06/how-rowling-killed-harry/</link>
		<comments>http://www.randity.com/blog/2009/06/how-rowling-killed-harry/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 04:26:10 +0000</pubDate>
		<dc:creator>Rahul Pisharody</dc:creator>
				<category><![CDATA[Literature]]></category>
		<category><![CDATA[Fun]]></category>

		<guid isPermaLink="false">http://www.randity.com/blog/?p=93</guid>
		<description><![CDATA[Rahul Pisharody shares his thoughts on Harry Potter and the recent allegation of plagiarism  on J. K. Rowling]]></description>
			<content:encoded><![CDATA[<p>I was a great fan of Harry Potter once it came out, way back in 1997. I was mesmerized by the style of writing, the depth of characters and subtle hints of back stories that J. K. Rowling provided in each of her books. It was like a jigsaw puzzle. I devoured each books on the day they came out. </p>
<p>When with much fanfare and hype the final book, The Deathly Hallows was released, I was almost sure that Rowling wouldn&#8217;t kill off the character that took the World by a rage. But I liked the way the book was done and all, until I came to the Epilogue. Now, I said I liked the book, not enjoyed it. In between the long gaps between books, I had read other fantasy works, including the famed and poetic Lord of the Rings. I had even ventured a bit into the lore and languages of Middle Earth which I found fascinating. As opposed to Rowling, Tolkein created a whole Universe where things took their natural turn in the course of time. There was no hidden Hogwarts and Muggles.</p>
<p>Coming back to Rowling, the very way she hinted at what became of Harry after the Hogwarts years exposed the immature writer in her. I&#8217;m not saying that she isn&#8217;t talented. That would be an understatement , provided she was able to captivate not only English readers, but everyone who was interested in reading. She was a textbook rags to riches case. In my opinion, a written book is for the reader. Every reader has his or her own right to dream and imagine the World that he/she is to see. A skilled reader could even feel the walls of Hogwarts and the wind in Harry&#8217;s face in a Quidditch match. The Epilogue spoiled the way Rowling had been writing so far. She was always open ended, never giving out a plot completely, most of them would be left out for the reader to shape up to his/her passion. </p>
<p>The perfect way to end Deathly Hallows would have been something which complements the opening sentence of The Sorcerer&#8217;s Stone. We all know that Rowling had borrowed a lot from the Lord of the Rings Universe, but now <a rel="nofollow" target="_blank" href="http://www.dailymail.co.uk/tvshowbiz/article-1193283/JK-Rowling-sued-500m-plagiarism-lawsuit-family-late-Willy-The-Wizard-author.html">this</a> ? She had so far only drawn inspiration from other works. Those who have read Tolkein would know that Dobby resembles Gollum, Gandalf inspired Dumbledore and even Voldemort himself was sculptured after Sauron. This should be expected, because both deal with the theme of good vs. evil. Hence I think that the lawsuit has to be viewed in such an angle. </p>
<p>What do you think ?  </p>
<h3  class="related_post_title">Related</h3><ul class="related_post"><li><a href="http://www.randity.com/blog/2009/06/bash-youtube-downloader/" title="Bash YouTube Downloader">Bash YouTube Downloader</a></li><li><a href="http://www.randity.com/blog/2009/06/making-twitter-useful/" title="Making twitter useful">Making twitter useful</a></li><li><a href="http://www.randity.com/blog/2009/06/bing-searches-google/" title="Bing Searches &#8220;Google&#8221;">Bing Searches &#8220;Google&#8221;</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.randity.com/blog/2009/06/how-rowling-killed-harry/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The Palm Gamble</title>
		<link>http://www.randity.com/blog/2009/06/the-palm-gamble/</link>
		<comments>http://www.randity.com/blog/2009/06/the-palm-gamble/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 18:13:22 +0000</pubDate>
		<dc:creator>Rahul Pisharody</dc:creator>
				<category><![CDATA[Gadgets]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://www.randity.com/blog/?p=85</guid>
		<description><![CDATA[iPhone 3G S battles Palm Pre. What is the deciding factor in switch ?]]></description>
			<content:encoded><![CDATA[<p>What does it take to go up against something that has a solid market, a fanatic following and a brilliant strategist? An excellent foresight and the ability to make the possible out of the impossible. Who else would dare to take on something like the <a rel="nofollow" target="_blank" href="http://www.apple.com/iphone/">iPhone</a>, that literally marked the era of touch-phones? None other than <a rel="nofollow" target="_blank" href="http://en.wikipedia.org/wiki/Jon_Rubinstein">Jon Rubinstein</a>, CEO, <a rel="nofollow" target="_blank" href="http://www.palm.com/">Palm Inc</a>.Known better as the &#8220;guy who invented iPod&#8221;, Rubinstein worked as the Senior Vice President of Apple&#8217;s iPod Division till 2006. </p>
<p>Rubinstein joined Palm in 2007. As with Apple, he has helped bring out a revolutionary product, the <a rel="nofollow" target="_blank" href="http://www.palm.com/us/products/phones/pre/index.html">Palm Pre</a>. Its not new for Rubinstein to play his part as the underdog, rejuvenating and establishing a practically dead brand name. Apple was much in the same condition as Palm was before Rubinstein joined both. Palm which was once the alias for PDAs had succumbed to time and fate. Nowhere was Palm heard and told about until the Pre.</p>
<p>What makes Pre different from iPhone ? We have heard that the Pre and the new iPhone 3G S has essentially the same specs. The Pre takes the upper hand in the software. <a rel="nofollow" target="_blank" href="http://en.wikipedia.org/wiki/WebOS">WebOS</a>, the new Linux based OS introduced by Palm revolutionizes the way a developer used to program applications. They need not any longer be coded based on platform specific, company based programming languages. WebOS Applications can be programmed by anyone having knowledge of javascript, HTML and CSS. In this age of global blogging and web, most of us know some HTML. </p>
<p>It is not the quality or the ease of developing that is going to attract users. Because, for the majority, once an Apple, always an Apple. The success and the future of Palm will depend on the impact, both visual and usage, of the Pre. Apple on the other hand, convinced that they have an upper hand in the mobile market, are not to be ashamed or offended. </p>
<p>Apple responded within a couple of days by announcing the iPhone 3G S. It has been a while since Pre got out and the reviews are coming in. Almost all agree that the hardware is a bit flimsy, but at the same time praise and accolade WebOS and asks every phone developer to use WebOS as the platform of the future. </p>
<p>Where did Apple fail ? And why hasn&#8217;t iPhone 3G S developed the same sense of innovation and excitement that the original iPhone or the iPhone 3G had shown ? Apple is simply trying to get back in the race with a new, shiny, extra nice, eye candy wine in an old bottle. Save the Compass, nothing in iPhone 3G S is worth the switch from iPhone 3G. But as for Pre, a compelling and innovative OS resides pulling everyone to its grip like <a rel="nofollow" target="_blank" href="http://en.wikipedia.org/wiki/One_Ring">the Ring</a>.<br />
And Apple has to compete with iPhone 3G itself, coming out with the new iPhone OS3.0</p>
<p>But, will the Pre succeed ? Only time will win.<br />
My liitle, secret?, Pre.</p>
<p>Everone likes the <a rel="nofollow" target="_blank" href="http://www.idiva.com/bin/idiva/Homepage_Topstory_Undergomillionaire_fat">story</a> of the Underdog.</p>
<h3  class="related_post_title">Related</h3><ul class="related_post"><li><a href="http://www.randity.com/blog/2009/06/a-day-without-wordpress/" title="A Day without Wordpress">A Day without Wordpress</a></li><li><a href="http://www.randity.com/blog/2009/06/packing-and-unpacking-in-perl/" title="Packing and Unpacking in Perl">Packing and Unpacking in Perl</a></li><li><a href="http://www.randity.com/blog/2009/06/bash-youtube-downloader/" title="Bash YouTube Downloader">Bash YouTube Downloader</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.randity.com/blog/2009/06/the-palm-gamble/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
