Skip to content

Commit 8900386

Browse files
author
neil.hamilton
committed
Add arbitrary waveform generation to ps5000aSigGen.py
1 parent c55a43e commit 8900386

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

ps5000aExamples/ps5000aSigGen.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
from picosdk.ps5000a import ps5000a as ps
1313
import time
1414
from picosdk.functions import assert_pico_ok
15+
import numpy as np
16+
import math
1517

1618

1719
status = {}
@@ -118,10 +120,38 @@
118120
# Pauses the script to show signal
119121
time.sleep(36)
120122

123+
# create a custom waveform
124+
awgBuffer = np.sin(np.linspace(0,2*math.pi,1024))
125+
awgbufferPointer = awgBuffer.ctypes.data_as(ctypes.POINTER(ctypes.c_int16))
126+
127+
# output custom waveform with peak-to-peak of 2 V and frequency of 10 kHz
128+
# handle = chandle
129+
# offsetVoltage = 0
130+
# pkToPk = 2000000
131+
# startDeltaPhase = 0
132+
# stopDeltaPhase = 0
133+
# deltaPhaseIncrement = 0
134+
# dwellCount = 0
135+
# *arbitaryWaveform = awgbufferPointer
136+
# arbitaryWaveformSize = 1024
137+
# sweepType = ctypes.c_int32(1) = PS5000A_UP
138+
# operation = 0
139+
# shots = 0
140+
# sweeps = 0
141+
# triggerType = ctypes.c_int16(0) = PS5000A_SIGGEN_RISING
142+
# triggerSource = ctypes.c_int16(0) = PS5000A_SIGGEN_NONE
143+
# extInThreshold = 0
144+
145+
status["setSigGenArbitrary"] = ps.ps5000aSetSigGenArbitrary(chandle, 0, 2000000, 0, 0, 0, 0, awgbufferPointer, 1024, 0, 0, 0, 0, 0, 0, 0, 0)
146+
assert_pico_ok(status["setSigGenArbitrary"])
147+
148+
# Pauses the script to show signal
149+
time.sleep(10)
150+
121151
# Closes the unit
122152
# Handle = chandle
123153
status["close"] = ps.ps5000aCloseUnit(chandle)
124-
assert_pico_ok(status["stop"])
154+
assert_pico_ok(status["close"])
125155

126156
# Displays the status returns
127157
print(status)

0 commit comments

Comments
 (0)