Skip to content
Snippets Groups Projects
Commit c19eda36 authored by Yb Tweezer's avatar Yb Tweezer
Browse files

uncommitted changes -- DG800 controller interface

parent 2e9ca0e8
No related branches found
No related tags found
No related merge requests found
......@@ -161,12 +161,74 @@ class SCPIController:
return a
raise AttributeError
class DSG800(SCPIController):
class DG800(SCPIController):
"""
Class to drive commnication with a Rigol DSG800-series RF signal generator.
All methods that do not have an explicit return type return `self`.
"""
pass
def _check_source(self, source: int):
if source not in {1, 2}:
raise RuntimeError("source must be either 1 or 2")
def get_frequency(self, source: int) -> float:
"""
Get the frequency, in MHz, of a source.
"""
self._check_source(source)
return float(self.query(f":source{source:.0f}:frequency?")) / 1e6
def set_frequency(self, source: int, freq: float):
"""
Set the frequency, in MHz, of a source.
"""
self._check_source(source)
return self.write(f":source{source:.0f}:frequency {1e6 * freq:.3f}")
def get_amplitude(self, source: int) -> float:
"""
Get the amplitude, in Vpp, of a source.
"""
self._check_source(source)
return float(self.query(f":source{source:.0f}:voltage?"))
def set_amplitude(self, source: int, ampl: float):
"""
Set the amplitude, in Vpp, of a source.
"""
self._check_source(source)
return self.write(f":source{source:.0f}:voltage {ampl:.4f}")
def get_phase(self, source: int) -> float:
"""
Get the phase, in degrees, of a source.
"""
self._check_source(source)
return float(self.query(f":source{source:.0f}:phase?"))
def set_phase(self, source: int, phase: float):
"""
Set the phase, in degrees, of a source.
"""
self._check_source(source)
return self.write(f":source{source:.0f}:phase {phase:.3f}")
def get_delay(self, source: int) -> float:
"""
Get the delay of a channel, in seconds, of a source
"""
self._check_source(source)
return float(self.query(f":source{source:.0f}:tdelay?"))
def set_delay(self, source: int, delay: float):
"""
Set the delay, in seconds, of a source
"""
self._check_source(source)
return self.write(f":source{source:.0f}:burst:tdelay {delay:.3f}")
# TODO: trigger/mode/function settings
class DG4000(SCPIController):
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment