Wednesday 25 July 2012

VB-6 Code for Input & Output function of 8 Channel GPIO USB Card

(A) Following is the circuit diagram of  8 channel GPIO USB card with Microchip PIC18F14K50 Controller. 

 

(B) Following is the wiring diagram of  8 channel GPIO USB card with 8 On/Off Switch connected as INPUT for testing input function of GPIO USB card.


(C) Following is the wiring diagram of  8 channel GPIO USB card with 8 LED connected as OUTPUT  for testing Output function of GPIO USB card.



(D) VB-6 Code for Input & Output function of 8 Channel GPIO USB Card download from follwing web Links.

INPUT CODE: - (A)

Dim line1 As String, line2 As String

Private Sub Command1_Click()
MSComm1.CommPort = 6
MSComm1.Settings = "9600,N,8,1"
MSComm1.InputLen = 0
'*****************************************
MSComm1.PortOpen = True
Text1.Text = "gpio read "
X = Text1.Text
Y = Text2.Text
Label5.Caption = (X + Y & Chr$(13))
'
MSComm1.Output = Label5.Caption
'
'Print Label1.Caption & vbCrLf  'Chr$(13)
'
Do
DoEvents
Buffer = MSComm1.Input
Loop Until InStr(Buffer, “10”)
'
'Loop Until InStr(Buffer, “”) '& Chr$(13))
'Loop Until InStr(Buffer, “” & vbCrLf)
Label1.Caption = Buffer                                 'This is the INPUT Value on Lavel1
P = (line1 + line2)
P = Label1.Caption
MSComm1.PortOpen = False
Q = Label1.Caption
Open "C:\AEP\AR.txt" For Output As #1       'Save Buffer in the file AR .TXT
Write #1, Q
Close #1
End Sub
'*****************************************
Private Sub Command2_Click()
End
End Sub

Private Sub Command3_Click()
Call Command1_Click
Open "C:\AEP\AR.txt" For Input As #1
Input #1, Q
Close #1
Label10.Caption = Q
End Sub

Private Sub Command4_Click()
MsgBox ("Adeeb" & vbCrLf & "Raza")           ' Checking Function of  vbCrLf
End Sub

Private Sub Timer1_Timer()
'Call Command1_Click
End Sub

Screen Shot of INPUT TESTING OF 8 Channel GPIO USB Card


*************************   TESTED FINAL  ********************************
INPUT CODE: - (B)

Dim X, P

Private Sub Form_Load()
P = 1
Timer1.Enabled = False
MSComm1.CommPort = P                 'Text3.Text Com Port Number
MSComm1.Settings = "9600,N,8,1"      '9600 baud, no parity, 8 data, and 1 stop bit.
MSComm1.InputLen = 0                 'Tell the control to read entire buffer when Input is used.
MSComm1.PortOpen = True              'Open the port.
End Sub
Private Sub Command1_Click()
Line1 = "gpio read "
Line2 = Text2.Text
Line3 = Chr$(13)
MSComm1.Output = Line1 + Line2 + Line3  'Text1.Text & Chr$(13) + A
Buffer = MSComm1.Input
'http://www.vb6.us/tutorials/vb6-string-functions
'************************************************
strSubstr = Mid$(Buffer, 14, 1)     'strSubstr = In Buffer 14 Positision one data Switch ON=1 OFF=0
Label1.Caption = strSubstr            'strSubstr = Input Switch ON=1 OFF=0
X = Buffer
Text1.Text = X
'************************************************
If Label1.Caption = "0" Then Label2.Caption = "OFF"
If Label1.Caption = "1" Then Label2.Caption = "ON"
End Sub

Private Sub Command2_Click()
Timer1.Enabled = True
End Sub

Private Sub Command3_Click()
MSComm1.PortOpen = False
End
End Sub

Private Sub Command4_Click()
Timer1.Enabled = False
End Sub

Private Sub Command5_Click()
P = Text3.Text
MSComm1.PortOpen = False
MSComm1.CommPort = P                   'Text3.Text Com Port Number
MSComm1.Settings = "9600,N,8,1"      '9600 baud, no parity, 8 data, and 1 stop bit.
MSComm1.InputLen = 0                      'Tell the control to read entire buffer when Input is used.
MSComm1.PortOpen = True                'Open the pot.
End Sub

Private Sub Timer1_Timer()
Call Command1_Click
End Sub

Screen Shot of INPUT TESTING OF 8 Channel GPIO USB Card
Thanks
Adeeb Raza


Sunday 17 June 2012

PC's Pareller Port Input & Out Put VB6 code

Following is the visual basic 6 program code for PC's LPT-1 Port for device controlling.
START MODULE
'//*******************************************************************************
'// LPT-Port.bas (Module)
'// (Learn how to access PC's LPT-1 Port through Visual Basic)
'// Microsoft Visual Basic Ver.6 with Windows XP as OS
'// This program required Driver file "inpout32.dll"
'//-------------------------------------------------------------------------------
'// Learn how to access PS's LPT Port through VB6 with an interface unit)
'// connected at PC's LPT-1 Port
'// Project By Mr Adeeb Raza
'// Allahabad (U.P) INDIA
'// Dated 1st March 2005
'// Email: adeebraza@hotmail.com or adeebraza@areptone.com
'//********************************************************************************
''
'' This has written in Module LPT-Port.bas
''
'' ********************************************************************************
''
'// INPUT
'//******
Public Declare Function Inp Lib "inpout32.dll" Alias "Inp32" _
(ByVal address As Integer) _
As Integer
'
'// OUTPUT
'//*******
Public Declare Sub Out Lib "inpout32.dll" Alias "Out32" _
(ByVal address As Integer, _
ByVal Value As Integer)
******************************* End Module **************************************

START
'//*******************************************************************************
'// LPT-Port.vbp (Learn how to access PC's LPT-1 Port through Visual Basic)
'// Microsoft Visual Basic Ver.6 with Windows XP as OS
'// This program required Driver file "inpout32.dll"
'//-------------------------------------------------------------------------------
'// Learn how to access PS's LPT Port through VB6 with an interface unit)
'// connected at PC's LPT-1 Port
'// Project By Mr Adeeb Raza
'// Allahabad (U.P) INDIA
'// Dated 1st March 2005
'// Email: adeebraza@hotmail.com or adeebraza@areptone.com
'//********************************************************************************
''
'' This has written in LPT-Port.VBP with Module LPT-Port.bas
''
'' ********************************************************************************
Option Explicit
Dim AEPPort As Integer
Dim AEPData As Integer
Dim pat, data, portinput, code
'
Sub AEPOut(data As Integer)
Out AEPPort, AEPData
End Sub
Private Sub Command1_Click()
pat = Text1.Text
If pat >= 1 Then GoTo X Else GoTo Y
X:
AEPPort = &H378                  'Input port = Base H378 as (Data Bus)
AEPData = Val(pat)
AEPOut (data)
Label20.Caption = AEPData
Shape1.Visible = True
Shape2.Visible = False
Y:
End Sub
Private Sub Command2_Click()
pat = 0
AEPPort = &H378
AEPData = Val(pat)
AEPOut (data)
Label20.Caption = AEPData
Shape1.Visible = False
Shape2.Visible = True
End Sub
Private Sub Command3_Click()
Unload Form1
Load Form2
Form2.Show
End Sub
Private Sub Command4_Click()
pat = 0
AEPPort = &H378
AEPData = Val(pat)
AEPOut (data)
Label20.Caption = AEPData
End
End Sub
Private Sub Form_Load()
End Sub
Private Sub Timer1_Timer()
AEPPort = &H379                    'Input port = Base+1  as (Status Bus)
Label21.Caption = Inp(AEPPort)
portinput = Label21.Caption
code = portinput - 7               'CODE (Input value - 7) (Status Bus)
Label26.Caption = code
End Sub
********************************** End  **********************************
Screebn Shot of Above Program download http://www.areptone.com/vb6/arlptefy.zip

Thanks
Adeeb Raza