Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Inputting data in vb6 using parallel port

Status
Not open for further replies.

rayearth92188

Newbie level 3
Joined
Feb 7, 2010
Messages
4
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,310
Hello Guys!

I am currently doing a project which deals with accessing my parallel port through visual basic 6. Currently, I can send data from my pc to the external devices that I have but I can not receive any data from my external devices to my pc. I've tried all possible solutions to my problem. I even tried placing a .dll library. I am currently using windows xp. Any help is appreciated. :D

Thank you for taking time in helping me. :D
 

Hii,

I don't whether you have check it or not, parallel is divided into 3 :
1. Standar parallel port
2. Enhanced parallel port (EPP)

Check your BIOS setting for this, EPP has capability for read and write, But standart Parallel port just write ( can' read).

**broken link removed**

And I if you are using VB 6 in Windows XP, I bet you need DLL for this. Check this link

**broken link removed**

Download dll at this site.
 
the_balistic,

Thank you for your reply. And it was very helpful to my project. The url that you gave me finally gave me the right answers. Thank you so much! :D
 

HI Mr. rayearth92188:

i currently also doing the project accessing the parallel port through visual basic, and i also need to send data to my hardware. I heard about u got to send data from pc to the external devices. Can u share me your work to me? because i cant fix the problem to send data to my hardware. it is URGENT
a million thanks to you
 

Did you try setting the "Enable Bi-Directional Port" bit in control register ? when you set this bit the data register will go to input mode and read 0xFF when nothing is connected to the port. This is because on most machines the data bit lines have pull ups which will pull the lines high. Your hardware should be able to pull the lines low when needed.

Find some parallel port interfacing resources at **broken link removed**
 
TO Mr cvhow1127,

May i just know what version of visual basic you are currently using. And sorry for the late reply. I'll just post here the script that i had made. But you need some libraries for you to access the parallel port

Added after 1 minutes:

To everyone:

Thank you for all your replies it really helped me a lot in doing my thesis. :D

Added after 4 minutes:

TO Mr cvhow1127,
here's my source code of the program that I did, I hope that I could help you in your problem

[mod:3314d80487="bassa"]All (program codes) coding should be include "code display tag"[/mod:3314d80487]
Code:
Option Explicit 'declaration of variables
Dim TempTV As Double, HumidityTV As Double, LightTV As String, smtv As String
Dim Ta As Double, Ha As Double, Tb As Double, Hb As Double, row As Integer
Dim Displaytemp As Double, Displayhumidity As Double, Displaylight As String
Dim DisplaySM As String, Ct As Double, Ht As Double, LightT As Double, SMT As Double
Dim Dt As Double, Dh As Double, savec As Integer, dis As Double
Dim counter As Integer, clock As Integer, io As Integer, Tempout As Integer
Dim Hout As Integer, Lightout As String, SMout As Integer, outc As Integer
Public konek As ADODB.Connection
Public datars As ADODB.Recordset
Dim adding As Boolean, addc As Boolean, Tempo As Double, Ho As Double
Dim Lo As Integer, SMo As Double, Hvin As Double, hrest As Double, lightc As Double
Dim ldis As Double, lup As Double, have As Double, smt2 As Double, smin As Double
Dim smin2 As Double, smave As Double, outt As String, outp As Double, hdev As String, htext
As String, hcs As Double
Dim smdev As Double, smtv1 As Double, smtext As String, smcs As Double, initial As Integer,
clear As Integer, cleardata As Integer
Dim clearp As Integer, cleard As Integer, clear2 As Integer, prev As Integer, prev2 As Integer
Private Sub Command1_Click()
If Profile.Text = "" Then
MsgBox "Select a profile before data acquisition starts.", _
vbExclAMation, _
"Error"
195
ElseIf Profile.Text = "Custom" And Text1.Text = "" Or Text4.Text = "" Or LightS.Text = ""
Or SMS.Text = "" Then
MsgBox "Enter the necessary values.", _
vbExclAMation, _
"Error"
ElseIf Text2.Text = "" Or Text5.Text = "" Or Text7.Text = "" Or Text9.Text = "" Then
MsgBox "You need to update in order to compare the necessary values.", _
vbExclAMation, _
"Error"
Else
Timer2.Enabled = True
Timer4.Enabled = False
Timer5.Enabled = True
End If
End Sub
Private Sub Command2_Click()
Timer2.Enabled = True
Timer3.Enabled = False
Timer5.Enabled = False
End Sub
Private Sub Form_Load()
Ta = 26
Ha = 70
Tb = 32
Hb = 50
counter = 0
savec = 0
io = 0
outc = 0
initial = 0
Call openserver
196
Set datars = New ADODB.Recordset
datars.Open "Select * from data order by Adate", konek, adOpenStatic, adLockOptimistic
Label1.Caption = Date
Label2.Caption = Time
Profile.AddItem "Koppen A"
Profile.AddItem "Koppen B"
Profile.AddItem "Custom"
LightS.AddItem "No Light"
LightS.AddItem "Dark"
LightS.AddItem "Dim"
LightS.AddItem "Bright"
LightS.AddItem "Brighter"
LightS.AddItem "Brightest"
SMS.AddItem "Dry"
SMS.AddItem "DAMp"
SMS.AddItem "Wet"
Text2.Enabled = False
Text3.Enabled = False
Text5.Enabled = False
Text6.Enabled = False
Text7.Enabled = False
Text8.Enabled = False
Text9.Enabled = False
Text10.Enabled = False
Text11.Enabled = False
Text12.Enabled = False
Text13.Enabled = False
Text14.Enabled = False
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
197
Case vbKeyEscape
End
End Select
End Sub
Public Sub openserver()
Set konek = New ADODB.Connection
konek.CursorLocation = adUseClient
konek.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & App.Path &
"\Database.mdb"
End Sub
Private Sub Profile_click()
Select Case Profile.Text 'selection of profiles
Case "Koppen A"
Text1.Text = Ta
Text4.Text = Ha
LightS.Text = "Bright"
SMS.Text = "Wet"
Text1.Enabled = False
Text4.Enabled = False
LightS.Enabled = False
SMS.Enabled = False
Case "Koppen B"
Text1.Text = Tb
Text4.Text = Hb
LightS.Text = "Brightest"
SMS.Text = "Dry"
Text1.Enabled = False
Text4.Enabled = False
LightS.Enabled = False
SMS.Enabled = False
198
Case Else
Text1.Text = ""
Text4.Text = ""
LightS.Text = ""
SMS.Text = ""
Text1.Enabled = True
Text4.Enabled = True
LightS.Enabled = True
SMS.Enabled = True
End Select
End Sub
Private Sub Saveb_Click()
If adding = True Then
datars.AddNew
saveondisk
datars.Update
Else
saveondisk
End If
End Sub
Private Sub saveondisk()
datars.AddNew
datars!Adate = Label1.Caption
datars!atime = Label2.Caption
datars!Profile = Profile.Text
datars!Tempsetting = Text1.Text
datars!Hsetting = Text4.Text
datars!Lightsetting = LightS.Text
datars!Smsetting = SMS.Text
datars!TempTV = Text2.Text
datars!Htv = Text5.Text
199
datars!LightTV = Text7.Text
datars!smtv = Text9.Text
datars!Tempc = Text3.Text
datars!Hc = Text6.Text
datars!lightc = Text8.Text
datars!Smc = Text10.Text
datars!Tempstat = Text11.Text
datars!Hstat = Text12.Text
datars!Lightstat = Text13.Text
datars!Smstat = Text14.Text
End Sub
Private Sub Timer2_Timer()
counter = counter + 1
Select Case counter
Case 1
Out 890, 43
Ct = Inp(888)
Call calib_temp
Text3.Text = Displaytemp
Case 2
Out 890, 44
Ht = Inp(888)
If 0 <= Ht And Ht <= 127 Then
Hvin = 5 - (Ht * 5 / 128)
ElseIf 128 <= Ht And Ht <= 255 Then
Hvin = (Ht * 5 / 127) - 5
End If
Call calib_rh
Text6.Text = Displayhumidity
Case 4
200
Out 890, 45
LightT = Inp(888)
Call calib_light
Text8.Text = Displaylight
Case 6
Out 890, 47
SMT = Inp(888)
If 0 <= SMT And SMT <= 127 Then
smin = 5 - (SMT * 4.6 / 128)
ElseIf 127 < SMT And SMT <= 255 Then
smin = (SMT * 5 / 127) - 5
End If
Case 8
Out 890, 46
smt2 = Inp(888)
If 0 <= smt2 And smt2 <= 127 Then
smin2 = 5 - (smt2 * 4.6 / 128)
ElseIf 127 < smt2 And smt2 <= 255 Then
smin2 = smt2 * 5 / 127 - 5
End If
Call calib_SM
Text10.Text = DisplaySM
Case 10
Timer2.Enabled = False
Timer4.Enabled = True
End Select
If counter = 10 Then counter = 0
End Sub
Private Sub calib_temp()
Displaytemp = Ct * 20 / 51
End Sub
201
Private Sub calib_rh()
'hrest = 0
hrest = 10000 * (5 - Hvin) / (Hvin * 1000)
If 0 < Displaytemp And Displaytemp <= 10 And 5000 < hrest And hrest <= 20000 Then
Displayhumidity = 20
ElseIf 0 < Displaytemp And Displaytemp <= 10 And 3500 < hrest And hrest <= 5000 Then
Displayhumidity = 30
ElseIf 0 < Displaytemp And Displaytemp <= 10 And 400 < hrest And hrest <= 3500 Then
Displayhumidity = 40
ElseIf 0 < Displaytemp And Displaytemp <= 10 And 200 < hrest And hrest <= 400 Then
Displayhumidity = 50
ElseIf 0 < Displaytemp And Displaytemp <= 10 And 50 < hrest And hrest <= 200 Then
Displayhumidity = 60
ElseIf 0 < Displaytemp And Displaytemp <= 10 And 20 < hrest And hrest <= 50 Then
Displayhumidity = 70
ElseIf 0 < Displaytemp And Displaytemp <= 10 And 8 < hrest And hrest <= 20 Then
Displayhumidity = 80
ElseIf 0 < Displaytemp And Displaytemp <= 10 And 0 < hrest And hrest <= 8 Then
Displayhumidity = 90
ElseIf 10 < Displaytemp And Displaytemp <= 20 And 3500 < hrest And hrest <= 20000 Then
Displayhumidity = 20
ElseIf 10 < Displaytemp And Displaytemp <= 20 And 750 < hrest And hrest <= 3500 Then
Displayhumidity = 30
ElseIf 10 < Displaytemp And Displaytemp <= 20 And 250 < hrest And hrest <= 750 Then
Displayhumidity = 40
ElseIf 10 < Displaytemp And Displaytemp <= 20 And 100 < hrest And hrest <= 250 Then
Displayhumidity = 50
ElseIf 10 < Displaytemp And Displaytemp <= 20 And 25 < hrest And hrest <= 100 Then
Displayhumidity = 60
ElseIf 10 < Displaytemp And Displaytemp <= 20 And 12 < hrest And hrest <= 25 Then
Displayhumidity = 70
202
ElseIf 10 < Displaytemp And Displaytemp <= 20 And 7 < hrest And hrest <= 12 Then
Displayhumidity = 80
ElseIf 10 < Displaytemp And Displaytemp <= 20 And 0 < hrest And hrest <= 7 Then
Displayhumidity = 90
ElseIf 20 < Displaytemp And Displaytemp <= 30 And 2500 < hrest And hrest <= 20000 Then
Displayhumidity = 20
ElseIf 20 < Displaytemp And Displaytemp <= 30 And 500 < hrest And hrest <= 2500 Then
Displayhumidity = 30
ElseIf 20 < Displaytemp And Displaytemp <= 30 And 150 < hrest And hrest <= 500 Then
Displayhumidity = 40
ElseIf 20 < Displaytemp And Displaytemp <= 30 And 50 < hrest And hrest <= 150 Then
Displayhumidity = 50
ElseIf 20 < Displaytemp And Displaytemp <= 30 And 15 < hrest And hrest <= 50 Then
Displayhumidity = 60
ElseIf 20 < Displaytemp And Displaytemp <= 30 And 8 < hrest And hrest <= 15 Then
Displayhumidity = 70
ElseIf 20 < Displaytemp And Displaytemp <= 30 And 3 < hrest And hrest <= 8 Then
Displayhumidity = 80
ElseIf 20 < Displaytemp And Displaytemp <= 30 And 0 < hrest And hrest <= 3 Then
Displayhumidity = 90
ElseIf 30 < Displaytemp And Displaytemp <= 40 And 1500 < hrest And hrest <= 20000 Then
Displayhumidity = 20
ElseIf 30 < Displaytemp And Displaytemp <= 40 And 250 < hrest And hrest <= 1500 Then
Displayhumidity = 30
ElseIf 30 < Displaytemp And Displaytemp <= 40 And 75 < hrest And hrest <= 250 Then
Displayhumidity = 40
ElseIf 30 < Displaytemp And Displaytemp <= 40 And 30 < hrest And hrest <= 75 Then
Displayhumidity = 50
ElseIf 30 < Displaytemp And Displaytemp <= 40 And 13 < hrest And hrest <= 30 Then
Displayhumidity = 60
ElseIf 30 < Displaytemp And Displaytemp <= 40 And 5 < hrest And hrest <= 13 Then
203
Displayhumidity = 70
ElseIf 30 < Displaytemp And Displaytemp < 40 And 2 < hrest And hrest <= 5 Then
Displayhumidity = 80
ElseIf 30 < Displaytemp And Displaytemp <= 40 And 0 < hrest And hrest <= 2 Then
Displayhumidity = 90
ElseIf 40 < Displaytemp And Displaytemp <= 50 And 1500 < hrest And hrest <= 20000 Then
Displayhumidity = 20
ElseIf 40 < Displaytemp And Displaytemp <= 50 And 200 <= hrest And hrest <= 1500 Then
Displayhumidity = 30
ElseIf 40 < Displaytemp And Displaytemp <= 50 And 70 < hrest And hrest <= 200 Then
Displayhumidity = 40
ElseIf 40 < Displaytemp And Displaytemp <= 50 And 25 < hrest And hrest <= 70 Then
Displayhumidity = 50
ElseIf 40 < Displaytemp And Displaytemp <= 50 And 8 < hrest And hrest <= 25 Then
Displayhumidity = 60
ElseIf 40 < Displaytemp And Displaytemp <= 50 And 4 < hrest And hrest <= 8 Then
Displayhumidity = 70
ElseIf 40 < Displaytemp And Displaytemp <= 50 And 2 < hrest And hrest <= 4 Then
Displayhumidity = 80
ElseIf 40 < Displaytemp And Displaytemp <= 50 And 0 < hrest And hrest <= 2 Then
Displayhumidity = 90
ElseIf 50 < Displaytemp And Displaytemp <= 60 And 500 < hrest And hrest <= 20000 Then
Displayhumidity = 20
ElseIf 50 < Displaytemp And Displaytemp <= 60 And 150 < hrest And hrest <= 500 Then
Displayhumidity = 30
ElseIf 50 < Displaytemp And Displaytemp <= 60 And 50 < hrest And hrest <= 150 Then
Displayhumidity = 40
ElseIf 50 < Displaytemp And Displaytemp <= 60 And 20 < hrest And hrest <= 50 Then
Displayhumidity = 50
ElseIf 50 < Displaytemp And Displaytemp <= 60 And 7 < hrest And hrest <= 20 Then
Displayhumidity = 60
204
ElseIf 50 < Displaytemp And Displaytemp <= 60 And 3 < hrest And hrest <= 7 Then
Displayhumidity = 70
ElseIf 50 < Displaytemp And Displaytemp <= 60 And 1 < hrest And hrest <= 3 Then
Displayhumidity = 80
ElseIf 50 < Displaytemp And Displaytemp <= 60 And 0 < hrest And hrest <= 1 Then
Displayhumidity = 90
End If
End Sub
Private Sub calib_light()
If 0 <= LightT And LightT <= 43 Then
Displaylight = "No Light"
ElseIf 43 < LightT And LightT <= 85 Then
Displaylight = "Dark"
ElseIf 85 < LightT And LightT <= 128 Then
Displaylight = "Dim"
ElseIf 128 < LightT And LightT <= 171 Then
Displaylight = "Bright"
ElseIf 171 < LightT And LightT <= 214 Then
Displaylight = "Brighter"
ElseIf 214 < LightT And LightT <= 255 Then
Displaylight = "Brightest"
End If
End Sub
Private Sub calib_SM()
smave = (smin + smin2) / 2
If smave < 1 Then
DisplaySM = "Dry"
ElseIf 1 <= smave And smave <= 1.48 Then
DisplaySM = "DAMp"
ElseIf 1.48 < smave Then
DisplaySM = "Wet"
205
End If
End Sub
Private Sub Timer3_Timer()
initial = initial + 1
Select Case initial
Case 1
Out 890, 0
Out 888, 0
Case 2
Out 890, 1
Out 888, 0
Case 3
Out 890, 2
Out 888, 0
Case 4
Out 890, 6
Out 888, 0
Case 5
Out 890, 8
Out 888, 0
Case 6
Out 890, 7
Case 7
Out 890, 9
Out 888, 0
Case 8
Out 890, 10
Out 888, 0
End Select
If initial = 8 Then initial = 0
206
Timer3.Enabled = False
Timer2.Enabled = True
End Sub
Private Sub Timer4_Timer()
outc = outc + 1
Select Case outc
Case 1
Call comp_l
Text13.Text = Lightout
Out 890, 10
Out 888, Lo
Case 2
Call comp_rh
Out 890, clear
Out 888, cleardata
Case 4
Out 890, hcs
Out 888, Hout
Text12.Text = htext
Case 6
Call comp_sm
Case 8
Call comp_temp
Case 10
Text11.Text = outt
Case 12
Timer2.Enabled = True
Timer4.Enabled = False
207
End Select
If outc = 12 Then outc = 0
End Sub
Private Sub comp_temp()
Tempout = TempTV - Displaytemp
prev = outp
If -2 <= Tempout And Tempout <= 2 Then
outt = "Idle"
ElseIf 2 < Tempout And Tempout <= 4 Then
outt = "Heater 1"
ElseIf 4 < Tempout And Tempout <= 8 Then
outt = "Heater 2"
ElseIf 8 < Tempout Then
outt = "Heater 3"
ElseIf -4 <= Tempout And Tempout < -2 Then
outt = "Cooler 1"
ElseIf -8 <= Tempout And Tempout < -4 Then
outt = "Cooler 2"
ElseIf Tempout < -8 Then
outt = "Cooler 3"
End If
Select Case outt
Case "Idle"
outp = 2
Tempo = 0
Case "Heater 1"
outp = 1
Tempo = 128
Case "Heater 2"
outp = 1
Tempo = 192
208
Case "Heater 3"
outp = 1
Tempo = 255
Case "Cooler 1"
outp = 0
Tempo = 128
Case "Cooler 2"
outp = 0
Tempo = 192
Case "Cooler 3"
outp = 0
Tempo = 255
End Select
If prev = 1 And outp = 0 Then
Out 890, 2
Out 890, outp
Out 888, Tempo
ElseIf prev = 0 And outp = 1 Then
Out 890, 2
Out 890, outp
Out 888, Tempo
ElseIf prev = 0 And outp = 0 Then
Out 890, 2
Out 890, outp
Out 888, Tempo
ElseIf prev = 1 And outp = 1 Then
Out 890, 2
Out 890, outp
Out 888, Tempo
End If
End Sub
209
Private Sub comp_rh()
Dh = HumidityTV - Displayhumidity
If Dh = 0 Then
htext = "Idle"
ElseIf 2 < Dh And Dh <= 10 Then
htext = "Humidifier 1"
ElseIf 10 < Dh And Dh <= 20 Then
htext = "Humidifier 2"
ElseIf 30 < Dh Then
htext = "Humidifier 3"
ElseIf -20 < Dh And Dh <= -10 Then
htext = "Dehumidifier 1"
ElseIf -40 < Dh And Dh <= -20 Then
htext = "Dehumidifier 2"
ElseIf Dh < -40 Then
htext = "Dehumidifier 3"
End If
Select Case htext
Case "Idle"
hcs = 9
Hout = 0
Case "Dehumidifier 1"
clear = 9
cleardata = 0
hcs = 9
Hout = 128
Case "Dehumidifier 2"
clear = 8
cleardata = 0
hcs = 9
Hout = 192
210
Case "Dehumidifier 3"
clear = 8
cleardata = 0
hcs = 9
Hout = 255
Case "Humidifier 1"
clear = 9
cleardata = 0
hcs = 8
Hout = 128
Case "Humidifier 2"
clear = 9
cleardata = 0
hcs = 8
Hout = 192
Case "Humidifier 3"
clear = 9
cleardata = 0
hcs = 8
Hout = 255
End Select
End Sub
Private Sub comp_l()
Select Case LightTV
Case "No light"
lup = 22
Case "Dark"
lup = 64
Case "Dim"
lup = 107
Case "Bright"
211
lup = 150
Case "Brighter"
lup = 193
Case "Brightest"
lup = 235
End Select
Select Case Displaylight
Case "No Light"
lightc = 22
Case "Dark"
lightc = 64
Case "Dim"
lightc = 107
Case "Bright"
lightc = 150
Case "Brighter"
lightc = 193
Case "Brightest"
lightc = 235
End Select
ldis = lup - lightc
If ldis <= 0 Then
Lightout = "Idle"
ElseIf 0 < ldis And ldis <= 42 Then
Lightout = "Level 1"
ElseIf 42 < ldis And ldis <= 85 Then
Lightout = "Level 2"
ElseIf 85 < ldis Then
Lightout = "Level 3"
End If
Select Case Lightout
212
Case "Idle"
Lo = 0
Case "Level 1"
Lo = 154
Case "Level 2"
Lo = 185
Case "Level 3"
Lo = 216
End Select
End Sub
Private Sub comp_sm()
If smtv = "Dry" And DisplaySM = "Dry" Then
Out 890, 6
Text14.Text = "Idle"
ElseIf smtv = "DAMp" And DisplaySM = "Dry" Then
Out 890, 5
Text14.Text = "On"
ElseIf smtv = "Wet" And DisplaySM = "Dry" Then
Out 890, 5
Text14.Text = "On"
ElseIf DisplaySM = "DAMp" Then
Out 890, 6
Text14.Text = "Idle"
ElseIf DisplaySM = "Wet" Then
Out 890, 6
Text14.Text = "Idle"
End If
End Sub
Private Sub Update_click()
If Profile.Text = "Custom" And Text1.Text = "" Or Text4.Text = "" Or LightS.Text = "" Or
SMS.Text = "" Then
213
MsgBox "Enter the necessary values.", _
vbExclAMation, _
"Error"
End If
TempTV = Text1.Text
HumidityTV = Text4.Text
LightTV = LightS.Text
smtv = SMS.Text
Text2.Text = TempTV
Text5.Text = HumidityTV
Text7.Text = LightTV
Text9.Text = smtv
Timer3.Enabled = True
Timer2.Enabled = False
Timer4.Enabled = False
Timer5.Enabled = True
End Sub
Private Sub Timer1_Timer() ' for date and time
Label1.Caption = Date
Label2.Caption = Time
Label13.Caption = LightT
Label14.Caption = Ht
Label15.Caption = SMT
Label16.Caption = Ct
Label17.Caption = smt2
End Sub
Private Sub Timer5_Timer()
savec = savec + 1
If savec = 120 Then
datars.AddNew
saveondisk
214
datars.Update
savec = 0
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top