Solved

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

Posted on 2007-11-21
7
262 Views
Last Modified: 2013-11-25
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
Comment
Question by:Parvez_Siddiqui
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 25

Expert Comment

by:imitchie
ID: 20332419
are you sure the card can be found? maybe the dll cannot find the card due to other misconfiguration
0
 
LVL 25

Expert Comment

by:imitchie
ID: 20332424
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
 

Author Comment

by:Parvez_Siddiqui
ID: 20332511
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 25

Expert Comment

by:imitchie
ID: 20332526
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
 

Author Comment

by:Parvez_Siddiqui
ID: 20334878
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
 
LVL 25

Accepted Solution

by:
imitchie earned 500 total points
ID: 20335999
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
 

Author Comment

by:Parvez_Siddiqui
ID: 20336797
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This video teaches viewers how to process images for a time-lapse video. Programs required: Adobe Lightroom, Adobe After Effects, Video Editing Program. In Adobe Lightroom: Import sequence image files into Adobe Lightroom: Develop settings of an I…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question