Skip to content

Commit

Permalink
Add driver for Keysight B2901A SMU. Add support for SCPI concurrent s…
Browse files Browse the repository at this point in the history
…ense block.
  • Loading branch information
amba committed Nov 19, 2018
1 parent 2a74b1f commit 55d1603
Show file tree
Hide file tree
Showing 15 changed files with 1,089 additions and 254 deletions.
12 changes: 11 additions & 1 deletion lib/Lab/Measurement/Manual.pod
Expand Up @@ -136,9 +136,17 @@ alias: L<Lab::Moose::Instrument::Agilent34410A>

=item * L<Lab::Moose::Instrument::Yokogawa7651>

=item * L<Lab::Moose::Instrument::DummySource>

=back

=head3 Source/Measure Units

=over

=item * L<Lab::Moose::Instrument::Keithley2400>

=item * L<Lab::Moose::Instrument::DummySource>
=item * L<Lab::Moose::Instrument::KeysightB2901A>

=back

Expand Down Expand Up @@ -251,6 +259,8 @@ contains support for temperature sensor and He/N2 level meters.

=item * L<Lab::Moose::Instrument::SCPI::Sense::Function>

=item * L<Lab::Moose::Instrument::SCPI::Sense::Function::Concurrent>

=item * L<Lab::Moose::Instrument::SCPI::Sense::Impedance>

=item * L<Lab::Moose::Instrument::SCPI::Sense::NPLC>
Expand Down
1 change: 1 addition & 0 deletions lib/Lab/Moose/Instrument.pm
Expand Up @@ -10,6 +10,7 @@ use MooseX::Params::Validate;
use Module::Load 'load';
use Data::Dumper;
use Exporter 'import';
use Carp;

our @EXPORT_OK = qw(
timeout_param
Expand Down
164 changes: 4 additions & 160 deletions lib/Lab/Moose/Instrument/Keithley2400.pm
Expand Up @@ -32,23 +32,8 @@ has verbose => (
sub BUILD {
my $self = shift;

#

# # with USB-TMC, clear results in this error:
# # error in libusb_control_transfer_write: Pipe error at /home/simon/.plenv/versions/5.24.0/lib/perl5/site_perl/5.24.0/x86_64-linux/USB/LibUSB/Device/Handle.pm line 22.
# # apparently in USB::TMC::clear_feature_endpoint_out
# if ( $self->connection_type eq 'USB' ) {
# $self->clear( source => 1 );
# }
# else {
# $self->clear();
# }
$self->clear();
$self->cls();

# Concurrent sense is not really supported.
$self->sense_function_concurrent( value => 0 );

}

=encoding utf8
Expand Down Expand Up @@ -86,8 +71,9 @@ sub BUILD {
### Measurement
# Measure current
$source->sense_function(value => 'CURR');
$source->sense_function_on(value => ['CURR']);
# Use measurement integration time of 2 NPLC
$source->sense_function(value => 'CURR');
$source->sense_nplc(value => 2);
# Get measurement sample
Expand All @@ -111,7 +97,7 @@ Used roles:
=item L<Lab::Moose::Instrument::SCPI::Sense::NPLC>
=item L<Lab::Moose::Instrument::SCPI::Source::Function>
=item L<Lab::Moose::Instrument::SCPI::Source::Function::Concurrent>
=item L<Lab::Moose::Instrument::SCPI::Source::Level>
Expand Down Expand Up @@ -207,152 +193,10 @@ sub set_voltage {
return $self->set_level( value => $value );
}

cache source_range => ( getter => 'source_range_query' );

sub source_range_query {
my ( $self, %args ) = validated_getter( \@_ );
my $function = $self->cached_source_function();
return $self->cached_source_range(
$self->query( command => "SOUR:$function:RANG?", %args ) );
}

sub source_range {
my ( $self, $value, %args )
= validated_setter( \@_, value => { isa => 'Num' } );
my $function = $self->cached_source_function();
$self->write(
command => sprintf( "SOUR:$function:RANG %.15g", $value ),
%args
);
$self->cached_source_range($value);
}

# sub config_sweep {
# my ( $self, %args ) = validated_getter(
# \@_,
# point => { isa => 'Num' },
# rate => { isa => 'Num' },
# );

# my $target = delete $args{point};
# my $rate = delete $args{rate};

# $self->cls(%args);

# # Enforce limits
# $self->check_max_and_min($target);
# my $max_rate = $self->max_units_per_second;
# if ( $rate > $max_rate ) {
# croak "Sweep rate $rate exceeds max_untis_per_second ($max_rate)";
# }

# my $current_level = $self->get_level();
# my $time = abs( ( $target - $current_level ) / $rate );
# if ( $time < 0.1 ) {
# carp "sweep time < 0.1 seconds; adjusting to 0.1 seconds";
# $time = 0.1;
# }
# if ( $time > 3600 ) {
# croak "sweep time needs to be <= 3600 seconds";
# }

# $self->write( command => 'PROG:REP 0', %args );
# $self->write( command => sprintf( 'PROG:INT %.17g', $time ), %args );
# $self->write( command => sprintf( 'PROG:SLOP %.17g', $time ), %args );

# $self->write( command => 'PROG:EDIT:STAR', %args );

# # do not use 'source_level', no caching needed here
# $self->write( command => sprintf( "SOUR:LEV %.15g", $target ), %args );
# $self->write( command => 'PROG:EDIT:END', %args );
# }

# sub wait {
# my ( $self, %args ) = validated_getter(
# \@_,
# );
# my $verbose = $self->verbose;
# my $autoflush = STDOUT->autoflush();

# while (1) {
# if ($verbose) {
# my $level = $self->get_level(%args);
# printf( "Level: %.5e \r", $level );
# }
# if ( not $self->active(%args) ) {
# last;
# }
# }

# if ($verbose) {
# print " " x 70 . "\r";
# }

# # reset autoflush to previous value
# STDOUT->autoflush($autoflush);

# }

# sub active {
# my ( $self, %args ) = validated_getter( \@_ );

# # Set EOP (end of program) bit in Extended Event Enable Register
# $self->write( command => 'STAT:ENAB 128', %args );

# my $status = $self->get_status(%args);
# if ( $status->{'EES'} == 1 ) {
# return 0;
# }
# return 1;
# }

# # return hashref
# sub get_status {
# my ( $self, %args ) = validated_getter( \@_ );

# my $status = int( $self->query( command => '*STB?', %args ) );
# my @flags = qw/NONE EES ESB MAX NONE EAV MSS NONE/;
# my $result = {};
# for my $i ( 0 .. 7 ) {
# my $flag = $flags[$i];
# $result->{$flag} = $status & 1;
# $status >>= 1;
# }
# return $result;
# }

# sub trg {
# my ( $self, %args ) = validated_getter( \@_ );
# my $output = $self->query( command => 'OUTP:STAT?', %args );
# if ( $output == 0 ) {
# croak "output needs to be on before running a program";
# }
# $self->write( command => 'PROG:RUN' );
# }

# =head2 sweep_to_level

# $source->sweep_to_level(target => $value, rate => $rate);

# =cut

# sub sweep_to_level {
# my ( $self, %args ) = validated_getter(
# \@_,
# target => { isa => 'Num' },
# rate => { isa => 'Num' }
# );

# my $target = delete $args{target};
# my $rate = delete $args{rate};

# $self->config_sweep( point => $target, rate => $rate, %args );
# $self->trg(%args);
# $self->wait(%args);
# }

with qw(
Lab::Moose::Instrument::Common
Lab::Moose::Instrument::SCPI::Sense::Function::Concurrent
Lab::Moose::Instrument::SCPI::Sense::Protection
Lab::Moose::Instrument::SCPI::Sense::Range
Lab::Moose::Instrument::SCPI::Sense::NPLC
Expand Down

0 comments on commit 55d1603

Please sign in to comment.