PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
'
' Macro1 Macro
' Macro recorded 07/08/03 by MAS
'
'
Declare Function ps3000_open_unit Lib "ps3000.dll" () As Integer
Declare Function ps3000_set_unit Lib "ps3000.dll" (ByVal handle 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 handle As Integer)
Declare Function ps3000_get_unit_info Lib "ps3000.dll" (ByVal handle As Integer, ByVal str As String, ByVal lth As Integer, ByVal line_no As Integer) As Integer
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 Integer, ByVal channel As Integer, ByVal enabled As Integer, ByVal dc As Integer, ByVal range As Integer) As Integer
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 Integer, ByVal timebase As Integer, ByVal no_of_samples As Long, time_interval As Long, time_units As Integer, ByVal oversample As Integer, max_samples As Long) As Integer
Declare Function ps3000_run_block Lib "ps3000.dll" (ByVal handle As Integer, ByVal no_of_values As Long, ByVal timebase As Integer, ByVal oversample As Integer, time_indisposed_ms As Long) As Integer
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_ready Lib "ps3000.dll" (ByVal handle As Integer) As Integer
Declare Function ps3000_get_values Lib "ps3000.dll" (ByVal handle As Integer, buffer_a As Integer, buffer_b As Integer, buffer_c As Integer, buffer_d As Integer, overflow As Integer, ByVal no_of_values As Long) As Long
Declare Function ps3000_get_times_and_values Lib "ps3000.dll" (ByVal handle As Integer, times As Long, buffer_a As Integer, buffer_b As Integer, buffer_c As Integer, buffer_d As Integer, 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
Dim timebase As Integer
Dim no_of_samples As Long
Dim time_interval As Long
Dim time_units As Integer
Dim oversample As Integer
Dim time_indisposed_ms As Long
Dim S As String * 255
Dim ps3000_handle As Integer
Dim mv As Integer
Sub GetData()
ReDim values_a(100) As Integer
ReDim values_b(100) As Integer
ReDim values_c(100) As Integer
ReDim values_d(100) As Integer
ReDim times(100) As Long
Dim overflow As Integer
Dim max_samples As Long
ps3000_handle = ps3000_open_unit()
If ps3000_handle = 0 Then
MsgBox "Unit not opened", vbOKOnly, "Error Message"
Exit Sub
End If
For i = 0 To 5 Step 1
j = ps3000_get_unit_info(ps3000_handle, S, 255, i)
Cells(18 + i, "E").Value = S
Next i
Call ps3000_set_ets(ps3000_handle, 0, 0, 0)
Call ps3000_set_channel(ps3000_handle, 0, 1, 0, 10)
Call ps3000_set_channel(ps3000_handle, 1, 1, 0, 10)
Cells(17, "E").Value = "PS3000 opened"
'Trigger disabled
Call ps3000_set_trigger(ps3000_handle, 5, 0, 0, 0, 0)
'find the maximum number of samples, the time interval (in time_units),
'the most suitable time units, and the maximum oversample at the current timebase
timebase = 13
no_of_samples = 100
ok = ps3000_get_timebase(ps3000_handle, _
timebase, _
no_of_samples, _
time_interval, _
time_units, _
oversample, _
max_samples)
' Start it collecting,
' then wait for completion
Call ps3000_run_block(ps3000_handle, no_of_samples, timebase, oversample, time_indisposed_ms)
While ps3000_ready(ps3000_handle) = 0
Wend
ps3000_stop (ps3000_handle)
'Should be done now...
'get the times (in nanoseconds)
'and the values (in ADC counts)
Call ps3000_get_times_and_values(ps3000_handle, times(0), values_a(0), values_b(0), values_c(0), values_d(0), overflow, time_units, no_of_samples)
For i = 0 To 99
Cells(i + 4, "A").Value = times(i)
Cells(i + 4, "B").Value = values_b(i)
Cells(i + 4, "C").Value = (values_b(i) / 32767) * 20000
Next i
Call ps3000_close_unit(ps3000_handle)
End Sub
Sub StreamingData()
ReDim values_a(100) As Integer
ReDim values_b(100) As Integer
ReDim values_c(100) As Integer
ReDim values_d(100) As Integer
ReDim times(100) As Long
Dim no As Long
Dim overflow As Integer
Dim counter As Integer
ps3000_handle = ps3000_open_unit(1)
If ps3000_handle = 0 Then
MsgBox "Unit not opened", vbOKOnly, "Error Message"
Exit Sub
End If
Call ps3000_set_ets(ps3000_handle, 0, 0, 0)
Call ps3000_set_channel(ps3000_handle, 0, 0, 0, 10)
Call ps3000_set_channel(ps3000_handle, 1, 1, 0, 10)
Cells(17, "E").Value = "PS3000 opened"
'Trigger disabled
Call ps3000_set_trigger(ps3000_handle, 5, 0, 0, 0, 0)
'find the maximum number of samples, the time interval (in time_units),
'the most suitable time units, and the maximum oversample at the current timebase
'timebase = 13
no_of_samples = 100
ok = ps3000_run_streaming(ps3000_handle, 10, no_of_samples, 0)
counter = 0
'the values (in ADC counts)
no = ps3000_get_values(ps3000_handle, values_a(0), values_b(0), values_c(0), values_d(0), overflow, no_of_samples)
For i = 0 To (no - 1)
Cells(counter + i + 4, "B").Value = values_b(i)
Cells(counter + i + 4, "C").Value = (values_b(i) / 32767) * 20000
Next i
If counter > 1000 Then
counter = 0
Else
counter = counter + i
End If
Call ps3000_close_unit(ps3000_handle)
End Sub
Code: Select all
'
' Macro1 Macro
' Macro recorded 07/08/03 by MAS
'
'
Declare Function ps3000_open_unit Lib "ps3000.dll" () As Integer
Declare Function ps3000_set_unit Lib "ps3000.dll" (ByVal handle 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 handle As Integer)
Declare Function ps3000_get_unit_info Lib "ps3000.dll" (ByVal handle As Integer, ByVal str As String, ByVal lth As Integer, ByVal line_no As Integer) As Integer
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 Integer, ByVal channel As Integer, ByVal enabled As Integer, ByVal dc As Integer, ByVal range As Integer) As Integer
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 Integer, ByVal timebase As Integer, ByVal no_of_samples As Long, time_interval As Long, time_units As Integer, ByVal oversample As Integer, max_samples As Long) As Integer
Declare Function ps3000_run_block Lib "ps3000.dll" (ByVal handle As Integer, ByVal no_of_values As Long, ByVal timebase As Integer, ByVal oversample As Integer, time_indisposed_ms As Long) As Integer
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_ready Lib "ps3000.dll" (ByVal handle As Integer) As Integer
Declare Function ps3000_get_values Lib "ps3000.dll" (ByVal handle As Integer, buffer_a As Integer, buffer_b As Integer, buffer_c As Integer, buffer_d As Integer, overflow As Integer, ByVal no_of_values As Long) As Long
Declare Function ps3000_get_times_and_values Lib "ps3000.dll" (ByVal handle As Integer, times As Long, buffer_a As Integer, buffer_b As Integer, buffer_c As Integer, buffer_d As Integer, 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
Dim timebase As Integer
Dim no_of_samples As Long
Dim time_interval As Long
Dim time_units As Integer
Dim oversample As Integer
Dim time_indisposed_ms As Long
Dim S As String * 255
Dim ps3000_handle As Integer
Dim mv As Integer
Sub GetData()
ReDim values_a(100) As Integer
ReDim values_b(100) As Integer
ReDim values_c(100) As Integer
ReDim values_d(100) As Integer
ReDim times(100) As Long
Dim overflow As Integer
Dim max_samples As Long
ps3000_handle = ps3000_open_unit()
If ps3000_handle = 0 Then
MsgBox "Unit not opened", vbOKOnly, "Error Message"
Exit Sub
End If
For i = 0 To 5 Step 1
j = ps3000_get_unit_info(ps3000_handle, S, 255, i)
Cells(18 + i, "E").Value = S
Next i
Call ps3000_set_ets(ps3000_handle, 0, 0, 0)
Call ps3000_set_channel(ps3000_handle, 0, 1, 0, 10)
Call ps3000_set_channel(ps3000_handle, 1, 1, 0, 10)
Cells(17, "E").Value = "PS3000 opened"
'Trigger disabled
Call ps3000_set_trigger(ps3000_handle, 5, 0, 0, 0, 0)
'find the maximum number of samples, the time interval (in time_units),
'the most suitable time units, and the maximum oversample at the current timebase
timebase = 13
no_of_samples = 100
ok = ps3000_get_timebase(ps3000_handle, _
timebase, _
no_of_samples, _
time_interval, _
time_units, _
oversample, _
max_samples)
' Start it collecting,
' then wait for completion
Call ps3000_run_block(ps3000_handle, no_of_samples, timebase, oversample, time_indisposed_ms)
While ps3000_ready(ps3000_handle) = 0
Wend
ps3000_stop (ps3000_handle)
'Should be done now...
'get the times (in nanoseconds)
'and the values (in ADC counts)
Call ps3000_get_times_and_values(ps3000_handle, times(0), values_a(0), values_b(0), values_c(0), values_d(0), overflow, time_units, no_of_samples)
For i = 0 To 99
Cells(i + 4, "A").Value = times(i)
Cells(i + 4, "B").Value = values_b(i)
Cells(i + 4, "C").Value = (values_b(i) / 32767) * 20000
Next i
Call ps3000_close_unit(ps3000_handle)
End Sub
Sub StreamingData()
ReDim values_a(100) As Integer
ReDim values_b(100) As Integer
ReDim values_c(100) As Integer
ReDim values_d(100) As Integer
ReDim times(100) As Long
Dim no As Long
Dim overflow As Integer
Dim counter As Integer
ps3000_handle = ps3000_open_unit(1)
If ps3000_handle = 0 Then
MsgBox "Unit not opened", vbOKOnly, "Error Message"
Exit Sub
End If
Call ps3000_set_ets(ps3000_handle, 0, 0, 0)
Call ps3000_set_channel(ps3000_handle, 0, 0, 0, 10)
Call ps3000_set_channel(ps3000_handle, 1, 1, 0, 10)
Cells(17, "E").Value = "PS3000 opened"
'Trigger disabled
Call ps3000_set_trigger(ps3000_handle, 5, 0, 0, 0, 0)
'find the maximum number of samples, the time interval (in time_units),
'the most suitable time units, and the maximum oversample at the current timebase
'timebase = 13
no_of_samples = 100
ok = ps3000_run_streaming(ps3000_handle, 10, no_of_samples, 0)
counter = 0
'the values (in ADC counts)
no = ps3000_get_values(ps3000_handle, values_a(0), values_b(0), values_c(0), values_d(0), overflow, no_of_samples)
For i = 0 To (no - 1)
Cells(counter + i + 4, "B").Value = values_b(i)
Cells(counter + i + 4, "C").Value = (values_b(i) / 32767) * 20000
Next i
If counter > 1000 Then
counter = 0
Else
counter = counter + i
End If
Call ps3000_close_unit(ps3000_handle)
End Sub