|
1
|
|
|
# -*- coding: utf-8 -*- |
|
2
|
|
|
|
|
3
|
|
|
""" |
|
4
|
|
|
This file contains the Qudi hardware file to control Gigatronics Device. |
|
5
|
|
|
|
|
6
|
|
|
Qudi is free software: you can redistribute it and/or modify |
|
7
|
|
|
it under the terms of the GNU General Public License as published by |
|
8
|
|
|
the Free Software Foundation, either version 3 of the License, or |
|
9
|
|
|
(at your option) any later version. |
|
10
|
|
|
|
|
11
|
|
|
Qudi is distributed in the hope that it will be useful, |
|
12
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14
|
|
|
GNU General Public License for more details. |
|
15
|
|
|
|
|
16
|
|
|
You should have received a copy of the GNU General Public License |
|
17
|
|
|
along with Qudi. If not, see <http://www.gnu.org/licenses/>. |
|
18
|
|
|
|
|
19
|
|
|
Parts of this file were developed from a PI3diamond module which is |
|
20
|
|
|
Copyright (C) 2009 Helmut Rathgen <[email protected]> |
|
21
|
|
|
|
|
22
|
|
|
Copyright (c) the Qudi Developers. See the COPYRIGHT.txt file at the |
|
23
|
|
|
top-level directory of this distribution and at <https://github.com/Ulm-IQO/qudi/> |
|
24
|
|
|
""" |
|
25
|
|
|
|
|
26
|
|
|
import visa |
|
27
|
|
|
import numpy as np |
|
28
|
|
|
import time |
|
29
|
|
|
|
|
30
|
|
|
from core.base import Base |
|
|
|
|
|
|
31
|
|
|
from interface.microwave_interface import MicrowaveInterface |
|
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
class MicrowaveGigatronics(Base, MicrowaveInterface): |
|
35
|
|
|
""" Hardware file for Gigatronics. """ |
|
36
|
|
|
|
|
37
|
|
|
_modclass = 'MicrowaveInterface' |
|
38
|
|
|
_modtype = 'hardware' |
|
39
|
|
|
|
|
40
|
|
|
## declare connectors |
|
41
|
|
|
_out = {'mwsourcegigatronics': 'MicrowaveInterface'} |
|
42
|
|
|
|
|
43
|
|
|
def on_activate(self, e): |
|
|
|
|
|
|
44
|
|
|
""" Initialisation performed during activation of the module. |
|
45
|
|
|
|
|
46
|
|
|
@param object e: Event class object from Fysom. |
|
47
|
|
|
An object created by the state machine module Fysom, |
|
48
|
|
|
which is connected to a specific event (have a look in |
|
49
|
|
|
the Base Class). This object contains the passed event, |
|
50
|
|
|
the state before the event happened and the destination |
|
51
|
|
|
of the state which should be reached after the event |
|
52
|
|
|
had happened. |
|
53
|
|
|
""" |
|
54
|
|
|
# checking for the right configuration |
|
55
|
|
|
config = self.getConfiguration() |
|
|
|
|
|
|
56
|
|
|
if 'gpib_address' in config.keys(): |
|
57
|
|
|
self._gpib_address = config['gpib_address'] |
|
58
|
|
|
else: |
|
59
|
|
|
self.log.error('This is MWgigatronics: did not find ' |
|
|
|
|
|
|
60
|
|
|
'>>gpib_address<< in configration.') |
|
61
|
|
|
|
|
62
|
|
|
if 'gpib_timeout' in config.keys(): |
|
63
|
|
|
self._gpib_timeout = int(config['gpib_timeout']) |
|
64
|
|
|
else: |
|
65
|
|
|
self._gpib_timeout = 10 |
|
66
|
|
|
self.log.error('This is MWgigatronics: did not find ' |
|
|
|
|
|
|
67
|
|
|
'>>gpib_timeout<< in configration. I will set it to ' |
|
68
|
|
|
'10 seconds.') |
|
69
|
|
|
|
|
70
|
|
|
# trying to load the visa connection to the module |
|
71
|
|
|
visa.log_to_screen() |
|
72
|
|
|
self.rm = visa.ResourceManager() |
|
73
|
|
|
try: |
|
74
|
|
|
self._gpib_connection = self.rm.open_resource( |
|
75
|
|
|
self._gpib_address, |
|
76
|
|
|
read_termination='\r\n', |
|
77
|
|
|
timeout=self._gpib_timeout*1000, # config is seconds, pyvisa is millisecondss |
|
78
|
|
|
) |
|
79
|
|
|
except: |
|
80
|
|
|
self.log.error('This is MWgigatronics: could not connect to the ' |
|
|
|
|
|
|
81
|
|
|
'GPIB address >>{}<<.'.format(self._gpib_address)) |
|
82
|
|
|
raise |
|
83
|
|
|
self._gpib_connection.write('*RST') |
|
84
|
|
|
idnlist = [] |
|
85
|
|
|
while len(idnlist) < 3: |
|
86
|
|
|
idnlist = self._gpib_connection.query('*IDN?').split(', ') |
|
87
|
|
|
print(idnlist) |
|
88
|
|
|
time.sleep(0.1) |
|
89
|
|
|
self.model = idnlist[1] |
|
90
|
|
|
self.log.info('MWgigatronics initialised and connected to hardware.') |
|
|
|
|
|
|
91
|
|
|
|
|
92
|
|
|
def on_deactivate(self, e): |
|
|
|
|
|
|
93
|
|
|
""" Deinitialisation performed during deactivation of the module. |
|
94
|
|
|
|
|
95
|
|
|
@param object e: Event class object from Fysom. A more detailed |
|
96
|
|
|
explanation can be found in method activation. |
|
97
|
|
|
""" |
|
98
|
|
|
self._gpib_connection.close() |
|
99
|
|
|
self.rm.close() |
|
100
|
|
|
|
|
101
|
|
|
def get_limits(self): |
|
102
|
|
|
minpower = -144 |
|
103
|
|
|
maxpower = 10 |
|
104
|
|
|
minfreq = 100e3 |
|
105
|
|
|
maxfreq = 20e9 |
|
106
|
|
|
minliststep = 0.1 |
|
107
|
|
|
maxliststep = 20e9 |
|
108
|
|
|
listentries = 4000 |
|
109
|
|
|
minsweepstep = 0.1 |
|
110
|
|
|
maxsweepstep = 10e9 |
|
111
|
|
|
sweepentries = 10e6 |
|
112
|
|
|
if self.model.startswith('2508'): |
|
113
|
|
|
maxfreq = 8e9 |
|
114
|
|
|
elif self.model.startswith('2520'): |
|
115
|
|
|
maxfreq = 20e9 |
|
116
|
|
|
elif self.model.startswith('2526'): |
|
117
|
|
|
maxfreq = 26.5e9 |
|
118
|
|
|
elif self.model.startswith('2540'): |
|
119
|
|
|
maxfreq = 40e9 |
|
120
|
|
|
else: |
|
121
|
|
|
self.log.warn('Unknown Gigatronics moel, you are on your own!') |
|
|
|
|
|
|
122
|
|
|
|
|
123
|
|
|
limits = { |
|
124
|
|
|
'frequency': { |
|
125
|
|
|
'min': minfreq, |
|
126
|
|
|
'max': maxfreq |
|
127
|
|
|
}, |
|
128
|
|
|
'power': { |
|
129
|
|
|
'min': minpower, |
|
130
|
|
|
'max': maxpower |
|
131
|
|
|
}, |
|
132
|
|
|
'list': { |
|
133
|
|
|
'minstep': minliststep, |
|
134
|
|
|
'maxstep': maxliststep, |
|
135
|
|
|
'maxentries': listentries |
|
136
|
|
|
}, |
|
137
|
|
|
'sweep': { |
|
138
|
|
|
'minstep': minsweepstep, |
|
139
|
|
|
'maxstep': maxsweepstep, |
|
140
|
|
|
'maxentries': sweepentries |
|
141
|
|
|
} |
|
142
|
|
|
} |
|
143
|
|
|
return limits |
|
144
|
|
|
|
|
145
|
|
|
def on(self): |
|
146
|
|
|
""" Switches on any preconfigured microwave output. |
|
147
|
|
|
|
|
148
|
|
|
@return int: error code (0:OK, -1:error) |
|
149
|
|
|
""" |
|
150
|
|
|
self._gpib_connection.write(':OUTP ON') |
|
151
|
|
|
return 0 |
|
152
|
|
|
|
|
153
|
|
|
|
|
154
|
|
|
def off(self): |
|
155
|
|
|
""" Switches off any microwave output. |
|
156
|
|
|
|
|
157
|
|
|
@return int: error code (0:OK, -1:error) |
|
158
|
|
|
""" |
|
159
|
|
|
self._gpib_connection.write(':OUTP OFF') |
|
160
|
|
|
self._gpib_connection.write(':MODE CW') |
|
161
|
|
|
return 0 |
|
162
|
|
|
|
|
163
|
|
|
|
|
164
|
|
|
def get_power(self): |
|
165
|
|
|
""" Gets the microwave output power. |
|
166
|
|
|
|
|
167
|
|
|
@return float: the power set at the device in dBm |
|
168
|
|
|
""" |
|
169
|
|
|
return float(self._gpib_connection.ask(':POW?')) |
|
170
|
|
|
|
|
171
|
|
|
|
|
172
|
|
|
def set_power(self, power=None): |
|
173
|
|
|
""" Sets the microwave output power. |
|
174
|
|
|
|
|
175
|
|
|
@param float power: the power (in dBm) set for this device |
|
176
|
|
|
|
|
177
|
|
|
@return int: error code (0:OK, -1:error) |
|
178
|
|
|
""" |
|
179
|
|
|
if power != None: |
|
180
|
|
|
self._gpib_connection.write(':POW {:f} DBM'.format(power)) |
|
181
|
|
|
return 0 |
|
182
|
|
|
else: |
|
183
|
|
|
return -1 |
|
184
|
|
|
|
|
185
|
|
|
|
|
186
|
|
|
def get_frequency(self): |
|
187
|
|
|
""" Gets the frequency of the microwave output. |
|
188
|
|
|
|
|
189
|
|
|
@return float: frequency (in Hz), which is currently set for this device |
|
190
|
|
|
""" |
|
191
|
|
|
|
|
192
|
|
|
return float(self._gpib_connection.ask(':FREQ?')) |
|
193
|
|
|
|
|
194
|
|
|
|
|
195
|
|
|
def set_frequency(self, freq=None): |
|
196
|
|
|
""" Sets the frequency of the microwave output. |
|
197
|
|
|
|
|
198
|
|
|
@param float freq: the frequency (in Hz) set for this device |
|
199
|
|
|
|
|
200
|
|
|
@return int: error code (0:OK, -1:error) |
|
201
|
|
|
""" |
|
202
|
|
|
if freq is not None: |
|
203
|
|
|
self._gpib_connection.write(':FREQ {0:e}'.format(freq)) |
|
204
|
|
|
return 0 |
|
205
|
|
|
else: |
|
206
|
|
|
return -1 |
|
207
|
|
|
|
|
208
|
|
|
|
|
209
|
|
|
def set_cw(self, freq=None, power=None, useinterleave=None): |
|
|
|
|
|
|
210
|
|
|
""" Sets the MW mode to cw and additionally frequency and power |
|
211
|
|
|
|
|
212
|
|
|
@param float freq: frequency to set in Hz |
|
213
|
|
|
@param float power: power to set in dBm |
|
214
|
|
|
@param bool useinterleave: If this mode exists you can choose it. |
|
215
|
|
|
|
|
216
|
|
|
@return int: error code (0:OK, -1:error) |
|
217
|
|
|
|
|
218
|
|
|
Interleave option is used for arbitrary waveform generator devices. |
|
219
|
|
|
""" |
|
220
|
|
|
error = 0 |
|
221
|
|
|
self._gpib_connection.write(':MODE CW') |
|
222
|
|
|
|
|
223
|
|
|
if freq != None: |
|
224
|
|
|
error = self.set_frequency(freq) |
|
225
|
|
|
else: |
|
226
|
|
|
return -1 |
|
227
|
|
|
if power != None: |
|
228
|
|
|
error = self.set_power(power) |
|
229
|
|
|
else: |
|
230
|
|
|
return -1 |
|
231
|
|
|
|
|
232
|
|
|
return error |
|
233
|
|
|
|
|
234
|
|
|
def set_list(self, freq=None, power=None): |
|
235
|
|
|
""" Sets the MW mode to list mode |
|
236
|
|
|
|
|
237
|
|
|
@param list freq: list of frequencies in Hz |
|
238
|
|
|
@param float power: MW power of the frequency list in dBm |
|
239
|
|
|
|
|
240
|
|
|
@return int: error code (0:OK, -1:error) |
|
241
|
|
|
""" |
|
242
|
|
|
error = 0 |
|
243
|
|
|
|
|
244
|
|
|
if self.set_cw(freq[0], power) != 0: |
|
245
|
|
|
return -1 |
|
246
|
|
|
try: |
|
247
|
|
|
self._gpib_connection.write('*SRE 0') |
|
248
|
|
|
self._gpib_connection.write(':LIST:SEQ:AUTO ON') |
|
249
|
|
|
freqstring = '{0:.1f},'.format(freq[0]) + ','.join(('{0:.1f}'.format(f) for f in freq)) |
|
250
|
|
|
powstring = '{0:.3f},'.format(power) + ','.join(('{0:.3f}'.format(power) for f in freq)) |
|
251
|
|
|
self._gpib_connection.write('LIST:FREQ {0:s}'.format(freqstring)) |
|
252
|
|
|
self._gpib_connection.write('LIST:POW {0:s}'.format(powstring)) |
|
253
|
|
|
self._gpib_connection.write('LIST:DWEL 0.002000 S') |
|
254
|
|
|
self._gpib_connection.write('LIST:RFOffTime 0.000000 MS') |
|
255
|
|
|
self._gpib_connection.write('*OPC?') |
|
256
|
|
|
self._gpib_connection.write('LIST:PREC 1') |
|
257
|
|
|
# wait for '1' from OPC |
|
258
|
|
|
self._gpib_connection.read() |
|
259
|
|
|
self._gpib_connection.write(':LIST:REP STEP') |
|
260
|
|
|
self._gpib_connection.write(':TRIG:SOUR EXT') |
|
261
|
|
|
self._gpib_connection.write('*SRE 239') |
|
262
|
|
|
self._gpib_connection.write('*SRE 167') |
|
263
|
|
|
|
|
264
|
|
|
nrpoints = int(np.round(float(self._gpib_connection.query(':LIST:FREQ:POIN?')))) |
|
265
|
|
|
if nrpoints != len(freq) + 1: |
|
266
|
|
|
self.log.error('List upload failed: expected {0} points, got {1}.'.format(len(freq) + 1, nrpoints)) |
|
|
|
|
|
|
267
|
|
|
error = -1 |
|
268
|
|
|
except visa.VisaIOError: |
|
269
|
|
|
self.log.error('List upload failed, I/O error.') |
|
|
|
|
|
|
270
|
|
|
error = -1 |
|
271
|
|
|
return error |
|
272
|
|
|
|
|
273
|
|
|
def reset_listpos(self):# |
|
274
|
|
|
""" Reset of MW List Mode position to start from first given frequency |
|
275
|
|
|
|
|
276
|
|
|
@return int: error code (0:OK, -1:error) |
|
277
|
|
|
""" |
|
278
|
|
|
self._gpib_connection.write(':MODE CW') |
|
279
|
|
|
self._gpib_connection.write(':MODE LIST') |
|
280
|
|
|
mode = self._gpib_connection.query(':MODE?') |
|
281
|
|
|
return 0 if 'LIST' in mode else -1 |
|
282
|
|
|
|
|
283
|
|
|
def list_on(self): |
|
284
|
|
|
""" Switches on the list mode. |
|
285
|
|
|
|
|
286
|
|
|
@return int: error code (0:OK, -1:error) |
|
287
|
|
|
""" |
|
288
|
|
|
#self._gpib_connection.write(':LIST:REP STEP') |
|
289
|
|
|
#self._gpib_connection.write(':TRIG:SOUR EXT') |
|
290
|
|
|
#self._gpib_connection.write(':LIST:SYNC 3') |
|
291
|
|
|
#self._gpib_connection.write(':LIST:SYNC:DEL 50') |
|
292
|
|
|
#self._gpib_connection.write(':MODE LIST') |
|
293
|
|
|
self._gpib_connection.write(':OUTP ON') |
|
294
|
|
|
|
|
295
|
|
|
return 0 |
|
296
|
|
|
|
|
297
|
|
|
def set_ex_trigger(self, source, pol): |
|
|
|
|
|
|
298
|
|
|
""" Set the external trigger for this device with proper polarization. |
|
299
|
|
|
|
|
300
|
|
|
@param str source: channel name, where external trigger is expected. |
|
301
|
|
|
@param str pol: polarisation of the trigger (basically rising edge or |
|
302
|
|
|
falling edge) |
|
303
|
|
|
|
|
304
|
|
|
@return int: error code (0:OK, -1:error) |
|
305
|
|
|
""" |
|
306
|
|
|
return 0 |
|
307
|
|
|
|
|
308
|
|
|
|
|
309
|
|
|
|
|
310
|
|
|
|
|
311
|
|
|
|