| 1 | package Lab::Moose::Instrument::SR830; | ||||||||||||||||||||||||||||
| 2 | 2 | $Lab::Moose::Instrument::SR830::VERSION = '3.931'; | |||||||||||||||||||||||||||
| 3 | #ABSTRACT: Stanford Research SR830 Lock-In Amplifier | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use v5.20; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Moose::Util::TypeConstraints qw/enum/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use MooseX::Params::Validate; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Lab::Moose::Instrument qw/ | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 2 | validated_getter validated_setter setter_params /; | |||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Lab::Moose::Instrument::Cache; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use POSIX qw/log10 ceil floor/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 2 | extends 'Lab::Moose::Instrument'; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 2 | with qw( | |||||||||||||||||||||||||||
| 20 | Lab::Moose::Instrument::Common | ||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 2 | has empty_buffer_count => | |||||||||||||||||||||||||||
| 24 | ( is => 'ro', isa => 'Lab::Moose::PosInt', default => 1 ); | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 1 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 28 | 1 | $self->clear(); | |||||||||||||||||||||||||||
| 29 | 1 | $self->cls(); | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | # When killing a script with Ctrl-C, garbage might remain in the output | ||||||||||||||||||||||||||||
| 32 | # buffer. Try read and catch possible timeout exception with eval. | ||||||||||||||||||||||||||||
| 33 | 1 | for ( 1 .. $self->empty_buffer_count ) { | |||||||||||||||||||||||||||
| 34 | 0 | eval { $self->read( timeout => 1 ); }; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 2 | cache frq => ( getter => 'get_frq' ); | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 4 | ▶ | sub get_frq { | ||||||||||||||||||||||||||
|
Subroutine
get_frq: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 42 | 4 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||
| 43 | 4 | return $self->cached_frq( $self->query( command => 'FREQ?', %args ) ); | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 4 | ▶ | sub set_frq { | ||||||||||||||||||||||||||
|
Subroutine
set_frq: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 47 | 4 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||
| 48 | \@_, | ||||||||||||||||||||||||||||
| 49 | value => { isa => 'Num' } | ||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 4 | $self->write( command => "FREQ $value", %args ); | |||||||||||||||||||||||||||
| 53 | 4 | $self->cached_frq($value); | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 2 | cache amplitude => ( getter => 'get_amplitude' ); | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 5 | ▶ | sub get_amplitude { | ||||||||||||||||||||||||||
|
Subroutine
get_amplitude: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 60 | 5 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||
| 61 | 5 | return $self->cached_amplitude( | |||||||||||||||||||||||||||
| 62 | $self->query( command => 'SLVL?', %args ) ); | ||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 5 | ▶ | sub set_amplitude { | ||||||||||||||||||||||||||
|
Subroutine
set_amplitude: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 5 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||
| 67 | \@_, | ||||||||||||||||||||||||||||
| 68 | value => { isa => 'Num' } | ||||||||||||||||||||||||||||
| 69 | ); | ||||||||||||||||||||||||||||
| 70 | 5 | $self->write( command => "SLVL $value", %args ); | |||||||||||||||||||||||||||
| 71 | 5 | $self->cached_amplitude($value); | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 2 | cache phase => ( getter => 'get_phase' ); | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 6 | ▶ | sub get_phase { | ||||||||||||||||||||||||||
|
Subroutine
get_phase: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 78 | 6 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||
| 79 | 6 | return $self->cached_phase( $self->query( command => 'PHAS?', %args ) ); | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 6 | ▶ | sub set_phase { | ||||||||||||||||||||||||||
|
Subroutine
set_phase: called CC=3 SCAR=12.7
Pod
documented
| |||||||||||||||||||||||||||||
| 83 | 6 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||
| 84 | \@_, | ||||||||||||||||||||||||||||
| 85 | value => { isa => 'Num' } | ||||||||||||||||||||||||||||
| 86 | ); | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 6 | ▶ | if ( $value < -360 || $value > 729.98 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$value < -360 or $value > "729.98"
MC/DC0%0/2
$value < -360 or $value > "729.98"
$value < -360
$value > "729.98"
Truth table33%1/3
A or B
A= $value < -360B= $value > "729.98"
| |||||||||||||||||||||||||||||
| 89 | 0 | croak "$value is not in allowed range of phase: [-360, 729.99] deg."; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | 6 | $self->write( command => "PHAS $value", %args ); | |||||||||||||||||||||||||||
| 92 | 6 | $self->cached_phase($value); | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 1 | ▶ | sub get_xy { | ||||||||||||||||||||||||||
|
Subroutine
get_xy: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 97 | 1 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||
| 98 | 1 | my $retval = $self->query( command => "SNAP?1,2", %args ); | |||||||||||||||||||||||||||
| 99 | 1 | my ( $x, $y ) = split( ',', $retval ); | |||||||||||||||||||||||||||
| 100 | 1 | chomp $y; | |||||||||||||||||||||||||||
| 101 | 1 | return { x => $x, y => $y }; | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 1 | ▶ | sub get_rphi { | ||||||||||||||||||||||||||
|
Subroutine
get_rphi: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 105 | 1 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||
| 106 | 1 | my $retval = $self->query( command => "SNAP?3,4", %args ); | |||||||||||||||||||||||||||
| 107 | 1 | my ( $r, $phi ) = split( ',', $retval ); | |||||||||||||||||||||||||||
| 108 | 1 | chomp $phi; | |||||||||||||||||||||||||||
| 109 | 1 | return { r => $r, phi => $phi }; | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 0 | ▶ | sub get_xyrphi { | ||||||||||||||||||||||||||
|
Subroutine
get_xyrphi: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 113 | 0 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||
| 114 | 0 | my $retval = $self->query( command => "SNAP?1,2,3,4", %args ); | |||||||||||||||||||||||||||
| 115 | 0 | my ( $x, $y, $r, $phi ) = split( ',', $retval ); | |||||||||||||||||||||||||||
| 116 | 0 | chomp( $x, $y, $r, $phi ); | |||||||||||||||||||||||||||
| 117 | 0 | return { x => $x, y => $y, r => $r, phi => $phi }; | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 2 | cache tc => ( getter => 'get_tc' ); | |||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 14 | ▶ | sub _int_to_tc { | ||||||||||||||||||||||||||
|
Subroutine
_int_to_tc: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 124 | 14 | my $self = shift; | |||||||||||||||||||||||||||
| 125 | 14 | my ($int_tc) = pos_validated_list( \@_, { isa => 'Int' } ); | |||||||||||||||||||||||||||
| 126 | 2 | ▶ | use integer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 127 | 14 | my $exponent = $int_tc / 2 - 5; | |||||||||||||||||||||||||||
| 128 | 2 | ▶ | no integer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 14 | my $tc = 10**($exponent); | |||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 14 | ▶ | if ( $int_tc % 2 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | 4 | $tc *= 3; | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | 14 | return $tc; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 6 | ▶ | sub get_tc { | ||||||||||||||||||||||||||
|
Subroutine
get_tc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 139 | 6 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||
| 140 | 6 | my $int_tc = $self->query( command => 'OFLT?', %args ); | |||||||||||||||||||||||||||
| 141 | 6 | return $self->cached_tc( $self->_int_to_tc($int_tc) ); | |||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 8 | ▶ | sub set_tc { | ||||||||||||||||||||||||||
|
Subroutine
set_tc: called CC=5 SCAR=17.1
Pod
documented
| |||||||||||||||||||||||||||||
| 145 | 8 | my ( $self, $tc, %args ) = validated_setter( | |||||||||||||||||||||||||||
| 146 | \@_, | ||||||||||||||||||||||||||||
| 147 | value => { isa => 'Num' } | ||||||||||||||||||||||||||||
| 148 | ); | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 8 | my $logval = log10($tc); | |||||||||||||||||||||||||||
| 151 | 8 | my $n = floor($logval); | |||||||||||||||||||||||||||
| 152 | 8 | my $rest = $logval - $n; | |||||||||||||||||||||||||||
| 153 | 8 | my $int_tc = 2 * $n + 10; | |||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 8 | ▶ | if ( $rest > log10(6.5) ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 156 | 0 | $int_tc += 2; | |||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | elsif ( $rest > log10(2) ) { | ||||||||||||||||||||||||||||
| 159 | 2 | $int_tc += 1; | |||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 8 | ▶ | if ( $int_tc < 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | 0 | croak "minimum value for time constant is 1e-5"; | |||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||
| 165 | 8 | ▶ | if ( $int_tc > 19 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | 0 | croak "maximum value for time constant is 30000"; | |||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 8 | $self->write( command => "OFLT $int_tc", %args ); | |||||||||||||||||||||||||||
| 170 | 8 | $self->cached_tc( $self->_int_to_tc($int_tc) ); | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 2 | cache filter_slope => ( getter => 'get_filter_slope' ); | |||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 4 | ▶ | sub get_filter_slope { | ||||||||||||||||||||||||||
|
Subroutine
get_filter_slope: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 177 | 4 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||
| 178 | 4 | my $filter_slope = $self->query( command => 'OFSL?', %args ); | |||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 4 | my %filter_slopes = ( 0 => 6, 1 => 12, 2 => 18, 3 => 24 ); | |||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 4 | return $self->cached_filter_slope( $filter_slopes{$filter_slope} ); | |||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 6 | ▶ | sub set_filter_slope { | ||||||||||||||||||||||||||
|
Subroutine
set_filter_slope: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 186 | 6 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||
| 187 | \@_, | ||||||||||||||||||||||||||||
| 188 | value => { isa => enum( [qw/6 12 18 24/] ) } | ||||||||||||||||||||||||||||
| 189 | ); | ||||||||||||||||||||||||||||
| 190 | 6 | my %filter_slopes = ( 6 => 0, 12 => 1, 18 => 2, 24 => 3 ); | |||||||||||||||||||||||||||
| 191 | 6 | my $filter_slope = $filter_slopes{$value}; | |||||||||||||||||||||||||||
| 192 | 6 | $self->write( command => "OFSL $filter_slope", %args ); | |||||||||||||||||||||||||||
| 193 | 6 | $self->cached_filter_slope($value); | |||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 17 | ▶ | sub _int_to_sens { | ||||||||||||||||||||||||||
|
Subroutine
_int_to_sens: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 198 | 17 | my $self = shift; | |||||||||||||||||||||||||||
| 199 | 17 | my ($int_sens) = pos_validated_list( \@_, { isa => 'Int' } ); | |||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 17 | ++$int_sens; | |||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 2 | ▶ | use integer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 204 | 17 | my $exponent = $int_sens / 3 - 9; | |||||||||||||||||||||||||||
| 205 | 2 | ▶ | no integer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 17 | my $sens = 10**($exponent); | |||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | 17 | ▶ | if ( $int_sens % 3 == 1 ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 210 | 4 | $sens *= 2; | |||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | elsif ( $int_sens % 3 == 2 ) { | ||||||||||||||||||||||||||||
| 213 | 7 | $sens *= 5; | |||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 17 | return $sens; | |||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | 9 | ▶ | sub _sens_to_int { | ||||||||||||||||||||||||||
|
Subroutine
_sens_to_int: called CC=6 SCAR=18.7
| |||||||||||||||||||||||||||||
| 220 | 9 | my $self = shift; | |||||||||||||||||||||||||||
| 221 | 9 | my ($sens) = pos_validated_list( \@_, { isa => 'Lab::Moose::PosNum' } ); | |||||||||||||||||||||||||||
| 222 | 9 | my $logval = log10($sens); | |||||||||||||||||||||||||||
| 223 | 9 | my $n = floor($logval); | |||||||||||||||||||||||||||
| 224 | 9 | my $rest = $logval - $n; | |||||||||||||||||||||||||||
| 225 | 9 | my $int_sens = 3 * $n + 26; | |||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 9 | ▶ | if ( $rest > log10(7.5) ) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 228 | 0 | $int_sens += 3; | |||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | elsif ( $rest > log10(3.5) ) { | ||||||||||||||||||||||||||||
| 231 | 4 | $int_sens += 2; | |||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | elsif ( $rest > log10(1.5) ) { | ||||||||||||||||||||||||||||
| 234 | 2 | $int_sens += 1; | |||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 9 | ▶ | if ( $int_sens < 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 238 | 0 | croak "minimum value for sensitivity is 2nV"; | |||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 9 | ▶ | if ( $int_sens > 26 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 242 | 0 | croak "maximum value for sensitivity is 1V"; | |||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 9 | return $int_sens; | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 2 | cache sens => ( getter => 'get_sens' ); | |||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | 8 | ▶ | sub get_sens { | ||||||||||||||||||||||||||
|
Subroutine
get_sens: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 251 | 8 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||
| 252 | 8 | my $int_sens = $self->query( command => 'SENS?', %args ); | |||||||||||||||||||||||||||
| 253 | 8 | return $self->cached_sens( $self->_int_to_sens($int_sens) ); | |||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 9 | ▶ | sub set_sens { | ||||||||||||||||||||||||||
|
Subroutine
set_sens: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 257 | 9 | my ( $self, $sens, %args ) = validated_setter( | |||||||||||||||||||||||||||
| 258 | \@_, | ||||||||||||||||||||||||||||
| 259 | value => { isa => 'Num' } | ||||||||||||||||||||||||||||
| 260 | ); | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 9 | my $int_sens = $self->_sens_to_int($sens); | |||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | 9 | $self->write( command => "SENS $int_sens", %args ); | |||||||||||||||||||||||||||
| 265 | 9 | $self->cached_sens( $self->_int_to_sens($int_sens) ); | |||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | 0 | ▶ | sub set_auto_sens { | ||||||||||||||||||||||||||
|
Subroutine
set_auto_sens: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 270 | 0 | my ( $self, %args ) = validated_getter( | |||||||||||||||||||||||||||
| 271 | \@_, | ||||||||||||||||||||||||||||
| 272 | r => { isa => 'Lab::Moose::PosNum' }, | ||||||||||||||||||||||||||||
| 273 | min_sens => { isa => 'Lab::Moose::PosNum', default => 2e-9 }, | ||||||||||||||||||||||||||||
| 274 | max_sens => { isa => 'Lab::Moose::PosNum', default => 1 }, | ||||||||||||||||||||||||||||
| 275 | up_at => { isa => 'Lab::Moose::PosNum', default => 0.9 }, | ||||||||||||||||||||||||||||
| 276 | down_at => { isa => 'Lab::Moose::PosNum', default => 0.9 } | ||||||||||||||||||||||||||||
| 277 | ); | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | my ( $r, $min_sens, $max_sens, $up_at, $down_at ) | ||||||||||||||||||||||||||||
| 280 | 0 | = delete @args{qw/r min_sens max_sens up_at down_at/}; | |||||||||||||||||||||||||||
| 281 | 0 | my $current_sens = $self->cached_sens(); | |||||||||||||||||||||||||||
| 282 | 0 | my $current_sens_int = $self->_sens_to_int($current_sens); | |||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 0 | ▶ | if ( $r > $current_sens * $up_at ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | # Go to next higher range | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | 0 | ▶ | if ( $current_sens_int == 26 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | # Already in 1V range | ||||||||||||||||||||||||||||
| 291 | 0 | return; | |||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 0 | my $upper_sens = $self->_int_to_sens( $current_sens_int + 1 ); | |||||||||||||||||||||||||||
| 295 | 0 | ▶ | if ( $upper_sens <= $max_sens ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 296 | 0 | return $self->set_sens( value => $upper_sens ); | |||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||
| 299 | elsif ( $current_sens_int > 0 ) { | ||||||||||||||||||||||||||||
| 300 | 0 | my $lower_sens = $self->_int_to_sens( $current_sens_int - 1 ); | |||||||||||||||||||||||||||
| 301 | 0 | ▶ | if ( $r < $lower_sens * $down_at ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 302 | 0 | ▶ | if ( $lower_sens >= $min_sens ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 303 | 0 | return $self->set_sens( value => $lower_sens ); | |||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||
| 308 | 0 | return; | |||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | 2 | cache input => ( getter => 'get_input' ); | |||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | 4 | ▶ | sub get_input { | ||||||||||||||||||||||||||
|
Subroutine
get_input: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 315 | 4 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||
| 316 | 4 | my $input = $self->query( command => 'ISRC?', %args ); | |||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 4 | my %inputs = ( 0 => 'A', 1 => 'AB', 2 => 'I1M', 3 => 'I100M' ); | |||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | 4 | return $self->cached_input( $inputs{$input} ); | |||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | 4 | ▶ | sub set_input { | ||||||||||||||||||||||||||
|
Subroutine
set_input: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 324 | 4 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||
| 325 | \@_, | ||||||||||||||||||||||||||||
| 326 | value => { isa => enum( [qw/A AB I1M I100M/] ) } | ||||||||||||||||||||||||||||
| 327 | ); | ||||||||||||||||||||||||||||
| 328 | 4 | my %inputs = ( A => 0, AB => 1, I1M => 2, I100M => 3 ); | |||||||||||||||||||||||||||
| 329 | 4 | my $input = $inputs{$value}; | |||||||||||||||||||||||||||
| 330 | 4 | $self->write( command => "ISRC $input", %args ); | |||||||||||||||||||||||||||
| 331 | 4 | $self->cached_input($value); | |||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | 2 | cache ground => ( getter => 'get_ground' ); | |||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | 2 | ▶ | sub get_ground { | ||||||||||||||||||||||||||
|
Subroutine
get_ground: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 338 | 2 | my ( $self, %args ) = validated_hash( \@_ ); | |||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | 2 | my $ground = $self->query( command => 'IGND?', %args ); | |||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | 2 | ▶ | return $self->cached_ground( $ground ? 'GROUND' : 'FLOAT' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 2 | ▶ | sub set_ground { | ||||||||||||||||||||||||||
|
Subroutine
set_ground: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 346 | 2 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||
| 347 | \@_, | ||||||||||||||||||||||||||||
| 348 | value => { isa => enum( [qw/GROUND FLOAT/] ) } | ||||||||||||||||||||||||||||
| 349 | ); | ||||||||||||||||||||||||||||
| 350 | 2 | ▶ | my $ground = $value eq 'GROUND' ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 351 | 2 | $self->write( command => "IGND $ground", %args ); | |||||||||||||||||||||||||||
| 352 | 2 | $self->cached_ground($value); | |||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | 2 | cache coupling => ( getter => 'get_coupling' ); | |||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | 2 | ▶ | sub get_coupling { | ||||||||||||||||||||||||||
|
Subroutine
get_coupling: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 359 | 2 | my ( $self, %args ) = validated_hash( \@_ ); | |||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | 2 | my $coupling = $self->query( command => 'ICPL?', %args ); | |||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | 2 | ▶ | return $self->cached_coupling( $coupling ? 'DC' : 'AC' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | 2 | ▶ | sub set_coupling { | ||||||||||||||||||||||||||
|
Subroutine
set_coupling: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 367 | 2 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||
| 368 | \@_, | ||||||||||||||||||||||||||||
| 369 | value => { isa => enum( [qw/AC DC/] ) } | ||||||||||||||||||||||||||||
| 370 | ); | ||||||||||||||||||||||||||||
| 371 | 2 | ▶ | my $coupling = $value eq 'DC' ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 372 | 2 | $self->write( command => "ICPL $coupling", %args ); | |||||||||||||||||||||||||||
| 373 | 2 | $self->cached_coupling($value); | |||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | 2 | cache line_notch_filters => ( getter => 'get_line_notch_filters' ); | |||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | 4 | ▶ | sub get_line_notch_filters { | ||||||||||||||||||||||||||
|
Subroutine
get_line_notch_filters: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 380 | 4 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||
| 381 | 4 | my $filters = $self->query( command => 'ILIN?', %args ); | |||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | 4 | my %filters = ( 0 => 'OUT', 1 => 'LINE', 2 => '2xLINE', 3 => 'BOTH' ); | |||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | 4 | return $self->cached_line_notch_filters( $filters{$filters} ); | |||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | 4 | ▶ | sub set_line_notch_filters { | ||||||||||||||||||||||||||
|
Subroutine
set_line_notch_filters: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 389 | 4 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||
| 390 | \@_, | ||||||||||||||||||||||||||||
| 391 | value => { isa => enum( [qw/OUT LINE 2xLINE BOTH/] ) } | ||||||||||||||||||||||||||||
| 392 | ); | ||||||||||||||||||||||||||||
| 393 | 4 | my %filters = ( OUT => 0, LINE => 1, '2xLINE' => 2, BOTH => 3 ); | |||||||||||||||||||||||||||
| 394 | 4 | my $filters = $filters{$value}; | |||||||||||||||||||||||||||
| 395 | 4 | $self->write( command => "ILIN $filters", %args ); | |||||||||||||||||||||||||||
| 396 | 4 | $self->cached_line_notch_filters($value); | |||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | 3 | ▶ | sub calculate_settling_time { | ||||||||||||||||||||||||||
|
Subroutine
calculate_settling_time: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 401 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 402 | 3 | my ($settling) = validated_list( | |||||||||||||||||||||||||||
| 403 | \@_, | ||||||||||||||||||||||||||||
| 404 | settling => enum( [qw/63.2 90 99 99.9/] ) | ||||||||||||||||||||||||||||
| 405 | ); | ||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | 3 | my $tc = $self->cached_tc(); | |||||||||||||||||||||||||||
| 408 | 3 | my $filter_slope = $self->cached_filter_slope(); | |||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | # For the following table, see "Principles of lock-in detection and the | ||||||||||||||||||||||||||||
| 411 | # state of the art" white paper by Zurich Instruments. | ||||||||||||||||||||||||||||
| 412 | 3 | my %settling_factors = ( | |||||||||||||||||||||||||||
| 413 | '6' => { | ||||||||||||||||||||||||||||
| 414 | '63.2' => 1, | ||||||||||||||||||||||||||||
| 415 | '90' => 2.3, | ||||||||||||||||||||||||||||
| 416 | '99' => 4.61, | ||||||||||||||||||||||||||||
| 417 | '99.9' => 6.91 | ||||||||||||||||||||||||||||
| 418 | }, | ||||||||||||||||||||||||||||
| 419 | '12' => { | ||||||||||||||||||||||||||||
| 420 | '63.2' => 2.15, | ||||||||||||||||||||||||||||
| 421 | '90' => 3.89, | ||||||||||||||||||||||||||||
| 422 | '99' => 6.64, | ||||||||||||||||||||||||||||
| 423 | '99.9' => 9.23 | ||||||||||||||||||||||||||||
| 424 | }, | ||||||||||||||||||||||||||||
| 425 | '18' => { | ||||||||||||||||||||||||||||
| 426 | '63.2' => 3.26, | ||||||||||||||||||||||||||||
| 427 | '90' => 5.32, | ||||||||||||||||||||||||||||
| 428 | '99' => 8.41, | ||||||||||||||||||||||||||||
| 429 | '99.9' => 11.23 | ||||||||||||||||||||||||||||
| 430 | }, | ||||||||||||||||||||||||||||
| 431 | '24' => { | ||||||||||||||||||||||||||||
| 432 | '63.2' => 4.35, | ||||||||||||||||||||||||||||
| 433 | '90' => 6.68, | ||||||||||||||||||||||||||||
| 434 | '99' => 10.05, | ||||||||||||||||||||||||||||
| 435 | '99.9' => 13.06 | ||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||
| 437 | ); | ||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||
| 439 | 3 | my $multiplier = $settling_factors{$filter_slope}->{$settling}; | |||||||||||||||||||||||||||
| 440 | 3 | return $multiplier * $tc; | |||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||
| 445 | 0 | ▶ | sub get_auxin { | ||||||||||||||||||||||||||
|
Subroutine
get_auxin: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 446 | 0 | my ( $self, %args ) = validated_getter( | |||||||||||||||||||||||||||
| 447 | \@_, | ||||||||||||||||||||||||||||
| 448 | channel => { isa => 'Int' }, | ||||||||||||||||||||||||||||
| 449 | ); | ||||||||||||||||||||||||||||
| 450 | 0 | my $channel = $args{channel}; | |||||||||||||||||||||||||||
| 451 | 0 | return $self->query( command => "OAUX? $channel", %args ); | |||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | 2 | __PACKAGE__->meta()->make_immutable(); | |||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||
| 458 | 2 | 1; | |||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||
| 460 | __END__ | ||||||||||||||||||||||||||||