Instrument/Lakeshore33x.pm untested

filter: Statementstmt 0.0% 0 / 370 Branchbran 0.0% 0 / 228 Conditioncond 0.0% 0 / 168 MC/DCmcdc 0.0% 0 / 101 Subroutinesub 0.0% 0 / 35 Podpod 0.0% 0 / 31 totaltotal 0.0% 0 / 933 CC 115 SCAR 46.0
CC
115
Cov
0%
set_control_loop
306.0
set_zone
272.0
set_filter
110.0
CRAP 99.6
1 package Lab::Instrument::Lakeshore33x;
2 $Lab::Instrument::Lakeshore33x::VERSION = '3.899';
3 #ABSTRACT: Lakeshore 33x Temperature controller
4  
5 use v5.20;
6  
7 use strict;
8 use Lab::Instrument;
9 use warnings;
10  
11  
12 our @ISA = ('Lab::Instrument');
13  
14 our %fields = (
15 supported_connections => [ 'GPIB', 'VISA' ],
16  
17 # default settings for the supported connections
18 connection_settings => {
19 gpib_board => 0,
20 gpib_address => undef,
21 timeout => 1
22 },
23  
24 device_settings => {
25  
26 },
27  
28 device_cache => {
29 T => undef,
30 setpoint => undef,
31 range => undef,
32 },
33  
34 device_cache_order => [ 'function', 'range' ],
35 request => 0
36 );
37  
38 sub new {
39 my $proto = shift;
40 my $class = ref($proto) || $proto;
41 my $self = $class->SUPER::new(@_);
42 $self->${ \( __PACKAGE__ . '::_construct' ) }(__PACKAGE__);
43  
44 return $self;
45 }
46  
47 sub get_value {
48 my $self = shift;
49  
50 return $self->get_T(@_);
51 }
52  
53 sub get_T {
54  
55 my $self = shift;
56 my ( $channel, $tail ) = $self->_check_args( \@_, ['channel'] );
57  
58 if ( not defined $channel ) {
59 $channel = "A";
60 }
61 elsif ( not $channel =~ /\b(A|a|B|b)\b/ ) {
62 die
63 "unexpected value ($channel) for CHANNEL in sub get_T. Expected values are A or B.";
64 }
65  
66 return $self->query( "KRDG? $channel", $tail );
67 }
68  
69 sub set_T {
70 my $self = shift;
71 return $self->set_setpoint(@_);
72 }
73  
74 sub get_setpoint {
75  
76 my $self = shift;
77  
78 my ( $loop, $tail ) = $self->_check_args( \@_, ['loop'] );
79  
80 if ( not defined $loop ) {
81 $loop = 1;
82 }
83 elsif ( $loop != 1 and $loop != 2 ) {
84 die
85 "unexpected value ($loop) for LOOP in sub get_setpoint. Expected values are 1 or 2.";
86 }
87  
88 return $self->query("SETP? $loop");
89 }
90  
91 sub set_setpoint {
92 my $self = shift;
93  
94 my ( $setpoint, $loop, $tail )
95 = $self->_check_args( \@_, [ 'value', 'loop' ] );
96  
97 if ( not defined $loop ) {
98 $loop = 1;
99 }
100 elsif ( $loop != 1 and $loop != 2 ) {
101 die
102 "unexpected value ($loop) for LOOP in sub set_T. Expected values are 1 or 2.";
103 }
104  
105 if ( $setpoint < 0 or $setpoint > 300 ) {
106 die
107 "unexpected value ($setpoint) for SETPOINT in sub set_T. Expected values are between 0...300 K.";
108 }
109  
110 return $self->query( "SETP $loop,$setpoint; SETP? $loop", $tail );
111  
112 }
113  
114 sub set_range {
115 my $self = shift;
116 my $range = shift;
117  
118 if ( $range =~ /\b(OFF|off)\b/ ) {
119 $range = 0;
120 }
121 elsif ( $range =~ /\b(LOW|low)\b/ ) {
122 $range = 1;
123 }
124 elsif ( $range =~ /\b(MEDIUM|medium|MED|med)\b/ ) {
125 $range = 2;
126 }
127 elsif ( $range =~ /\b(HIGH|high)\b/ ) {
128 $range = 3;
129 }
130 else {
131 die
132 "unexpected value ($range) for RANGE in sub set_range. Expected values are OFF, LOW, MEDIUM, HIGH.";
133 }
134  
135 # set range
136 return $self->query("RANGE $range; RANGE?");
137  
138 }
139  
140 sub get_range {
141 my $self = shift;
142 my ($tail) = $self->_check_args( \@_, [] );
143 my $range = $self->query( "RANGE?", $tail );
144  
145 if ( $range == 0 ) {
146 $range = 'OFF';
147 }
148 elsif ( $range == 1 ) {
149 $range = 'LOW';
150 }
151 elsif ( $range == 2 ) {
152 $range = 'MEDIUM';
153 }
154 elsif ( $range == 3 ) {
155 $range = 'HIGH';
156 }
157 else {
158 die
159 "unexpected value ($range) for RANGE in sub set_range. Expected values are OFF, LOW, MEDIUM, HIGH.";
160 }
161 }
162  
163 sub set_heatercontrol {
164  
165 }
166  
167 sub set_control_mode {
168  
169 my $self = shift;
170  
171 my ( $mode, $loop, $tail )
172 = $self->_check_args( \@_, [ 'value', 'loop' ] );
173  
174 if ( not defined $loop ) {
175 $loop = 1;
176 }
177 elsif ( $loop != 1 and $loop != 2 ) {
178 die
179 "unexpected value ($loop) for LOOP in sub set_control_mode. Expected values are 1 or 2.";
180 }
181  
182 if ( $mode =~ /\b(MANUAL|manual|MAN|man)\b/ ) {
183 $mode = 1;
184 }
185 elsif ( $mode =~ /\b(ZONE|zone)\b/ ) {
186 $mode = 2;
187 }
188 elsif ( $mode =~ /\b(OFF|off)\b/ ) {
189 $mode = 3;
190 }
191 elsif ( $mode =~ /\b(AUTO_PID|auto_pid)\b/ ) {
192 $mode = 4;
193 }
194 elsif ( $mode =~ /\b(AUTO_PI|auto_pi)\b/ ) {
195 $mode = 5;
196 }
197 elsif ( $mode =~ /\b(AUTO_P|auto_p)\b/ ) {
198 $mode = 6;
199 }
200 else {
201 die
202 "unexpected value ($mode) for CONTROL MODE in sub set_controlmode. Expected values are MANUAL, ZONE, AUTO_PID, AUTO_PI, AUTO_P and OFF.";
203 }
204  
205 return $self->query("CMODE $loop,$mode; CMODE? $loop");
206  
207 }
208  
209 sub get_control_mode {
210 my $self = shift;
211 my ( $loop, $tail ) = $self->_check_args( \@_, ['loop'] );
212  
213 if ( not defined $loop ) {
214 $loop = 1;
215 }
216  
217 return $self->query( "CMODE? $loop", $tail );
218 }
219  
220 sub get_R {
221  
222 my $self = shift;
223 my ( $channel, $tail ) = $self->_check_args( \@_, ['channel'] );
224  
225 if ( not defined $channel ) {
226 $channel = "A";
227 }
228 elsif ( not $channel =~ /\b(A|a|B|b)\b/ ) {
229 die
230 "unexpected value ($channel) for CHANNEL in sub get_R. Expected values are A or B.";
231 }
232  
233 return $self->query( "SRDG? $channel", $tail );
234 }
235  
236 sub set_control_loop {
237  
238 my $self = shift;
239  
240 my ( $channel, $loop, $units, $powerup, $display, $tail )
241 = $self->_check_args(
242 \@_,
243 [ 'channel', 'loop', 'units', 'powerup', 'display' ]
244 );
245  
246 # loop optinal parameter; Usually you alwas want to use control loop 1
247 # units optinal parameter; 1 == Kelvin, 2 == Celsius, 3 == sensor units
248 # powerup optinal parameter; 0 == power up enable off, 1 == power up enable on
249 # display optinal parameter; 1 == current, 2 == power
250  
251 if ( not defined $loop ) {
252 $loop = 1;
253 }
254 elsif ( $loop != 1 and $loop != 2 ) {
255 die
256 "unexpected value ($loop) for LOOP in sub set_control_loop. Expected values are 1 or 2.";
257 }
258  
259 if ( not defined $units ) {
260 $units = 1;
261 }
262 elsif ( $units =~ /\b(KELVIN|kelvin|K|k)\b/ ) {
263 $units = 1;
264 }
265 elsif ( $units =~ /\b(CELSIUS|celsius|C|c)\b/ ) {
266 $units = 2;
267 }
268 elsif ( $units =~ /\b(SENSOR|sensor|S|s)\b/ ) {
269 $units = 3;
270 }
271 elsif ( $units != 1 and $units != 2 and $units != 3 ) {
272 die
273 "unexpected value ($units) for UNITS in sub set_control_loop. Expected values are KELVIN, CELSIUS or SENSOR.";
274 }
275  
276 if ( not defined $powerup ) {
277 $powerup = 1;
278 }
279 elsif ( $powerup =~ /\b(ON|on)\b/ ) {
280 $powerup = 1;
281 }
282 elsif ( $powerup =~ /\b(OFF|off)\b/ ) {
283 $powerup = 0;
284 }
285 elsif ( $powerup != 0 and $powerup != 1 ) {
286 die
287 "unexpected value ($powerup) for POWERUP in sub set_control_loop. Expected values are ON or OFF.";
288 }
289  
290 if ( not defined $display ) {
291 $display = 2;
292 }
293 elsif ( $display =~ /\b(CURRENT|current)\b/ ) {
294 $display = 1;
295 }
296 elsif ( $display =~ /\b(POWER|power)\b/ ) {
297 $display = 2;
298 }
299 elsif ( $display != 1 and $display != 2 ) {
300 die
301 "unexpected value ($display) for DISPLAY in sub set_control_loop. Expected values are CURRENT or POWER.";
302 }
303  
304 if ( not $channel =~ /\b(A|a|B|b)\b/ ) {
305 die
306 "unexpected value ($channel) for CHANNEL in sub set_control_loop. Expected values are 'A' or 'B'.";
307 }
308  
309 # set control loop:
310 $loop = $self->query(
311 "CSET $loop, $channel, $units, $powerup, $display; CSET? $loop",
312 $tail
313 );
314  
315 my @loop = split( /, /, $loop );
316 return @loop;
317  
318 }
319  
320 sub get_control_loop {
321 my $self = shift;
322  
323 my ( $loop, $tail ) = $self->_check_args( \@_, ['loop'] );
324  
325 if ( not defined $loop ) {
326 $loop = 1;
327 }
328 elsif ( $loop != 1 and $loop != 2 ) {
329 die
330 "unexpected value ($loop) for LOOP in sub set_control_loop. Expected values are 1 or 2.";
331 }
332  
333 my $result = $self->query( "CSET? $loop", $tail );
334  
335 return split( /, /, $result );
336  
337 }
338  
339 sub set_input_curve {
340  
341 my $self = shift;
342  
343 my ( $channel, $curve, $tail )
344 = $self->_check_args( \@_, [ 'channel', 'curve' ] );
345  
346 if ( not defined $curve and not defined $channel ) {
347 die
348 "too fiew parameters given in sub set_input_curve. Expected parameters are CHANNEL and CURVE.";
349 }
350 elsif ( not $channel =~ /\b(A|a|B|b)\b/ ) {
351 die
352 "unexpected value ($channel) for CHANNEL in sub set_input_curve. Expected values are 'A' or 'B'.";
353 }
354 elsif ( $curve < 0 and $curve > 41 ) {
355 die
356 "unexpected value ($curve) for CURVE in sub set_input_curve. Expected values are between 0 ... 41.";
357 }
358 return $self->query("INCRV $channel,$curve; INCRV? $channel");
359 }
360  
361 sub get_input_curve {
362 my $self = shift;
363 my ( $channel, $tail ) = $self->_check_args( \@_, ['channel'] );
364  
365 if ( not $channel =~ /\b(A|a|B|b)\b/ ) {
366 die
367 "unexpected value ($channel) for CHANNEL in sub set_input_curve. Expected values are 'A' or 'B'.";
368 }
369  
370 return $self->query( "INCRV? $channel", $tail );
371 }
372  
373 sub set_remote {
374 my $self = shift;
375  
376 my ( $mode, $tail ) = $self->_check_args( \@_, ['mode'] );
377  
378 if ( not defined $mode ) {
379  
380 }
381 elsif ( $mode =~ /\b(LOCAL|local)\b/ ) {
382 $mode = 0;
383 }
384 elsif ( $mode =~ /\b(REMOTE|remote)\b/ ) {
385 $mode = 1;
386 }
387 elsif ( $mode =~ /\b(LOCK|lock)\b/ ) {
388 $mode = 2;
389 }
390 else {
391 die
392 "unexpected value ($mode) for MODE in sub set_remote. Expected values are between LOCAL, REMOTE and LOCK.";
393 }
394  
395 $mode = $self->query("MODE $mode; MODE?");
396  
397 if ( $mode == 0 ) {
398 $mode = "LOCAL";
399 }
400 elsif ( $mode == 1 ) {
401 $mode = "REMOTE";
402 }
403 elsif ( $mode == 2 ) {
404 $mode = "LOCK";
405 }
406  
407 return $mode;
408 }
409  
410 sub get_remote {
411 my $self = shift;
412  
413 my ($tail) = $self->_check_args( \@_, [] );
414  
415 my $mode = $self->query( "MODE?", $tail );
416  
417 if ( $mode == 0 ) {
418 $mode = "LOCAL";
419 }
420 elsif ( $mode == 1 ) {
421 $mode = "REMOTE";
422 }
423 elsif ( $mode == 2 ) {
424 $mode = "LOCK";
425 }
426  
427 return $mode;
428 }
429  
430 # Bin bis hier her gekommen
431  
432 sub set_PID {
433 my $self = shift;
434 my $P = shift;
435 my $I = shift;
436 my $D = shift;
437 my $loop = shift
438 ; # optinal parameter; Usually you alwas want to use control loop 1
439  
440 if ( not defined $loop
441 and not defined $D
442 and not defined $I
443 and not defined $P ) {
444 $loop = 1;
445 my $PID = $self->query("PID $loop, $P, $I, $D; PID?");
446 chomp $PID;
447 chomp $PID;
448 my @PID = split( /, /, $PID );
449  
450 return @PID;
451 }
452 elsif ( not defined $loop
453 and not defined $D
454 and not defined $I
455 and ( $P == 1 or $P == 2 ) ) {
456 $loop = $P;
457 my $PID = $self->query("PID $loop, $P, $I, $D; PID?");
458 chomp $PID;
459 chomp $PID;
460 my @PID = split( /, /, $PID );
461  
462 return @PID;
463 }
464 elsif ( not defined $loop and not defined $D ) {
465 die
466 "too fiew parameters given in sub set_PID. Expected parameters are P, I, D.";
467 }
468 elsif ( not defined $loop ) {
469 $loop = 1;
470 }
471 elsif ( $loop != 1 and $loop != 2 ) {
472 die
473 "unexpected value ($loop) for LOOP in sub set_PID. Expected values are between 1 and 2.";
474 }
475  
476 # else {
477 # die "unexpected values in sub set_PID.";
478 # }
479  
480 if ( $D < 0 or $D > 200 ) {
481 die
482 "unexpected value ($D) for D in sub set_PID. Expected values are between 0 and 200.";
483 }
484 elsif ( $I < 0.1 or $I > 1000 ) {
485 die
486 "unexpected value ($I) for I in sub set_PID. Expected values are between 0.1 and 1000.";
487 }
488 elsif ( $P < 0.1 or $P > 1000 ) {
489 die
490 "unexpected value ($P) for P in sub set_PID. Expected values are between 0.1 and 1000.";
491 }
492 else {
493 my $PID = $self->query("PID $loop, $P, $I, $D; PID? $loop");
494 chomp $PID;
495 chomp $PID;
496 my @PID = split( /, /, $PID );
497  
498 return @PID;
499 }
500  
501 }
502  
503 sub set_zone {
504  
505 my $self = shift;
506 my $zone = shift;
507 my $t_limit = shift;
508 my $P = shift;
509 my $I = shift;
510 my $D = shift;
511 my $range = shift;
512 my $man_output = shift; # optional parameter, usually zero
513 my $loop = shift
514 ; # optinal parameter; Usually you alwas want to use control loop 1
515  
516 if ( defined $zone and ( $zone < 1 or $zone > 10 ) ) {
517 die
518 "unexpected value ($zone) for ZONE in sub set_zone. Expected values are all integer values from 1 to 10.";
519 }
520  
521 if ( not defined $loop ) {
522 $loop = 1;
523 }
524 elsif ( $loop != 1 and $loop != 2 ) {
525 die
526 "unexpected value ($loop) for LOOP in sub set_zone. Expected values are 1 or 2.";
527 }
528  
529 if ( not defined $man_output ) {
530 $man_output = 0;
531 }
532 elsif ( $man_output < 0 or $man_output > 100 ) {
533 die
534 "unexpected value ($man_output) for MANUAL OUTPUT in sub set_zone. Expected values are between 0 ... 100 %.";
535 }
536  
537 if ( not defined $range
538 and not defined $D
539 and not defined $I
540 and not defined $P
541 and not defined $t_limit ) {
542 return;
543 }
544  
545 if ( not defined $range ) {
546 die
547 "too fiew parameters given for sub set_zone. Expected parameters are ZONE, T_LIMIT, P, I, D, RANGE and optional <MAN_OUTPUT> and <LOOP>.";
548 }
549  
550 if ( $t_limit < 0 or $t_limit > 300 ) {
551 die
552 "unexpected value ($t_limit) for T_LIMIT in sub set_zone. Expected values are between 0 and 300 K.";
553 }
554 elsif ( $D < 0 or $D > 200 ) {
555 die
556 "unexpected value ($D) for D in sub set_zone. Expected values are between 0 and 200.";
557 }
558 elsif ( $I < 0.1 or $I > 1000 ) {
559 die
560 "unexpected value ($I) for I in sub set_zone. Expected values are between 0.1 and 1000.";
561 }
562 elsif ( $P < 0.1 or $P > 1000 ) {
563 die
564 "unexpected value ($P) for P in sub set_zone. Expected values are between 0.1 and 1000.";
565 }
566  
567 if ( $range =~ /\b(OFF|off)\b/ ) {
568 $range = 0;
569 }
570 elsif ( $range =~ /\b(LOW|low)\b/ ) {
571 $range = 1;
572 }
573 elsif ( $range =~ /\b(MEDIUM|medium|MED|med)\b/ ) {
574 $range = 2;
575 }
576 elsif ( $range =~ /\b(HIGH|high)\b/ ) {
577 $range = 3;
578 }
579 else {
580 die
581 "unexpected value ($range) for RANGE in sub set_zone. Expected values are OFF, LOW, MEDIUM, HIGH.";
582 }
583  
584 # set zone:
585 $zone
586 = $self->query(
587 "ZONE $loop, $zone, $t_limit, $P, $I, $D, $man_output, $range; ZONE?"
588 );
589 chomp $zone;
590 chomp $zone;
591 my @zone = split( /, /, $zone );
592 return @zone;
593  
594 }
595  
596 sub set_heateroutput {
597  
598 my $self = shift;
599 my $output = shift;
600 my $loop = shift
601 ; # optinal parameter; Usually you alwas want to use control loop 1
602  
603 if ( not defined $loop ) {
604 $loop = 1;
605 }
606 elsif ( $loop != 1 and $loop != 2 ) {
607 die
608 "unexpected value ($loop) for LOOP in sub set_heater_output. Expected values are 1 or 2.";
609 }
610  
611 if ( not defined $output ) {
612 $output = $self->query("Mout? $loop");
613 chomp $output;
614 chomp $output;
615 return $output;
616 }
617 elsif ( $output >= 0 and $output <= 100 ) {
618 $output = $self->query("MOUT $loop, $output; Mout? $loop");
619 chomp $output;
620 chomp $output;
621 return $output;
622 }
623 else {
624 die
625 "unexpected value ($output) for OUTPUT in sub set_heater_output. Expected values are between 0 ... 100 % of full heater range.";
626 }
627  
628 }
629  
630 sub set_input_sensor {
631  
632 my $self = shift;
633 my $channel = shift;
634 my $sensor_type = shift;
635 my $compensation = shift;
636  
637 # check input parameter:
638  
639 if ( not defined $channel ) {
640 $channel = $self->query(
641 "INTYPE $channel, $sensor_type, $compensation; INTYPE? $channel");
642 chomp $channel;
643 chomp $channel;
644 my @channel = split( /, /, $channel );
645 return @channel;
646 }
647 elsif ( not $channel =~ /\b(A|a|B|b)\b/ ) {
648 die
649 "unexpected value ($channel) for CHANNEL in sub set_input_sensor. Expected values are 'A' or 'B'.";
650 }
651  
652 if ( not defined $sensor_type ) {
653  
654 # 0 = Silicon Diode
655 # 1 = GaAlAs Diode
656 # 2 = Platinum 100/250 O
657 # 3 = Platinum 100/500 O
658 # 4 = Platinum 1000 O
659 # 5 = NTC RTD 75mV 7.5 kO
660 # 6 = Thermocouple 25 mV
661 # 7 = Thermocouple 50 mV
662 # 8 = NTC RTD 75mV 75 O
663 # 9 = NTC RTD 75mV 750 O
664 # 10 = NTC RTD 75mV 7.5 kO
665 # 11 = NTC RTD 75mV 75 kO
666 # 12 = NTC RTD 75mV Auto
667  
668 $sensor_type = 12;
669  
670 }
671 elsif ( not( $sensor_type >= 1 and $sensor_type <= 12 ) ) {
672 die
673 "unexpected value ($sensor_type) for SENSOR_TYPE in sub set_input_sensor. Expected values are all integervalues between 0 ... 12.";
674 }
675  
676 if ( not defined $compensation ) {
677 $compensation = 0; # 0 == OFF, 1 == ON
678 }
679 elsif ( $compensation =~ /\b(ON|on)\b/ ) {
680 $compensation = 1;
681 }
682 elsif ( $compensation =~ /\b(OFF|off)\b/ ) {
683 $compensation = 0;
684 }
685 elsif ( $compensation != 0 and $compensation != 1 ) {
686 die
687 "unexpected value ($compensation) for COMPENSATION in sub set_input_sensor. Expected values are ON or OFF.";
688 }
689  
690 # set input sensor:
691  
692 $channel = $self->query(
693 "INTYPE $channel, $sensor_type, $compensation; INTYPE? $channel");
694 chomp $channel;
695 chomp $channel;
696 my @channel = split( /, /, $channel );
697 return @channel;
698  
699 }
700  
701 sub set_filter {
702  
703 my $self = shift;
704 my $channel = shift;
705 my $points = shift;
706 my $window = shift;
707  
708 my $active = 1; # set the filter active after changing parameters
709  
710 # check input paramters:
711 if ( defined $channel and not $channel =~ /\b(A|a|B|b)\b/ ) {
712 die
713 "unexpected value ($channel) for CHANNEL in sub set_filter. Expected values are between 'A' and 'B'.";
714 }
715  
716 if ( not defined $window
717 and not defined $points
718 and not defined $channel ) {
719 die
720 "too fiew parameters given. Expected parameters are CHANNEL, POINTS, <WINDOW>";
721 }
722 elsif ( not defined $window and not defined $points ) {
723 my $filter = $self->query("FILTER? $channel");
724 chomp $filter;
725 chomp $filter;
726  
727 my @filter = split( /, /, $filter );
728  
729 if ( $filter[0] == 0 ) {
730 $filter[0] = 'OFF';
731 }
732 else {
733 $filter[0] = 'ON';
734 }
735  
736 return @filter;
737  
738 }
739 elsif ( not defined $window ) {
740 $window = 1;
741 }
742 elsif ( $window < 1 or $window > 10 ) {
743 die
744 "unexpected value ($window) for WINDOW in sub set_filter. Expected values are between 1 .. 10 % of full scale reading limits.";
745 }
746  
747 if ( $points =~ /\b(OFF|off)\b/ ) {
748 my $filter = $self->query("FILTER? $channel");
749 chomp $filter;
750 chomp $filter;
751 my @filter = split( /, /, $filter );
752  
753 $active = 0;
754 $points = $filter[1];
755 $window = $filter[2];
756  
757 }
758 if ( $points < 2 or $points > 64 ) {
759 die
760 "unexpected value ($points) for POINTS in sub set_filter. Expected values are between 2 .. 64.";
761 }
762  
763 # set filter paramters:
764  
765 my $filter = $self->query(
766 "FILTER $channel,$active,$points,$window; FILTER? $channel");
767 chomp $filter;
768 chomp $filter;
769 my @filter = split( /, /, $filter );
770  
771 if ( $filter[0] == 0 ) {
772 $filter[0] = 'OFF';
773 }
774 else {
775 $filter[0] = 'ON';
776 }
777  
778 return @filter;
779  
780 }
781  
782 sub config_sweep {
783 my $self = shift;
784 my $setpoint = shift;
785 my $rate = shift;
786 my $loop = shift
787 ; # optinal parameter; Usually you alwas want to use control loop 1
788  
789 if ( not defined $loop ) {
790 $loop = 1;
791 }
792 elsif ( $loop != 1 and $loop != 2 ) {
793 die
794 "unexpected value ($loop) for LOOP in sub config_sweep. Expected values are 1 or 2.";
795 }
796  
797 if ( not defined $rate or $rate < 0.1 or $rate > 100 ) {
798 die
799 "unexpected value ($rate) for RATE in sub config_sweep. Expected values are between 0...100 K/min.";
800 }
801 elsif ( not defined $setpoint or $setpoint < 0 or $setpoint > 300 ) {
802 die
803 "unexpected value ($setpoint) for SETPOINT in sub config_sweep. Expected values are between 0...300 K.";
804 }
805  
806 $rate = $self->query("RAMP $loop,0,$rate; RAMP? $loop");
807 $setpoint = $self->query("SETP $loop,$setpoint; SETP? $loop");
808  
809 return $setpoint, $rate;
810  
811 }
812  
813 sub trg {
814 my $self = shift;
815 my $loop = shift
816 ; # optinal parameter; Usually you alwas want to use control loop 1
817  
818 if ( not defined $loop ) {
819 $loop = 1;
820 }
821 elsif ( $loop != 1 and $loop != 2 ) {
822 die
823 "unexpected value ($loop) for LOOP in sub trg. Expected values are 1 or 2.";
824 }
825  
826 my $rate = $self->query("RAMP? $loop");
827 $rate = $self->write("RAMP $loop,1,$rate");
828  
829 return 1;
830  
831 }
832  
833 sub halt {
834  
835 my $self = shift;
836 my $loop = shift
837 ; # optinal parameter; Usually you alwas want to use control loop 1
838  
839 if ( not defined $loop ) {
840 $loop = 1;
841 }
842 elsif ( $loop != 1 and $loop != 2 ) {
843 die
844 "unexpected value ($loop) for LOOP in sub halt. Expected values are 1 or 2.";
845 }
846  
847 my $rate = $self->query("RAMP? $loop");
848 $rate = $self->write("RAMP $loop,0,$rate");
849  
850 # get control loop channel
851 my @channel = $self->set_control_loop();
852 my $channel = $channel[0];
853  
854 # get current temperature
855 my $temperature_now = $self->get_T($channel);
856 $self->set_T($temperature_now);
857  
858 # stop sweeping
859 $rate = $self->write("RAMP $loop,0,0.1");
860  
861 return 1;
862 }
863  
864 sub active {
865  
866 my $self = shift;
867 my $loop = shift
868 ; # optinal parameter; Usually you alwas want to use control loop 1
869  
870 if ( not defined $loop ) {
871 $loop = 1;
872 }
873 elsif ( $loop != 1 and $loop != 2 ) {
874 die
875 "unexpected value ($loop) for LOOP in sub active. Expected values are 1 or 2.";
876 }
877  
878 my $status = $self->query('RAMPST? $loop');
879 chomp $status;
880 chomp $status;
881 return $status;
882 }
883  
884 sub wait {
885  
886 my $self = shift;
887 my $loop = shift
888 ; # optinal parameter; Usually you alwas want to use control loop 1
889  
890 if ( not defined $loop ) {
891 $loop = 1;
892 }
893 elsif ( $loop != 1 and $loop != 2 ) {
894 die
895 "unexpected value ($loop) for LOOP in sub active. Expected values are 1 or 2.";
896 }
897  
898 print "waiting for the temperature sweep to end.";
899 while ( $self->active() ) {
900 print $self->get_T('A') . ", " . $self->get_T('B') . "\n";
901 }
902  
903 return;
904  
905 }
906  
907 sub id {
908 my $self = shift;
909 $self->query('*IDN?');
910 }
911  
912 sub reset {
913  
914 my $self = shift;
915 $self->write("*RST");
916  
917 }
918  
919 sub factory_reset {
920  
921 my $self = shift;
922 $self->write("DFLT 99");
923  
924 }
925  
926 1;
927  
928 __END__