| 1 | package Lab::Moose::Instrument::SR830; | ||||||||||||||||||||||||||||
| 2 | 2 | $Lab::Moose::Instrument::SR830::VERSION = '3.881'; | |||||||||||||||||||||||||||
| 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/ | |||||||||||||||||||||||||||
| 11 | 2 | ▶ | validated_getter validated_setter setter_params /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 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 | sub BUILD { | ||||||||||||||||||||||||||||
| 27 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 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 | sub get_frq { | ||||||||||||||||||||||||||||
| 42 | 4 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||||||||||||||||||||
|
Subroutine
get_frq: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 43 | 4 | return $self->cached_frq( $self->query( command => 'FREQ?', %args ) ); | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | sub set_frq { | ||||||||||||||||||||||||||||
| 47 | 4 | ▶ | my ( $self, $value, %args ) = validated_setter( | ||||||||||||||||||||||||||
|
Subroutine
set_frq: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub get_amplitude { | ||||||||||||||||||||||||||||
| 60 | 5 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||||||||||||||||||||
|
Subroutine
get_amplitude: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 61 | 5 | return $self->cached_amplitude( | |||||||||||||||||||||||||||
| 62 | $self->query( command => 'SLVL?', %args ) ); | ||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | sub set_amplitude { | ||||||||||||||||||||||||||||
| 66 | 5 | ▶ | my ( $self, $value, %args ) = validated_setter( | ||||||||||||||||||||||||||
|
Subroutine
set_amplitude: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub get_phase { | ||||||||||||||||||||||||||||
| 78 | 6 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||||||||||||||||||||
|
Subroutine
get_phase: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 79 | 6 | return $self->cached_phase( $self->query( command => 'PHAS?', %args ) ); | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | sub set_phase { | ||||||||||||||||||||||||||||
| 83 | 6 | ▶ | my ( $self, $value, %args ) = validated_setter( | ||||||||||||||||||||||||||
|
Subroutine
set_phase: called CC=3 SCAR=12.7
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub get_xy { | ||||||||||||||||||||||||||||
| 97 | 1 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||||||||||||||||||||
|
Subroutine
get_xy: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub get_rphi { | ||||||||||||||||||||||||||||
| 105 | 1 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||||||||||||||||||||
|
Subroutine
get_rphi: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub get_xyrphi { | ||||||||||||||||||||||||||||
| 113 | 0 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||||||||||||||||||||
|
Subroutine
get_xyrphi: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub _int_to_tc { | ||||||||||||||||||||||||||||
| 124 | 14 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_int_to_tc: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 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 | sub get_tc { | ||||||||||||||||||||||||||||
| 139 | 6 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||||||||||||||||||||
|
Subroutine
get_tc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub set_tc { | ||||||||||||||||||||||||||||
| 145 | 8 | ▶ | my ( $self, $tc, %args ) = validated_setter( | ||||||||||||||||||||||||||
|
Subroutine
set_tc: called CC=5 SCAR=17.1
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub get_filter_slope { | ||||||||||||||||||||||||||||
| 177 | 4 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||||||||||||||||||||
|
Subroutine
get_filter_slope: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub set_filter_slope { | ||||||||||||||||||||||||||||
| 186 | 6 | ▶ | my ( $self, $value, %args ) = validated_setter( | ||||||||||||||||||||||||||
|
Subroutine
set_filter_slope: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub _int_to_sens { | ||||||||||||||||||||||||||||
| 198 | 17 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_int_to_sens: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 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 | sub _sens_to_int { | ||||||||||||||||||||||||||||
| 220 | 9 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_sens_to_int: called CC=6 SCAR=18.7
| |||||||||||||||||||||||||||||
| 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 | sub get_sens { | ||||||||||||||||||||||||||||
| 251 | 8 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||||||||||||||||||||
|
Subroutine
get_sens: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub set_sens { | ||||||||||||||||||||||||||||
| 257 | 9 | ▶ | my ( $self, $sens, %args ) = validated_setter( | ||||||||||||||||||||||||||
|
Subroutine
set_sens: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub set_auto_sens { | ||||||||||||||||||||||||||||
| 270 | 0 | ▶ | my ( $self, %args ) = validated_getter( | ||||||||||||||||||||||||||
|
Subroutine
set_auto_sens: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub get_input { | ||||||||||||||||||||||||||||
| 315 | 4 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||||||||||||||||||||
|
Subroutine
get_input: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub set_input { | ||||||||||||||||||||||||||||
| 324 | 4 | ▶ | my ( $self, $value, %args ) = validated_setter( | ||||||||||||||||||||||||||
|
Subroutine
set_input: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub get_ground { | ||||||||||||||||||||||||||||
| 338 | 2 | ▶ | my ( $self, %args ) = validated_hash( \@_ ); | ||||||||||||||||||||||||||
|
Subroutine
get_ground: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub set_ground { | ||||||||||||||||||||||||||||
| 346 | 2 | ▶ | my ( $self, $value, %args ) = validated_setter( | ||||||||||||||||||||||||||
|
Subroutine
set_ground: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub get_coupling { | ||||||||||||||||||||||||||||
| 359 | 2 | ▶ | my ( $self, %args ) = validated_hash( \@_ ); | ||||||||||||||||||||||||||
|
Subroutine
get_coupling: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub set_coupling { | ||||||||||||||||||||||||||||
| 367 | 2 | ▶ | my ( $self, $value, %args ) = validated_setter( | ||||||||||||||||||||||||||
|
Subroutine
set_coupling: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub get_line_notch_filters { | ||||||||||||||||||||||||||||
| 380 | 4 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||||||||||||||||||||
|
Subroutine
get_line_notch_filters: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub set_line_notch_filters { | ||||||||||||||||||||||||||||
| 389 | 4 | ▶ | my ( $self, $value, %args ) = validated_setter( | ||||||||||||||||||||||||||
|
Subroutine
set_line_notch_filters: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub calculate_settling_time { | ||||||||||||||||||||||||||||
| 401 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
calculate_settling_time: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | sub get_auxin { | ||||||||||||||||||||||||||||
| 446 | 0 | ▶ | my ( $self, %args ) = validated_getter( | ||||||||||||||||||||||||||
|
Subroutine
get_auxin: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||
| 462 | =pod | ||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||
| 464 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||
| 466 | =head1 NAME | ||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||
| 468 | Lab::Moose::Instrument::SR830 - Stanford Research SR830 Lock-In Amplifier | ||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | =head1 VERSION | ||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||
| 472 | version 3.881 | ||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||
| 474 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||
| 476 | use Lab::Moose; | ||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | # Constructor | ||||||||||||||||||||||||||||
| 479 | my $lia = instrument( | ||||||||||||||||||||||||||||
| 480 | type => 'SR830', | ||||||||||||||||||||||||||||
| 481 | connection_type => 'VISA::GPIB', | ||||||||||||||||||||||||||||
| 482 | connection_options => {'gpib_address' => 10} | ||||||||||||||||||||||||||||
| 483 | ); | ||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | # Set reference frequency to 10 kHz | ||||||||||||||||||||||||||||
| 486 | $lia->set_frq(value => 10000); | ||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||
| 488 | # Set time constant to 10 sec | ||||||||||||||||||||||||||||
| 489 | $lia->set_tc(value => 10); | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | # Set sensitivity to 1 mV | ||||||||||||||||||||||||||||
| 492 | $lia->set_sens(value => 0.001); | ||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | # Get X and Y values | ||||||||||||||||||||||||||||
| 495 | my $xy = $lia->get_xy(); | ||||||||||||||||||||||||||||
| 496 | say "X: ", $xy->{x}; | ||||||||||||||||||||||||||||
| 497 | say "Y: ", $xy->{y}; | ||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | =head1 METHODS | ||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||
| 501 | =head2 get_frq | ||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||
| 503 | my $frq = $lia->get_frq(); | ||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||
| 505 | Query frequency of the reference oscillator. | ||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | =head2 set_frq | ||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||
| 509 | $lia->set_frq(value => $frq); | ||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | Set frequency of the reference oscillator. | ||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||
| 513 | =head2 get_amplitude | ||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||
| 515 | my $ampl = $lia->get_amplitude(); | ||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | Query amplitude of the sine output. | ||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||
| 519 | =head2 set_amplitude | ||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||
| 521 | $lia->set_amplitude(value => $ampl); | ||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||
| 523 | Set amplitude of the sine output. | ||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||
| 525 | =head2 get_phase | ||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | my $phase = $lia->get_phase(); | ||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | Get reference phase shift (in degree). Result is between -180 and 180. | ||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||
| 531 | =head2 set_phase | ||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | $lia->set_phase(value => $phase); | ||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||
| 535 | Set reference phase shift. The C<$phase> parameter has to be between -360 and | ||||||||||||||||||||||||||||
| 536 | 729.99. | ||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||
| 538 | =head2 get_xy | ||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | my $xy = $lia->get_xy(); | ||||||||||||||||||||||||||||
| 541 | my $x = $xy->{x}; | ||||||||||||||||||||||||||||
| 542 | my $y = $xy->{y}; | ||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||
| 544 | Query the X and Y values. | ||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||
| 546 | =head2 get_rphi | ||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||
| 548 | My $rphi = $lia->get_rphi(); | ||||||||||||||||||||||||||||
| 549 | my $r = $rphi->{r}; | ||||||||||||||||||||||||||||
| 550 | my $phi = $rphi->{phi}; | ||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||
| 552 | Query R and the angle (in degree). | ||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||
| 554 | =head2 get_xyrphi | ||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | Get x, y, R and the angle all in one call. | ||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||
| 558 | =head2 get_tc | ||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||
| 560 | my $tc = $lia->get_tc(); | ||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | Query the time constant. | ||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | =head2 set_tc | ||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | # Set tc to 30μs | ||||||||||||||||||||||||||||
| 567 | $lia->set_tc(value => 30e-6); | ||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||
| 569 | Set the time constant. The value is rounded to the nearest valid | ||||||||||||||||||||||||||||
| 570 | value. Rounding is performed in logscale. Croak if the the value is out of | ||||||||||||||||||||||||||||
| 571 | range. | ||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||
| 573 | =head2 get_filter_slope | ||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | my $filter_slope = $lia->get_filter_slope(); | ||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||
| 577 | Query the low pass filter slope (dB/oct). Possible return values: | ||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||
| 579 | =over | ||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||
| 581 | =item * 6 | ||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||
| 583 | =item * 12 | ||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||
| 585 | =item * 18 | ||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||
| 587 | =item * 24 | ||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||
| 589 | =back | ||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||
| 591 | =head2 set_filter_slope | ||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||
| 593 | $lia->set_filter_slope(value => 18); | ||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||
| 595 | Set the low pass filter slope (dB/oct). Allowed values: | ||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||
| 597 | =over | ||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||
| 599 | =item * 6 | ||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||
| 601 | =item * 12 | ||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||
| 603 | =item * 18 | ||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||
| 605 | =item * 24 | ||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||
| 607 | =back | ||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||
| 609 | =head2 get_sens | ||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||
| 611 | my $sens = $lia->get_sens(); | ||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||
| 613 | Get sensitivity (in Volt). | ||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||
| 615 | =head2 set_sens | ||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||
| 617 | $lia->set_sens(value => $sens); | ||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||
| 619 | Set sensitivity (in Volt). | ||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||
| 621 | Same rounding as for C<set_tc>. | ||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||
| 623 | =head2 set_auto_sens | ||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||
| 625 | my $rphi = $lia->get_rphi | ||||||||||||||||||||||||||||
| 626 | my $r = $rphi->{r}; | ||||||||||||||||||||||||||||
| 627 | $lia->set_auto_sens( | ||||||||||||||||||||||||||||
| 628 | r => $r, | ||||||||||||||||||||||||||||
| 629 | min_sens => 10e-6, # Smallest allowed range is 10μV (default: 2nV range) | ||||||||||||||||||||||||||||
| 630 | max_sens => 2e-3 , # Largest allowed range is 2mV (default: 1V range) | ||||||||||||||||||||||||||||
| 631 | up_at => 0.8 , # Go to next higher sens if $r is above 80% | ||||||||||||||||||||||||||||
| 632 | # of current range (default: 90%) | ||||||||||||||||||||||||||||
| 633 | down_at => 0.8 , # Go to next lower sens if $r is below 80% of | ||||||||||||||||||||||||||||
| 634 | # next lower sens (default: 90%) | ||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||
| 636 | ); | ||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||
| 638 | Set optimal sensitvity for current input signal, determined from the C<r> attribute. | ||||||||||||||||||||||||||||
| 639 | Except for C<r>, all attributes are optional. For stable operation, 1 > C<up_at> >= C<down_at> is required. | ||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||
| 641 | If the sensitvity is changed, return the new value. Otherwise return nothing. | ||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||
| 643 | =head2 get_input | ||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||
| 645 | my $input = $lia->get_input(); | ||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||
| 647 | Query the input configuration. Possible return values: | ||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||
| 649 | =over | ||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||
| 651 | =item * A | ||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||
| 653 | =item * AB | ||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||
| 655 | =item * I1M | ||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||
| 657 | =item * I100M | ||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||
| 659 | =back | ||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||
| 661 | =head2 set_input | ||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||
| 663 | $lia->set_input(value => 'AB'); | ||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||
| 665 | Set input configuration. Allowed values: | ||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||
| 667 | =over | ||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||
| 669 | =item * A | ||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||
| 671 | =item * AB | ||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||
| 673 | =item * I1M | ||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||
| 675 | =item * I100M | ||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||
| 677 | =back | ||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||
| 679 | =head2 get_ground | ||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||
| 681 | my $ground = $lia->get_ground(); | ||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||
| 683 | Query the input shield grounding. Possible return values: | ||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||
| 685 | =over | ||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||
| 687 | =item * GROUND | ||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||
| 689 | =item * FLOAT | ||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||
| 691 | =back | ||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||
| 693 | =head2 set_ground | ||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||
| 695 | $lia->set_ground(value => 'GROUND'); | ||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||
| 697 | # or: | ||||||||||||||||||||||||||||
| 698 | $lia->set_ground(value => 'FLOAT'); | ||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||
| 700 | Set the input shield grounding. Allowed values: | ||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||
| 702 | =over | ||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||
| 704 | =item * GROUND | ||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||
| 706 | =item * FLOAT | ||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||
| 708 | =back | ||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||
| 710 | =head2 get_coupling | ||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||
| 712 | my $coupling = $lia->get_coupling(); | ||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||
| 714 | Query the input coupling. Possible return values: | ||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||
| 716 | =over | ||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||
| 718 | =item * AC | ||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||
| 720 | =item * DC | ||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||
| 722 | =back | ||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||
| 724 | =head2 set_coupling | ||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||
| 726 | $lia->set_coupling(value => 'AC'); | ||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||
| 728 | # or: | ||||||||||||||||||||||||||||
| 729 | $lia->set_coupling(value => 'DC'); | ||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||
| 731 | Set the input coupling. Allowed values: | ||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||
| 733 | =over | ||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||
| 735 | =item * AC | ||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||
| 737 | =item * DC | ||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||
| 739 | =back | ||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||
| 741 | =head2 get_line_notch_filters | ||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||
| 743 | my $filters = $lia->get_line_notch_filters(); | ||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||
| 745 | Query the line notch filter configuration. Possible return values: | ||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||
| 747 | =over | ||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||
| 749 | =item * OUT | ||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||
| 751 | =item * LINE | ||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||
| 753 | =item * 2xLINE | ||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||
| 755 | =item * BOTH | ||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||
| 757 | =back | ||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||
| 759 | =head2 set_line_notch_filters | ||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||
| 761 | $lia->set_line_notch_filters(value => 'BOTH'); | ||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||
| 763 | Set the line notch filter configuration. Allowed values: | ||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||
| 765 | =over | ||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||
| 767 | =item * OUT | ||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||
| 769 | =item * LINE | ||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||
| 771 | =item * 2xLINE | ||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||
| 773 | =item * BOTH | ||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||
| 775 | =back | ||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||
| 777 | =head2 calculate_settling_time | ||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||
| 779 | my $settling_time = $lia->calculate_settling_time(settling => '99'); | ||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||
| 781 | Calculate settling time independent of current time constant and filter slope. | ||||||||||||||||||||||||||||
| 782 | See "Principles of lock-in detection and the state of the art" white paper by | ||||||||||||||||||||||||||||
| 783 | Zurich Instruments. The C<settling> parameter is given in percent. Allowed | ||||||||||||||||||||||||||||
| 784 | values: | ||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||
| 786 | =over | ||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||
| 788 | =item * '63.2' | ||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||
| 790 | =item * '90' | ||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||
| 792 | =item * '99' | ||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||
| 794 | =item * '99.9' | ||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||
| 796 | =back | ||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||
| 798 | =head2 get_auxin | ||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||
| 800 | my $v = $lia->get_auxin(); | ||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||
| 802 | Measure voltage on one of the four auxiliary input ports 1..4. | ||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||
| 804 | =head2 Consumed Roles | ||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||
| 806 | This driver consumes the following roles: | ||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||
| 808 | =over | ||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||
| 810 | =item L<Lab::Moose::Instrument::Common> | ||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||
| 812 | =back | ||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||
| 814 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||
| 816 | This software is copyright (c) 2023 by the Lab::Measurement team; in detail: | ||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||
| 818 | Copyright 2016 Simon Reinhardt | ||||||||||||||||||||||||||||
| 819 | 2017 Andreas K. Huettel, Simon Reinhardt | ||||||||||||||||||||||||||||
| 820 | 2018 Simon Reinhardt | ||||||||||||||||||||||||||||
| 821 | 2020-2021 Andreas K. Huettel, Simon Reinhardt | ||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||
| 824 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 825 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||
| 827 | =cut | ||||||||||||||||||||||||||||