XPRESS/Sweep/Voltage.pm

filter: Statementstmt 62.5% 50 / 80 Branchbran 37.5% 6 / 16 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 84.6% 11 / 13 Podpod 14.2% 1 / 7 totaltotal 55.5% 70 / 126 SCAR 30.3
CC
11
Cov
57%
exit_loop
17.2
go_to_sweep_start
5.2
go_to_next_step
2.6
CRAP 20.7
« XPRESS/Sweep/Level.pm ↑ Summary Connection/LinuxGPIB.pm »
1 package Lab::XPRESS::Sweep::Voltage;
2 2 $Lab::XPRESS::Sweep::Voltage::VERSION = '3.881';
3 #ABSTRACT: Voltage sweep
4  
5 2 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use Lab::XPRESS::Sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Time::HiRes qw/usleep/, qw/time/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 our @ISA = ('Lab::XPRESS::Sweep');
13  
14 sub new {
15 1 ▶ my $proto = shift;
Subroutine new: called CC=2 SCAR=7.1
Pod undocumented
16 1 my @args = @_;
17 1 ▶ my $class = ref($proto) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
18 my $self->{default_config} = {
19 1 id => 'Voltage_sweep',
20 filename_extension => 'V=',
21 interval => 1,
22 points => [],
23 duration => [],
24 mode => 'continuous',
25 jump => 0,
26 allowed_instruments => [
27 qw/
28 Lab::Instrument::Yokogawa7651 Lab::Instrument::Keithley2400
29 Lab::Moose::Instrument::KeysightE3633E
30 Lab::Instrument::YokogawaGS200 Lab::Instrument::DummySource
31 Lab::Instrument::SR830::AuxOut Lab::Moose::Instrument::DummySource
32 Lab::Moose::Instrument::YokogawaGS200 Lab::Moose::Instrument::ZI_MFLI Lab::Moose::Instrument::ZI_MFIA/
33 ],
34 allowed_sweep_modes => [ 'continuous', 'list', 'step' ],
35 number_of_points => [undef]
36 };
37  
38 1 $self = $class->SUPER::new( $self->{default_config}, @args );
39 1 bless( $self, $class );
40  
41 1 return $self;
42 }
43  
44 sub go_to_sweep_start {
45 1 ▶ my $self = shift;
Subroutine go_to_sweep_start: called CC=4 SCAR=16.4
Pod undocumented
46  
47 # go to start:
48 1 print "Setting voltage to start value ... ";
49 1 ▶ if ( $self->{config}->{mode} =~ /step|list/
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'config'}{'mode'} =~ /step|list/u and $self->{'config'}{'jump'}) { } 1 0 1
Condition33%1/3
$self->{"config"}{"mode"} =~ /step|list/u and $self->{"config"}{"jump"}
!ll&&!rl&&r
001
MC/DC0%0/2
$self->{"config"}{"mode"} =~ /step|list/u and $self->{"config"}{"jump"}
$self->{"config"}{"mode"} =~ /step|list/u $self->{"config"}{"jump"}
Truth table33%1/3
A and B
A= $self->{"config"}{"mode"} =~ /step|list/uB= $self->{"config"}{"jump"}
ABresult
0X0
100
111
50 && $self->{config}->{jump} ) {
51 1 my $target = $self->{config}{points}[ $self->{iterator} ];
52 1 my $rate = $self->{config}{rate}[ $self->{iterator} ];
53 1 my $current = $self->{config}{instrument}->get_level();
54 1 my $stepwidth = $self->{config}{stepwidth}[ $self->{iterator} ];
55 1 ▶ if ( not defined $stepwidth ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $stepwidth) 0 1 1
56 0 croak "no 'stepwidth' defined for sweep with mode 'step'";
57 }
58 1 my $time = abs( ( $target - $current ) / $rate );
59 $self->{config}{instrument}
60 1 ->sweep_to_level( $target, $time, $stepwidth );
61 }
62 else {
63 $self->{config}->{instrument}->config_sweep(
64 {
65 'points' =>
66 0 @{ $self->{config}->{points} }[ $self->{iterator} ],
67 0 'rate' => @{ $self->{config}->{rate} }[ $self->{iterator} ]
68 }
69 );
70 0 $self->{config}->{instrument}->trg();
71 0 $self->{config}->{instrument}->wait();
72 }
73 1 print "Done \n";
74  
75 }
76  
77 sub start_continuous_sweep {
78 0 ▶ my $self = shift;
Subroutine start_continuous_sweep: not called CC=1 SCAR=6.9
Pod undocumented
79  
80 $self->{config}->{instrument}->config_sweep(
81 {
82 'points' =>
83 0 @{ $self->{config}->{points} }[ $self->{iterator} + 1 ],
84 0 'rate' => @{ $self->{config}->{rate} }[ $self->{iterator} + 1 ]
85 }
86 );
87 0 $self->{config}->{instrument}->trg();
88 }
89  
90 sub go_to_next_step {
91 11 ▶ my $self = shift;
Subroutine go_to_next_step: called CC=2 SCAR=9.7
Pod undocumented
92  
93 11 ▶ if ( $self->{config}->{jump} == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'config'}{'jump'} == 1) { } 11 0 11
94 $self->{config}->{instrument}->set_voltage(
95 11 ${ $self->{config}->{points} }[ $self->{iterator} ] );
96 }
97 else {
98 $self->{config}->{instrument}->config_sweep(
99 {
100 'points' =>
101 0 @{ $self->{config}->{points} }[ $self->{iterator} ],
102 0 'rate' => @{ $self->{config}->{rate} }[ $self->{iterator} ]
103 }
104 );
105 0 $self->{config}->{instrument}->trg();
106 0 $self->{config}->{instrument}->wait();
107 }
108 }
109  
110 sub exit_loop {
111 11 ▶ my $self = shift;
Subroutine exit_loop: called CC=6 SCAR=28.5
Pod undocumented
112  
113 # if ( not $self->{config}->{instrument}->active() ) {
114 11 ▶ if ( $self->{config}->{mode} =~ /step|list/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"config"}{"mode"} =~ /step|list/u) 11 0 11
115 11 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
unless (defined @{$$self{"config"}{"points"};}[$self->{"iterator"} + 1]) 1 10 11
116 not
117 11 defined @{ $self->{config}->{points} }[ $self->{iterator} + 1 ] )
118 {
119 1 return 1;
120 }
121 10 return 0;
122 }
123 0 ▶ if ( not $self->{config}->{instrument}->active() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{'config'}{'instrument'}->active) { } 0 0 0
124 0 ▶ if ( $self->{config}->{mode} eq "continuous" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"config"}{"mode"} eq "continuous") 0 0 0
125 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
unless (defined @{$$self{"config"}{"points"};}[$self->{"sequence"} + 2]) 0 0 0
126 0 not defined @{ $self->{config}->{points} }
127 [ $self->{sequence} + 2 ] ) {
128 0 return 1;
129 }
130 0 $self->{sequence}++;
131 $self->{config}->{instrument}->config_sweep(
132 {
133 0 'points' => @{ $self->{config}->{points} }
134 [ $self->{sequence} + 1 ],
135 'rate' =>
136 0 @{ $self->{config}->{rate} }[ $self->{sequence} + 1 ]
137 }
138 );
139 0 $self->{config}->{instrument}->trg();
140 }
141 0 return 0;
142 }
143 else {
144 0 return 0;
145 }
146 }
147  
148 sub get_value {
149 12 ▶ my $self = shift;
Subroutine get_value: called CC=1 SCAR=0.0
Pod documented
150 12 return $self->{config}->{instrument}->get_level();
151 }
152  
153 sub exit {
154 0 ▶ my $self = shift;
Subroutine exit: not called CC=1 SCAR=6.9
Pod undocumented
155 0 $self->{config}->{instrument}->abort();
156 }
157  
158 2 1;
159  
160 __END__
161  
162 =pod
163  
164 =encoding UTF-8
165  
166 =head1 NAME
167  
168 Lab::XPRESS::Sweep::Voltage - Voltage sweep
169  
170 =head1 VERSION
171  
172 version 3.881
173  
174 =head1 SYNOPSIS
175  
176 use Lab::XPRESS::hub;
177 my $hub = new Lab::XPRESS::hub();
178
179
180 my $Yoki = $hub->Instrument('Yokogawa7651',
181 {
182 connection_type => 'VISA_GPIB',
183 gpib_address => 2
184 });
185
186 my $sweep_voltage = $hub->Sweep('Voltage',
187 {
188 instrument => $Yoki,
189 points => [-1,1],
190 rate => [0.1,0.001],
191 mode => 'continuous',
192 interval => 1,
193 backsweep => 1
194 });
195  
196 =head1 DESCRIPTION
197  
198 Parent: Lab::XPRESS::Sweep
199  
200 The Lab::XPRESS::Sweep::Voltage class implements a module for voltage Sweeps in the Lab::XPRESS::Sweep framework.
201  
202 =head1 CONSTRUCTOR
203  
204 my $sweep_voltage = $hub->Sweep('Voltage',
205 {
206 instrument => $Yoki,
207 points => [-1,1],
208 rate => [0.1,0.001],
209 mode => 'continuous',
210 interval => 1,
211 backsweep => 1
212 });
213  
214 Instantiates a new voltage-sweep.
215  
216 =head1 PARAMETERS
217  
218 =head2 instrument [Lab::Instrument] (mandatory)
219  
220 Instrument, conducting the sweep. Must be of type Lab:Instrument.
221 Allowed instruments: Lab::Instrument::Yokogawa7651
222  
223 =head2 mode [string] (default = 'continuous' | 'step' | 'list')
224  
225 continuous: perform a continuous voltage sweep. Measurements will be performed constantly at the time-interval defined in interval.
226  
227 step: measurements will be performed at discrete values of the applied voltage between start and end points defined in parameter points, seperated by voltage steps defined in parameter stepwidth
228  
229 list: measurements will be performed at a list voltage values defined in parameter points
230  
231 =head2 points [float array] (mandatory)
232  
233 array of voltage values (in volts) that defines the characteristic points of the sweep.
234 First value is appraoched before measurement begins.
235  
236 Case mode => 'continuous' :
237 List of at least 2 values, that define start and end point of the sweep or a sequence of consecutive sweep-sections (e.g. if changing the sweep-rate for different sections or reversing the sweep direction).
238 points => [-5, 5] # Start: -5 / Stop: 5
239  
240 points => [-5, -1, 1, 5]
241  
242 points => [0, -5, 5]
243  
244 Case mode => 'step' :
245 Same as in 'continuous' but voltage will be swept in stop and go mode. I.e. voltage source approaches values between start and stop at the interval defined in 'stepwidth'. A measurement is performed, when voltage source is idle.
246  
247 Case mode => 'list' :
248 Array of voltages, with minimum length 1, that are approached in sequence to perform a measurment.
249  
250 =head2 rate [float array] (mandatory if not defined duration)
251  
252 array of rates, at which the voltage is swept (V / sec).
253 Has to be of length 1 or greater (Maximum length: length of points-array).
254 The first value defines the rate to approach the starting point.
255 The following values define the rates to approach the voltages defined by the points-array.
256 If the number of values in the rates-array is less than the length of the points-array, the last defined rate will be used for the remaining sweep sections.
257  
258 points => [-5, -1, 1, 5],
259 rates => [1, 0.005, 0.02]
260
261 rate to approach -5 V (the starting point): 1 V/sec
262 rate to approach -1 V : 0.005 V/sec
263 rate to approach 1 V : 0.02 V/sec
264 rate to approach 5 V : 0.02 V/sec (last defined rate)
265  
266 =head2 duration [float array] (mandatory if not defined rate)
267  
268 can be used instead of 'rate'. Attention: Use only the 'duration' or the 'rate' parameter. Using both will cause an Error!
269  
270 The first value defines the duration to approach the starting point.
271 The second value defines the duration to approach the voltage value defined by the second value of the points-array.
272 ...
273 If the number of values in the duration-array is less than the length of the points-array, last defined duration will be used for the remaining sweep sections.
274  
275 =head2 stepwidth [float array]
276  
277 This parameter is relevant only if mode = 'step' has been selected.
278 Stepwidth has to be an array of length '1' or greater. The values define the width for each step within the corresponding sweep sequence.
279 If the length of the defined sweep sequence devided by the stepwidth is not an integer number, the last step will be smaller in order to reach the defined points-value.
280  
281 points = [0, 0.5, 3]
282 stepwidth = [0.2, 0.5]
283
284 ==> steps: 0, 0.2, 0.4, 0.5, 1.0, 1.5, 2.0, 2.5, 3
285  
286 =head2 number_of_points [int array]
287  
288 can be used instead of 'stepwidth'. Attention: Use only the 'number_of_points' or the 'stepwidth' parameter. Using both will cause an Error!
289 This parameter is relevant only if mode = 'step' has been selected.
290 Number_of_points has to be an array of length '1' or greater. The values defines the number of steps within the corresponding sweep sequence.
291  
292 points = [0, 0.5, 3]
293 number_of_points = [5, 2]
294
295 ==> steps: 0, 0.1, 0.2, 0.3, 0.4, 0.5, 1.75, 3
296  
297 =head2 interval [float] (default = 1)
298  
299 interval in seconds for taking measurement points. Only relevant in mode 'continuous'.
300  
301 =head2 backsweep [int] (default = 0 | 1 | 2)
302  
303 0 : no backsweep (default)
304 1 : a backsweep will be performed
305 2 : no backsweep performed automatically, but sweep sequence will be reverted every second time the sweep is started (relevant eg. if sweep operates as a slave. This way the sweep sequence is reverted at every second step of the master)
306  
307 =head2 jump [int] (default = 0 | 1 )
308  
309 can be used to switch off the sweeping between adjacent points in step or list mode.
310  
311 0 : a sweep is performed between adjacent steps (default)
312 1 : the voltage is set without sweeping, given that gateprotect does not trigger a sweep.
313  
314 =head2 id [string] (default = 'Voltage_sweep')
315  
316 Just an ID.
317  
318 =head2 filename_extention [string] (default = 'V=')
319  
320 Defines a postfix, that will be appended to the filenames if necessary.
321  
322 =head2 delay_before_loop [int] (default = 0)
323  
324 defines the time in seconds to wait after the starting point has been reached.
325  
326 =head2 delay_in_loop [int] (default = 0)
327  
328 This parameter is relevant only if mode = 'step' or 'list' has been selected.
329 Defines the time in seconds to wait after the value for the next step has been reached.
330  
331 =head2 delay_after_loop [int] (default = 0)
332  
333 Defines the time in seconds to wait after the sweep has been finished. This delay will be executed before an optional backsweep or optional repetitions of the sweep.
334  
335 =head1 CAVEATS/BUGS
336  
337 probably none
338  
339 =head1 SEE ALSO
340  
341 =over 4
342  
343 =item L<Lab::XPRESS::Sweep>
344  
345 =back
346  
347 =head1 COPYRIGHT AND LICENSE
348  
349 This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
350  
351 Copyright 2012 Stefan Geissler
352 2013 Alois Dirnaichner, Andreas K. Huettel, Christian Butschkow, Stefan Geissler
353 2014 Alois Dirnaichner, Andreas K. Huettel
354 2015 Alois Dirnaichner
355 2016 Simon Reinhardt
356 2017 Andreas K. Huettel, Simon Reinhardt
357 2019 Simon Reinhardt
358 2020 Andreas K. Huettel
359  
360  
361 This is free software; you can redistribute it and/or modify it under
362 the same terms as the Perl 5 programming language system itself.
363  
364 =cut
« XPRESS/Sweep/Level.pm ↑ Summary Connection/LinuxGPIB.pm »