| 1 | package Lab::Moose::Instrument::Keithley2450; | ||||||||||||||
| 2 | 1 | $Lab::Moose::Instrument::Keithley2450::VERSION = '3.881'; | |||||||||||||
| 3 | #ABSTRACT: Keithley 2450 voltage/current sourcemeter. | ||||||||||||||
| 4 | |||||||||||||||
| 5 | 1 | ▶ | use v5.20; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | 1 | ▶ | use Moose; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 1 | ▶ | use MooseX::Params::Validate; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | use Lab::Moose::Instrument | ||||||||||||||
| 10 | 1 | ▶ | qw/validated_getter validated_setter setter_params/; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | 1 | ▶ | use Lab::Moose::Instrument::Cache; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 12 | 1 | ▶ | use Carp; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 13 | 1 | ▶ | use namespace::autoclean; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 14 | |||||||||||||||
| 15 | 1 | extends 'Lab::Moose::Instrument'; | |||||||||||||
| 16 | |||||||||||||||
| 17 | around default_connection_options => sub { | ||||||||||||||
| 18 | 0 | ▶ | my $orig = shift; | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||
| 19 | 0 | my $self = shift; | |||||||||||||
| 20 | 0 | my $options = $self->$orig(); | |||||||||||||
| 21 | 0 | my $usb_opts = { vid => 0x05e6, pid => 0x2450 }; # FIXME | |||||||||||||
| 22 | 0 | $options->{USB} = $usb_opts; | |||||||||||||
| 23 | 0 | $options->{'VISA::USB'} = $usb_opts; | |||||||||||||
| 24 | 0 | return $options; | |||||||||||||
| 25 | 1 | }; | |||||||||||||
| 26 | |||||||||||||||
| 27 | 1 | has [qw/max_units_per_second max_units_per_step min_units max_units/] => | |||||||||||||
| 28 | ( is => 'ro', isa => 'Num', required => 1 ); | ||||||||||||||
| 29 | |||||||||||||||
| 30 | 1 | has source_level_timestamp => ( | |||||||||||||
| 31 | is => 'rw', | ||||||||||||||
| 32 | isa => 'Num', | ||||||||||||||
| 33 | init_arg => undef, | ||||||||||||||
| 34 | ); | ||||||||||||||
| 35 | |||||||||||||||
| 36 | 1 | has verbose => ( | |||||||||||||
| 37 | is => 'ro', | ||||||||||||||
| 38 | isa => 'Bool', | ||||||||||||||
| 39 | default => 1 | ||||||||||||||
| 40 | ); | ||||||||||||||
| 41 | |||||||||||||||
| 42 | sub BUILD { | ||||||||||||||
| 43 | 0 | ▶ | my $self = shift; | ||||||||||||
|
Subroutine
BUILD: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 44 | |||||||||||||||
| 45 | 0 | $self->clear(); | |||||||||||||
| 46 | 0 | $self->cls(); | |||||||||||||
| 47 | } | ||||||||||||||
| 48 | |||||||||||||||
| 49 | |||||||||||||||
| 50 | |||||||||||||||
| 51 | sub set_level { | ||||||||||||||
| 52 | 0 | ▶ | my ( $self, $value, %args ) = validated_setter( | ||||||||||||
|
Subroutine
set_level: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 53 | \@_, | ||||||||||||||
| 54 | value => { isa => 'Num' }, | ||||||||||||||
| 55 | ); | ||||||||||||||
| 56 | |||||||||||||||
| 57 | 0 | return $self->linear_step_sweep( | |||||||||||||
| 58 | to => $value, verbose => $self->verbose, | ||||||||||||||
| 59 | %args | ||||||||||||||
| 60 | ); | ||||||||||||||
| 61 | } | ||||||||||||||
| 62 | |||||||||||||||
| 63 | |||||||||||||||
| 64 | sub get_value { | ||||||||||||||
| 65 | 0 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||||||
|
Subroutine
get_value: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 66 | 0 | return $self->query( command => 'READ?', %args ); | |||||||||||||
| 67 | } | ||||||||||||||
| 68 | |||||||||||||||
| 69 | |||||||||||||||
| 70 | sub source_limit { | ||||||||||||||
| 71 | 0 | ▶ | my ( $self, $value, %args ) = validated_setter( | ||||||||||||
|
Subroutine
source_limit: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||
| 72 | \@_, | ||||||||||||||
| 73 | value => { isa => 'Num' }, | ||||||||||||||
| 74 | ); | ||||||||||||||
| 75 | 0 | my $func = $self->cached_source_function(); | |||||||||||||
| 76 | 0 | my $lim_func; | |||||||||||||
| 77 | |||||||||||||||
| 78 | 0 | ▶ | if ( $func eq 'VOLT' ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 79 | 0 | $lim_func = 'I'; | |||||||||||||
| 80 | } | ||||||||||||||
| 81 | elsif ( $func eq 'CURR' ) { | ||||||||||||||
| 82 | 0 | $lim_func = 'V'; | |||||||||||||
| 83 | } | ||||||||||||||
| 84 | else { | ||||||||||||||
| 85 | 0 | croak("unknown source function $func (must one of VOLT or CURR)"); | |||||||||||||
| 86 | } | ||||||||||||||
| 87 | 0 | $self->write( command => "SOUR:${func}:${lim_func}LIM $value", %args ); | |||||||||||||
| 88 | } | ||||||||||||||
| 89 | |||||||||||||||
| 90 | sub source_limit_query { | ||||||||||||||
| 91 | 0 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||||||
|
Subroutine
source_limit_query: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||
| 92 | |||||||||||||||
| 93 | 0 | my $func = $self->cached_source_function(); | |||||||||||||
| 94 | 0 | my $lim_func; | |||||||||||||
| 95 | |||||||||||||||
| 96 | 0 | ▶ | if ( $func eq 'VOLT' ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 97 | 0 | $lim_func = 'I'; | |||||||||||||
| 98 | } | ||||||||||||||
| 99 | elsif ( $func eq 'CURR' ) { | ||||||||||||||
| 100 | 0 | $lim_func = 'V'; | |||||||||||||
| 101 | } | ||||||||||||||
| 102 | else { | ||||||||||||||
| 103 | 0 | croak("unknown source function $func (must one of VOLT or CURR)"); | |||||||||||||
| 104 | } | ||||||||||||||
| 105 | 0 | return $self->query( command => "SOUR:${func}:${lim_func}LIM?", %args ); | |||||||||||||
| 106 | } | ||||||||||||||
| 107 | |||||||||||||||
| 108 | # | ||||||||||||||
| 109 | # Aliases for Lab::XPRESS::Sweep API | ||||||||||||||
| 110 | # | ||||||||||||||
| 111 | |||||||||||||||
| 112 | |||||||||||||||
| 113 | sub cached_level { | ||||||||||||||
| 114 | 0 | ▶ | my $self = shift; | ||||||||||||
|
Subroutine
cached_level: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 115 | 0 | return $self->cached_source_level(@_); | |||||||||||||
| 116 | } | ||||||||||||||
| 117 | |||||||||||||||
| 118 | |||||||||||||||
| 119 | sub get_level { | ||||||||||||||
| 120 | 0 | ▶ | my $self = shift; | ||||||||||||
|
Subroutine
get_level: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 121 | 0 | return $self->source_level_query(@_); | |||||||||||||
| 122 | } | ||||||||||||||
| 123 | |||||||||||||||
| 124 | |||||||||||||||
| 125 | sub set_voltage { | ||||||||||||||
| 126 | 0 | ▶ | my $self = shift; | ||||||||||||
|
Subroutine
set_voltage: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 127 | 0 | my $value = shift; | |||||||||||||
| 128 | 0 | return $self->set_level( value => $value ); | |||||||||||||
| 129 | } | ||||||||||||||
| 130 | |||||||||||||||
| 131 | 1 | with qw( | |||||||||||||
| 132 | Lab::Moose::Instrument::Common | ||||||||||||||
| 133 | Lab::Moose::Instrument::SCPI::Output::State | ||||||||||||||
| 134 | Lab::Moose::Instrument::SCPI::Sense::Function | ||||||||||||||
| 135 | Lab::Moose::Instrument::SCPI::Sense::Range | ||||||||||||||
| 136 | Lab::Moose::Instrument::SCPI::Sense::NPLC | ||||||||||||||
| 137 | Lab::Moose::Instrument::SCPI::Source::Function | ||||||||||||||
| 138 | Lab::Moose::Instrument::SCPI::Source::Level | ||||||||||||||
| 139 | Lab::Moose::Instrument::SCPI::Source::Range | ||||||||||||||
| 140 | Lab::Moose::Instrument::LinearStepSweep | ||||||||||||||
| 141 | ); | ||||||||||||||
| 142 | |||||||||||||||
| 143 | 1 | __PACKAGE__->meta()->make_immutable(); | |||||||||||||
| 144 | |||||||||||||||
| 145 | 1 | 1; | |||||||||||||
| 146 | |||||||||||||||
| 147 | __END__ | ||||||||||||||
| 148 | |||||||||||||||
| 149 | =pod | ||||||||||||||
| 150 | |||||||||||||||
| 151 | =encoding UTF-8 | ||||||||||||||
| 152 | |||||||||||||||
| 153 | =head1 NAME | ||||||||||||||
| 154 | |||||||||||||||
| 155 | Lab::Moose::Instrument::Keithley2450 - Keithley 2450 voltage/current sourcemeter. | ||||||||||||||
| 156 | |||||||||||||||
| 157 | =head1 VERSION | ||||||||||||||
| 158 | |||||||||||||||
| 159 | version 3.881 | ||||||||||||||
| 160 | |||||||||||||||
| 161 | =head1 SYNOPSIS | ||||||||||||||
| 162 | |||||||||||||||
| 163 | use Lab::Moose; | ||||||||||||||
| 164 | |||||||||||||||
| 165 | my $smu = instrument( | ||||||||||||||
| 166 | type => 'Keithley2450', | ||||||||||||||
| 167 | connection_type => 'LinuxGPIB', | ||||||||||||||
| 168 | connection_options => {gpib_address => 15}, | ||||||||||||||
| 169 | # mandatory protection settings | ||||||||||||||
| 170 | max_units_per_step => 0.001, # max step is 1mV/1mA | ||||||||||||||
| 171 | max_units_per_second => 0.01, | ||||||||||||||
| 172 | min_units => -10, | ||||||||||||||
| 173 | max_units => 10, | ||||||||||||||
| 174 | ); | ||||||||||||||
| 175 | |||||||||||||||
| 176 | ### Sourcing | ||||||||||||||
| 177 | |||||||||||||||
| 178 | |||||||||||||||
| 179 | # Source voltage | ||||||||||||||
| 180 | $smu->source_function(value => 'VOLT'); | ||||||||||||||
| 181 | $smu->source_range(value => 210); | ||||||||||||||
| 182 | |||||||||||||||
| 183 | # Step-sweep to new level. | ||||||||||||||
| 184 | # Stepsize and speed is given by (max|min)_units* settings. | ||||||||||||||
| 185 | $smu->set_level(value => 9); | ||||||||||||||
| 186 | |||||||||||||||
| 187 | # Get current level from device cache (without sending a query to the | ||||||||||||||
| 188 | # instrument): | ||||||||||||||
| 189 | my $level = $smu->cached_level(); | ||||||||||||||
| 190 | |||||||||||||||
| 191 | ### Measurement | ||||||||||||||
| 192 | |||||||||||||||
| 193 | # Measure current | ||||||||||||||
| 194 | $smu->sense_function(value => 'CURR'); | ||||||||||||||
| 195 | $smu->sense_nplc(value => 2); | ||||||||||||||
| 196 | |||||||||||||||
| 197 | # Get value of current | ||||||||||||||
| 198 | my $current = $smu->get_value(); | ||||||||||||||
| 199 | |||||||||||||||
| 200 | =head1 METHODS | ||||||||||||||
| 201 | |||||||||||||||
| 202 | Used roles: | ||||||||||||||
| 203 | |||||||||||||||
| 204 | =over | ||||||||||||||
| 205 | |||||||||||||||
| 206 | =item L<Lab::Moose::Instrument::Common> | ||||||||||||||
| 207 | |||||||||||||||
| 208 | =item L<Lab::Moose::Instrument::SCPI::Output::State> | ||||||||||||||
| 209 | |||||||||||||||
| 210 | =item L<Lab::Moose::Instrument::SCPI::Sense::Range> | ||||||||||||||
| 211 | |||||||||||||||
| 212 | =item L<Lab::Moose::Instrument::SCPI::Sense::NPLC> | ||||||||||||||
| 213 | |||||||||||||||
| 214 | =item L<Lab::Moose::Instrument::SCPI::Source::Function> | ||||||||||||||
| 215 | |||||||||||||||
| 216 | =item L<Lab::Moose::Instrument::SCPI::Source::Level> | ||||||||||||||
| 217 | |||||||||||||||
| 218 | =item L<Lab::Moose::Instrument::SCPI::Source::Range> | ||||||||||||||
| 219 | |||||||||||||||
| 220 | =item L<Lab::Moose::Instrument::LinearStepSweep> | ||||||||||||||
| 221 | |||||||||||||||
| 222 | =back | ||||||||||||||
| 223 | |||||||||||||||
| 224 | =head2 set_level | ||||||||||||||
| 225 | |||||||||||||||
| 226 | $smu->set_level(value => $new_level); | ||||||||||||||
| 227 | |||||||||||||||
| 228 | Go to new level. Sweep with multiple steps if the distance between current and | ||||||||||||||
| 229 | new level is larger than C<max_units_per_step>. | ||||||||||||||
| 230 | |||||||||||||||
| 231 | =head2 get_value | ||||||||||||||
| 232 | |||||||||||||||
| 233 | my $value = $smu->get_value(); | ||||||||||||||
| 234 | |||||||||||||||
| 235 | Perform measurement of value defined by C<sense_function>. | ||||||||||||||
| 236 | |||||||||||||||
| 237 | =head2 source_limit/source_limit_query | ||||||||||||||
| 238 | |||||||||||||||
| 239 | Set current compliance limit of voltage source to 1mA | ||||||||||||||
| 240 | |||||||||||||||
| 241 | $smu->source_function(value => 'VOLT'); | ||||||||||||||
| 242 | $smu->source_limit(value => 1e-3); | ||||||||||||||
| 243 | |||||||||||||||
| 244 | Set voltage compliance limit of current source to 1V | ||||||||||||||
| 245 | |||||||||||||||
| 246 | $smu->source_function(value => 'CURR'); | ||||||||||||||
| 247 | $smu->source_limit(value => 1); | ||||||||||||||
| 248 | |||||||||||||||
| 249 | Get current source limit | ||||||||||||||
| 250 | my $limit = $smu->source_limit_query(); | ||||||||||||||
| 251 | |||||||||||||||
| 252 | =head2 cached_level | ||||||||||||||
| 253 | |||||||||||||||
| 254 | my $current_level = $smu->cached_level(); | ||||||||||||||
| 255 | |||||||||||||||
| 256 | Get current value from device cache. | ||||||||||||||
| 257 | |||||||||||||||
| 258 | =head2 get_level | ||||||||||||||
| 259 | |||||||||||||||
| 260 | my $current_level = $smu->get_level(); | ||||||||||||||
| 261 | |||||||||||||||
| 262 | Query current level. | ||||||||||||||
| 263 | |||||||||||||||
| 264 | =head2 set_voltage | ||||||||||||||
| 265 | |||||||||||||||
| 266 | $smu->set_voltage($value); | ||||||||||||||
| 267 | |||||||||||||||
| 268 | For XPRESS voltage sweep. Equivalent to C<< set_level(value => $value) >>. | ||||||||||||||
| 269 | |||||||||||||||
| 270 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||
| 271 | |||||||||||||||
| 272 | This software is copyright (c) 2023 by the Lab::Measurement team; in detail: | ||||||||||||||
| 273 | |||||||||||||||
| 274 | Copyright 2021 Simon Reinhardt | ||||||||||||||
| 275 | |||||||||||||||
| 276 | |||||||||||||||
| 277 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||
| 278 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||
| 279 | |||||||||||||||
| 280 | =cut | ||||||||||||||