-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutoMeasureSignalGen.py
122 lines (106 loc) · 3.76 KB
/
AutoMeasureSignalGen.py
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
from sourceCode.AutoMeasure import AutoMeasure
from sourceCode.Config import getCustomLogger
from pathlib import Path
import numpy as np
import sys
sys.path.append('../hardwareinterfaces')
from Rigol1000 import Rigol1022a
import time
"""
This script runs a lock-in measurement series at different frequencies or
powers with the new IR camera and creates data files from the .irb files.
"""
# DASHBOARD
name = 'PEEK07_PowerSweep'
folder = Path('E:/Thomas/2022-05-05_PEEK07')
camera = 'dell'
Sentinel = getCustomLogger(name, folder)
signalGen = Rigol1022a('USB0::0x0400::0x09C4::DG1D194304542::INSTR')
cameraFrequency = 500
dutyCycle = 0.3
# For frequency sweep
doFreqSweep = False
if doFreqSweep:
dropPeriods = None
startFreq = 0.1
stopFreq = 125
stepsFreq = 50
power = 2.5 / 2.5 # Relative power between 0 and 1 (= 0 and 0.9 W)
# For a power sweep
doPowerSweep = True
if doPowerSweep:
lockInFrequency = 1
dropPeriods = 60 * lockInFrequency
measPeriods = 60 * lockInFrequency
startPower = 0.5 / 2.5 # Relative power between 0 and 1 (= 0 and 0.9 W)
stopPower = 0.025 / 2.5
stepsPower = 39
# For a combined sweep
doCombinedSweep = False
if doCombinedSweep:
startFreq = 0.1
stopFreq = 30
stepsFreq = 30
startPower = 0.2
stopPower = 1
stepsPower = 5
# MAIN
automeasure = AutoMeasure(folder / name, camera)
camPeriod = 1 / cameraFrequency
# Do a frequency sweep
if doFreqSweep:
amplitude = round(power * 2.5, 3)
offset = amplitude / 2
for f in np.logspace(np.log10(startFreq), np.log10(stopFreq), stepsFreq):
# Calculate needed parameters
lockInFrequency = 1 / (round(cameraFrequency / f) * camPeriod)
tempDropPer = max(30 * lockInFrequency, 50)
measPeriods = 60 * lockInFrequency
# Set up instruments
automeasure.configsave(measPeriods, lockInFrequency,
tempDropPer, dutyCycle * 100)
signalGen.applySquare(lockInFrequency, amplitude, offset, dutyCycle)
signalGen.setOutput(True)
# Start measuerment
automeasure.startMeasurement()
automeasure.fileCheck()
# Do a power sweep
if doPowerSweep:
automeasure.measureCount += 53
input(2.5 * np.linspace(startPower, stopPower, stepsPower))
lockInFrequency = 1 / \
(round(cameraFrequency / lockInFrequency) * camPeriod)
automeasure.configsave(measPeriods, lockInFrequency,
dropPeriods, dutyCycle * 100)
for p in np.linspace(startPower, stopPower, stepsPower):
# Calculate needed parameters
amplitude = round(p * 2.5, 3)
offset = amplitude / 2
# Set up instruments
signalGen.applySquare(lockInFrequency, amplitude, offset, dutyCycle)
signalGen.setOutput(True)
# Start measuerment
automeasure.startMeasurement()
automeasure.fileCheck()
# Do a combined sweep
if doCombinedSweep:
for p in np.linspace(startPower, stopPower, stepsPower):
amplitude = round(p * 2.5, 3)
offset = amplitude / 2
for f in np.logspace(np.log10(startFreq), np.log10(stopFreq), stepsFreq):
# Calculate needed parameters
lockInFrequency = 1 / (round(cameraFrequency / f) * camPeriod)
dropPer = max(30 * f, 50)
measPeriods = 60 * f
# Set up instruments
automeasure.configsave(
measPeriods, lockInFrequency, dropPer, dutyCycle * 100)
signalGen.applySquare(
lockInFrequency, amplitude, offset, dutyCycle)
signalGen.setOutput(True)
# Start measuerment
automeasure.startMeasurement()
automeasure.fileCheck()
# Set signal generator to 0.5 V DC and put it into local mode
signalGen.applyDC(0.5)
signalGen.disconnect()