Test and Measurement Forum

using Visual studio to access a DrDaq (usb) on Windows 7

Having problems ? let us know the details here

using Visual studio to access a DrDaq (usb) on Windows 7

Postby AlanVB » Mon Jan 31, 2011 7:49 pm

Hi,

I'm trying to access a USB DrDaq from my Windows 7 m/c using Visual Studio 2010 professional.

I can access the unit from Excel (office 2010) but I wish to write an application that will access the unit in Visual studio 2010.

As far as I can see there is no available component that can be referenced from Visual Studio. Have I missed something or don't you support that type of access?

I can get some response if I use the old mechanism of declaring library functions though these need modification from the vb6 examples because VB.net has different ideas about what a long and an integer are.

Code: Select all
    Private Declare Function UsbDrDaqOpenUnit Lib "USBDrDAQ.dll" (ByRef handle As Int16) As Int32
    Private Declare Function UsbDrDaqCloseUnit Lib "USBDrDAQ.dll" (ByVal handle As Int16) As Int32
    Private Declare Function UsbDrDaqSetInterval Lib "USBDrDAQ.dll" (ByVal handle As Int16, ByRef us_for_block As Int32, ByVal ideal_no_of_samples As Int32, ByRef channels As Int32, ByVal no_of_channels As Int16) As Int32
    Private Declare Function UsbDrDaqRun Lib "USBDrDAQ.dll" (ByVal handle As Int16, ByVal no_of_values As Int32, ByVal method As Int32) As Int32
    Private Declare Function UsbDrDaqGetValues Lib "USBDrDAQ.dll" (ByVal handle As Int16, ByRef values As Int16, ByRef noOfValues As Int32, ByRef overflow As Int16, ByRef triggerIndex As Int32) As Int32
    Private Declare Function UsbDrDaqReady Lib "USBDrDAQ.dll" (ByVal handle As Int16, ByRef ready As Int16) As Int32
    Private Declare Function UsbDrDaqGetUnitInfo Lib "USBDrDAQ.dll" (ByVal handle As Int16, ByVal S As String, ByVal stringLength As Int16, ByRef requiredSize As Int16, ByVal info As Int32) As Int32


However even though the call to these library functions is accepted a code sequence such as:

Code: Select all
   
Private Sub Container_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim Handle As Int16
        Dim status As Integer = UsbDrDaqOpenUnit(Handle)
        Dim requiredSize As Integer
        Dim SLegnth As Integer
        Dim S As String = Space(255)

        If status <> 0 Then
            MsgBox("Unit not opened", vbOKOnly, "Error Message")
            Exit Sub
        End If


    End Sub

Will always return the error message (the status returned is 3) after about 20 seconds. The led on the DrDaq has by this time started flashing..

Can anyone explain what is wrong with the above?

Oh and the DrDaq invariably then locks up and the only way to reset it is to restart the entire system.

Alan
AlanVB
 

Re: using Visual studio to access a DrDaq (usb) on Windows 7

Postby Chris » Tue Feb 01, 2011 4:50 pm

With the DrDAQ device connected to the PC, have a look in device manager to see if the Pico USB DrDAQ is listed (under Pico Technology Instruments)

If it's not, run the installer, DPInst.exe installer, from the winusb folder of the SDK.

Choose the exe from the x86 folder for 32 bit operating systems, or the exe from the amd64 folder for 64 bit operating systems. (Irrespective of the processor type)
Chris
Site Admin
Site Admin
 
Posts: 169
Joined: Tue Aug 17, 2010 9:00 am
Location: St. Neots

Re: using Visual studio to access a DrDaq (usb) on Windows 7

Postby AlanVB » Tue Feb 01, 2011 10:37 pm

I've managed to get some of the basic functions working now (I'm not sure why - it seemed to be a function of removing the device physically and reconnecting it after a machine restart).

I'm now having problems with some of the functions - in particular:

The function USBDRDAQGetChannelInfo doesn't seem to exist in the library (at least that's what the development environment tells me). The spec says it's there but none of the examples shows it's use - does it exist?

The definition I'm using is

Code: Select all
    Private Declare Function USBDRDAQGetChannelInfo Lib "USBDrDAQ.dll" (ByVal handle As Int16, ByRef Min As Single, ByRef Max As Int16, ByRef Places As Int16, ByRef Divider As Int16, ByVal Channel As Int16) As Int32


If the function does exist is this declaration correct?

Also when using the UsbDrDaqGetScalings function on channel 8 (onboard temperature) the return is just

Code: Select all
Temperature:°C

The documentation led me to expect something starting
Code: Select all
[Scale100]
Resistor=1
LongName=Temperature
ShortName-Temp
Units=C
.....

Can you explain what I should be getting and how to interpret it?

Thanks

Alan
AlanVB
 

Re: using Visual studio to access a DrDaq (usb) on Windows 7

Postby Chris » Wed Feb 02, 2011 3:15 pm

Hi Alan

The programmers guide should list all routines as
UsbDrDaq.......
not
USBDRDAQ
so
USBDRDAQGetChannelInfo
should be
UsbDrDaqGetChannelInfo


If you implement a *.dds file, and put it in the same location as the dll, you can get custom information from the UsbDrDaqGetScalings call.

An example for the Thermistor would be a dds file consisting of ....


[Scale1]
Resistor=1100
LongName=MyTemp
ShortName=TempF
Units=F
MinValue=-10
MaxValue=100
OutOfRange=1
Places=2
Method=1
Offset=10
Slope=1.1


Note: The ShortName field information isn't returned.

Chris.
Chris
Site Admin
Site Admin
 
Posts: 169
Joined: Tue Aug 17, 2010 9:00 am
Location: St. Neots

Re: using Visual studio to access a DrDaq (usb) on Windows 7

Postby AlanVB » Wed Feb 02, 2011 11:14 pm

Thanks Chris

That works now - I assume you'll get the documentation updated at some point.

It would be good it you could include somewhere the VB.Net Declare statements too it's quite confusing if you're not aware of the history.

Thanks again

Alan
AlanVB
 

Re: using Visual studio to access a DrDaq (usb) on Windows 7

Postby AuthorMike » Thu Feb 03, 2011 8:51 am

I'll ensure these changes are made to the documentation, and the updated document uploaded to the web as soon as possible.

Thanks,

Mike
Mike Valentine
(Automotive) Technical Author - Pico Technology
"I right complicate stuff in a easy too under stand weigh four those who need two no it"
User avatar
AuthorMike
Site Admin
Site Admin
 
Posts: 41
Joined: Mon Jan 31, 2011 11:22 am
Location: UK

Re: using Visual studio to access a DrDaq (usb) on Windows 7

Postby AuthorMike » Thu Feb 03, 2011 12:22 pm

Hi,

Updated Programmer's Guide now on the web.

Please visit http://www.picotech.com/document/pdf/us ... g_en-2.pdf to open the PDF,


Thanks,

Mike
Mike Valentine
(Automotive) Technical Author - Pico Technology
"I right complicate stuff in a easy too under stand weigh four those who need two no it"
User avatar
AuthorMike
Site Admin
Site Admin
 
Posts: 41
Joined: Mon Jan 31, 2011 11:22 am
Location: UK


Return to Getting Started

Who is online

Users browsing this forum: No registered users and 0 guests