Instrument/Lakeshore340.pm untested

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