-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsynth.py
More file actions
89 lines (61 loc) · 2.1 KB
/
synth.py
File metadata and controls
89 lines (61 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# -*- coding: utf-8 -*-
# Pyblab
# Copyright (C) 2021 Marco Pizzocaro <m.pizzocaro@inrim.it>
#
# This file is part of Pyblab.
#
# Pyblab is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyblab is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Pyblab. If not, see <https://www.gnu.org/licenses/>.
import pyvisa as visa
class Synth(object):
def __init__(self, address, source, cf, pas=1, name=''):
"""
Synthethizer class for driving AOM frequencies.
Optimized for Tektronix synthetizers.
Parameters
----------
address: string
visa address of the synthetizer.
source: int
channels source.
cf: float
center frequency in Hz.
pass: int
1 for single pass, 2 for double pass AOM.
considered with sign.
default = 1.
"""
self.address = address
rm = visa.ResourceManager()
self.instr = rm.open_resource(address)
self.cf = cf # center or original freq
self.pas = pas
self.name = name
self.command = "Source{}:Freq ".format(source) + "{:.6f}"
self.hop_command = "Source{}:FSK:Freq ".format(source) + "{:.6f}"
self.write(0.)
def write(self, shift):
"""Write a shift from the center frequency on the synth.
The shift is a laser ferquency shift and consider pass (single or double)
and sign of the AOM.
For example adouble pass AOM, plus sign, set at center freq 80 MHz,
when asked to write 1 MHz will output 80.5 MHz.
"""
freq = self.cf + shift/self.pas
cmd = self.command.format(freq)
self.instr.write(cmd)
def write_hop(self, shift):
"""Write FSK Hop freq."""
freq = self.cf + shift/self.pas
cmd = self.hop_command.format(freq)
self.instr.write(cmd)