PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
Declare Function ps4000aMemorySegments Lib "ps4000a.dll" (ByVal handle As Integer, ByVal nSegments As Integer, ByVal nMaxSamples As Long) As Integer
Code: Select all
Call ps4000aMemorySegments(handle, 1, maxSamples)
Code: Select all
Declare Function ps4000aMemorySegments Lib "ps4000a.dll" (ByVal handle As Integer, ByVal nSegments As Long, ByRef nMaxSamples As Long) As Long
Code: Select all
Declare Function ps4000aOpenUnit Lib "ps4000a.dll" (handle As Integer, ByVal serial As Byte) As Integer
Declare Sub ps4000aCloseUnit Lib "ps4000a.dll" (ByVal handle As Integer)
Declare Function ps4000aChangePowerSource Lib "ps4000a.dll" (ByVal handle As Integer, ByVal status As Integer) As Integer
Declare Function ps4000aGetUnitInfo Lib "ps4000a.dll" (ByVal handle As Integer, ByVal str As String, ByVal lth As Integer, requiredSize As Integer, ByVal info As Integer) As Integer
Declare Function ps4000aSetChannel Lib "ps4000a.dll" (ByVal handle As Integer, ByVal channel As Integer, ByVal enabled As Integer, ByVal dc As Integer, ByVal range As Integer, ByVal analogEffset As Single) As Integer
Declare Function ps4000aSetSimpleTrigger Lib "ps4000a.dll" (ByVal handle As Integer, ByVal enable As Integer, ByVal source As Integer, ByVal threshold As Integer, ByVal direction As Integer, ByVal delay As Long, ByVal autotrigger As Integer) As Integer
Declare Function ps4000aGetTimebase Lib "ps4000a.dll" (ByVal handle As Integer, ByVal timebase As Long, ByVal noSamples As Long, timeIntervalNanoseconds As Long, maxSamples As Long, ByVal segment As Integer) As Integer
Declare Function ps4000aSetDataBuffer Lib "ps4000a.dll" (ByVal handle As Integer, ByVal channel As Integer, buffer As Integer, ByVal length As Long, ByVal segmentIndex As Long, ByVal ratiomode As Integer) As Integer
Declare Function ps4000aGetValues Lib "ps4000a.dll" (ByVal handle As Integer, ByVal startIndex As Long, numSamples As Long, ByVal downSampleRatio As Long, ByVal downsampleRatioMode As Integer, ByVal segmentIndex As Integer, overflow As Integer) As Integer
Declare Function ps4000aGetValuesBulk Lib "ps4000a.dll" (ByVal handle As Integer, numSamples As Long, ByVal startIndex As Long, ByVal endIndex As Long, ByVal downSampleRatio As Long, ByVal downsampleRatioMode As Integer, overflow As Integer) As Integer
Declare Function ps4000aStop Lib "ps4000a.dll" (ByVal handle As Integer) As Integer
Declare Function RunBlock Lib "ps4000aWrap.dll" (ByVal handle As Integer, ByVal noPreTriggerSamples As Long, ByVal noPostTriggerSamples As Long, ByVal timebase As Long, ByVal segmentIndex As Integer) As Integer
Declare Function IsReady Lib "ps4000aWrap.dll" (ByVal handle As Integer) As Integer
Declare Function ps4000aSetBandwidthFilter Lib "ps4000a.dll" (ByVal handle As Integer, ByVal channel As Integer, ByVal bandwidth As Integer) As Long
Declare Function ps4000aMemorySegments Lib "ps4000a.dll" (ByVal handle As Integer, ByVal nSegments As Long, ByRef nMaxSamples As Long) As Long
Declare Function ps4000aSetNoOfCaptures Lib "ps4000a.dll" (ByVal handle As Integer, ByVal nCaptures As Integer) As Long
Declare Sub Sleep Lib "kernel32.dll" (ByVal time As Long)
Dim handle As Integer
Dim status As Integer
Dim str As String * 255
Dim serial As String * 255
Sub GetData()
Dim overflow As Integer
Dim maxSamples As Long
Dim timeInterval As Long
Dim required As Integer
Dim timebase As Integer
Dim threshold As Integer
handle = 0
serial = ""
status = ps4000aOpenUnit(handle, 0)
If handle = 0 Then
MsgBox "Unit not opened", vbOKOnly, "Error Message"
Exit Sub
End If
If status = 286 Then
status = ps4000aChangePowerSource(handle, status)
End If
' Set Channels
Call ps4000aSetChannel(handle, 0, 1, 1, 11, 0)
Call ps4000aSetChannel(handle, 1, 1, 1, 11, 0)
Call ps4000aSetChannel(handle, 2, 1, 1, 11, 0)
Call ps4000aSetChannel(handle, 3, 1, 1, 11, 0)
Call ps4000aSetChannel(handle, 4, 1, 1, 11, 0)
Call ps4000aSetChannel(handle, 5, 1, 1, 11, 0)
Call ps4000aSetChannel(handle, 6, 0, 1, 10, 0)
Call ps4000aSetChannel(handle, 7, 0, 1, 10, 0)
timebase = 799
numSamples = 5000
ReDim valuesChA(numSamples - 1) As Integer
ReDim valuesChB(numSamples - 1) As Integer
ReDim valuesChC(numSamples - 1) As Integer
ReDim valuesChD(numSamples - 1) As Integer
ReDim valuesChE(numSamples - 1) As Integer
ReDim valuesChF(numSamples - 1) As Integer
status = ps4000aGetTimebase(handle, timebase, numSamples, timeInterval, maxSamples, 0)
Call ps4000aMemorySegments(handle, 6, maxSamples)
Call ps4000aSetNoOfCaptures(handle, 1)
Call ps4000aSetDataBuffer(handle, 0, valuesChA(0), numSamples, 0, 0)
Call ps4000aSetDataBuffer(handle, 1, valuesChB(0), numSamples, 0, 0)
Call ps4000aSetDataBuffer(handle, 2, valuesChC(0), numSamples, 0, 0)
Call ps4000aSetDataBuffer(handle, 3, valuesChD(0), numSamples, 0, 0)
Call ps4000aSetDataBuffer(handle, 4, valuesChE(0), numSamples, 0, 0)
Call ps4000aSetDataBuffer(handle, 5, valuesChF(0), numSamples, 0, 0)
pParameter = False
Call ps4000aSetBandwidthFilter(handle, 0, 1000)
Call ps4000aSetBandwidthFilter(handle, 1, 1000)
Call ps4000aSetBandwidthFilter(handle, 2, 1000)
Call ps4000aSetBandwidthFilter(handle, 3, 1000)
Call ps4000aSetBandwidthFilter(handle, 4, 1000)
Call ps4000aSetBandwidthFilter(handle, 5, 1000)
Call ps4000aSetBandwidthFilter(handle, 6, 1000)
Call ps4000aSetBandwidthFilter(handle, 7, 1000)
threshold = (32767 * (1000 / 2000))
Call ps4000aSetSimpleTrigger(handle, 0, 0, threshold, 0, 0, 0)
status = RunBlock(handle, 0, numSamples, timebase, 0)
While IsReady(handle) = 0
Sleep (5)
Wend
Call ps4000aStop(handle)
overflow = 0
status = ps4000aGetValues(handle, 0, numSamples, 0, 0, 0, overflow)
For i = 0 To (numSamples - 1)
Cells(i + 5, "A").Value = (timeInterval * i) * 0.000001
Cells(i + 5, "B").Value = ConvertADCToMv(valuesChA(i), 32767, 50)
Cells(i + 5, "C").Value = ConvertADCToMv(valuesChB(i), 32767, 50)
Cells(i + 5, "D").Value = ConvertADCToMv(valuesChC(i), 32767, 50)
Cells(i + 5, "E").Value = ConvertADCToMv(valuesChD(i), 32767, 50)
Cells(i + 5, "F").Value = ConvertADCToMv(valuesChE(i), 32767, 50)
Cells(i + 5, "G").Value = ConvertADCToMv(valuesChF(i), 32767, 50)
Next i
ps4000aCloseUnit (handle)
Sheets("Pivot Sheet (unscaled data)").Select
ActiveSheet.PivotTables("PivotTable2").RefreshTable
Sheets("Pivot Sheet (scaled data)").Select
ActiveSheet.PivotTables("PivotTable1").RefreshTable
Sheets("Instantaneous Power").Select
ActiveSheet.PivotTables("PivotTable2").RefreshTable
End Sub
Function ConvertADCToMv(ByVal adcCount As Integer, ByVal maxADCCount As Integer, ByVal voltageRange As Integer) As Single
ConvertADCToMv = (adcCount / maxADCCount) * voltageRange
End Function
Code: Select all
Declare Function ps4000aOpenUnit Lib "ps4000a.dll" (handle As Integer, ByVal serial As Byte) As Long
Declare Sub ps4000aCloseUnit Lib "ps4000a.dll" (ByVal handle As Integer)
Declare Function ps4000aChangePowerSource Lib "ps4000a.dll" (ByVal handle As Integer, ByVal status As Long) As Long
Declare Function ps4000aGetUnitInfo Lib "ps4000a.dll" (ByVal handle As Integer, ByVal str As String, ByVal lth As Integer, ByRef requiredSize As Integer, ByVal info As Long) As Long
Declare Function ps4000aSetChannel Lib "ps4000a.dll" (ByVal handle As Integer, ByVal channel As Long, ByVal enabled As Integer, ByVal dc As Long, ByVal range As Long, ByVal analogOffset As Single) As Long
Declare Function ps4000aSetSimpleTrigger Lib "ps4000a.dll" (ByVal handle As Integer, ByVal enable As Integer, ByVal source As Long, ByVal threshold As Integer, ByVal direction As Long, ByVal delay As Long, ByVal autotrigger As Integer) As Long
Declare Function ps4000aGetTimebase Lib "ps4000a.dll" (ByVal handle As Integer, ByVal timebase As Long, ByVal noSamples As Long, ByRef timeIntervalNanoseconds As Long, ByRef maxSamples As Long, ByVal segmentIndex As Long) As Long
Declare Function ps4000aSetDataBuffer Lib "ps4000a.dll" (ByVal handle As Integer, ByVal channel As Long, ByRef buffer As Integer, ByVal length As Long, ByVal segmentIndex As Long, ByVal ratioMode As Long) As Long
Declare Function ps4000aGetValues Lib "ps4000a.dll" (ByVal handle As Integer, ByVal startIndex As Long, ByRef numSamples As Long, ByVal downSampleRatio As Long, ByVal downsampleRatioMode As Long, ByVal segmentIndex As Long, ByRef overflow As Integer) As Long
Declare Function ps4000aStop Lib "ps4000a.dll" (ByVal handle As Integer) As Long
Declare Function ps4000aMaximumValue Lib "ps4000a.dll" (ByVal handle As Integer, ByRef value As Integer) As Long
Declare Function RunBlock Lib "ps4000aWrap.dll" (ByVal handle As Integer, ByVal noPreTriggerSamples As Long, ByVal noPostTriggerSamples As Long, ByVal timebase As Long, ByVal segmentIndex As Long) As Long
Declare Function IsReady Lib "ps4000aWrap.dll" (ByVal handle As Integer) As Integer