Skip to content

Commit 6a9a534

Browse files
author
neil.hamilton
committed
Create frequency sweep example for picosynth
1 parent 8d6975c commit 6a9a534

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#
2+
# Copyright (C) 2022 Pico Technology Ltd. See LICENSE file for terms.
3+
#
4+
# PicoSource AS108 Agile Synthesizer Example
5+
# This example demonstrates how to use the PicoSource AS108 picosynth driver API functions to set up the signal generator to output a frequency sweep.
6+
#
7+
8+
import ctypes
9+
from picosdk.picosynth import picosynth as ps
10+
import time
11+
from picosdk.functions import assert_pico_ok
12+
13+
# setup needed variables
14+
status = {}
15+
chandle = ctypes.c_uint32()
16+
17+
# open AS108 device
18+
status["openunit"] = ps.picosynthOpenUnit(ps.PICO_SOURCE_MODEL["PICO_SYNTH"], ctypes.byref(chandle),0)
19+
assert_pico_ok(status["openunit"])
20+
21+
# set up a frequency sweep
22+
# handle = chandle
23+
startFreqHz = 300000 #Hz
24+
stopFreqHz = 1000000 #Hz
25+
startLevel = 2
26+
stopLevel = 2
27+
levelUnit = 1 # VoltsPkToPk
28+
dwellTimeUs = 100
29+
pointsInSweep = 1000
30+
mode = 0 #SweepAndFlyback
31+
triggerMode = 0 # InternalTrigger
32+
33+
status["setFrequencyAndLevelSweep"] = ps.picosynthSetFrequencyAndLevelSweep(chandle,startFreqHz,stopFreqHz,startLevel,stopLevel,levelUnit,dwellTimeUs,pointsInSweep,mode,triggerMode)
34+
assert_pico_ok(status["setFrequencyAndLevelSweep"])
35+
36+
time.sleep(10)
37+
38+
# close AS108 device
39+
status["closeunit"] = ps.picosynthCloseUnit(chandle)
40+
assert_pico_ok(status["closeunit"])
41+
42+
time.sleep(20)
43+
44+
# open AS108 device
45+
status["openunit"] = ps.picosynthOpenUnit(ps.PICO_SOURCE_MODEL["PICO_SYNTH"], ctypes.byref(chandle),0)
46+
assert_pico_ok(status["openunit"])
47+
48+
# set output off
49+
status["setOutputOff"] = ps.picosynthSetOutputOff(chandle)
50+
51+
# close AS108 device
52+
status["closeunit"] = ps.picosynthCloseUnit(chandle)
53+
assert_pico_ok(status["closeunit"])
54+
55+
# Displays the status returns
56+
print(status)

0 commit comments

Comments
 (0)