Sunday, August 21, 2011

Be careful with your directory seperator when using Slverlight

I have observed something weird with the images in Silverlight:

In Visual studio you may specify the path towards an image using slash ("/") or backslash ("\") as separator: both give the correct result.

But if you run the silverlight application only the picture with the slash in the path does appear: the image whose path contains backslashes remains invisible.

May be the engine within visual studio uses Windows service to retrieve files and that service accepts both "/" and "\" as separators while the browser uses the HTTP conventions where the separator is always "/". Anyway for yor Silverlight developments be sure to always use "/" to avoid any problem.

Tuesday, August 9, 2011

Building my own pocket Calculator

I always wanted to make my own pocket calculator (in the 80's this seemed quite an impossible dream). With the currently available components this has become much easier.

I made it using a PIC 16F877, an 2x16 characters LCD display, and a telephone keyboard.

The schematics is quite straightforward

I used ExpressSCH to draw it.

For the programming I used the classic MPLAB 8.30 from microchip with the C compiler from Hi-tech software. This is a free C compiler that makes something I would think as nearly impossible for a C compiler: support the PIC 16 architecture.

The C compiler saved me from the mess of having to perform floating point operations in assembly language.
But to get the right accuracy, I had to set correctly the floating point size to 32bits

In the first time it did not work at all and I had to search to find why. In the end I found that I had incorrectly set the 16F877 chip options: I had forgotten to disable the "Low Voltage Programming". Since the Low Voltage programming interacts with Port B bit 3 which I use for keyboard this was preventing my software from working

by using:


I did solve the problem.

And now my pocket calculator is ready.