Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LeCroy T3DSO1204 Oscilloscope #697

Closed
wants to merge 122 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
1cd00a0
LeCroy T3DSO1204 Oscilloscope
LastStarDust Sep 30, 2022
c2fe61b
Short documentation about LeCroy T3DSO1204 Oscilloscope
LastStarDust Sep 30, 2022
52a8eba
Set line wrap at 100 characters to make flake8 happy
LastStarDust Oct 3, 2022
8711716
Stripped whitespaces from docstrings to make flake8 happy
LastStarDust Oct 3, 2022
b705296
Added links to the instruments class in docs and __init__.py
LastStarDust Oct 3, 2022
e5651ef
Uncommented skip test directive in unit test with device
LastStarDust Oct 3, 2022
7956643
Small fixes requested in the pull request comments
LastStarDust Oct 3, 2022
89cec68
Fixed docstrings to make sphinx happy
LastStarDust Oct 3, 2022
983f52a
Removed useless sanitize_dictionary method
LastStarDust Oct 3, 2022
5bf0538
Unit tests of communication protocol that can be run without a device
LastStarDust Oct 3, 2022
b9aeffa
Bugfixes regarding the parsing of input/output of instrument properties
LastStarDust Oct 3, 2022
65d5e3a
Uncommented skip test directive in unit test with device
LastStarDust Oct 3, 2022
ea309a1
All string parameters are now defined as lowercase for consistency
LastStarDust Oct 3, 2022
8c1a8f5
bind static methods explicitly, passing in a dummy context
LastStarDust Oct 3, 2022
4eae028
Python 3.9 and before really doesn't like calling static methods
LastStarDust Oct 3, 2022
3839b54
Directly use scope variables in unit test with device
LastStarDust Oct 4, 2022
266aba3
Added tweakable recommended sleep time between commands
LastStarDust Oct 4, 2022
196d77f
Fixed bug introduced in previous commits
LastStarDust Oct 4, 2022
f7318da
Update pymeasure/instruments/lecroy/lecroyT3DSO1204.py
LastStarDust Oct 4, 2022
7903d76
I keep forgetting to uncomment this line
LastStarDust Oct 4, 2022
0f2fd74
Removed useless _MATCH_INT variable
LastStarDust Oct 4, 2022
f812262
Add unit test to test skew_factor property
LastStarDust Oct 4, 2022
19a43ea
Fixed range of channel skew factor
LastStarDust Oct 4, 2022
5887d6f
More consistent formatting of SCPI messages
LastStarDust Oct 7, 2022
4dc1fcd
Improved documentation and variable names
LastStarDust Oct 7, 2022
db0c12d
Fixed docstring indentation
LastStarDust Oct 7, 2022
7a18226
Added partial support for math operators
LastStarDust Oct 8, 2022
fd28778
Improvement to skew_factor property suggested by Christoph Buchner
LastStarDust Oct 11, 2022
c20760f
Acquisition sample size property (SANU? query)
LastStarDust Oct 11, 2022
72c3d57
memory size property (MSIZ? query)
LastStarDust Oct 11, 2022
8b3bfbf
72c3d5
LastStarDust Oct 11, 2022
b479827
Block if the user tries to send commands faster than a certain rate
LastStarDust Oct 11, 2022
5d06cf1
Command header property (CHDR command)
LastStarDust Oct 11, 2022
b828d56
Debugged waveform download (many thanks to Bastian Leykauf)
LastStarDust Oct 11, 2022
58023df
Remove needless sleep calls in tests
LastStarDust Oct 11, 2022
fcf1b03
Only query about average points if the acquisition type is "average"
LastStarDust Oct 11, 2022
1921095
Debugged downloading of waveform data
LastStarDust Oct 11, 2022
945867a
Fixed unit tests
LastStarDust Oct 11, 2022
3c08010
Skip unit tests if they are meant to be run by a human or are failing
LastStarDust Oct 12, 2022
2b92a7c
Added fixed requested in pull request 697
LastStarDust Oct 12, 2022
28a2145
Reverted previous commit
LastStarDust Oct 12, 2022
2ca80be
Fixed bug in _sanitize_source helper function
LastStarDust Oct 12, 2022
d34f0ae
Improvement suggested by Christoph Buchner in PR 697
LastStarDust Oct 12, 2022
643ad37
single entry point for `acquisition_sample_size_cX` methods
LastStarDust Oct 12, 2022
f5080ee
Fixed bug in download_data when the number of requested points is max
LastStarDust Oct 12, 2022
e5989d3
More info in waveform preamble
LastStarDust Oct 12, 2022
40e7c38
Remove bitstring dependency
LastStarDust Oct 14, 2022
ff305f8
Remove unneeded check in _ChunkResizer
LastStarDust Oct 14, 2022
bb59bd1
More concise selection of channel object from channel name or index
LastStarDust Oct 14, 2022
35c2c67
Typos in docstrings
LastStarDust Oct 14, 2022
21c9431
Suggested default value in docstring would lead to exception
LastStarDust Oct 14, 2022
5f726b7
Do not request for waveform header twice
LastStarDust Oct 14, 2022
7806ed4
PR 660 has been merged so no need to skip that unit test
LastStarDust Oct 14, 2022
cfce4a3
Fixed and improved download_data unit tests with and without device
LastStarDust Oct 14, 2022
6e8c981
Split the download_data method in smaller chunks (pun intended)
LastStarDust Oct 14, 2022
64a02c5
Fixed unit tests
LastStarDust Oct 14, 2022
6f95322
Added docstring to _process_data method
LastStarDust Oct 14, 2022
3778d8c
Removed unneeded TODOs
LastStarDust Oct 14, 2022
cb68137
Report Y-axis units in waveform preamble
LastStarDust Oct 14, 2022
3f5d5c8
Bugfix in _acquire_data (source was used before being set)
LastStarDust Oct 14, 2022
6ea642f
Bugfix of a bug introduced in the previous bugfix
LastStarDust Oct 14, 2022
70961eb
Sanitize source string and then always use self.waveform_source
LastStarDust Oct 14, 2022
74fec5d
I found a bug in the scope firmware but it can be avoided by software
LastStarDust Oct 21, 2022
75bdd81
Fixed previous commit : I meant divide and not multiply
LastStarDust Oct 21, 2022
78190d1
Fixed bug in math_define syntax
LastStarDust Oct 21, 2022
ddb3f3a
Fixed waveform scaling when source is math
LastStarDust Oct 24, 2022
f76d992
Fixed waveform scaling when source is math, again
LastStarDust Oct 24, 2022
abd2191
Improved and debugged waveform download
LastStarDust Oct 25, 2022
e9298f0
Fixed unit tests (maybe)
LastStarDust Oct 25, 2022
92ffba0
Forgot to uncomment some stuff
LastStarDust Oct 25, 2022
ee16a4c
Make acquiring only one data point faster
LastStarDust Oct 26, 2022
37ed2e7
Fixed unit tests
LastStarDust Oct 26, 2022
9e50639
Decreased adapter timeout
LastStarDust Oct 27, 2022
cea6ad2
No need to set the trigger type every time we arm the acquisition
LastStarDust Oct 28, 2022
b4a3faa
Revert commit about trigger level
LastStarDust Oct 28, 2022
577f61d
Better channel name sanitizing
Nov 12, 2022
8d1cc04
Fixed typos
LastStarDust Nov 12, 2022
369ba6e
Improved docstring of "display" property
LastStarDust Nov 12, 2022
9c071e0
Improved docstring of boolean properties
Nov 12, 2022
8f45997
Moved __init__ to the beginning of the class
Nov 12, 2022
4edc350
Use setattr in order to set the current value
Nov 12, 2022
94f02ec
Improved docstring of "_comm_header" property
Nov 12, 2022
3813c1a
Fixed typos
LastStarDust Nov 12, 2022
90581f6
Fixed typos
LastStarDust Nov 12, 2022
85fa216
Fixed mistake
LastStarDust Nov 12, 2022
b480cb9
Fixed typos
LastStarDust Nov 12, 2022
429cb3c
renamed SLEEP_SECONDS to WRITE_INTERVAL_S
Nov 12, 2022
f4f6613
Every adapter has a connection so I remove the "hasattr" check.
Nov 12, 2022
b9cdef8
Fixed typos
Nov 12, 2022
c8eea2d
Fixed typos and docstrings
Nov 12, 2022
79202cd
Combined waveform header and footer sanity checks into one
Nov 12, 2022
6f5dafc
Fixed typo
LastStarDust Nov 12, 2022
67a1f00
Converted trigger_50 property into center_trigger method
Nov 12, 2022
396219f
Improved docstring of trigger_select
Nov 12, 2022
2135cd8
First set and then read in unit tests
Nov 12, 2022
edd643b
Rename "single" method into "arm_acquisition"
Nov 13, 2022
f645645
Improved regex of source name sanity check
LastStarDust Nov 14, 2022
3a30917
Improved regex of source name sanity check
LastStarDust Nov 14, 2022
fe1ddbf
Add warning in docstring not to change the COMM_HEADER during operation
LastStarDust Nov 14, 2022
9ac6580
Removed redundant group name in regex
LastStarDust Nov 14, 2022
f7be8de
Simplify source name sanity check
LastStarDust Nov 15, 2022
6b928f2
Correctly process waveform parameters
LastStarDust Nov 15, 2022
05bb9fd
Renamed some methods
LastStarDust Nov 18, 2022
e0dc656
Pass keyworded arguments through the write method
LastStarDust Nov 18, 2022
7855466
Measuring a single point with a scope does not make much sense
LastStarDust Nov 18, 2022
98fb0d1
Implemented measure functions
LastStarDust Nov 18, 2022
600c2cf
Fixed indentation in docstrings
LastStarDust Nov 18, 2022
1227929
Fixed indentation (line too long)
LastStarDust Nov 18, 2022
78dc2e0
Implemented some display functions
LastStarDust Nov 18, 2022
87f3944
Removed unused import
LastStarDust Nov 18, 2022
81b0bc2
Removed useless line in docstring
LastStarDust Nov 21, 2022
52db6b8
Renamed some ambiguous variables and added comments
LastStarDust Nov 21, 2022
6143fe8
Increase write interval to 20ms
LastStarDust Nov 22, 2022
5bbabe5
Moved measure commands to channel subclass
Nov 26, 2022
9a2e224
Renamed chX to ch_X
Nov 26, 2022
d7bdb5a
ScopeChannel now inherits from instrument.Channel
Nov 26, 2022
c96323c
Applied suggestion from PR about new Channel implementation
Nov 26, 2022
6fc893b
Applied suggestion from PR about new Channel implementation
Nov 26, 2022
7e52a10
No need to replace whitespaces in the source string
LastStarDust Nov 29, 2022
8a3721f
Renamed _trigger_select_vals
LastStarDust Nov 29, 2022
57a25c7
Renamed display_parameter to set_display_parameter
LastStarDust Nov 29, 2022
2a75a88
Improved the _ChunkResizer docstring
LastStarDust Nov 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions pymeasure/instruments/lecroy/lecroyT3DSO1204.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import numpy as np

from pymeasure.instruments import Instrument
from pymeasure.instruments import Instrument, Channel
from pymeasure.instruments.validators import strict_discrete_set, strict_range, \
strict_discrete_range

Expand Down Expand Up @@ -206,8 +206,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
self.adapter.connection.chunk_size = self.old_chunk_size


# noinspection DuplicatedCode
class Channel:
class ScopeChannel(Channel):
""" Implementation of a LeCroy T3DSO1204 Oscilloscope channel.

Implementation modeled on Channel object of Keysight DSOX1102G instrument. """
Expand Down Expand Up @@ -510,10 +509,10 @@ def __init__(self, adapter, **kwargs):
self._seconds_since_last_write = 0 # Timestamp of the last command
self._header_size = 16 # bytes
self._footer_size = 2 # bytes
self.ch1 = Channel(self, 1)
self.ch2 = Channel(self, 2)
self.ch3 = Channel(self, 3)
self.ch4 = Channel(self, 4)
self.ch_1 = ScopeChannel(self, 1)
self.ch_2 = ScopeChannel(self, 2)
self.ch_3 = ScopeChannel(self, 3)
self.ch_4 = ScopeChannel(self, 4)
self.waveform_source = "C1"
self.default_setup()

BenediktBurger marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
48 changes: 24 additions & 24 deletions tests/instruments/lecroy/test_lecroyT3DSO1204.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ def test_bwlimit():
(b"C1:BWL?", b"ON")
]
) as instr:
instr.ch1.bwlimit = False
assert instr.ch1.bwlimit is False
instr.ch1.bwlimit = True
assert instr.ch1.bwlimit is True
instr.ch_1.bwlimit = False
assert instr.ch_1.bwlimit is False
instr.ch_1.bwlimit = True
assert instr.ch_1.bwlimit is True


def test_coupling():
Expand All @@ -84,12 +84,12 @@ def test_coupling():
(b"C1:CPL?", b"GND")
],
) as instr:
instr.ch1.coupling = "dc 1M"
assert instr.ch1.coupling == "dc 1M"
instr.ch1.coupling = "ac 1M"
assert instr.ch1.coupling == "ac 1M"
instr.ch1.coupling = "ground"
assert instr.ch1.coupling == "ground"
instr.ch_1.coupling = "dc 1M"
assert instr.ch_1.coupling == "dc 1M"
instr.ch_1.coupling = "ac 1M"
assert instr.ch_1.coupling == "ac 1M"
instr.ch_1.coupling = "ground"
assert instr.ch_1.coupling == "ground"


def test_offset():
Expand All @@ -100,8 +100,8 @@ def test_offset():
(b"C1:OFST?", b"1.00E+00")
]
) as instr:
instr.ch1.offset = 1.
assert instr.ch1.offset == 1.
instr.ch_1.offset = 1.
assert instr.ch_1.offset == 1.


def test_attenuation():
Expand All @@ -114,10 +114,10 @@ def test_attenuation():
(b"C1:ATTN?", b"0.1")
]
) as instr:
instr.ch1.probe_attenuation = 100
assert instr.ch1.probe_attenuation == 100
instr.ch1.probe_attenuation = 0.1
assert instr.ch1.probe_attenuation == 0.1
instr.ch_1.probe_attenuation = 100
assert instr.ch_1.probe_attenuation == 100
instr.ch_1.probe_attenuation = 0.1
assert instr.ch_1.probe_attenuation == 0.1


def test_skew_factor():
Expand All @@ -128,8 +128,8 @@ def test_skew_factor():
(b"C1:SKEW?", b"1.00E-07S"),
]
) as instr:
instr.ch1.skew_factor = 1e-7
assert instr.ch1.skew_factor == 1e-7
instr.ch_1.skew_factor = 1e-7
assert instr.ch_1.skew_factor == 1e-7


def test_channel_setup():
Expand All @@ -151,7 +151,7 @@ def test_channel_setup():
(b"C1:TRSL?", b"POS"),
]
) as instr:
assert instr.ch1.current_configuration == {"channel": 1,
assert instr.ch_1.current_configuration == {"channel": 1,
"attenuation": 1.,
"bandwidth_limit": False,
"coupling": "dc 1M",
Expand All @@ -162,10 +162,10 @@ def test_channel_setup():
"volts_div": 0.05,
"inverted": False,
"trigger_coupling": "dc",
"trigger_level": 0.150,
"trigger_level2": 0.150,
"trigger_slope": "positive"
}
"trigger_level": 0.150,
"trigger_level2": 0.150,
"trigger_slope": "positive"
}


def test_memory_size():
Expand Down Expand Up @@ -426,7 +426,7 @@ def test_measure_parameter():
]
) as instr:
assert instr.measure_parameter("RISE", "channel2") == 3.6e-9
assert instr.ch3.measure_parameter("MEAN") == 3.6e-9
assert instr.ch_3.measure_parameter("MEAN") == 3.6e-9


def test_menu():
Expand Down
32 changes: 16 additions & 16 deletions tests/instruments/lecroy/test_lecroyT3DSO1204_with_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ def test_scope_connection(self):

# Channel
def test_ch_current_configuration(self, autoscaled_scope):
autoscaled_scope.ch1.offset = 0
autoscaled_scope.ch1.trigger_level = 0
autoscaled_scope.ch1.trigger_level2 = 0
autoscaled_scope.ch_1.offset = 0
autoscaled_scope.ch_1.trigger_level = 0
autoscaled_scope.ch_1.trigger_level2 = 0
expected = {"channel": 1,
"attenuation": 1.,
"bandwidth_limit": False,
Expand Down Expand Up @@ -163,21 +163,21 @@ def test_ch_scale(self, scope, ch_number):

def test_ch_trigger_level(self, autoscaled_scope):
for case in self.TRIGGER_LEVELS:
autoscaled_scope.ch1.trigger_level = case
assert autoscaled_scope.ch1.trigger_level == case
autoscaled_scope.ch_1.trigger_level = case
assert autoscaled_scope.ch_1.trigger_level == case

def test_ch_trigger_level2(self, autoscaled_scope):
for case in self.TRIGGER_LEVELS:
autoscaled_scope.ch1.trigger_level2 = case
assert autoscaled_scope.ch1.trigger_level2 == case
autoscaled_scope.ch_1.trigger_level2 = case
assert autoscaled_scope.ch_1.trigger_level2 == case

def test_ch_trigger_slope(self, autoscaled_scope):
with pytest.raises(ValueError):
autoscaled_scope.ch1.trigger_slope = "abcd"
autoscaled_scope.ch_1.trigger_slope = "abcd"
autoscaled_scope.trigger_select = ("edge", "c1", "off")
for case in self.TRIGGER_SLOPES:
autoscaled_scope.ch1.trigger_slope = case
assert autoscaled_scope.ch1.trigger_slope == case
autoscaled_scope.ch_1.trigger_slope = case
assert autoscaled_scope.ch_1.trigger_slope == case

# Timebase
def test_timebase(self, autoscaled_scope):
Expand Down Expand Up @@ -242,7 +242,7 @@ def test_waveform_points(self, scope, case):

def test_waveform_preamble(self, autoscaled_scope):
autoscaled_scope.acquisition_type = "normal"
autoscaled_scope.ch1.offset = 0
autoscaled_scope.ch_1.offset = 0
autoscaled_scope.waveform_points = 0
autoscaled_scope.waveform_first_point = 0
autoscaled_scope.waveform_sparsing = 1
Expand Down Expand Up @@ -356,7 +356,7 @@ def test_download_data(self, scope, case1, case2):

def test_download_single_point(self, scope):
scope.acquisition_type = "normal"
scope.ch1.display = True
scope.ch_1.display = True
scope.single()
data, time, preamble = scope.download_waveform(source="c1", requested_points=1)
assert type(data) is np.ndarray
Expand All @@ -378,7 +378,7 @@ def test_download_single_point(self, scope):
@pytest.mark.skip(reason="A human is needed to check the output waveform")
def test_download_data_all_points(self, scope):
from matplotlib import pyplot as plt
scope.ch1.display = True
scope.ch_1.display = True
scope.single()
sleep(1)
data, time, preamble = scope.download_waveform(source="c1", requested_points=0)
Expand All @@ -392,7 +392,7 @@ def test_download_data_all_points(self, scope):
@pytest.mark.skip(reason="A human is needed to check the output waveform")
def test_download_data_sparsing(self, scope):
from matplotlib import pyplot as plt
scope.ch1.display = True
scope.ch_1.display = True
scope.single()
sleep(1)
data, time, preamble = scope.download_waveform(source="c1", requested_points=7e5,
Expand All @@ -412,7 +412,7 @@ def test_download_data_sparsing(self, scope):
@pytest.mark.skip(reason="A human is needed to check the output waveform")
def test_download_data_averaging_16(self, scope):
from matplotlib import pyplot as plt
scope.ch1.display = True
scope.ch_1.display = True
scope.run()
scope.acquisition_type = "average"
scope.acquisition_average = 16
Expand All @@ -435,7 +435,7 @@ def test_download_data_averaging_16(self, scope):
@pytest.mark.skip(reason="A human is needed to check the output waveform")
def test_download_data_averaging_256(self, scope):
from matplotlib import pyplot as plt
scope.ch1.display = True
scope.ch_1.display = True
scope.run()
scope.acquisition_type = "average"
scope.acquisition_average = 256
Expand Down