line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lab::Instrument::TCD; |
2
|
|
|
|
|
|
|
#ABSTRACT: Temperature control for our Oxford Instruments TLM dilution fridge |
3
|
|
|
|
|
|
|
$Lab::Instrument::TCD::VERSION = '3.880'; |
4
|
1
|
|
|
1
|
|
1711
|
use v5.20; |
|
1
|
|
|
|
|
5
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
7
|
1
|
|
|
1
|
|
6
|
use Lab::Instrument; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
697
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @ISA = ("Lab::Instrument"); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our %fields = ( |
12
|
|
|
|
|
|
|
supported_connections => [ 'VISA_RS232', 'RS232', 'IsoBus', 'DEBUG' ], |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
connection_settings => { |
15
|
|
|
|
|
|
|
baudrate => 9600, |
16
|
|
|
|
|
|
|
databits => 8, |
17
|
|
|
|
|
|
|
stopbits => 1, |
18
|
|
|
|
|
|
|
parity => 'none', |
19
|
|
|
|
|
|
|
handshake => 'none', |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#rs232_echo => 'character', |
22
|
|
|
|
|
|
|
termchar => "\r", |
23
|
|
|
|
|
|
|
timeout => 1 |
24
|
|
|
|
|
|
|
}, |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
device_settings => { read_default => 'device' }, |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
device_cache => { |
29
|
|
|
|
|
|
|
id => 'Temperature Control', |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#T => undef |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub new { |
37
|
0
|
|
|
0
|
1
|
|
my $proto = shift; |
38
|
0
|
|
0
|
|
|
|
my $class = ref($proto) || $proto; |
39
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
40
|
0
|
|
|
|
|
|
$self->${ \( __PACKAGE__ . '::_construct' ) }(__PACKAGE__); |
|
0
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
return $self; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub get_value { |
46
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
47
|
0
|
|
|
|
|
|
return $self->get_T(@_); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub get_T { |
51
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
52
|
0
|
|
|
|
|
|
my ($read_mode) = $self->_check_args( \@_, ['read_mode'] ); |
53
|
0
|
|
|
|
|
|
my $temperature = "xxxxxxxx"; |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
0
|
|
|
|
if ( not defined $read_mode |
56
|
|
|
|
|
|
|
or not $read_mode =~ /device|cache|request|fetch/ ) { |
57
|
0
|
|
|
|
|
|
$read_mode = $self->device_settings()->{read_default}; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
0
|
|
|
|
if ( $read_mode eq 'cache' and defined $self->{'device_cache'}->{'T'} ) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
return $self->{'device_cache'}->{'T'}; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
elsif ( $read_mode eq 'request' ) { |
64
|
0
|
0
|
|
|
|
|
if ( $self->{'request'} != 0 ) { |
65
|
0
|
|
|
|
|
|
eval "$self->read();"; |
66
|
|
|
|
|
|
|
} |
67
|
0
|
|
|
|
|
|
while ( ( $self->write("getTemp\r\n") < 0 ) ) { |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#print "repeat sending\n"; |
70
|
|
|
|
|
|
|
} |
71
|
0
|
|
|
|
|
|
$self->{'request'} = 1; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
elsif ( $read_mode eq 'fetch' and $self->{'request'} == 1 ) { |
74
|
0
|
|
|
|
|
|
$self->{'request'} = 0; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
my $temperature; |
77
|
0
|
|
|
|
|
|
while (1) { |
78
|
0
|
|
|
|
|
|
eval '$temperature = $self->read()'; |
79
|
0
|
0
|
0
|
|
|
|
if ($@) { |
|
|
0
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
next; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
elsif ( $temperature < 0 or $temperature > 1.5 ) { |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
#print "from cache"; |
85
|
0
|
|
|
|
|
|
return $self->{'device_cache'}->{'T'}; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
else { |
88
|
0
|
|
|
|
|
|
chomp $temperature; |
89
|
0
|
|
|
|
|
|
$self->{'device_cache'}->{'T'} = $temperature; |
90
|
0
|
|
|
|
|
|
return $self->{'device_cache'}->{'T'}; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
else { |
97
|
0
|
|
|
|
|
|
for ( my $i = 0; $i < 3; $i++ ) { |
98
|
0
|
|
|
|
|
|
$self->write("getTemp\r\n"); |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
for ( my $j = 0; $j < 3; $j++ ) { |
101
|
0
|
|
|
|
|
|
eval '$temperature = $self->read()'; |
102
|
0
|
0
|
0
|
|
|
|
if ($@) { |
|
|
0
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
next; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
elsif ( $temperature < 0 or $temperature > 1.5 ) { |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
#print "from cache"; |
108
|
0
|
|
|
|
|
|
return $self->{'device_cache'}->{'T'}; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
else { |
111
|
0
|
|
|
|
|
|
chomp $temperature; |
112
|
0
|
|
|
|
|
|
$self->{'device_cache'}->{'T'} = $temperature; |
113
|
0
|
|
|
|
|
|
return $self->{'device_cache'}->{'T'}; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
return $self->{'device_cache'}->{'T'}; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub set_T { |
125
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
126
|
0
|
|
|
|
|
|
my ($temperature) = $self->_check_args( \@_, ['temperaure'] ); |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
my $temp = $self->query("setTemp\r\n$temperature\r\n"); |
129
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
chomp $temp; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
#sleep(1); |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
return $temp; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub set_heateroff { |
138
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
139
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
$self->write("heaterOff\r\n"); |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub set_heatercontrol { |
145
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
146
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
return; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
# sub stabilize_T { |
151
|
|
|
|
|
|
|
# my $self = shift; |
152
|
|
|
|
|
|
|
# my $external_sensor = shift; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# my $T = $self->get_T(); |
155
|
|
|
|
|
|
|
# my $Idc = $external_sensor->get_value(); |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
# push(@{$self->{data_buffer_T}}, $T); |
158
|
|
|
|
|
|
|
# push(@{$self->{data_buffer_Idc}}, $Idc); |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
# @{$self->{data_buffer_T}}= sort(@{$self->{data_buffer_T}}); |
161
|
|
|
|
|
|
|
# @{$self->{data_buffer_Idc}} = sort(@{$self->{data_buffer_Idc}}); |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
# my $length = @{$self->{data_buffer_T}}; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
# my $median_T = @{$self->{data_buffer_T}}[$length/2]; |
166
|
|
|
|
|
|
|
# my $median_Idc = @{$self->{data_buffer_Idc}}[$length/2]; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
# my $range_T = abs(@{$self->{data_buffer_T}}[-1]-@{$self->{data_buffer_T}}[0]); |
169
|
|
|
|
|
|
|
# my $range_Idc = abs(@{$self->{data_buffer_Idc}}[-1]-@{$self->{data_buffer_Idc}}[0]); |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
# print "Legth of buffer = $length\n"; |
172
|
|
|
|
|
|
|
# print "Median T = $median_T\n"; |
173
|
|
|
|
|
|
|
# print "Range T = $range_T\n"; |
174
|
|
|
|
|
|
|
# print "Median Idc = $median_Idc\n"; |
175
|
|
|
|
|
|
|
# print "Range Idc = $range_Idc\n"; |
176
|
|
|
|
|
|
|
# print "\n"; |
177
|
|
|
|
|
|
|
# print "T = $T\n"; |
178
|
|
|
|
|
|
|
# print "Idc = $Idc\n"; |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
# if ( $length > 30 ) |
181
|
|
|
|
|
|
|
# { |
182
|
|
|
|
|
|
|
# #print abs($median_T - @{$self->{data_buffer_T}}[-1])." ?= ".(0.01*$range_T)."\n"; |
183
|
|
|
|
|
|
|
# if ( $range_T <= abs(0.05*$T) ) |
184
|
|
|
|
|
|
|
# { |
185
|
|
|
|
|
|
|
# print "T stable\n"; |
186
|
|
|
|
|
|
|
# if ( $range_Idc <= abs(0.01*$Idc) ) |
187
|
|
|
|
|
|
|
# { |
188
|
|
|
|
|
|
|
# print "Idc stable\n"; |
189
|
|
|
|
|
|
|
# return 0; |
190
|
|
|
|
|
|
|
# } |
191
|
|
|
|
|
|
|
# return 1; |
192
|
|
|
|
|
|
|
# } |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
# shift @{$self->{data_buffer_T}}; |
195
|
|
|
|
|
|
|
# shift @{$self->{data_buffer_Idc}}; |
196
|
|
|
|
|
|
|
# } |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
# print "===============================\n\n\n"; |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
# return 1; |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
# } |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
1; |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
__END__ |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=pod |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=encoding UTF-8 |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 NAME |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Lab::Instrument::TCD - Temperature control for our Oxford Instruments TLM dilution fridge |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 VERSION |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
version 3.880 |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head1 SYNOPSIS |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
use Lab::Instrument::RS232; |
223
|
|
|
|
|
|
|
my $rs232=new Lab::Instrument::RS232(); |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
use Lab::Instrument::TCD; |
226
|
|
|
|
|
|
|
my $tcd=new Lab::Instrument::TCD($rs232,$addr); |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head1 DESCRIPTION |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
The Lab::Instrument::ITC class implements an interface to our Oxford Dilution Fridge |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
my $tcd=new Lab::Instrument::TCD($rs232,$addr); |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
Instantiates a new object attached to the RS232 port. |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head1 METHODS |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head2 get_T |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
$temperature=$tcd->get_T(); |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
Returns the current temperature of the mixing chamber. |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head2 set_T |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
$temperature=$tcd->set_T($temperature); |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
Set target value for the temperature control circuit. |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=over 4 |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=item $temperature |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
TEMPERATURE can be between 0 ... 1 K. |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=back |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=head2 set_heateroff |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
$temperature=$tcd->set_heateroff(); |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
Switch OFF the heater for the mixing chamber |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=head1 CAVEATS/BUGS |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
probably many |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=head1 SEE ALSO |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=over 4 |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=item L<Lab::Instrument> |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=back |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
This software is copyright (c) 2023 by the Lab::Measurement team; in detail: |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
Copyright 2013 Christian Butschkow |
283
|
|
|
|
|
|
|
2016 Simon Reinhardt |
284
|
|
|
|
|
|
|
2017 Andreas K. Huettel |
285
|
|
|
|
|
|
|
2020 Andreas K. Huettel |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
289
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=cut |