Once there lived a ladySometimes the real things are stranger and mysterious.....
She could travel faster than light
She left out of home today
And returned back yesterday!
Wednesday, December 30, 2009
A lady who travelled faster than light....
Tuesday, December 29, 2009
Gui front end for parallel port controller in Linux
Now the program supports only on Linux platforms even though qt frame work is independent of platform. The reason is that, parallel port controlling is directly depend upon the OS you are used. You can easily control your parallel port in MS DOS environment, but things become worse when you try in Windows XP. Since the program calls the ioperm() function, you should have root privileges. Otherwise an abrupt exiting of the program occur. You only need to do the following things:
- Be root, and start the program by ./parport2. Try to open it from terminal at least for the first time in order to track bugs.
- Click 'Initialize' to call ioperm(). If you are not root, then the program abruptly exits while you click it.
- Nothing will be happened at outside while you click in 'Initialize'.
- You can use 8 switches to turn on or off the output data ports.
- The current output value in decimal is displayed on lineEdit.
Download parport.tar.gz (1.4MB)
I tested it in my PC and worked without any problem.
Warning: Take care while you play with parallel port. Very rarely, the after effect may fatal.
Note:- This program is intended for educational purposes only. May not be updated until anyone report a bug or a request to modify.
Saturday, December 26, 2009
PHET science simulations for students
I found those simulations were good in today's eduction- thanks for university of Colorado. Most of them are intended for Upper and High school students and pre- graduate students. However, if you just spend your time in experimenting with it, I am sure you get something new. Phet interactive simulations create a virtual lab environment. It's just a feeling that to enter into a physics or chemistry lab in a college. You can do anything in your own lab. Nothing to fear. No more comments from teachers...
One more advantage is that, you only need a java powered web browser. You can browse through different lab environments. If you like PhET virtual lab, you can download it for offline usage. Linux(80MB), Windows(97MB) and Mac OS(85MB) installation supported.
Browse phet simulations
Download phet for offline usage.
Wednesday, December 23, 2009
Parallel port programming using C/C++
Parallel port programming in GNU/Linux
I am not intended to make a wide description. I am directly give an example and this is what you want. If you are experienced the taste of C, you can easily catch what the program code mean.(We use LEDs to check whether our program run. You can see a simple circuit in the intro page). Connect the circuit described in intro page. to the parallel port properly. Then make new file parport.c and edit the file as shown:
#includestdio.h
#include stdlib.h
#include asm/io.h
#include unistd.h
#define base 0x378 /* printer port base address */
#define value 255 /* numeric value to send to printer port */
main(int argc, char **argv)
{
if (ioperm(base,1,1))
fprintf(stderr, "Couldn't get the port at %x\n", base), exit(1);
outb(value, base);
}
The above program is copied from epanorama. You should compile the program as su (super user) since ioperm() function needs root access. But in my system the above program didn't work. Many of my friends got error while compiling. The solution is to change the 4th line
#include
to
#include sys/io.h
You change the line and recompile only if you get a linking error. Sometimes you get an error like "Couldn't get the port at 378". But this is not a problem due to the port address. You probably may not be su.
Parallel port programming in MS windows
Converse the subtitle suggests, this program is not working in the windows environment, but in the MS DOS environment. I think you have basic knowledge of how to compile a C program.
#includestdio.h
#include conio.h
#include dos.h
/********************************************/
/*This program set the parallel port outputs*/
/********************************************/
void main (void)
{
clrscr(); /* clear screen */
outportb(0x378,0xff); /* output the data to parallel port */
getch(); /* wait for keypress before exiting */
}
The above program is also from epanorama. If you try to compare those programs, you can see a very little difference between those codes. Parallel port is a hardware and surely it is depended upon the OS you are using. So you can't write a cross-platform code for the parallel/printer port control. Please note that you can read inputs as well as write as output however, the example only shows the output control. Sometimes your port address may be different, however in most cases it will be 0x378. If it fails try 0x278 and 0x3BC. Read more here.
You can check your program by simply inserting an LED connected in serial with 1K ohm resistor.
Read my post on parallel port control on python
How do we think? A brief introduction
x1*w1+x2*w2+.........+x7*w7If the resultant value is greater than a threshold (Typically 0), y=1; otherwise y=0.
I hope you understand something. But I know most of you are not satisfied because, you don't know what is really going on! Right?
Let me tell an example. This is a story. Here is you, Heroin is you.
Consider you have three friends and you(your brain) thinks that they are:
- Albert - Your best friend. You have a confidence level of 0.7 on him. You trust him and ask his opinion before every important attempt
- Deepika - Your classmate. Confidence level 0.3. Good personality.
- Tom(me) - Confidence level of -0.55. Always say lie. Cheating personality.
The problem starts here. You are getting ready to go to your office/college. There are two ways to go. One is short path (easy way). Other is long. But short way has a problem is that sometimes it will be blocked. If you take the long path, you may reach the destination late. But if you choose the short path and in any case if blocked, you can't reach the destination on that day.
Then you come to know that today short way will be blocked. Then you consult your friends. Check their opinion:
- Albert - Short road is not blocked. Damn sure.
- Deepika - Someone told me about it. Short way may not be blocked. But I am not sure.
- Tom - Hey man, road is blocked.
Let's look how your brain solve the problem. Albert surely says that road is not blocked. Put a value of +0.95 for his opinion. The positive sign indicates that he is opposing. If Albert says sure that road blocked, the value may be -0.95. You don't know much about Deepika. But she may be right. Put a value of +0.1. Tom says it is blocked. So put -0.8.
Here threshold value is 0. If weighted sum is greater than 0. road is blocked. It is good to choose the long way. I not, road is not blocked, choose the short path.
Weighted sum is:
signal strength of Albert * confidence level+ signal strength of Deepika * confidence level+ signal strength of Tom * confidence level
=0.95*0.7 + 0.1*o.3 + (-0.8)*(-0.55)
=0.66+0.03+0.44
=1.13 which is greater than 0.
The brain successfully derived a decision for you. It is almost sure that road blocked with a confidence level of 1.13. Did you notice the analysis of Mr.Tom's opinion. You think tom is cheat. So the opposite of what he tells will be right. If you didn't understand the meaning of previous sentence just read one more time because some interesting things hidden in that sentence.
Ok, let's continue our story. Then you started going straight away through short path. You started journey in your own car but Alas! road is blocked. You couldn't just believe your eyes. but suddenly you realize the fact that you can't reach your destination today - you trapped in a huge road block.
Here, your brain attempts to rewire the entire circuitry inside it. Your thoughts were entirely wrong. Both Albert and Deepika was wrong, but Tom was right. You change the congedence level as,
- Albert - 0.4 - I can't blive he cheated me.
- Deepika - 0.1 - no coments.
- Tom - 0.2 - oh, sorry Tom.
Tuesday, December 8, 2009
Go on with pyS60
I got a very good feedback from my previous post: "How to simulate PyS60 in your PC". As the request of opentechlab readers, I am attempting to write a brief beginner level tutorial on pyS60 emulator.
Once you are successful in installing and setting up the environment (If you didn't set up yet, click here), it is the time to go on.
Start the emulator program from:
Start->All programs -> S60 Developer tools -> 3rd edition FP2 SDK -> v1.1 -> Emulator
You probably need to wait for a couple of seconds to load it if your system is slow. Then a medium sized window with a full fledged mobile phone appears on the screen.
Now you need to open python. Just do as in your mobile phone. it's in Menu -> Installations -> python.
Now it's ready and do what you want.
Hacking python script
Select options -> Run script ->ball.py
You can move the ball anwhere in the screen. It's a physics simulation example in python. You can see the actual python script by opening ball.py file using any editor (notepad is not recommended. programmers notepad is good). The file is stored in :
C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\winscw\c\python
Search for the word 'blobsize'. Then you can find a line like:
blobsize = 16
Change the value of blobsize into 25 and save it. Then open ball.py in emulator. Did you notice any change? Similarly you can change acceleration, gravity (what about changing gravity into -0.01 ?) etc.
Developing your own programs
I am just starting with a hello world. Here is the program.
1)Simple hello world
print "Hello World!"
2)Say, hello world
from audio import*
say("Hello World!")
3)graphical hello world!
import appuifw
appuifw.note(u"Hello World!", "info")
It is good practice to make a short cut of python on the mobile desktop by changing options in settings.
Monday, December 7, 2009
How to simulate PyS60 in your PC
Download the required things:
1)Download S60_3rd_Edition_SDK_Feature_Pack_2_v1_1_en.zipfrom the following link:
http://www.forum.nokia.com/info/sw.nokia.com/id/807ec36d-0a8e-4bda-8e10-4d5e5bb4764a/S60_3rd_Edition_SDK_Feature_Pack_2_v1_1_en.zip.html
2)You can find ActivePerl 5.6.1 build 635 here:
First install ActivePerl because S60 SDK requires it.
Then install S60 SDK. Please note to install it in C:\ drive to avoid confusion.
Extract PythonForS60_1_4_5_SDK_3rdEdFP1.zip. Then you get another archived file sdk_files.zip.
Extract it again and you get a directory named 'epoc32'.
Copy this directory into "C:\S60\devices\S60_3rd_FP2_SDK_v1.1"
Then probably Windows XP asks to replace the already existing folder 'epoc32'. Click yes.
You have done. Cheers!
Sunday, December 6, 2009
Don't believe your eyes!
Don't believe your eyes, because everything you see, touch and feel is just a feeling only. Consider you are traveling in a space ship. No way to look outside. Space ship is traveling with higher velocity. If there is an obstacle present in front of the spaceship, sensors feel the presence of obstacle and it is reported on your computer. Then you turn the spaceship left or right. Then sensors feels that obstacle is removed (not obstacle, you!) and computer indicates that you can go straight way.
The above explained is a successful turning. But here I go in a something different way. The sensors are intelligent enough to send a fake signal that "there is some sort of obstacle" on the monitor. Actually, there is nothing in front of it. But your computer shows some obstacle. So you put a signal to turn right. Then the sensors shows that "now obstacle is removed. Go straight". You feel that you done well, but the sensor and the computer system really cheated you. Sometimes it was not a cheating, because ,there will be a possibility of thinking that there is an obstacle.
Our brain is not much different or error free in similar cases. If you are think that you know the universe, I think it is actually bad. Things you feeling from the surroundings may be different from reality. Your eyes are similar to the spaceship sensors. Not only your eyes, every sensors just see one phase of the reality. That really implies that knowing reality is too difficult.
I am not going too inside. I am not a philosopher. So let's have a fun. just go thruogh this link. A number of good eye illusions are included. Here I give a puzzle from eyetricks.com - Find which is longer?
Why there is so many constants in equations?
Consider you are a young scientist. You close your room's door and start experimenting on something when you get leisure time on Sundays. You are doing something seriously on your table, with an electrical circuit. Your aim is to find the dependence of a node voltage X (ie, a voltage in a part of the circuit). You came to know that X depend upon the supply voltage V. You start experimenting and plot graph of X for different values of V. Then you
got a graph like this:
It is perfectly linear. So you write,
X is directly proportional to V
To be more specific, X increases for an equivalent increase in V. You repeated your experiment and plot another characteristics with time. This time, your supply voltage kept constant. Plot X with time t.
From the plot, it easy to find that dependence is,
X is directly proportional to e^(-t)
Then from the above town experiments, you can write that,
X is directly proportional to V*e^(-t)
ie, X = K*V*e^(-t) where a K is the proportionality constant.
You can find K from single experiment. Once you got the value X when for a particular V and t,
K = X/(V*e^(-t)
But I want to tell you that your experiment as well as your mathematical expression is not perfectly true. A true dependence of X on it's environment will be very complex and tedious to express in mathematical form. Your X may depend on the atmospheric pressure, temperature, material properties,...raining in New Delhi,.....war on Iraq and so so.
After several years, you repeated your experiment and find that X depending on temperature also. Temperature has a direct linear relationship (like V) on X. But last time, you didn't got it. What's the reason? You were not aware of that, you did the experiment in room temperature itself. But this time you get different answers in day and chilled night. Now you modify your equation as,
X is directly proportional to V*T*e^(-t) where T is the temperature
X = L*V*T*e^(-t) where L is the proportionality constant.
Here I want a point to stress. Do you think your previous equation was wrong? Not at all. It is correct in an isothermal environment. But it become wrong in a temperature varying environment. A single measurement depending upon many things in the surroundings. But many of them can be ignored, because, they have less relationship with X. Something can't be ignored, but they may not be measurable (such as number of electron collision per second).In such cases, just put a constant for that, as long as they are constants. To be more clear, if your experiment depends upon the radius of earth, just put it as a constant in your equation. But when you do the experiment in moon, your experiment may troubled, unless you replaced the radius of earth with moon. I meant that variables can be considered as a constant or variable according to the environment.