Skip to content

Commit 95832b8

Browse files
author
neil.hamilton
committed
update ps5000aSigGen.py with additional functions for arbitrary waveform
1 parent 5568bf8 commit 95832b8

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

ps5000aExamples/ps5000aSigGen.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,28 +121,43 @@
121121
time.sleep(36)
122122

123123
# create a custom waveform
124-
awgBuffer = np.sin(np.linspace(0,2*math.pi,1024))
124+
minValue = ctypes.c_int16(0)
125+
maxValue = ctypes.c_int16(0)
126+
minSize = ctypes.c_int16(0)
127+
maxSize = ctypes.c_int16(0)
128+
status["sigGenArbMinMax"] = ps.ps5000aSigGenArbitraryMinMaxValues(chandle, ctypes.byref(minValue), ctypes.byref(maxValue),ctypes.byref(minSize),ctypes.byref(maxSize))
129+
assert_pico_ok(status["sigGenArbMinMax"])
130+
131+
awgBuffer = (np.sin(np.linspace(0,2*math.pi,1024)))*maxValue.value
125132
awgbufferPointer = awgBuffer.ctypes.data_as(ctypes.POINTER(ctypes.c_int16))
126133

134+
# convert 10 KHZ frequency to phase
135+
freq = 10000
136+
indexMode = 0
137+
bufferLength = len(awgBuffer)
138+
phase = ctypes.c_int16(0)
139+
status["freqToPhase"] = ps.ps5000aSigGenFrequencyToPhase(chandle, freq, indexMode, bufferLength, ctypes.byref(phase))
140+
assert_pico_ok(status["freqToPhase"])
141+
127142
# output custom waveform with peak-to-peak of 2 V and frequency of 10 kHz
128143
# handle = chandle
129144
# offsetVoltage = 0
130145
# pkToPk = 2000000
131-
# startDeltaPhase = 0
132-
# stopDeltaPhase = 0
146+
# startDeltaPhase = phase
147+
# stopDeltaPhase = phase
133148
# deltaPhaseIncrement = 0
134149
# dwellCount = 0
135150
# *arbitaryWaveform = awgbufferPointer
136151
# arbitaryWaveformSize = 1024
137-
# sweepType = ctypes.c_int32(1) = PS5000A_UP
152+
# sweepType = ctypes.c_int32(0)
138153
# operation = 0
139154
# shots = 0
140155
# sweeps = 0
141156
# triggerType = ctypes.c_int16(0) = PS5000A_SIGGEN_RISING
142157
# triggerSource = ctypes.c_int16(0) = PS5000A_SIGGEN_NONE
143158
# extInThreshold = 0
144159

145-
status["setSigGenArbitrary"] = ps.ps5000aSetSigGenArbitrary(chandle, 0, 2000000, 0, 0, 0, 0, awgbufferPointer, 1024, 0, 0, 0, 0, 0, 0, 0, 0)
160+
status["setSigGenArbitrary"] = ps.ps5000aSetSigGenArbitrary(chandle, 0, 2000000, phase.value, phase.value, 0, 0, awgbufferPointer, bufferLength, 0, 0, 0, 0, 0, 0, 0, 0)
146161
assert_pico_ok(status["setSigGenArbitrary"])
147162

148163
# Pauses the script to show signal

0 commit comments

Comments
 (0)