PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Open Adc11 on USB
'1 Check that the driver(optional)
'2 Open the unit
'3 Set trigger mode (optional)
'4 Set sampling mode
'5: .Run()
'6.Wait until ready
'7: .Get(values)
'8.Close the unit
opened = UsbAdc11OpenUnit() ' Open unit
If opened <> 0 Then
MsgBox("OK")
UsbAdc11SetInterval(opened, 1000000, 1, 7, 1) 'Set Sampling mode
UsbAdc11Run(opened, 1, 0) ' Run()
Do While Ready = 0
Ready = UsbAdc11Ready(opened) '<----- doesnt work
Loop
Dim reading As Integer
ok = UsbAdc11GetValue(opened, 7, reading) ' GetValue
TextBox1.Text = TextBox1.Text & "------>" & reading
Call UsbAdc11CloseUnit(opened) ' Close unit
Else
MsgBox("Unable to open ADC ")
End If
End Sub
Code: Select all
Module Module1
Declare Sub pl1000OpenUnit Lib "pl1000.dll" (ByVal handle As Integer)
Declare Function pl1000SetInterval Lib "pl1000.dll" (ByVal handle As Integer, ByVal us_for_block As Long, ByVal ideal_no_of_samples As Long, ByVal channels As Integer, ByVal No_of_channels As Integer) As Long
Code: Select all
pl1000OpenUnit(Open)
Value = pl1000SetInterval(Open, 1000000, 1, 7, 1)
MsgBox(Value)
Code: Select all
Module Module1
Declare Function pl1000OpenUnit Lib "pl1000.dll" (ByRef handle As Short) As Integer
Declare Function pl1000CloseUnit Lib "pl1000.dll" (ByRef handle As Short) As Integer
Declare Function pl1000GetUnitInfo Lib "pl1000.dll" (ByRef 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" (ByRef 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" (ByRef handle As Short, ByRef us_for_block As Integer, ByVal ideal_no_of_samples As Integer, ByVal channels As Short, ByVal No_of_channels As Short) As Integer
Declare Function pl1000GetValues Lib "pl1000.dll" (ByRef 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" (ByRef 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, ByVal ready As Short) As Integer
Declare Function pl1000MaxValue Lib "pl1000.dll" (ByVal handle As Short, ByRef maxValue As Short) As Integer
End Module
Code: Select all
Public Class Form1
Dim status As Integer
Dim handled As Short
Dim opened As Short
Dim values(200) As Short
Dim channels(22) As Short
Dim nValues As Integer
Dim ok As Short
Private ready As Short
Dim requiredSize As Short
Dim s As String 'in VB6 it was string*255
Public port As Short
Public product As Short
Dim maxValue As Short
Dim Slenght As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Open device
status = pl1000OpenUnit(handled)
opened = handled <> 0
If opened Then
status = pl1000MaxValue(handled, maxValue)
' Slenght = pl1000GetUnitInfo(handled, s, 255, requiredSize, 3)
Call pl1000SetTrigger(handled, False, 0, 0, 0, 0, 0, 0, 0)
nValues = 100
channels(0) = 1
channels(1) = 2
Dim sampleInterval As Integer
Dim us_for_block As Integer
us_for_block = 1000000
status = pl1000SetInterval(handled, us_for_block, nValues, channels(0), 2)
status = pl1000Run(handled, nValues, 0)
ready = 0
Do While ready = 0
status = pl1000Ready(handled, ready)
Loop
MsgBox("ok")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
pl1000CloseUnit(handled)
End Sub
End Class
Code: Select all
ready = 0
Do While ready = 0
status = pl1000Ready(handled, ready)
Loop
Code: Select all
Declare Function pl1000OpenUnit Lib "pl1000.dll" (ByRef handle As Integer) As Long
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
This declarations must be changed in "Byval" otherwhise i get an "Accessviolation exceptions.."
Declare Function pl1000SetInterval Lib "pl1000.dll" (ByVal handle As Integer, ByRef us_for_block As Long, ByVal ideal_no_of_samples As Long, channels As Integer, ByVal No_of_channels As Integer) As Long
Declare Function pl1000GetValues Lib "pl1000.dll" (ByVal handle As Integer, values As Integer, no_of_values As Long, overflow As Integer, triggerIndex As Long) As Long
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 Long
Declare Function pl1000MaxValue Lib "pl1000.dll" (ByVal handle As Integer, ByRef maxValue As Integer) As Long
Dim status As Long
Dim handle As Integer
Dim values(200) As Integer
Dim channels(22) As Integer
Dim nValues As Long
Dim ok As Integer
Dim ready As Integer
Dim requiredSize As Integer
Dim S As String * 255
Public port As Integer
Public product As Integer
Dim maxValue As Integer
Function adc_to_mv(value As Integer) As Integer
adc_to_mv = value / maxValue * 2500
End Function
Sub GetPl1000()
' 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
Cells(6, "E").value = "Unit opened"
SLegnth = pl1000GetUnitInfo(handle, S, 255, requiredSize, 3)
Cells(7, "E").value = S
SLegnth = pl1000GetUnitInfo(handle, S, 255, requiredSize, 4)
Cells(8, "E").value = S
SLegnth = pl1000GetUnitInfo(handle, S, 255, requiredSize, 1)
Cells(9, "E").value = S
' No Trigger
Call pl1000SetTrigger(handle, False, 0, 0, 0, 0, 0, 0, 0)
' Say that we want to take 100 readings in 1 s
' from channels 1 and 2
nValues = 100
channels(0) = 1
channels(1) = 2
Dim sampleInterval As Long
Dim us_for_block As Long
us_for_block = 1000000
status = pl1000SetInterval(handle, us_for_block, nValues, channels(0), 2)
status = pl1000Run(handle, nValues, 0)
ready = 0
Do While ready = 0
status = pl1000Ready(handle, ready)
Loop
' Get a block of 100 readings...
' we can call this routine repeatedly
' to get more blocks with the same settings
Dim triggerIndex As Long
Dim overflow As Integer
status = pl1000GetValues(handle, values(0), nValues, overflow, triggerIndex)
' Copy the data into the spreadsheet
For i = 0 To nValues - 1
Cells(i + 4, "A").value = adc_to_mv(values(2 * i))
Cells(i + 4, "B").value = adc_to_mv(values(2 * i + 1))
Next i
' Close the unit when finished to drop the driver
Call pl1000CloseUnit(handle)
Else
Cells(17, "E").value = "Unable to open unit"
End If
End Sub
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