Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/docs/ref/ps6000a/conversions.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ the PicoScope needs to be initialized using `scope.open_unit()` followed by the
>>> import pypicosdk as psdk
>>> scope = psdk.ps6000a()
>>> scope.open_unit(resolution=psdk.RESOLUTION._8BIT)
>>> scope.mv_to_adc(100, channel_range=psdk.RANGE.V1)
>>> scope.mv_to_adc(100, channel=psdk.CHANNEL.A)
3251
>>> scope.close_unit()
```
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/ref/psospa/conversions.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ the PicoScope needs to be initialized using `scope.open_unit()` followed by the
>>> import pypicosdk as psdk
>>> scope = psdk.psospa()
>>> scope.open_unit(resolution=psdk.RESOLUTION._8BIT)
>>> scope.mv_to_adc(100, channel_range=psdk.RANGE.V1)
>>> scope.mv_to_adc(100, channel=psdk.CHANNEL.A)
3251
>>> scope.close_unit()
```
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced_block_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
scope.set_channel(channel=psdk.CHANNEL.A, range=psdk.RANGE.V1)

# Configure a simple rising edge trigger for channel A, wait indefinitely (do not auto trigger)
scope.set_simple_trigger(channel=psdk.CHANNEL.A, threshold_mv=0, auto_trigger=0)
scope.set_simple_trigger(channel=psdk.CHANNEL.A, threshold=0, auto_trigger=0)

# Helper function to set timebase of scope via requested sample rate
TIMEBASE = scope.sample_rate_to_timebase(sample_rate=50, unit=psdk.SAMPLE_RATE.MSPS)
Expand Down
3 changes: 1 addition & 2 deletions examples/advanced_block_capture_downsampled.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"""

from matplotlib import pyplot as plt
import numpy as np
import pypicosdk as psdk

# Number of raw samples to request from the driver before downsampling
Expand All @@ -43,7 +42,7 @@
scope.set_channel(channel=psdk.CHANNEL.A, range=psdk.RANGE.V1)

# Configure a simple rising edge trigger for channel A, wait indefinitely (do not auto trigger)
scope.set_simple_trigger(channel=psdk.CHANNEL.A, threshold_mv=0, auto_trigger=0)
scope.set_simple_trigger(channel=psdk.CHANNEL.A, threshold=0, auto_trigger=0)

# Helper function to set timebase of scope via requested sample rate
TIMEBASE = scope.sample_rate_to_timebase(sample_rate=50, unit=psdk.SAMPLE_RATE.MSPS)
Expand Down
2 changes: 1 addition & 1 deletion examples/dead_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
scope.set_channel(channel=psdk.CHANNEL.A, range=psdk.RANGE.V2)

# Configure a simple rising edge trigger for channel A, wait indefinitely (do not auto trigger)
scope.set_simple_trigger(channel=psdk.CHANNEL.A, threshold_mv=0, auto_trigger=0)
scope.set_simple_trigger(channel=psdk.CHANNEL.A, threshold=0, auto_trigger=0)

# Helper function to set timebase of scope via requested sample rate
TIMEBASE = scope.sample_rate_to_timebase(sample_rate=50, unit=psdk.SAMPLE_RATE.GSPS)
Expand Down
2 changes: 1 addition & 1 deletion examples/eres_res_enhance.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
scope.set_channel(channel=psdk.CHANNEL.A, range=psdk.RANGE.V2)

# Configure a simple rising edge trigger for channel A, wait indefinitely (do not auto trigger)
scope.set_simple_trigger(channel=psdk.CHANNEL.A, threshold_mv=0, auto_trigger=0)
scope.set_simple_trigger(channel=psdk.CHANNEL.A, threshold=0, auto_trigger=0)

# Helper function to set timebase of scope via requested sample rate
TIMEBASE = scope.sample_rate_to_timebase(sample_rate=1.25, unit=psdk.SAMPLE_RATE.GSPS)
Expand Down
2 changes: 1 addition & 1 deletion examples/fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
scope.set_channel(channel=psdk.CHANNEL.A, range=psdk.RANGE.V1)

# Configure a simple rising edge trigger for channel A, wait indefinitely (do not auto trigger)
scope.set_simple_trigger(channel=psdk.CHANNEL.A, threshold_mv=0, auto_trigger=0)
scope.set_simple_trigger(channel=psdk.CHANNEL.A, threshold=0, auto_trigger=0)

# Helper function to set timebase of scope via requested sample rate
TIMEBASE = scope.sample_rate_to_timebase(50, psdk.SAMPLE_RATE.MSPS)
Expand Down
2 changes: 1 addition & 1 deletion examples/measurement_examples/amplitude_pk2pk_rms.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

# Setup channel and trigger
scope.set_channel(channel=CHANNEL, range=RANGE)
scope.set_simple_trigger(channel=CHANNEL, threshold_mv=THRESHOLD)
scope.set_simple_trigger(channel=CHANNEL, threshold=THRESHOLD)

scope.set_siggen(1E6, 1.6, psdk.WAVEFORM.SINE, offset=0.1)

Expand Down
2 changes: 1 addition & 1 deletion examples/measurement_examples/frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

# Setup channel and trigger
scope.set_channel(channel=CHANNEL, range=RANGE)
scope.set_simple_trigger(channel=CHANNEL, threshold_mv=THRESHOLD)
scope.set_simple_trigger(channel=CHANNEL, threshold=THRESHOLD)

scope.set_siggen(0.05E6, 1.0, psdk.WAVEFORM.SINE)

Expand Down
2 changes: 1 addition & 1 deletion examples/measurement_examples/overshoot.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

# Setup channel and trigger
scope.set_channel(channel=CHANNEL, range=RANGE)
scope.set_simple_trigger(channel=CHANNEL, threshold_mv=THRESHOLD)
scope.set_simple_trigger(channel=CHANNEL, threshold=THRESHOLD)

scope.set_siggen(1E6, 1.6, psdk.WAVEFORM.SQUARE)

Expand Down
2 changes: 1 addition & 1 deletion examples/pk2pk_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
scope.set_channel(channel=psdk.CHANNEL.A, coupling=psdk.COUPLING.DC, range=psdk.RANGE.mV500)

# Configure a simple rising edge trigger for channel A, wait indefinitely (do not auto trigger)
scope.set_simple_trigger(channel=psdk.CHANNEL.A, threshold_mv=200,
scope.set_simple_trigger(channel=psdk.CHANNEL.A, threshold=200,
direction=psdk.TRIGGER_DIR.RISING, auto_trigger=0)

# Set siggen to 10MHz & 0.9Vpkpk output sine wave
Expand Down
2 changes: 1 addition & 1 deletion examples/rapid_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
scope.set_channel(channel=psdk.CHANNEL.A, range=psdk.RANGE.V1)

# Configure a simple rising edge trigger for channel A, wait indefinitely (do not auto trigger)
scope.set_simple_trigger(channel=psdk.CHANNEL.A, threshold_mv=0, auto_trigger=0)
scope.set_simple_trigger(channel=psdk.CHANNEL.A, threshold=0, auto_trigger=0)

# Set siggen to 100kHz & 0.8Vpkpk output sine wave
scope.set_siggen(frequency=100_000, pk2pk=0.8, wave_type=psdk.WAVEFORM.SINE)
Expand Down
2 changes: 1 addition & 1 deletion examples/saving_files/save_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
scope.open_unit()
scope.set_siggen(frequency=50_000, pk2pk=1.8, wave_type=psdk.WAVEFORM.SINE)
scope.set_channel(channel=psdk.CHANNEL.A, range=psdk.RANGE.V1)
scope.set_simple_trigger(channel=psdk.CHANNEL.A, threshold_mv=0, auto_trigger=0)
scope.set_simple_trigger(channel=psdk.CHANNEL.A, threshold=0, auto_trigger=0)
TIMEBASE = scope.sample_rate_to_timebase(sample_rate=50, unit=psdk.SAMPLE_RATE.MSPS)

# Get data to save as channel buffer and time axis
Expand Down
2 changes: 1 addition & 1 deletion examples/saving_files/save_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
scope.open_unit()
scope.set_siggen(frequency=50_000, pk2pk=1.8, wave_type=psdk.WAVEFORM.SINE)
scope.set_channel(channel=psdk.CHANNEL.A, range=psdk.RANGE.V1)
scope.set_simple_trigger(channel=psdk.CHANNEL.A, threshold_mv=0, auto_trigger=0)
scope.set_simple_trigger(channel=psdk.CHANNEL.A, threshold=0, auto_trigger=0)
TIMEBASE = scope.sample_rate_to_timebase(sample_rate=50, unit=psdk.SAMPLE_RATE.MSPS)

# Get data to save as channel buffer and time axis
Expand Down
8 changes: 4 additions & 4 deletions examples/simple_block_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@
SAMPLES = 5_000

# Create "scope" class and initialize PicoScope
scope = psdk.psospa()
scope = psdk.ps6000a()
scope.open_unit()

# Print the returned serial number of the initialized instrument
print(scope.get_unit_serial())

# Set siggen to 1MHz & 0.8Vpkpk output sine wave
scope.set_siggen(frequency=1_000_000, pk2pk=1.8, wave_type=psdk.WAVEFORM.SINE)
scope.set_siggen(frequency=10_000, pk2pk=1.8, wave_type=psdk.WAVEFORM.SINE)

# Enable channel A with +/- 1V range (2V total dynamic range)
scope.set_channel(channel=psdk.CHANNEL.A, range=psdk.RANGE.V1)

# Configure a simple rising edge trigger for channel A, wait indefinitely (do not auto trigger)
scope.set_simple_trigger(channel=psdk.CHANNEL.A, threshold_mv=0, auto_trigger=0)
scope.set_simple_trigger(channel=psdk.CHANNEL.A, threshold=0, auto_trigger=0)

# Helper function to set timebase of scope via requested sample rate
TIMEBASE = scope.sample_rate_to_timebase(sample_rate=50, unit=psdk.SAMPLE_RATE.MSPS)
Expand All @@ -61,7 +61,7 @@
plt.grid(True)

# Set the Y axis of the graph to the largest voltage range selected for enabled channels, in mV
plt.ylim(scope.get_ylim(unit='mv'))
plt.ylim(scope.get_ylim())

# Display the completed plot
plt.show()
Empty file added pypicosdk/_classes/__init__.py
Empty file.
33 changes: 33 additions & 0 deletions pypicosdk/_classes/_channel_class.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
This file contains a class to hold the channel data
i.e. range information and probe scale information
"""
from dataclasses import dataclass
import numpy as np
if __name__ != '__main__':
from .. import constants as cst
else:
from pypicosdk import constants as cst


@dataclass
class ChannelClass:
"Dataclass containing channel information"
range: cst.RANGE
range_mv: int
probe_scale: float
ylim_mv: int
ylim_v: float

def __init__(self, ch_range: cst.RANGE, probe_scale: float):
self.range = ch_range
self.probe_scale = probe_scale
self.range_mv = cst.RANGE_LIST[ch_range]
self.range_v = self.range_mv / 1000
self.ylim_mv = np.array([-self.range_mv, self.range_mv]) * probe_scale
self.ylim_v = self.ylim_mv / 1000


if __name__ == '__main__':
test = ChannelClass(ch_range=cst.RANGE.V1, probe_scale=10)
print(test)
9 changes: 9 additions & 0 deletions pypicosdk/_classes/_general.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"This file contains general classes for pyPicoSDK"

from dataclasses import dataclass


@dataclass
class BaseDataClass:
"Class containing data for PicoScopeBase"
last_pre_trig: float = 50
Loading