PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
#Generate our waveform
repPeriod = 0.6667e-3
wf_Ratio = burstPeriod/repPeriod
totalLength = 2**15
burstLength = int(wf_Ratio * totalLength)
totalLength - burstLength
#make our pulse like square wave.
waveform = [32767 if x < burstLength else 0 for x in range(totalLength)]
#Get the phase value:
phase = ctypes.c_uint32()
ps.ps5000aSigGenFrequencyToPhase(scope, 1500.0, 0, len(waveform), ctypes.byref(phase))
#Convert waveform to ctypes:
waveform_ctypes = ctypes.c_int16 * len(waveform)
waveform_ctypes.values = tuple(waveform)
#Try and produce the waveform
handle = scope
offsetVoltage = 1000000 #in uVolts
pkToPk = 2000000 #in uVolts
startDeltaPhase = phase
stopDeltaPhase = phase
deltaPhaseIncrement = 0
dwellCount = 0
arbitraryWaveform = ctypes.POINTER(waveform_ctypes)
arbitraryWaveformSize = len(waveform)
sweepType = 0
operation = 0
indexMode = 0
shots = 5
sweeps = 0
triggerType = 0
triggerSource = 4
extInThreshold = 0
ret = ps.ps5000aSetSigGenArbitrary(handle,\
offsetVoltage,\
pkToPk,\
startDeltaPhase,\
stopDeltaPhase,\
deltaPhaseIncrement,\
dwellCount,\
arbitraryWaveform,\
arbitraryWaveformSize,\
sweepType,\
operation,\
indexMode,\
shots,\
sweeps,\
triggerType,\
triggerSource,\
extInThreshold)
Code: Select all
ArgumentError: argument 8: type 'exceptions.TypeError': wrong type
Code: Select all
#'waveform' is just a list of values equivalent int16 values before this point
waveform = np.array(waveform, dtype=np.int16)
phase = ctypes.c_uint32()
#get the start & stop DeltaPhase values for the SetSig function.
ps.ps5000aSigGenFrequencyToPhase(scope, 1000, 0, len(waveform), ctypes.byref(phase))
offsetVoltage = 1000000 #in uVolts
pkToPk = 2 #in uVolts
startDeltaPhase = phase
stopDeltaPhase = phase
deltaPhaseIncrement = 0
dwellCount = 0
#########################################
## this is the magic line I was looking for
#########################################
arbitraryWaveform = waveform.ctypes.data_as(ctypes.POINTER(ctypes.c_int16))
arbitraryWaveformSize = len(waveform)
sweepType = 0
operation = 0
indexMode = 0
shots = ctypes.c_uint32(pulses)
sweeps = ctypes.c_uint32(0)
triggerType = 0
triggerSource = 4
extInThreshold = 0
ret = ps.ps5000aSetSigGenArbitrary(
self.handle,
offsetVoltage,
c_uint32(int(pkToPk * 1E6)),
startDeltaPhase,
stopDeltaPhase,
c_uint32(0),
c_uint32(0),
arbitraryWaveform,
c_int32(len(waveform)),
0,
0,
indexMode,
c_uint32(1200),
c_uint32(0),
triggerType,
triggerSource,
c_int16(0))