Test and Measurement Forum

Problem with pl1000GetValues (PICO_NULL_PARAMETER)

Post your .Net discussions here

Problem with pl1000GetValues (PICO_NULL_PARAMETER)

Postby virgilou83 » Fri Nov 12, 2010 3:34 pm

Hi ! :)

I'm a new user of PicoLog 1012 and I'm working on my own software with VB.Net !

I'm in front of a problem, and after two intensive days of work, I can't find any solution, so I'm asking for your help !

My code is the following :

Code: Select all
    Declare Function pl1000OpenUnit Lib "pl1000.dll" (ByRef handle As Integer) As Integer
    Declare Function pl1000CloseUnit Lib "pl1000.dll" (ByVal handle As Integer) As Long
    Declare Function pl1000GetUnitInfo Lib "pl1000.dll" (ByVal handle As Integer, ByVal S As String, ByVal lth As Integer, ByRef requiredSize As Integer, ByVal info As Integer) As Integer
    Declare Function pl1000SetTrigger Lib "pl1000.dll" (ByVal handle As Integer, ByVal enabled As Integer, ByVal enable_auto As Integer, ByVal auto_ms As Integer, ByVal channel As Integer, ByVal dir As Integer, ByVal threshold As Integer, ByVal hysterisis As Integer, ByVal delay As Single) As Integer
    Declare Function pl1000SetInterval Lib "pl1000.dll" (ByVal handle As Short, ByRef us_for_block As Integer, ByVal ideal_no_of_samples As Integer, ByRef channels As Short, ByVal No_of_channels As Short) As Integer
    Declare Function pl1000GetValues Lib "pl1000.dll" (ByVal handle As Short, ByVal PLvalues As Short, ByVal no_of_values As Integer, ByVal overflow As Short, ByVal triggerIndex As Long) As Short
    Declare Function pl1000Run Lib "pl1000.dll" (ByVal handle As Integer, ByVal no_of_values As Long, ByVal method As Integer) As Integer
    Declare Function pl1000Ready Lib "pl1000.dll" (ByVal handle As Integer, ByRef ready As Integer) As Integer
    Declare Function pl1000MaxValue Lib "pl1000.dll" (ByVal handle As Integer, ByRef maxValue As Integer) As Long


    Public status As Long
    Public handle As Integer
    Public values As Integer
    Public channels(22) As Short
    Public nValues As Long
    Public ready As Integer
    Public requiredSize As Integer
    Public S As New String(" "c, 255)
    Public SLegnth As Long
    Public maxValue As Integer
    Public opened As Integer
    Public triggerIndex As Long
    Public overflow As Short


    Function adc_to_mv(ByRef value As Integer) As Integer
        adc_to_mv = value / maxValue * 2500
    End Function

    Sub Pl1000()


        ' Open device
        status = pl1000OpenUnit(handle)
        opened = handle <> 0

        If opened Then


            'Get the maximum ADC value for this variant
            status = pl1000MaxValue(handle, maxValue)


            ' Get the unit information
            TestBoitier.Label1.Text = "Picolog plugged"
            SLegnth = pl1000GetUnitInfo(handle, S, 255, requiredSize, 3)
            TestBoitier.Label2.Text = S
            'MsgBox(SLegnth)
            SLegnth = pl1000GetUnitInfo(handle, S, 255, requiredSize, 4)
            TestBoitier.Label3.Text = S
            'MsgBox(SLegnth)


            ' Say that we want to take 1 reading in 1 s
            ' from channels 1


            channels(0) = 1

            status = pl1000SetInterval(handle, 1000000, 1, 1, 1)
            'MsgBox(status)

            status = pl1000Run(handle, 1, 0)
            'MsgBox(status)

            ready = 0
            Do While ready = 0
                status = pl1000Ready(handle, ready)
                'MsgBox("" & status & " " & ready & " ")
            Loop

            ' Get a block of 1 reading...

            status = pl1000GetValues(handle, values, 2, overflow, triggerIndex)
            MsgBox(status)

       

            ' Copy the data into the Label

            TestBoitier.Label4.Text = adc_to_mv(values)


            ' Close the unit when finished to drop the driver
            Call pl1000CloseUnit(handle)


        Else
            TestBoitier.Label1.Text = "Picolog not plugged"
        End If
     

    End Sub


Everything works (Label1 is filled, Label2 and Label3 too), but the problem is that I get every time the value "0" in my Label4, where I want to write the result of the mesure, and even if the voltage is higher as 0V.

I've tried to find out where the problem is, and thanks to message boxes, I've seen that everything goes well until this lign :

Code: Select all
status = pl1000GetValues(handle, values, 2, overflow, triggerIndex)


In fact, the message box which come after give me the return 22 which mean "PICO_NULL_PARAMETER" :A parameter that was required is NULL.

I've tried everything to solve this problem, but I havn't found which parameter is null ! I think that my problem come from the declaration of my function:

Code: Select all
Declare Function pl1000GetValues Lib "pl1000.dll" (ByVal handle As Short, ByVal PLvalues As Short, ByVal no_of_values As Integer, ByVal overflow As Short, ByVal triggerIndex As Integer) As Short

But I've tried to change a lot of things (ByVal, ByRef, String, Integer, Short, Long ...) and that doesn't work either.

I need to find a solution, I will continue to search, but I thank you in advance for your help and your advices.
virgilou83
Newbie
 
Posts: 0
Joined: Thu Nov 11, 2010 12:38 am

Re: Problem with pl1000GetValues (PICO_NULL_PARAMETER)

Postby Chris » Mon Nov 15, 2010 11:10 am

A couple of changes to make.....


Long in vb meant 32 bit.
Long in vb.net is 64bit, so substitute
Integer for Long
UInteger for unsigned Long.

In pl1000GetValues you have ByVal in place of ByRef (maybe where you're changing things to get it working)

This should be....
Declare Function pl1000GetValues Lib "pl1000.dll" (ByVal handle As Short, ByRef PLvalues As UShort, ByRef no_of_values As UInteger, ByRef overflow As UShort, ByRef triggerIndex As UInteger) As Short


In the call to status = pl1000GetValues, the values parameter should be an array......


public handle As Short
Public values(200) As UShort
Public nValues As UInteger
Public overflow As UShort
Public triggerIndex As UInteger

status = pl1000GetValues(handle, values(0), nValues, overflow, triggerIndex)


(Also noticed you'd got some variables declared as Short when they should be UShort, which may lead to problems during execution. May be worth rechecking all declaration types.)

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


Return to .Net Languages (C#, VB.Net, .)

Who is online

Users browsing this forum: No registered users and 0 guests