Test and Measurement Forum

PS3000a.dll with VB.NET

Post your .Net discussions here

PS3000a.dll with VB.NET

Postby bikertt » Tue Jun 05, 2012 7:32 pm

Hello,

today I tried to connect from a VB.NET application via API-functions of the PS3000a.dll to a PicoScope 3204A.
Unfortunately without success.

Is there an example how to connet a PicoScope 3204A to a VB.NET application? I found a lot of examples in the SDK, but not for VB.NET. By the way, the C#-Example works fine.
Do I really need the PS3000a.dll or is there an .NET class to use?

Any help is appreciated,

Michael
bikertt
Newbie
 
Posts: 0
Joined: Tue Jun 05, 2012 7:18 pm

Re: PS3000a.dll with VB.NET

Postby bikertt » Wed Jun 06, 2012 8:49 am

Hello,

in the meantime I figured out how to connect to the PicoScope 3204A via PS3000a.dll. :D

Now I try to to Get Values and started to work with API "GetValues" and aigain it doesn't work so far.
I don't know how to declarate this API-Funktion in VB.NET.
I just want to get 1 measurement value when I click a button in the VB.NET application

So I ask again. Is there an example VB.NET with PS3000a.dll?

Thank you, Michael
bikertt
Newbie
 
Posts: 0
Joined: Tue Jun 05, 2012 7:18 pm

Re: PS3000a.dll with VB.NET

Postby Hitesh » Wed Jun 06, 2012 2:39 pm

Hi Michael,

Please try the following line of code:

Code: Select all
Declare Function ps3000aGetValues Lib "ps3000a.dll" (ByVal handle As Short, ByVal startIndex As Integer, ByRef numSamples As Integer, ByVal downSampleRatio As Integer, ByVal downSampleRatioMode As Integer, ByVal segmentIndex As Integer, ByRef overflow As Integer) As Integer


Please also refer to the following Knowledge Base article:

http://www.picotech.com/support/kb/PicoScopeSDK-kb244

Please note that Strings have to be pre-allocated and passed 'ByVal'.

We don't have .NET examples I'm afraid - we have ported VBA code into MS Visual Studio Express 2008 and 2010.

I hope this helps,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2009
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: PS3000a.dll with VB.NET

Postby bikertt » Fri Jun 08, 2012 9:42 am

Hello,

thank you for your replay.

I have tried your declaration of ps3000aGetValues.

Unfortunately I get an error message "System.AccessViolationException" when I use it.

Can you please provide a little bit more code showing how to get a value?

Thank you, Michael
bikertt
Newbie
 
Posts: 0
Joined: Tue Jun 05, 2012 7:18 pm

Re: PS3000a.dll with VB.NET

Postby Martyn » Fri Jun 08, 2012 10:51 am

Can you post your code for us to look at.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2287
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: PS3000a.dll with VB.NET

Postby bikertt » Mon Jun 11, 2012 8:23 am

Hello,

I continued working on it. Now the problem is the return value of ps3000aGetValues. The returnValue is 70 (Hex 46) --> PICO_BUFFERS_NOT_SET.

What's wrong with my code?


Thank you very much for your help, Michael

here you can see my coding:



Code: Select all
    Private Sub cmdTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdTest.Click

        Dim status As Short
        Dim handle As Short
        Dim intReturnValue As Integer

        'This call works
        'Declare Function ps3000aOpenUnit Lib "ps3000a.dll" (ByRef handle As Short, ByVal serial As System.Text.StringBuilder) As Short
        status = ps3000aOpenUnit(Handle, Nothing)

        If handle <> 0 Then

            Dim sng As Single
            'Declare Function ps3000aSetChannel Lib "ps3000a.dll" (ByRef handle As Short, ByVal channel As Integer, ByVal enabled As Short, ByVal type As Integer, ByVal range As Integer, ByVal analogueOffset As Single) As Short
            Call ps3000aSetChannel(shthandle, 0, 1, 1, 1, sng)

            Dim channel As Integer
            Dim buffer As Integer
            Dim bufferLth As Integer
            Dim segmentIndex As Integer
            Dim mode As Integer
            buffer = 0
            channel = 0
            bufferLth = 1024
            segmentIndex = 0
            mode = 0

            'This call works
            'Declare Function ps3000aSetDataBuffer Lib "ps3000a.dll" (ByVal handle As Short, ByVal channel As Integer, ByRef buffer As Integer, ByVal bufferLth As Integer, ByVal segmentIndex As Integer, ByVal mode As Integer) As Integer
            intReturnValue = ps3000aSetDataBuffer(handle, channel, buffer, bufferLth, segmentIndex, mode)

            If intReturnValue = 0 Then

                Dim startIndex As Integer
                Dim numSamples As Integer
                Dim downSampleRatio As Integer
                Dim downSampleRatioMode As Integer
                'Dim segmentIndex As Integer
                Dim overflow As Integer
                numSamples = 1024
                downSampleRatioMode = 2

                'Here I get the returnValue 70 (Hex 46) --> PICO_BUFFERS_NOT_SET
                'An attempt was made to get data before a data buffer was defined
                'Declare Function ps3000aGetValues Lib "ps3000a.dll" (ByVal handle As Short, ByVal startIndex As Integer, ByRef numSamples As Integer, ByVal downSampleRatio As Integer, ByVal downSampleRatioMode As Integer, ByVal segmentIndex As Integer, ByRef overflow As Integer) As Integer
                intReturnValue = ps3000aGetValues(handle, startIndex, numSamples, downSampleRatio, downSampleRatioMode, segmentIndex, overflow)

            End If
        End If

    End Sub
bikertt
Newbie
 
Posts: 0
Joined: Tue Jun 05, 2012 7:18 pm

Re: PS3000a.dll with VB.NET

Postby Hitesh » Tue Jun 12, 2012 1:34 pm

Hi Michael,

Prior to calling the ps3000aGetValues function, you will need to call the 'RunBlock' function and then poll the driver using the IsReady function from the PS3000aWrap dll.

The wrapper dll is there to provide support for languages that do not support callback functions.

Once the device is ready, you can then extract the data values.

You will also need to set a timebase prior to calling the 'RunBlock' function.

Please also refer to the Programmer's guide as that will give you an overview of the steps to take to collect data.

I hope this helps.
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2009
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: PS3000a.dll with VB.NET

Postby AsO » Thu Feb 28, 2013 1:51 pm

I put a VB.Net(2010) codes on Github. It is directly translated from a SDK's C#.Net sample project.
https://github.com/AsO/PS3000AVBConsole
_____
AsO
User avatar
AsO
Newbie
 
Posts: 0
Joined: Sat Feb 23, 2013 11:44 pm
Location: Japan


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

Who is online

Users browsing this forum: No registered users and 0 guests