PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
Declare Function pl1000OpenUnit Lib "pl1000.dll" (ByRef handle As Short) As Integer
Declare Function pl1000CloseUnit Lib "pl1000.dll" (ByVal handle As Short) As Integer
Declare Function pl1000GetUnitInfo Lib "pl1000.dll" (ByVal handle As Short, ByVal S As String, ByVal lth As Short, ByRef requiredSize As Short, ByVal info As Short) As Short
Declare Function pl1000SetTrigger Lib "pl1000.dll" (ByVal handle As Short, ByVal enabled As Short, ByVal enable_auto As Short, ByVal auto_ms As Short, ByVal channel As Short, ByVal dir As Short, ByVal threshold As Short, ByVal hysterisis As Short, ByVal delay As Single) As Short
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 values As Short, ByVal no_of_values As Integer, ByVal overflow As Short, ByVal triggerIndex As Integer) As Integer
Declare Function pl1000Run Lib "pl1000.dll" (ByVal handle As Short, ByVal no_of_values As Integer, ByVal method As Short) As Short
Declare Function pl1000Ready Lib "pl1000.dll" (ByVal handle As Short, ByRef ready As Short) As Integer
Declare Function pl1000MaxValue Lib "pl1000.dll" (ByVal handle As Short, ByRef maxValue As Short) As Integer
Dim MAXVALUE As Integer = 4096 ' module level
And here is the code:
Sub GetPl1000()
Dim msg As String
Dim us_for_block As Long
Dim triggerIndex As Long
Dim overflow As Integer
Dim status As Long
Dim handle As Integer
Dim values(200) As Integer
Dim channels(16) As Integer
Dim nValues As Long
Dim ready As Integer
' Open device
status = pl1000OpenUnit(handle)
If status <> 0 Then
MsgBox("Bad OpenUnit Call " & status)
Exit Sub
End If
' test for a valid handle
If handle = 0 Then
MsgBox("Invalid Handle " & status)
Exit Sub
End If
'Get the maximum ADC value for this variant
status = pl1000MaxValue(handle, MAXVALUE)
If status <> 0 Then
MsgBox("Bad MaxVal Call " & status)
Exit Sub
End If
' No Trigger
status = pl1000SetTrigger(handle, False, 0, 0, 0, 0, 0, 0, 0)
If status <> 0 Then
MsgBox("Bad SetTrigger Call " & status)
Exit Sub
End If
' define time window, number of samples and channel we wish to use
us_for_block = 1000
nValues = 100
channels(0) = 1
channels(1) = 2
status = pl1000SetInterval(handle, us_for_block, nValues, channels(0), 2)
If status <> 0 Then ' !!!!status returns 16 !!!!!!!!
MsgBox("Bad SetInterval Call " & status)
Exit Sub
End If
status = pl1000Run(handle, nValues, 0)
If status <> 0 Then
MsgBox("Bad Run Call " & status)
Exit Sub
End If
ready = 0
Do While ready = 0
status = pl1000Ready(handle, ready)
Loop
' Get a block of 100 readings...
status = pl1000GetValues(handle, values(0), nValues, overflow, triggerIndex)
If status <> 0 Then
MsgBox("Bad GetValues Call " & status)
Exit Sub
End If
' Copy the data into a string
For i = 0 To nValues - 1
msg = msg & "," & adc_to_mv(values(2 * i))
Next i
' Close the unit when finished to drop the driver
Call pl1000CloseUnit(handle)
MsgBox(msg)
End Sub
Code: Select all
pl1000SetInterval
PICO_STATUS pl1000SetInterval(
short handle,
unsigned long * us_for_block,
unsigned long ideal_no_of_samples,
short * channels,
short no_of_channels
)
Code: Select all
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
Code: Select all
Dim msg As String
Dim us_for_block As Long
Dim triggerIndex As Long
Dim overflow As Integer
Dim status As Long
Dim handle As Integer
Dim values(200) As Integer
Dim channels(16) As Integer
Dim nValues As Long
Dim ready As Integer
Code: Select all
status = pl1000SetInterval(handle, us_for_block, nValues, channels(0), 2)
Code: Select all
Declare Function pl1000OpenUnit Lib "pl1000.dll" (ByRef handle As Short) As Short
Declare Function pl1000CloseUnit Lib "pl1000.dll" (ByVal handle As Short) As Short
Declare Function pl1000GetUnitInfo Lib "pl1000.dll" (ByVal handle As Short, ByVal S As String, ByVal lth As Short, ByRef requiredSize As Short, ByVal info As Short) As Short
Declare Function pl1000SetTrigger Lib "pl1000.dll" (ByVal handle As Short, ByVal enabled As Short, ByVal enable_auto As Short, ByVal auto_ms As Short, ByVal channel As Short, ByVal dir As Short, ByVal threshold As Short, ByVal hysterisis As Short, ByVal delay As Single) As Short
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 Short
Declare Function pl1000GetValues Lib "pl1000.dll" (ByVal handle As Short, ByRef values As Short, ByRef no_of_values As Integer, ByRef overflow As Short, ByRef triggerIndex As Integer) As Short
Declare Function pl1000Run Lib "pl1000.dll" (ByVal handle As Short, ByVal no_of_values As Integer, ByVal method As Short) As Short
Declare Function pl1000Ready Lib "pl1000.dll" (ByVal handle As Short, ByRef ready As Short) As Short
Declare Function pl1000MaxValue Lib "pl1000.dll" (ByVal handle As Short, ByRef maxValue As Short) As Short
Sub GetPl1000()
Dim msg As String
Dim us_for_block As Integer 'integerLong
Dim triggerIndex As Integer
Dim overflow As Short
Dim status As Short
Dim handle As Integer
Dim values(200) As Short
Dim channels(16) As Short
Dim nValues As Integer
Dim ready As Integer
' Open device
status = pl1000OpenUnit(handle)
If status <> 0 Then
MsgBox("Bad OpenUnit Call " & status)
Exit Sub
End If
' test for a valid handle
If handle = 0 Then
MsgBox("Invalid Handle " & status)
Exit Sub
End If
'Get the maximum ADC value for this variant
status = pl1000MaxValue(handle, MAXVALUE)
If status <> 0 Then
MsgBox("Bad MaxVal Call " & status)
Exit Sub
End If
' No Trigger
status = pl1000SetTrigger(handle, False, 0, 0, 0, 0, 0, 0, 0)
If status <> 0 Then
MsgBox("Bad SetTrigger Call " & status)
Exit Sub
End If
' define time window, number of samples and channel we wish to use
us_for_block = 1000
nValues = 100
channels(0) = 1
channels(1) = 2
status = pl1000SetInterval(handle, us_for_block, nValues, channels(0), 2)
If status <> 0 Then
MsgBox("Bad SetInterval Call " & status)
Exit Sub
End If
status = pl1000Run(handle, nValues, 0)
If status <> 0 Then
MsgBox("Bad Run Call " & status)
Exit Sub
End If
ready = 0
Do While ready = 0
status = pl1000Ready(handle, ready)
Loop
' Get a block of 100 readings...
status = pl1000GetValues(handle, values(0), nValues, overflow, triggerIndex)
If status <> 0 Then
MsgBox("Bad GetValues Call " & status)
Exit Sub
End If
' Copy the data into a string
For i = 0 To nValues - 1
msg = msg & "," & adc_to_mv(values(2 * i))
Next i
' Close the unit when finished to drop the driver
Call pl1000CloseUnit(handle)
MsgBox(msg)
End Sub