PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
******************************************************************************************
Dim handle As Short
Dim status As UInteger
Dim numPreTriggerSamples As Integer
Dim numPostTriggerSamples As Integer
Dim timeIntervalNs As Single
Dim maxSamples As Integer
Dim segmentIndex As UInteger
Dim getTimebase2Status As UInteger
Dim delay As UInteger
Dim autoTriggerMs As Long
Dim Ch_Conditions As TriggerConditions
Dim Ch_prop(0) As TRIGGER_CHANNEL_PROPERTIES
handle = 0
ps5000aCloseUnit(handle)
status = ps5000aOpenUnit(handle, vbNullString, DeviceResolution.PS5000A_DR_12BIT)
deviceReady = False
timeBase = 7
numPreTriggerSamples = 20
numPostTriggerSamples = 200
totalSamples = numPreTriggerSamples + numPostTriggerSamples
timeIntervalNs = CSng(0.0)
maxSamples = 0
segmentIndex = 0
getTimebase2Status = 14 ' Initialise as invalid timebase
'
status = ps5000aMaximumValue(handle, maxADCValue) ' Find maximum ADC count (resolution dependent)
'getDeviceInfo(handle) 'Read and display the device information
'
'Setup CHannels A e B
status = ps5000aSetChannel(handle, Channel.PS5000A_CHANNEL_A, CShort(1), CouplingMode.PS5000A_DC, VoltageRange.PS5000A_10V, 0.0)
status = ps5000aSetBandwidthFilter(handle, Channel.PS5000A_CHANNEL_A, BandwidthLimiter.PS5000A_BW_20MHZ)
status = ps5000aSetChannel(handle, Channel.PS5000A_CHANNEL_B, CShort(1), CouplingMode.PS5000A_DC, VoltageRange.PS5000A_20V, 0.0)
status = ps5000aSetBandwidthFilter(handle, Channel.PS5000A_CHANNEL_B, BandwidthLimiter.PS5000A_BW_20MHZ)
'
'Trun Off Channels C e D
status = ps5000aSetChannel(handle, Channel.PS5000A_CHANNEL_C, CShort(0), CouplingMode.PS5000A_DC, VoltageRange.PS5000A_1V, 0.0)
status = ps5000aSetChannel(handle, Channel.PS5000A_CHANNEL_D, CShort(0), CouplingMode.PS5000A_DC, VoltageRange.PS5000A_1V, 0.0)
'
Do Until getTimebase2Status = 0
getTimebase2Status = ps5000aGetTimebase2(handle, timeBase, totalSamples, timeIntervalNs, maxSamples, segmentIndex)
If getTimebase2Status <> 0 Then
timeBase = timeBase + 1
End If
Loop
'
delay = 0
autoTriggerMs = 2000
'
'stop triggering
status = ps5000aStop(handle)
'
'ThresholdDirection for Channels A,B,C,D,Ext,Aux
status = ps5000aSetTriggerChannelDirections(handle, ThresholdDirection2.PS5000A_RISING, ThresholdDirection2.PS5000A_NONE, ThresholdDirection2.PS5000A_NONE, ThresholdDirection2.PS5000A_NONE, ThresholdDirection2.PS5000A_NONE, ThresholdDirection2.PS5000A_NONE)
'
'Set Trigger Channels Conditions
Ch_Conditions.ChannelA = TriggerState.CONDITION_TRUE
Ch_Conditions.ChannelB = TriggerState.CONDITION_DONT_CARE
Ch_Conditions.ChannelC = TriggerState.CONDITION_DONT_CARE
Ch_Conditions.ChannelD = TriggerState.CONDITION_DONT_CARE
Ch_Conditions.Aux = TriggerState.CONDITION_DONT_CARE
Ch_Conditions.External = TriggerState.CONDITION_DONT_CARE
Ch_Conditions.pulseWidthQualifier = TriggerState.CONDITION_DONT_CARE
status = ps5000aSetTriggerChannelConditions(handle, Ch_Conditions, 1)
'
'Set Trigger Channels Properties
Ch_prop(0).Channel = Channel.PS5000A_CHANNEL_A
Ch_prop(0).thresholdLower = mvToAdc(0, VoltageRange.PS5000A_5V)
Ch_prop(0).thresholdLowerHysteresis = 256
Ch_prop(0).thresholdUpper = mvToAdc(0, VoltageRange.PS5000A_5V)
Ch_prop(0).thresholdUpperHysteresis = 256
Ch_prop(0).thresholdMode = ThresholdMode.WINDOW
status = ps5000aSetTriggerChannelProperties(handle, Ch_prop(0), 1, 0, autoTriggerMs)
'
status = ps5000aMemorySegments(handle, 5, totalSamples)
status = ps5000aSetNoOfCaptures(handle, 5)
' Create instance of delegate
ps5000aBlockCallback = New ps5000aBlockReady(AddressOf BlockCallback)
'
Dim timeIndisposedMs As Integer = 0
' Capture block
status = ps5000aRunBlock(handle, numPreTriggerSamples, numPostTriggerSamples, timeBase, timeIndisposedMs, segmentIndex, ps5000aBlockCallback, IntPtr.Zero)
'
While deviceReady = False
Me.Refresh()
End While
' Stop the device
status = ps5000aStop(handle)
******************************************************************************************