computer interfacing tutorial-printer, serial, game, usb port
 

 

3.2. Basic Swicht Input Detection Port Status-Parallel Port

Refer to the circuit as shown in figure bellow - Printer Port Test Circuitry. This illustrates a very simple test fixture to allow you to figure out what inversions are taking place in the hardware associated with the printer port.

3.2.1. Basic Input - 5 Bits Port Input

Program exp321.pas detects wether the swicht is opened or closed, as shown in test circuit above, for opens condition port receives logic '1', by pulling up with resistor 10k to Vcc ( +5V ), for swicht close condition port will receive logic '0', by connecting to ground.

Delphi Programming ( Download File exp321.zip )

a. Puts 1 Timers Components, 1 Edit Components and label on Form, as shown in picture bellow. Setting up Timer1 component for Enabled = true, and Interval = 1000 ( approximataly = 1000 ms delay time ).

           

b.Click on start, stop button, amd timer to insert with the program as shown bellow

procedure TInput.Timer1Timer(Sender: TObject);
var data:byte;
begin
asm
mov dx,$379 {saving port status to Register DX }
in al,dx {get the data form port status }
mov data,al {saving data Reg AL to external variable data }
and data,11111000b {bit masking D0, D1, and D2 }
xor data,10000000b {invert for bit 7 }
end;
edit1.text:=inttostr(data);{display data on Edit1 component } end;


c. To run the program, you can hits F9 or RUN menu, and then you will show a picture as shown bellow, and try to simulate the program by clicking on Start and Stop Button and see what happen on your display .

PREVIOUS NEXT

 

Free Software
Delphi

Lesson 1
Delphi Programming
1.1. IDE Delphi
1.2. Component


Lesson 2
Printer Port
/ LPT
1.1.Basic
1.2.Address
1.3.Port Register
1.4.8 Bit Data Input
1.5.Test Circuitry
1.6.Assignment

Lesson 3
Printer Port / LPT
Experiments

3.1.LED
3.2.Swicht
3.3.Motor Stepper
3.4.DAC
3.5.ADC
3.6.Graph Display

Lesson 4
Serial Port

4.1.Basic
4.2.Hardware
4.3.Port Register

Lesson 5
Serial Port Experiments

5.1.LED
5.2.Stepper Motor
5.3.Swicht
5.4.ADC

Lesson 6
Game Port
Joy Stick
6.1. Basic
6.2. Experiments