Thursday, May 14, 2009

A PICuliar problem!

Long long ago when I created this blog I had resolved to not post anything which relates to how much fight I put into getting Object X up and running if more than 80% of the world doesn't give a damn what Object X is. However the events of last night do deserve a mention somewhere, lest I ever forget them! (Although I am sure it wont happen.)

So we begin this tale of timeless tragedy at around 8 pm on the 13th of May 2009. For some god-forsaken reason I decided to get the HiTech C compiler for PIC16 running. (Don't ask why or what). Well things began on a rather promising note and in under 15 min I was able to blink a few LEDs. Enthused by this (seemingly) successful result I decided to get the UART interrupt running and Voila it refuses to work. Finally things were getting back to normal: codes not working and uCs refusing to do as they were told. However the real issue was that I had the (almost) same code up and running in assembly. All I had done was translate it to C.

Thus began the Herculean task of finding something to lay the blame on. So the first thing I did was to read the 2 codes again and conclude that they were indeed the same. After this the only logical thing was to turn to the panacea of 21th century problems - Google. Unfortunately over an hour of massaging different search queries couldn't get the required result. On a normal day this would be a warning sign that this isnt a real problem and I had messed up somewhere but unfortunately not yesterday.

It was then time to tinker around with the code, this was slighlty more helpful than googling and I figured out that the send portion of the code was working but the recieve interrupt was being called an infinite number of times. So far so good. Now I decided to read the datasheet once more. (Another half an hour down the drain) At this point for some god-forsaken reason I was sure it was the compiler's fault.

With great conviction and a little help from Kartik I found a disassembler for the 2 hex files.
(For those of you who have battled through all this nonsense and have understood the last line I can see the incredulous looks on your faces). Thus began the grand task of studying the 2 disassemblies. I dont know why but the HiTech C compiler puts this huge chunk of "start-up" code but after an hour of reading the disassembly I finally figured out what the "start-up" code did only to realise it was absolutely nothing. Then came the real code, this was much faster . In half an hour I realised the cause of this affliction. The assembly file I had the written used a btss somewhere but the C-code dissassembly used a btsc. (For the PIC16 instruction set uninitiated they are Bit Test Skip if Set and Bit Test Skip if Clear). As is obvious I had mistranslated the assembly and forgotten to put a not where it was deserved. Ofcourse if this were it the whole episode could have been excused but as most of you can conclude by now, there is more.

Well all the UART transmits worked perfectly but I was still getting infinite receive interrupts. However wisened by the events that had just transpired it was evident that it was mostly my own doing that stuff was not working. So another read of the codes was called for and yes once again the culprit was easily (ya right!) tracked down. In a hurry I had set the entire port with the LEDs as output. By a cruel twist of fate the UART was on the same port. So I made the receive pin of the UART an input and all was fine in wonderland. I am yet to check why the data direction of the UART pins matters, but maybe later.

So after aroung 6 hours of more or less pointless effort the UART which was happily working in assembly also works in C.

Whats the moral of the story you ask?
If you cant find the fault you are looking for on google and if it takes more than an hour of debugging to find an error it means YOU have made a mistake.

Sunday, April 26, 2009

Dance of Democracy

So it is election time once again, and this time around I get to make a difference.
But, before we begin the the usual cliches of 'How true power lies in the hands of the masses', 'How politicians have ruined this nation' and 'How politics is a profession and not social service' lets look at things from a different angle.

Therefore without much further ado we present:
-------------------------------------------------------------------------------------------------
The 15th General Elections Pop Quiz
Maximum Marks: 100 Passing Marks: 35
Maximum Time: 30 min

Additional Notes: This is a closed notes, closed book and closed internet examination.

1. Do you have a Voter's Card? (2 marks)
2. Have you checked your serial number in the electoral rolls? (5 marks)
3. Where is the polling booth where your name appears? (5 marks)
4. When does your constituency go to polls? (3 marks)
5. Name your Loksabha Constituency? (10 marks)
6. Name your Legislative Assembly Constituency? (5 marks)
7. How many candidates have registered from your constituency?
(10 marks for exact answer, 7 for +-2, 5 for +- 5, 0 otherwise)
8. How many of these are independents?
(5 marks for exact answer, 3 for +-5, 0 otherwise)
9. Can you name 5 political parties contesting your constituency?
(10 marks for 5, 5 for 4, 0 for 3/2, -5 otherwise)
10. Can you name any 5 candidates from your constituency?
(15 marks for 5, 10 for 4, 5 for 3, 0 otherwise)
12. Can you name atleast 1 independent?
(5 marks)
13. How many candidates have convictions or have been accused in criminal cases from your constituency?
(10 marks for exact number, 5 for +- 1, 0 otherwise)
14. Have you read the actual text of any of the election manifestos?
(15 marks for 3 or more, 10 marks for 2, 5 marks for 1, 0 otherwise)

End of Quiz
(Best of Luck)
-------------------------------------------------------------------------------------------------

I really dont know whether all the contestants from my constituency are qualified to govern, but I do know that I barely managed to pass when asked whether I was fit to vote. So the next time you decide to pass the buck to your neighbourhood errant, apathectic politician do ask yourself am I any different?

Signing off,
Lok Sabha Constituency Number: 30
Legislative Assenbly Constituency Number: 181
Voter List Number: 170
Serial Number: 418

Saturday, April 25, 2009

And we're back!

In the last 2 days 8 chats on Gtalk began with "whats new?"
"Nothing much" I meekly replied. Thats when I decided to do something about it.

Unfortunately given that my exams just got over and coupled with the fact that I am exceptionally lazy, there was precious little I was willing to do. As always things have a way of working out and an old friend pointed very politely pointed out I have a blog. So it was posting time.

Thats when it occured to me that I had changed my email id. Yup after 5 years 2.9979245e8@gmail.com (Ya I know its wrong by 8 m/s but what the heck) had lost some of its charm. I had to shift this blog to the more sober chiraag.juvekar@gmail.com. Luckily I had already ruined a nice afternoon typing balderdash into the google accounts password box in a desperate bid to recollect the password my mind refused to remember. So armed with the password that I had recovered after a notable 23 attempts I set out refurbish this dying blog-space.

"So what's new?" you ask, is it?
A new theme for the tasteful lot.
A new name to lift the curse of eternal damnation.
A decent address that I did manage to find. (Well awgn.blogspot.com is being squatted by some random chinese guy)
And a not so well thought out resolution to post atleast once a week.

Saturday, May 31, 2008

A View from the Other Side : Part 1

A View from the Other Side
A trilogy based on the events at the X - INAO camp.
(For some reason in 3.5 parts)
Sometimes also called "The Many Morals of Astro Camp".

Part 1: Well begun is barely one third done
May 3 to May 8

Day 1 :
This was the day the camp had finally begun. All seniors had arrived and true to our soon-to-be short lived form both Mehul and me got up at 8 am. The reason being breakfast (of all things breakfast). Not mine (I refuse to acknowledge the existence of anything so far fetched). But that of 50 odd astro campers.
Moral 11 : Most of the Indian population has been misled by unknown sources into believing that breakfast exists. It is very difficult to convince them otherwise :(
After this so called breakfast routine, we proceeded to the inaugral lecture.
Day 1 was a day of unexpected surprises :
1. Both I and Mehul had slept through "Powers of Ten" twice before when we were supposed to pay attention, we remained awake this time when we could officially sleep.
2. I knew very little black body physics.
3. Laptop hard-disk crash for no reasons.
When rephrased,
Moral 12 : Mehul, electronics and astro-camps don't mix. (Part A)
4. We slept in lecture no 3 and were woken up by the kids for tea. (Almost bed-tea)
5. "Sling shot effect" is an excellent lecture delivered by a divine lecturer.
Also known as,
Moral 13: If a lecture is understood by 1 student and 2 facilitators, then there is more to it than sadistic pleasure.
The last part does deserve clarification, it took us about 4 hours in the dorm with my laptop, an LCD projector and photos of sir's notes to make people see what that one hour lecture was all about. This was the winner of the "dorm session of the camp" award.

Day 2 :
Moral 14 : The fact that I have lost my voice does not imply people have lost their enthusiasm.
There were observations after the dorm session. And there was post dinner.
The next morning we overslept, missed "the breakfast" and barely managed to reach class in time.
Moral 15 : It feels nice when things get back to normal.
There were a few lectures nothing noteworthy except for the fact that the everyone hated the optics one.
Almost forgot, Vishal and Simit dropped by to say hello.
That evening was the first observation session. Given our skill with observations, the big guns had to be called. That was our first encounter with Anoop. The evening went of pretty smoothly and mostly everyone was comfortable using a telescope.

Day 3 :
This day too began with post dinner followed by some sleep.
It seems that this time around the moon had decided to play truant and the first observation outing had to be preponed. For reasons natural and unnatural this year it was at Vangani. Vangani is a small village about three hours from Mumbai by bus and it is a pretty decent observation site.
Moral 16 : Time spent in a bus is inversely proportional to square of the quality of the bus.
(Note from Munjeshwari Travels : We specialise in suspensionless busses)
Moral 17 : Busses are excellent locations for courses in literature ;)
At Vangani we met Piyush, who along with Anoop would be helping out with the observations. Vangani was where I saw Mercury for the first time. Vangani was also where I had used a telescope for the first time in my life. (Quite some time ago)
After unpacking the scopes the kids were free to do any observations they pleased. Although observations are always fun it is always troublesome when you don't have an extra telescope.
Moral 18 : A student's lecture session is a facilitators time to use the telescope.

Day 4 :
Overnight observations are not about staying awake all night. They are about choosing the right time and place to sleep. For most people this was session 3. The fault is not theirs alone.
Moral 19 : It is criminal to not provide biscuits with tea at 4am.
Around day break I was thankful we had no extra telescope. I dont know whether someone can have post dinner at 5:45, but the Pohe were welcome anyways. As we boarded the bus to leave I realized the beauty of mathematics.
Moral 20 : If a 50 seater has 46 occupants and if when horizontal an individual occupies 3 seats, then by pigeon hole principle 2 facilitaors can sleep.
As I later came to realize, thanks to a certain 10 Mpixels
Moral 21 : People who throw stones at others should not SLEEP in glass houses.
I do not really know when we reached IITB, I do not know what I did later. I do vaguely remember a co-ordinate systems lecture I mostly slept through (there was some coffee involved somewhere).
But I do think this was the day we played football. Yes I was the goal keeper and no my team did not lose.
Moral 22 : If the size of the goal is larger than the maximum span of the goal keeper, the goal keeper is expected to move.

Day 5 :
There was post dinner as H13. Although we did oversleep again, the next morning we woke up with fresh vigor. It was the day before TT1. I had given my TT1 with much anxiety.
Moral 23 : The view is indeed much better from the other side.
While the kids sat for the lectures we planned and plotted. Kedar Sir and Vahia sir had come down for the TT. By the evening the questions were finalized (thank God for the coffee shack). By the time the papers were ready, we had almost missed dinner. There was some doubt solving to be done.
Moral 24 : Spherical co-ordinate systems are never too easy for beginners.

Day 6 :
TT1 is always a funny experience. It has always been an open notes examination.
I have never seen anybody open their notes in TT1.
Nevertheless it is slightly boring when you have nothing to do for 4 hours (almost hoped I could write the test too [On third thoughts, its sometimes better to have nothing to do]).
After the test and the discussion, there was the first lab session. First by Aniket Sir, then by Vishal. I remember Vishal from my camp. He always did the labs and he did them well. Incidentally I also remember the problem he did that day (all too well). It was from my camp (Retrograding of Mars).
Moral 25 : Mistakes always seem exponentially more stupid with a linear increase in knowledge.
After the labs, it was time for some enrichment. It was a lecture on Cosmic rays. It was the lecture that went on and on till about 8:30pm. We were just in time for dinner. After that it was time for some observations. There was an OT coming soon. Something for which planning had begun quite some time ago.

Thursday, May 22, 2008

A View from the Other Side : Part 0.5

A View from the Other Side
A trilogy based on the events at the X - INAO camp.
(For some reason in 3.5 parts)
Sometimes also called "The Many Morals of Astro Camp".

Part 0.5: Before the Beginning
April 30 to May 2


Day -2
For me this year's camp began on April 30th. Not because I had to travel from some far off place to Mumbai to attend the camp but because it was around 4am on 30 April that I made the first concious effort to locate some of my Camp stuff (sky charts etc).
Which brings me to
Moral 1 : Any search expedition started after 4am is doomed to fail.
After this failed attempt I tried to console my self with a game of Warcraft, bringing us to
Moral 2 : If you try to play DOTA at 5:30 am you will most probably lose.
So after sleeping at around 6:00 am I got up at around 2:00 pm , had my bath(hereby referred to as bath 0). By the end of lunch it was already 3:30, did some work and left for IIT around 5:30pm.
Reaching IIT at around 7:30 pm I realised
Moral 3 : Time spent sleeping in a cab is time well spent.

At IIT I met Mehul (mildy frustrated I might add). It seems that while I was enjoying my mid-evening nap, he was running from pillar to post to put up the IJSO kids in their rooms and ensuring that the matresses arrived. I dumped my luggage in our room (No. 48 hereby referred to as the store-house). Entering the H-8 lounge where the Astro-Juniors were put up I came across
Moral 4 : H-8 lounge - All ventilation + Summer = Noisy Oven.

After getting all the juniors cooked to medium well-done we proceeded to H-13 Mess (No not canteen) for dinner. Dinner was good (anybody who thinks otherwise has not eaten in NSC).
After dinner we decided to have our first observation session (my first session after almost a year) bringing me to
Moral 5: I remember the sky only two months in a year (May+June).


Day -1:
At around midnight the observation got over the kids went back to the oven. And we followed to answer some doubts. There we had our first encounter with the ramaiya kind. Leading us to
Moral 6 : It is bad idea to discuss academics with anybody who enrolls into a class to get into a class.

However Day 1 did start on a good note as well. We discovered "post dinner". Post dinner is the midnight analog of breakfast. You see, my eating schedule is shifted ahead by a good 5 hours. Hence breakfast correponds to lunch, so on and so forth and finally dinner corresponds to post dinner. H13 canteen does the job surprisingly well i might add.

After barely 4 hours of sleep, I was woken up by a familliar "Chiraag Bhaiyya". Which brings me to
Moral 7 : It is futile to try to act as though you are sleeping with Senapati around. It does more harm than good.

Day 1 consisted mainly of rousing speech by Vahia Sir, a lecture by us on the basic use of calculators. Some lectures by Sagir Sheik on basic maths and ofcourse the infamous polar plotting session by us.
Moral 8 : r = 1.5*(cos (theta))^2 - 0.5 looks nice but is ridiculously difficult to imagine for 8th graders.
Day 1 is often also called the day of the exodus. It was the day when the we led the junior from the oven to the mess which they called theor home for the next 19 days. Akshay I remember had arrived by then.
By the end if the dorm session for the day it was time for some rest.

Day 0:
After having our second post dinner we went to sleep. By the time we awoke it seems one of the kids had already ran away. It took quite some tracing to figure out that he had actually left the camp.
Moral 9 : Kids should come with RFID tags.
Day 2 again was pretty dull. The basic physics was pretty basic. Well may be not for the juniors. However Day 2 is famous for a rather unconnected incident. Day 2 was the day I went to my old hostel (H3) consequently it became the day of Bath 1.
Moral 10 : It is very difficult to stay clean in any camp, especially if you are a facilitator.

Tuesday, April 29, 2008

Map of the Heavens

I have been using Starry Night for quite some time now. Almost three years if I am not mistaken. The package is very nice indeed, but a bit heavy for my old Celeron. I finally got tired of waiting an eternity for the screen to scroll.
Then I remebered a nifty package called Cartes du Ciel (CDC). CDC works on Linux and Windows. The core installer for the Windows version is around 9 MB. In addition you can download most of the standard catalogues. I'd recommend both the Hiparchos and the Tycho. If you are going to use it alongwith a telescope, I would also suggest a few of the deep sky ones. You might have to tweak the colour setting to your personal preferrences. I find the default to be very irritating.
Also if you are planning to install it on your laptop and take it outdoors there is a night vision mode is available.
One thing I find very nice is the ability to mark out telescope fields on the sky charts which makes it very easy to star hop to Messier Objects.
Enjoy your cloudless skies.

Here are some links:
Wiki Page : http://en.wikipedia.org/wiki/Cartes_du_Ciel
Home Page : http://www.stargazing.net/astropc/

Some Screenshots :
Telescope View


Night Vision Mode

Friday, April 18, 2008

Fractly Speaking

After using Photoshop for over three years I finally got tired of doing the same things to get a random fractal-like background. Credit for some of the frustration goes to DeviantArt.com
Seeing some of the work there I was crushed to note that my pseudo-complex designs just didn't match up.
Nonetheless with 2GB of RAM and a 2.2GHz dual core beckoning it was time to call in the big guns. Thats where I came across Apophysis. It generates amazing fractals in real-time on the basis of the transformation you select. Yes I know the description is a bit vague, but given that even I am a noob as far as this software is concerned I hope most of you guys will tolerate it.
Any way I strongly suggest downloading one of the newer (post 2.05) beta versions as most of the tutorials I found work with these.
Also to get an idea of what you can do with Apophysis I have uploaded 3 of my latest creations.

Enjoy :)

The Bedouin



The Lady in the Water(This was touched up in PS later)



Dancing Twins