[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

calling a dll function...no errors....but returns the value -1

hello sir/madam,
i have a Analog to digital converter card connected via usb port to my laptop. it converts the analog value and displays digital value. i want that digital value on my web page. To access that value i m trying to use the dll dunction which is used by that card
Private Declare Function ReadAnalogChannel Lib "C:\Inetpub\wwwroot\K8055D.DLL" (ByVal data As Long) As Long
Private Declare Function OpenDevice Lib "C:\Inetpub\wwwroot\K8055D.DLL" (ByVal N As Long) As Long
Dim data As Long
Dim i As Long
Dim N As Integer
Sub opencard()
i = OpenDevice(0)
End Sub
Sub callBeepDll()
data = ReadAnalogChannel(1)
End Sub
Private Sub cmd1_Click()
Dim data As Long
Call opencard
data = ReadAnalogChannel(1)
Text1.Text = data
End Sub
This is my code. In the description  of the card details says

If succeeded the return value will be the card address read from the K8055 hardware.
Return value -1 indicates that K8055 card was not found.

When i run this vb file...it gives me the value  -1. i.e. card is not connected. Can u plz give me solution or give me an alternate solution for this.
many thanks
0
Parvez_Siddiqui
Asked:
Parvez_Siddiqui
  • 4
  • 3
1 Solution
 
imitchieCommented:
are you sure the card can be found? maybe the dll cannot find the card due to other misconfiguration
0
 
imitchieCommented:
try

Sub opencard()
i = OpenDevice(0)
Text1.Text = i
End Sub
Sub callBeepDll()
data = ReadAnalogChannel(1)
End Sub
Private Sub cmd1_Click()
Dim data As Long
Call opencard
data = ReadAnalogChannel(1)
Text1.Text = Text1.Text & " " & data
End Sub
0
 
Parvez_SiddiquiAuthor Commented:
Hi imitchie,
I tried the code u said. its showing -1-1...

maybe the dll cannot find the card due to other misconfiguration.....can u plz explain wats the meaning of this..?
this is explained in the k8055 card pdf file


OpenDevice
Syntax
FUNCTION OpenDevice(CardAddress: Longint): Longint;
Parameter
CardAddress: Value between 0 and 3 which corresponds to the jumper (SK5, SK6) setting on the
K8055 board. See table 1.
Result
Longint: If succeeded the return value will be the card address read from the K8055 hardware.
Return value -1 indicates that K8055 card was not found.
Description
Opens the communication link to the K8055 card. Loads the drivers needed to communicate via the
USB port. This procedure must be performed before any attempts to communicate with the K8055
card.
This function can also be used to selects the active K8055 card to read and write the data. All the
communication routines after this function call are addressed to this card until the other card is
selected by this function call.
Example
var h: longint;
BEGIN
h:=OpenDevice(0); // Opens the link to card number 0
END;




ReadAnalogChannel
Syntax
FUNCTION ReadAnalogChannel (Channel: Longint): Longint;
4 Description of the DLL
© 2003 ... Velleman
Parameter
Channel: Value between 1 and 2 which corresponds to the AD channel whose status is to be read.
Result
Longint: The corresponding Analogue to Digital Converter data is read.
Description
The input voltage of the selected 8-bit Analogue to Digital converter channel is converted to a value
which lies between 0 and 255.
Example
var data: longint;
BEGIN
data := ReadAnalogChannel(1);
// AD channel 1 is read to variable 'data'
END;

MANY THANKS
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
imitchieCommented:
try in Sub opencard()

i = OpenDevice(0)
Text1.Text = i
i = OpenDevice(1)
Text1.Text = Text1.Text & " " & i
i = OpenDevice(2)
Text1.Text = Text1.Text & " " & i
i = OpenDevice(3)
Text1.Text = Text1.Text & " " & i

FUNCTION OpenDevice(CardAddress: Longint):
CardAddress: Value between 0 and 3 which corresponds to the jumper (SK5, SK6) setting on the K8055 board. See table 1.

you may have the wrong CardAddress?
0
 
Parvez_SiddiquiAuthor Commented:
HI imitchie,
its showing me again -1...when the card is connected...i can see that it is connected via that k8055d card software...its also showing me the default value...but when i m calling through visual basic..it is giving me -1...plz help

0
 
imitchieCommented:
i'm afraid either
- the DLL has a problem, because we've tried the OpenDevice with all four CardAddresses and none are connecting
- or it cannot connect while you have the Card software connected (I hope you're not trying it with other software connecteD!)
0
 
Parvez_SiddiquiAuthor Commented:
hey imitchie...thanks dear....thank-you very very much...previuosly i was trying when the other software was connected...no i tried without that...and it worked...once again thanks dear...
bye
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now