Subscribe to this blog!
Sunday, April 4, 2010
LinkedIn profile URL changed
Saturday, August 22, 2009
Thursday, June 19, 2008
Thanks to MCS Electronics!
Initially, I was using the demo version avilable on the MCS Electronics website. After some experience, my code size often went above 4 KB and that won't compile in the demo version. One fine day, I got the full version crack and installed it on my PC. Then, it was another very fine day (:)) when I was showing the same connections to a friend of mine (Note: now I was using the help section of the full version which was a bit updated), BINGO! I came across this italicized text which almost explained the thing I wanted to know for so long!
I have been having spurious success with the simple cable programmer from Sample Electronics for the AVR series.Although I'm using Kanda Systems' STK200+/300 as of now, this one explained to me the reason of the old weird problem. My sincere thanks to whoever updated that help section and to the research guy too!!
After resorting to hooking up the CRO I have figured it out (I think). When trying to identify the chip, no response on the MISO pin indicates that the Programming Enable command has not been correctly received by the target.
The SCK line Mark/Space times were okay but it looked a bit sad with a slow rise time but a rapid fall time. So I initially tried to improve the rise time with a pull-up. No change ie still could not identify chip. I was about to add some buffers when I came across an Atmel app note for their serial programmer "During this first phase of the programming cycle, keeping the SCK line free from pulses is critical, as pulses will cause the target AVR to loose synchronization with the programmer. When synchronization is lost, the only means of regaining synchronization is to release the RESET line for more than 100ms."
I have added a 100pF cap from SCK to GND and works first time every time now. The SCK rise time is still sad but there must have been enough noise to corrupt the initial command despite using a 600mm shielded cable.
Note: Although the loading is done via the parallel port, the communication is done in serial mode as stated in the app note.
Monday, May 26, 2008
Linking Chess and Astrology

Saturday, May 24, 2008
The Seven Habits of Effective C++
I’m on my fourth cup of coffee this morning and feeling a bit plagiaristic, so please indulge my rip-off of Stephan Covey’s popular (and terrific) book The Seven Habits of Highly-Effective People. Here are my top picks for successful C++ habits:
1. Don’t expect miracles: Object-oriented programming is valuable and C++ is a good way to make a transition from C. These tools can make development easier, but not effortless. Be realistic in your expectations of them.
2. Get plenty of training: Don’t be content to learn OO/C++ by reading the book that came with your compiler. Learn to use OO and C++ effectively by attending expert seminars and workshops. Supplement these sessions by also reading various OO/C++ books and magazines.
3. Plan prior to coding: Contrary to what you might think, the oft-recommended iterative design process does not recommend that you dive recklessly into coding. Software development is about problem solving, and good solutions require up-front planning.
4. Design for maintainability: Many developers focus on program size or speed as if 8080 processors and 64K of RAM were still mainstream. Size and speed are still important factors, but the primary costs of software are in maintenance. C++ provides many ways to enhance the structure, modularity, and reusability of your code, but it’s up to you to use them.
5. Don’t feel obliged to use every language feature: The C++ language is overflowing with features (e.g. templates, namespaces, RTTI, etc). Although each of these has its place, you can write very effective programs without using each and every one. Such showmanship is best left for the obfuscated C++ contest.
6. Apply design heuristics and metrics: Don’t throw away the entire software rulebook for OO designs. Modules should still be small, cohesive, and have minimal coupling. You can improve your designs and project planning by using simple metrics and design rules-of-thumb.
7. Help stamp out memory leaks: C++ programs rely heavily on dynamic memory allocation, and “garbage collection” is not a built-in feature. For this reason, C++ programs have a nasty habit of leaking memory like crazy. Fortunately there are several design techniques and software utilities that are invaluable for preventing and detecting leaks. Use them!
Copyright 1997 by Jerry Fitzpatrick. All rights reserved.
Originally published in C++ Report, October 1997.
Friday, May 23, 2008
Personal chess game - 1
White: GNUChess
Black: Jishnu
Result: 0-1
1. e4 c6 2. d4 d5 3. e5
B12; Caro-Kann Defense, Advance Variation. It concedes Black's objectives in the hope of a kingside attack.
3… Bf5 4. h4 h6
A less bookish move against the standard line 4… h5.
5. g4 Bh7 6. Nc3 e6 7. Nf3 Be7 8. Be3 Nd7 9. Be2 Qb6
Attacks White's pawn at b2 and enables the long castle.
10. Qc1 O-O-O 11. a3 f6 12. g5
Flips open the f-file and adds an extra pawn in the very center.
13. dxe5
Threatens Black’s queen.
13… c5
Time for black to act in the center.
14. gxh6
Attacks and isolates Black's pawn at g7.
14… Nxh6 15. Bf4?
White is wasting a move and is not attempting to castle on either sides.
15… d4
Using the center pawn majority to create passed pawns.
16. Nb1 Qa5+ 17. c3 d3
Pushing harder! Use of the seemingly dormant h7 bishop.
18. Bd1 Ng4
Preparing to free the crowded h-file.
19. Nbd2 Bf5 20. b3?
Still not interested in castling.
20… Rh5 21. Nc4 Qc7 22. Nd6+
The correct outpost for the knight. But the initiative gained is both, weak and late.
22… Kb8 23. Bg3?
Losing initiative… Still not castling!
23… Rdh8
Doubling rooks on the h-file. Slightly better is 23… Ndxe5 24.Nb5 d2+ 25.Qxd2 Qc6 26.Nbd4 cxd4 27.O-O Rxh4 28.Bxh4 dxc3.
24. Rg1 Bxd6
The exchange is profitable, as it leaves white with only a passed pawn (that too, a blocked one) hanging on the king-side.
25. exd6 Qc6 26. Ng5
Pins Black’s knight at g4.
26… e5
Attacks White’s pawn at g6.
27. Bf3 e4!
Removes the threat on Black's queen and threatens White's bishop at f3.
28. Bxg4 Bxg4 29. Qf4 Bf3
Moves it out of immediate jeopardy and blocks White's pawn at f2.
30. Qf7 Be2
Loss of an isolated pawn, in turn gaining time to develop pieces around the 2 passed pawns, that too passed center pawns against an uncastled king stuck in the center. White is up a pawn in material but its position is miserable.
31. Qxg7 Re8 32. Qf7 Rhh8 33. Ne6?
Leads to 33...Bg4 34.Ng5 Rhf8 35.Qe7 Kc8 36.Qg7 Qd5 37.Kd2 Qxb3 38.Ke3, which loses a pawn. Better is Kd2, leading to 33...Rhf8 34.Qg7 Qb5 35.Rab1 c4 36.a4 Qf5 37.bxc4 Bh5, which wins a pawn.
33… Bg4 34. Nc7??
Yikes! Leads to 34...e3 35.f3 Bxf3 36.Nxe8 d2+ 37.Kf1 Qe4 38.Qc4 Qxc4+ 39.bxc4 Rxe8 40.Re1 d1=Q 41.Rxd1 e2+ 42.Kf2 exd1=Q 43.Rxd1 Bxd1. Much better is Ng5, leading to 34...Rhf8 35.Qe7 Kc8 36.Qh7 Qd5 37.f3 exf3+ 38.Kf2 Re2+ 39.Kf1 c4, which gains a queen, a rook and a knight and loses a queen, a rook and two pawns in comparison. This was White's key error. White was not able to regain the lost ground and was eventually mated.
34… e3 35. f3 Bxf3
Material is even.
36. Rd1
White moves into a forced mate. Much better is 36. Kf1. Rd1 leads to 36...d2+ 37.Kf1 Qe4 38.Na6+ bxa6 39.Qxe8+ Rxe8 40.Rg2 e2+ 41.Kg1 e1=Q+ 42.Bxe1 dxe1=Q+ 43.Rxe1 Qxe1+ 44.Kh2 Qxh4+ 45.Kg1 Re1#.
36… Qe4
Black misses the forced mate.
37. Qxf3
White gives Black another forced mate opportunity. Much better is 37. Qd5. Qxf3 leads to 37...Qxf3 38.Rxd3 Rhg8 39.Rg2 Qxg2 40.Kd1 e2+ 41.Kc1 e1=Q+ 42.Bxe1 Rxe1+ 43.Rd1 Rxd1+ 44.Kxd1 Qf3+ 45.Kc1 Rg1+ 46.Kd2 Rg2+ 47.Kc1 Qf1#.
37… Qxf3 38. Rg2 Ref8 39. Bf4 Qxf4 40. Na6+ bxa6 41. Rc2 Qf1#
