Skip to content

Commit c823ef3

Browse files
author
neil-hamilton
authored
Merge branch 'master' into setuptools
2 parents 75b27b7 + 97c73f0 commit c823ef3

File tree

13 files changed

+198
-48
lines changed

13 files changed

+198
-48
lines changed

README.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,37 @@ to install the required driver packages for your product.
1818

1919
### macOS
2020

21-
macOS users should install PicoScope Beta for macOS, and then may find this [forum post](https://www.picotech.com/support/topic22221.html) helpful for installing the C
22-
libraries.
21+
Please visit [our Downloads page](https://www.picotech.com/downloads) to download the PicoSDK C Libraries for MacOS.
2322

2423
## Installing the python driver bindings
2524

2625
A `distutils` installer is provided. After you have installed the PicoSDK
27-
driver package (see above), the Python installer can be used as follows:
26+
driver package (see above), the Python package can be installed using the
27+
following command in the top-level directory:
28+
29+
pip install .
30+
31+
If you are not using a virtualenv or are not elevated, use:
2832

2933
python setup.py install
34+
35+
=======
36+
For using the AS108 you will need to use the following as well:
37+
38+
python setupPicosynth.py install
39+
3040

3141
On macOS and Linux you will either need to use `sudo` with this command, to
3242
install into the system folders, or to install for the current user only you
3343
can use:
3444

35-
python setup.py install --user
45+
pip install . --user
3646

3747
Within python, the library for `import` is called `picosdk`.
3848

3949
## Compatibility
4050

41-
This code is written to be compatible with both python 2.7 and python 3 (any version).
51+
This code is written to be compatible with both Python 2.7 and Python 3 (any version).
4252

4353
If you find a compatibility problem please raise an [Issue](https://www.picotech.com/tech-support), listing all the versions you can find (python, numpy,
4454
picosdk commit hash, etc.) and your error message(s).
@@ -64,11 +74,10 @@ The following drivers and devices are not yet supported:
6474

6575
* `plcm3` - PicoLog CM3 Current Data Logger
6676
* `ps3000` - PicoScope 3204, 3205, 3206, 3223, 3224, 3423 & 3423
67-
* `usbpt104` - PT-104 Platinum Resistance Data Logger
6877

6978
### Dependencies
7079

71-
As well as depending on the C libraries, the Pythonic wrappers use some python libraries like `numpy`. Many of the
80+
As well as depending on the C libraries, the Python wrappers use some Python libraries like `numpy`. Many of the
7281
examples scripts also use the `matplotlib` plotting library. You can install these dependencies with pip as follows:
7382

7483
pip install -r requirements.txt
@@ -77,7 +86,8 @@ examples scripts also use the `matplotlib` plotting library. You can install the
7786
### Driver-agnostic examples
7887

7988
The `anyScopeExamples` folder contains examples in pure python which do the same thing as the C-style examples, but
80-
in a driver-generic way.
89+
in a driver-generic way. These examples are currently not being developed further but are still avaliable to use
90+
and develop futher yourself.
8191

8292
### Python Classes
8393

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

picosdk/ps6000.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,18 @@ class PS6000_TRIGGER_INFO (Structure):
637637
ps6000.make_symbol("_RunStreaming", "ps6000RunStreaming", c_uint32,
638638
[c_int16, c_void_p, c_int32, c_uint32, c_uint32, c_int16, c_uint32, c_int32, c_uint32], doc)
639639

640+
doc = """ void ps6000BlockReady
641+
(
642+
int16_t handle,
643+
PICO_STATUS status,
644+
void *pParameter
645+
); """
646+
ps6000.BlockReadyType = C_CALLBACK_FUNCTION_FACTORY(None,
647+
c_int16,
648+
c_uint32,
649+
c_void_p)
650+
ps6000.BlockReadyType.__doc__ = doc
651+
640652
doc = """ void ps6000StreamingReady
641653
(
642654
int16_t handle,

picosdk/ps6000a.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from picosdk.library import Library
1212
from picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY
1313
from picosdk.constants import make_enum
14+
from picosdk.PicoDeviceEnums import picoEnum as enums
1415

1516

1617
class Ps6000alib(Library):
@@ -19,6 +20,8 @@ def __init__(self):
1920

2021
ps6000a = Ps6000alib()
2122

23+
ps6000a.DEFAULT_RESOLUTION = enums.PICO_DEVICE_RESOLUTION["PICO_DR_8BIT"]
24+
2225
doc = """ void ps6000aBlockReady
2326
(
2427
int16_t handle,
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)

ps3000aExamples/ps3000aBlockMSOExample.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
0)
9999
assert_pico_ok(status["SetDataBuffers"])
100100

101-
print "Starting data collection..."
101+
print ("Starting data collection...")
102102

103103
# Starts the block capture
104104
# handle = chandle
@@ -143,7 +143,7 @@
143143
status["GetValues"] = ps.ps3000aGetValues(chandle, 0, ctypes.byref(cTotalSamples), 1, 0, 0, ctypes.byref(overflow))
144144
assert_pico_ok(status["GetValues"])
145145

146-
print "Data collection complete."
146+
print ("Data collection complete.")
147147

148148
# Obtain binary for Digital Port 0
149149
# The tuple returned contains the channels in order (D7, D6, D5, ... D0).
@@ -154,7 +154,7 @@
154154

155155
# Plot the data from digital channels onto a graph
156156

157-
print "Plotting data..."
157+
print ("Plotting data...")
158158

159159
plt.figure(num='PicoScope 3000 Series (A API) MSO Block Capture Example')
160160
plt.title('Plot of Digital Port 0 digital channels vs. time')
@@ -171,7 +171,7 @@
171171
plt.legend(loc="upper right")
172172
plt.show()
173173

174-
print "Close figure to stop the device and close the connection."
174+
print ("Close figure to stop the device and close the connection.")
175175

176176
# Stops the scope
177177
# handle = chandle

ps3000aExamples/ps3000aRapidBlockExample.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import ctypes
99
from picosdk.ps3000a import ps3000a as ps
1010
import numpy as np
11+
import matplotlib
1112
import matplotlib.pyplot as plt
1213
from picosdk.functions import adc2mV, assert_pico_ok
1314

@@ -292,7 +293,9 @@
292293
Times = (ctypes.c_int16*10)()
293294
TimeUnits = ctypes.c_char()
294295
status["GetValuesTriggerTimeOffsetBulk"] = ps.ps3000aGetValuesTriggerTimeOffsetBulk64(chandle, ctypes.byref(Times), ctypes.byref(TimeUnits), 0, 9)
295-
assert_pico_ok(status["GetValuesTriggerTimeOffsetBulk"])
296+
297+
print(Times[0:9])
298+
print(TimeUnits)
296299

297300
# Finds the max ADC count
298301
# Handle = chandle
@@ -312,21 +315,25 @@
312315
adc2mVChAMax7 = adc2mV(bufferAMax7, chARange, maxADC)
313316
adc2mVChAMax8 = adc2mV(bufferAMax8, chARange, maxADC)
314317
adc2mVChAMax9 = adc2mV(bufferAMax9, chARange, maxADC)
318+
assert_pico_ok(status["GetValuesTriggerTimeOffsetBulk"])
315319

316320
# Creates the time data
317321
time = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)
318322

319323
# Plots the data from channel A onto a graph
320-
plt.plot(time, adc2mVChAMax[:])
321-
plt.plot(time, adc2mVChAMax1[:])
322-
plt.plot(time, adc2mVChAMax2[:])
323-
plt.plot(time, adc2mVChAMax3[:])
324-
plt.plot(time, adc2mVChAMax4[:])
325-
plt.plot(time, adc2mVChAMax5[:])
326-
plt.plot(time, adc2mVChAMax6[:])
327-
plt.plot(time, adc2mVChAMax7[:])
328-
plt.plot(time, adc2mVChAMax8[:])
329-
plt.plot(time, adc2mVChAMax9[:])
324+
325+
plt.plot(time, adc2mVChAMax)
326+
print('test')
327+
plt.plot(time, adc2mVChAMax1)
328+
plt.plot(time, adc2mVChAMax2)
329+
plt.plot(time, adc2mVChAMax3)
330+
plt.plot(time, adc2mVChAMax4)
331+
plt.plot(time, adc2mVChAMax5)
332+
plt.plot(time, adc2mVChAMax6)
333+
plt.plot(time, adc2mVChAMax7)
334+
plt.plot(time, adc2mVChAMax8)
335+
plt.plot(time, adc2mVChAMax9)
336+
330337
plt.xlabel('Time (ns)')
331338
plt.ylabel('Voltage (mV)')
332339
plt.show()

ps5000aExamples/ps5000aRapidBlockExample.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
# MaxSamples = ctypes.byref(returnedMaxSamples)
8181
# Segement index = 0
8282
timeIntervalns = ctypes.c_float()
83-
returnedMaxSamples = ctypes.c_int16()
83+
returnedMaxSamples = ctypes.c_int32()
8484
status["GetTimebase"] = ps.ps5000aGetTimebase2(chandle, timebase, maxsamples, ctypes.byref(timeIntervalns), ctypes.byref(returnedMaxSamples), 0)
8585
assert_pico_ok(status["GetTimebase"])
8686

@@ -288,7 +288,7 @@
288288
# Timeunits = TimeUnits = ctypes.c_char() = ctypes.byref(TimeUnits)
289289
# Fromsegmentindex = 0
290290
# Tosegementindex = 9
291-
Times = (ctypes.c_int16*10)()
291+
Times = (ctypes.c_int64*10)()
292292
TimeUnits = ctypes.c_char()
293293
status["GetValuesTriggerTimeOffsetBulk"] = ps.ps5000aGetValuesTriggerTimeOffsetBulk64(chandle, ctypes.byref(Times), ctypes.byref(TimeUnits), 0, 9)
294294
assert_pico_ok(status["GetValuesTriggerTimeOffsetBulk"])

ps6000Examples/ps6000SigGen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
triggerSource = ctypes.c_int32(0)
7272

7373
status["SetSigGenBuiltIn"] = ps.ps6000SetSigGenBuiltIn(chandle, 0, 2000000, wavetype, 10000, 10000, 0, 1, sweepType, 0, 0, 0, triggertype, triggerSource, 1)
74-
assert_pico_ok(status["SetSignGenBuiltIn"])
74+
assert_pico_ok(status["SetSigGenBuiltIn"])
7575

7676
# Pauses the script to show signal
7777
time.sleep(10)

ps6000aExamples/ps6000aBlockAdvancedTriggerExample.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
action = clear|add # PICO_ACTION["PICO_CLEAR_WAVEFORM_CLEAR_ALL"] | PICO_ACTION["PICO_ADD"]
112112
status["setDataBuffers"] = ps.ps6000aSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), nSamples, dataType, waveform, downSampleMode, action)
113113
assert_pico_ok(status["setDataBuffers"])
114-
status["setDataBuffers"] = ps.ps6000aSetDataBuffers(chandle, channelB, ctypes.byref(bufferBMax), ctypes.byref(bufferBMin), nSamples, dataType, waveform, downSampleMode, action)
114+
status["setDataBuffers"] = ps.ps6000aSetDataBuffers(chandle, channelB, ctypes.byref(bufferBMax), ctypes.byref(bufferBMin), nSamples, dataType, waveform, downSampleMode, add)
115115
assert_pico_ok(status["setDataBuffers"])
116116

117117
# Run block capture

0 commit comments

Comments
 (0)