Principe
Page d'accueil Remonter Principe Composants Utilisation

 

Email

Principle:

 

 

optique1.gif (1930 octets)

 

This optical pencil bases itself on a phototransistor which is like a switch. The collector's current' value is linked to the number of photons which reach the phototransistor.

The joystick port of the PC have 2 analogics inputs and numerics inputs.

Also we will connect the phototransistor, linked to a resistance, to an analogic input and the switch P to a numeric input, which will tell us if we must use the value of the analogic input linked to the phototransistor.

 

The Joystick port of your PC :

 

optique2.gif (4332 octets)

 

The joystick port of the PC uses one 8 bits register. In this register we can find 4 bits used to manage the 4 numerics input and 4 others uses to manage the 4 analogics input.

4 Bits for 4 analogics inputs ? Somebody can think that there is a mistake. But there isn't. In fact the analogic reading of a analogic input is based on the time during which the bit stay at 1. (The PC uses a condensator ).

How can I read the analogics and numerics inputs 's value of the joystick port?

- To read the value of the analogics inputs you must ask for a new comparison on the inputs (you must ask the PC to unload the condesnators). An operation of writening is made at the Joystick port adress: 201h. After an waiting loop is made in order to obtain a numeric value which is proportionnal to the time. Endly i must say that the analogics inputs are linked to the bits 0 - 3 of the joystick port.

For the programmation go and see the programming/c c++/electronic heading.

- To read the numerics input you just have to read the correct bits on the joystick port (the port 201 h). The numerics inputs are linked to the bits 4 - 7 of the joystick port.

For the programmation go and see the programming/c c++/electronic heading.




@