Skip to content

Commit 8b26c38

Browse files
author
neil.hamilton
committed
Merge TSP-321-AS108-Python-Examples into master
2 parents 45aa22a + 6a9a534 commit 8b26c38

File tree

3 files changed

+93
-1
lines changed

3 files changed

+93
-1
lines changed

picosdk/picosynth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from picosdk.errors import ArgumentOutOfRangeError
1212
from picosdk.constants import make_enum
1313

14-
class Picosynthlib(library):
14+
class Picosynthlib(Library):
1515
def __init__(self):
1616
super(Picosynthlib, self).__init__("picosynth")
1717

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)

setupPicosynth.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#
2+
# Copyright (C) 2017-2018 Pico Technology Ltd.
3+
#
4+
from __future__ import print_function
5+
from distutils.core import setup
6+
7+
import ctypes
8+
from ctypes import *
9+
from ctypes.util import find_library
10+
import sys
11+
import os.path
12+
13+
14+
signalfile = ".sdkwarning"
15+
if not os.path.exists(signalfile):
16+
name = 'picosynth'
17+
try:
18+
if sys.platform == 'win32':
19+
result = ctypes.WinDLL(find_library(name))
20+
print(result)
21+
else:
22+
result = cdll.LoadLibrary(find_library(name))
23+
except OSError:
24+
print("Please install PicoSynth software in order to use this wrapper."
25+
"Visit https://www.picotech.com/downloads")
26+
exit(1)
27+
open(signalfile, 'a').close()
28+
29+
30+
setup(name='PicoSDK',
31+
version='1.0',
32+
description='PicoSDK Python wrapper',
33+
author='Pico Technology Ltd',
34+
author_email='[email protected]',
35+
url='https://www.picotech.com',
36+
packages=['picosdk'])

0 commit comments

Comments
 (0)