............Areptone Electronic Products ..

..................

  .............Technical Article By Mr. Adeeb Raza

..........PC Hardware Interface through LPT-1

Many circuits and ideas has been published in this magazine for DOS based PC hardware interfacing through LPT port but the following article is different from them because this is a Windows based program developed in Programming Language Visual Basic 6 & program name is ARPORT.EXE

This is a simple introduction to programming the parallel port in Visual Basic, before we go any further, we must figure out a way around some limitations built into Visual Basic. VB can not directly access the hardware on a system. All hardware requests must go through Windows. Because of this, the closest we can get to manipulate the parallel port is wit the Printer object. While this is all fine and good when you want to actually print something, it is useless when we want direct hardware control. In order to control the port directly, we must use something external to our program. A DLL is defined as “Dynamic Link Library”. Use WIN95IO.DLL for VB4 32bit, VB5 or VB6. No matter which one you choose the DLL file itself must be in the Windows\system directory in any machine the interface control software is to be used or developed on. Please note that no matter which DLL you use, this won't work under Windows NT (due to security).

           

The parallel port is composed of 4 control lines, 5 status lines and 8 data lines. It's found commonly on the back of PC as a D-Type 25 Pin female connector. There are 8 data lines, D0 to D7 and they are the primary means of getting information out of the port. In simple projects, you will be concentrating mostly on the data lines. The control lines are another 4 outputs. They are meant to provide control signals to the printer (such as form feed or initialize). The status lines are a standard parallel port's only inputs. There are 5 of them. They were meant to allow the printer to communicate things such as error, paper out and busy to the PC. The Parallel Port is the most commonly used port for interfacing home made projects. This port will allow the input of up to 9 bits or the output of 12 bits at any one given time, thus requiring minimal external circuitry to implement many simpler tasks. Newer Parallel Port’s are standardized under the IEEE 1284 standard first released in 1994.

Here we are concern only Data lines that is D0, D1, D2, D3, D4, D5, D6, D7, LPT-1 Printer Port 25 pin D-Type Female connector Pin no. 2 to 9 respectively and Pin no 18 to 25 are Gnd. Now Connect 8 LED’s LED1 to LED 8 between Pin 2 & Gnd, Pin 3 & Gnd, Pin 4 & Gnd Pin 5 & Gnd, Pin 6 & Gnd, Pin 7 & Gnd, Pin 8 & Gnd, Pin 9 & Gnd respectively as given in Circuit Diagram Fig 1. All these 8 LED’s can be On and Off through Software as per the Data Input. One can used Fig 2 IC-4N35 or MCT2E in place of LED’s to connect Electro Magnetic Relay for isolation between PC and Equipment for Operating Mains gadget. Circuit is self explanatory PROGRAMMING CODE for ARPORT.EXE is given below.

25 Pin D-Type Printer Port Details

Pin No.            Description               

1.                                          Strobe      (-) Output

2.                                          Data 0 Output

3.                                          Data 1 Output

4.                                          Data 2 Output

5.                                          Data 3 Output

6.                                          Data 4 Output

7.                                          Data 5 Output

8.                                          Data 6 Output

9.                                          Data 7 Output

10.                                      ACK        (-) Input

11.                                      Busy Input

12.                                      Paper Empty Input

13.                                      Select Input                                             

14.                                      Autofeed     (-) Output                                          

15.                                      Error           (-) Output                                          

16.                                      Initialize Printer Output                                          

17.                                      Select Input (-) Output                                          

18.                                      Gnd

19.                                      Gng

20.                                      Gnd

21.                                      Gnd

22.                                      Gnd

23.                                      Gnd

24.                                      Gnd

25.                                      Gnd

It is assumed that Microsoft Visual Basic 6 installed on your PC and you are aware of basic programming knowledge.

Start Program from Here

Private Declare Sub vbOut Lib "WIN95IO.DLL" (ByVal AEPPort As Integer, ByVal AEPData as Integer)

Dim AEPPort As Integer

Dim AEPData As Integer

Sub AEPOut(Data As Integer)

vbOut AEPPort, AEPData

End Sub

Private Sub Form_Load()

Shape1.Visible = False

pat = 0

End Sub

Private Sub Command1_Click()

AEPPort = &H378

pat = Text1.Text

AEPData = Val(pat)

AEPOut (Data)

If pat = "" Then GoTo y Else GoTo x

x:

Shape1.Visible = True

Shape2.Visible = False

y:

End Sub

Private Sub Command2_Click()

AEPPort = &H378

pat = 0

AEPData = Val(pat)

AEPOut (Data)

Shape1.Visible = False

Shape2.Visible = True

End Sub

Private Sub Command3_Click()

AEPPort = &H378

pat = 0

AEPData = Val(pat)

AEPOut (Data)

End 

End Sub

                                                       

End of program