aboutsummaryrefslogtreecommitdiff
path: root/hardware
diff options
context:
space:
mode:
Diffstat (limited to 'hardware')
-rw-r--r--hardware/scope/__init__.py23
-rw-r--r--hardware/scope/sds1104x.py6
-rw-r--r--hardware/scpi.py63
3 files changed, 82 insertions, 10 deletions
diff --git a/hardware/scope/__init__.py b/hardware/scope/__init__.py
index e6b6573..23462a7 100644
--- a/hardware/scope/__init__.py
+++ b/hardware/scope/__init__.py
@@ -2,21 +2,30 @@
Provide basic class to operate scope
Created by Eugeniy E. Mikhailov 2021/11/29
"""
-import scpi
+from hardware.scpi import SCPIinstr
-class Scope(scpi.SCPIinstr):
- """
- Do not instantiate directly, use
- rm = pyvisa.ResourceManager()
- Scope(rm.open_resource('TCPIP::192.168.0.2::INSTR'))
- """
+class Scope:
# Minimal set of methods to be implemented by a scope.
# Should work with minimal arguments list
# but might be faster if parameters provided: less IO requests
+ def __init__(self):
+ self.numberOfChannels = 0
+
def getTrace(self, chNum, availableNpnts=None, maxRequiredPoints=None):
warnings.warn( 'this function is not implemented' )
+class ScopeSCPI(SCPIinstr, Scope):
+ """
+ Do not instantiate directly, use
+ rm = pyvisa.ResourceManager()
+ ScopeSCPI(rm.open_resource('TCPIP::192.168.0.2::INSTR'))
+ """
+ pass
+ def __init__(self, resource):
+ SCPIinstr.__init__(self, resource)
+ Scope.__init__(self)
+
from .sds1104x import SDS1104X
diff --git a/hardware/scope/sds1104x.py b/hardware/scope/sds1104x.py
index 53e945a..23ac1be 100644
--- a/hardware/scope/sds1104x.py
+++ b/hardware/scope/sds1104x.py
@@ -3,19 +3,19 @@ Provide basic class to operate scope
Created by Eugeniy E. Mikhailov 2021/11/29
"""
-from hardware.scope import Scope
+from hardware.scope import ScopeSCPI
from datatrace import DataTrace
import re
import numpy as np
-class SDS1104X(Scope):
+class SDS1104X(ScopeSCPI):
""" Siglent SDS1104x scope """
vertDivOnScreen = 10
horizDivOnScreen = 14
- numberOfChannels = 4
def __init__(self, resource):
super().__init__(resource)
self.resource.read_termination='\n'
+ self.numberOfChannels = 4
self.maxRequiredPoints = 1000; # desired number of points per channel, can return twice more
def response2numStr(self, strIn, firstSeparator=None, unit=None):
diff --git a/hardware/scpi.py b/hardware/scpi.py
new file mode 100644
index 0000000..279ef24
--- /dev/null
+++ b/hardware/scpi.py
@@ -0,0 +1,63 @@
+"""
+provide basic class to operate SCPI capable instruments
+"""
+
+class SCPIinstr:
+ """ Basic class which support SCPI commands """
+ """
+ Do not instantiate directly, use
+ rm = pyvisa.ResourceManager()
+ SCPIinstr(rm.open_resource('TCPIP::192.168.0.2::INSTR'))
+ """
+ def __init__(self, resource):
+ self.resource = resource
+
+ # convenience pyvisa functions
+ self.write = self.resource.write
+ self.read = self.resource.read
+ self.query = self.resource.query
+ self.read_bytes = self.resource.read_bytes
+ self.read_binary_values = self.resource.read_binary_values
+ self.query_binary_values = self.resource.query_binary_values
+
+ @property
+ def idn(self):
+ return self.query("*IDN?")
+
+ def clear_status(self):
+ self.write("*CLS")
+
+ def set_event_status_enable(self):
+ self.write("*ESE")
+
+ def query_event_status_enable(self):
+ self.query("*ESE?")
+
+ def query_event_status_register(self):
+ self.query("*ESR?")
+
+ def set_wait_until_finished(self):
+ self.query("*OPC")
+
+ def wait_until_finished(self):
+ self.query("*OPC?")
+
+ def reset(self):
+ self.write("*RST")
+
+ def set_service_request_enable(self):
+ self.write("*SRE")
+
+ def query_service_request_enable(self):
+ self.query("*SRE?")
+
+ def query_status_byte(self):
+ self.query("*STB?")
+
+ def self_test_result(self):
+ self.query("*TST?")
+
+ def wait(self):
+ self.write("*WAI")
+
+