VB.net declare Statements

Post your .Net discussions here
Post Reply
AnthonyCSheehy
User
User
Posts: 7
Joined: Fri May 04, 2007 10:18 am

VB.net declare Statements

Post by AnthonyCSheehy »

I would like to share the following code for those people wanting to access the PS3000.dll functions in VB.net 2005/2008

The types have been matched as close as possible with the equivalent types specified in the picoscope documentation. I have not tested everything but my applications do work with both block and streaming mode.

I use this block of code now every time I go to program with the 3224. You might have to check that the location of the ps3000.dll is in your path environment variable.

Code: Select all

Declare Function ps3000_open_unit Lib "ps3000.dll" () As Integer
Declare Function ps3000_set_unit Lib "ps3000.dll" (ByVal handler As Integer) As Integer
Declare Function ps3000_flash_led Lib "ps3000.dll" (ByVal handle As Integer) As Integer
Declare Sub ps3000_close_unit Lib "ps3000.dll" (ByVal handler As Integer)

Declare Function ps3000_get_unit_info Lib "ps3000.dll" (ByVal handle As Short, ByVal str As String, ByVal lth As Short, ByVal line_no As Short) As Short

Declare Function ps3000_set_siggen Lib "ps3000.dll" (ByVal handle As Integer, ByVal wave_type As Integer, ByVal start As Long, ByVal stop_freq As Long, ByVal increment As Integer, ByVal dwell As Integer, ByVal repeat As Integer, ByVal dual As Integer) As Long

Declare Function ps3000_set_channel Lib "ps3000.dll" (ByVal handle As Short, ByVal channel As Short, ByVal enabled As Short, ByVal dc As Short, ByVal range As Short) As Short
Declare Function ps3000_set_trigger Lib "ps3000.dll" (ByVal handle As Integer, ByVal source As Integer, ByVal threshold As Integer, ByVal direction As Integer, ByVal delay As Integer, ByVal auto_trigger_ms As Integer) As Integer
Declare Function ps3000_get_timebase Lib "ps3000.dll" (ByVal handle As Short, ByVal timebase As Short, ByVal no_of_samples As Int32, ByRef time_interval As Int32, ByRef time_units As Short, ByVal oversample As Short, ByRef max_samples As Int32) As Short

Declare Function ps3000_run_block Lib "ps3000.dll" (ByVal handle As Short, ByVal no_of_values As Int32, ByVal timebase As Short, ByVal oversample As Short, ByRef time_indisposed_ms As Int32) As Short
Declare Function ps3000_run_streaming Lib "ps3000.dll" (ByVal handle As Integer, ByVal time_interval As Long, ByVal max_samples As Long, ByVal windowed As Integer) As Integer
Declare Function ps3000_run_streaming_ns Lib "ps3000.dll" (ByVal handle As Short, ByVal sample_interval As UInteger, ByVal time_units As Short, ByVal max_samples As UInteger, ByVal auto_stop As Short, ByVal noOfSamplesPerAggregate As UInteger, ByVal overview_buffer_size As UInteger) As Short

Declare Function ps3000_get_streaming_last_values Lib "ps3000.dll" (ByVal handle As Short, ByVal MyFunction As CallBack) As Short
Declare Function ps3000_get_streaming_values Lib "ps3000.dll" (ByVal handle As Short, ByRef start_time As Double, ByRef pbuffer_a_max As Short, ByRef pbuffer_a_min As Short, ByRef pbuffer_b_max As Short, ByRef pbuffer_b_min As Short, ByRef pbuffer_c_max As Short, ByRef bpuffer_c_min As Short, ByRef pbuffer_d_max As Short, ByRef pbuffer_d_min As Short, ByRef overflow As Short, ByRef triggerat As UInteger, ByRef triggered As Short, ByVal no_of_values As UInteger, ByVal noOfSamplesPerAggregate As UInteger) As Short

Declare Function ps3000_ready Lib "ps3000.dll" (ByVal handle As Short) As Short
Declare Function ps3000_get_values Lib "ps3000.dll" (ByVal handle As Short, ByRef buffer_a As Short, ByRef buffer_b As Short, ByRef buffer_c As Short, ByRef buffer_d As Short, ByRef overflow As Short, ByVal no_of_values As Int32) As Int32
Declare Function ps3000_get_times_and_values Lib "ps3000.dll" (ByVal handle As Integer, ByVal times As Long, ByVal buffer_a As Integer, ByVal buffer_b As Integer, ByVal buffer_c As Integer, ByVal buffer_d As Integer, ByVal overflow As Integer, ByVal time_units As Integer, ByVal no_of_samples As Long) As Long
Declare Function ps3000_stop Lib "ps3000.dll" (ByVal handle As Integer) As Integer

Declare Function ps3000_set_ets Lib "ps3000.dll" (ByVal handle As Integer, ByVal mode As Integer, ByVal ets_cycles As Integer, ByVal ets_interleave As Integer) As Long
and helpful constants and vars

Code: Select all

    'PS3000 Device Settings

    Friend PS3000_AGREGATION As UInteger = 1
    Friend PS3000_VoltageRange As Integer = 3
    Friend PS3000_Channel As Integer = 0
    Friend PS3000_Max_Samples As UInteger = 15000


    'constants

    Friend Const PS3000_CHANNEL_A = 0
    Friend Const PS3000_CHANNEL_B = 1
    Friend Const PS3000_CHANNEL_C = 2
    Friend Const PS3000_CHANNEL_D = 3
    Friend Const PS3000_EXTERNAL = 4
    Friend Const PS3000_NONE = 5

    Friend Const PS3000_RISING = 0
    Friend Const PS3000_FALLING = 1

    Friend Const PS3000_20MV = 1
    Friend Const PS3000_50MV = 2
    Friend Const PS3000_100MV = 3
    Friend Const PS3000_200MV = 4
    Friend Const PS3000_500MV = 5
    Friend Const PS3000_1V = 6
    Friend Const PS3000_2V = 7
    Friend Const PS3000_5V = 8
    Friend Const PS3000_10V = 9
    Friend Const PS3000_20V = 10

    Friend Const PS3000_BUFFER = 15000

    Friend Const PS3000_FS = 0
    Friend Const PS3000_PS = 1
    Friend Const PS3000_NS = 2
    Friend Const PS3000_US = 3
    Friend Const PS3000_MS = 4
    Friend Const PS3000_S = 5
Regards
Anthony Sheehy
MCP

Post Reply