URGENT: NEED HELP

 
Post new topic   Reply to topic    Pico Technology Forum Index -> General Software Discussions
Author Message
Rebecca
Guest





PostPosted: Tue Dec 13, 2005 12:56 pm    Post subject: URGENT: NEED HELP Reply with quote

I am having problems with my DrDaq visual basic project. I Originally had it working but am now getting errors. I have deleted all of the drivers and software and reinstalled everything, I am still getting an error message when i open up the example saying "cannot open DRDaq on LPT1". This is where I got the code from
http://www.comp.lancs.ac.uk/~albrecht/sw/DrDAQ/


Option Explicit

Dim port As Integer 'Used to store port used(1 = lpt1)
Dim opened As Boolean 'boolean value; shows if driver opened

Private Sub chkTimer_Click()
If chkTimer.Value = 1 Then
Timer1.Interval = CInt(mstxt.Text)
Timer1.Enabled = True
Else
Timer1.Enabled = False
End If
End Sub

Private Sub cmdClose_Click()
If opened Then
'close the port
drdaq_close_unit (port)
End If

statustxt.Text = "DrDAQ Driver Closed on LPT" + CStr(port)

cmdOpen.Enabled = True
cmdClose.Enabled = False
cmdRead.Enabled = False
chkTimer.Enabled = False
End Sub

Private Sub cmdOpen_Click()
Dim VNUm As Integer ' Version number
port = Val(txtPortNum) ' Get Port

opened = drdaq_open_unit(port) <> 0 'Open drdaq driver

If opened Then 'Check driver opened ok
VNUm = drdaq_get_driver_version()
statustxt.Text = "DrDAQ Driver Opened on LPT" + CStr(port) + " - Driver Version:" + CStr(VNUm)

' change temp units to C
drdaq_apply_fix 1, 0

cmdOpen.Enabled = False
cmdClose.Enabled = True
cmdRead.Enabled = True
chkTimer.Enabled = True
chkTimer.Value = 1
cmdRead.Default = True

Else 'If driver fails to open...
statustxt.Text = "Cannot open DrDaq on Port LPT" + txtPortNum
End If
End Sub

Private Sub cmdQuit_Click()
If opened Then
' Close down drdaq
drdaq_close_unit port
End If
End
End Sub


Private Sub cmdread_Click()
Dim Value As Single 'Stores ADC count
Dim volts As Integer 'Stores voltage
Dim S As String

If opened Then
'toggle LED ON
drdaq_set_led 1
DoEvents

'Sample from all channels
S = ""

'Channel 2 - Sound Level
Value = drdaq_get_value(2)
soundtxt.Text = Format$(Value / 10, "0.00")

'Channel 3 - Voltage
Value = drdaq_get_value(3)
voltagetxt.Text = Format$(Value, "0")

'Channel 6 - Temperature
Value = drdaq_get_value(6)
temptxt.Text = Format$(Value / 10, "0.00")

'Channel 7 - Light
Value = drdaq_get_value(7)
lighttxt.Text = Format$(Value / 10, "0.0")

'Channel 8 - Ext 1
Value = drdaq_get_value(8)
ext1txt.Text = Format$(Value, "0")

'Channel 9 - Ext 2
Value = drdaq_get_value(9)
ext2txt.Text = Format$(Value, "0")

DoEvents

' toggle led off
drdaq_set_led 0

Else
MsgBox "Port not opened!"
End If
End Sub

Private Sub Form_Load()
' Center Form on screen

Top = (Screen.Height - Height) / 2
Left = (Screen.Width - Width) / 2

statustxt.Text = ""
cmdRead.Enabled = False
cmdClose.Enabled = False
cmdOpen.Enabled = True
chkTimer.Enabled = False
End Sub

Private Sub Form_Terminate()
cmdQuit_Click
End
End Sub

Private Sub Form_Unload(Cancel As Integer)
cmdQuit_Click
End
End Sub

Private Sub mstxt_Change()
If mstxt.Text <> "" Then
On Error GoTo skipConv
If CLng(mstxt.Text) > 0 And CLng(mstxt.Text) < 30000 Then
Timer1.Interval = CInt(mstxt.Text)
If chkTimer.Value = 0 Then Timer1.Enabled = False
End If
End If
skipConv:
End Sub

Private Sub Timer1_Timer()
If opened = True Then cmdread_Click
End Sub

Private Sub txtPortNum_KeyPress(KeyAscii As Integer)
Select Case (KeyAscii)
Case 48 To 57, 8:
KeyAscii = KeyAscii
Case Else:
Beep
KeyAscii = 0
End Select
End Sub
Back to top
wilba
Active User
Active User


Joined: 30 Nov 2005
Posts: 7

PostPosted: Tue Dec 13, 2005 1:54 pm    Post subject: Reply with quote

I get this frequently if you do not close down the port and end you application. Eg press stop in vb. Then try to open it again.

The only remedy i have found so far is to reboot the computer.

William
Back to top
Michael
Guru
Guru


Joined: 07 Jul 2005
Posts: 93
Location: St Neots, Cambridgeshire

PostPosted: Wed Dec 14, 2005 11:55 am    Post subject: Reply with quote

Hello,

User 'Wilba' is right. You will need to close the port. You must call the close unit function to do this effectively.

Best regards,
Michael
Back to top
Rebecca
Guest





PostPosted: Thu Dec 15, 2005 1:19 pm    Post subject: Help! Reply with quote

i have tried your solutuions as given but it is stil not working for me. by any chance could you send a piece of code that will open and close the port on the DrDaq and read in a value as i am still unsure whether it is a software or hardware problem,so if i receive a working prgram and it does not work on my pc i will be able to tell it then.
Back to top
Michael
Guru
Guru


Joined: 07 Jul 2005
Posts: 93
Location: St Neots, Cambridgeshire

PostPosted: Fri Dec 16, 2005 4:01 pm    Post subject: Reply with quote

Hello,

Paste this into your code in crucial places and step through each line.
drdaq_close_unit (port)
When you get to the next "close" call, step over if the previous fucntions have worked or step into if the previous portions have failed.

Best regards,
Michael
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Pico Technology Forum Index -> General Software Discussions
All times are GMT
Page 1 of 1

 


Pico Technology topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group