#============================================================ # Keithley236 #============================================================ package Keithley236; use Device::DeviceObject; @ISA = qw(DeviceObject); #公開したいサブルーチン @EXPORT = qw(); use strict; use Deps; #============================================================ # 大域変数 #============================================================ # コマンドごとのsleep時間(秒) my $delay = 0.1; # s #============================================================ # コンストラクタ、デストラクタ #============================================================ BEGIN { } sub new { my ($module, @args) = @_; my $this = {}; bless $this; return $this; } sub DESTROY { my $this = shift; $this->Finish(); } #============================================================ # 変数取得関数 #============================================================ sub GetFunctions { return "|DCISource|DCVSource|DCIMeasure|DCVMeasure|ACVMeasure|ACIMeasure|"; } #============================================================ # 一般関数 #============================================================ sub Initialize { my ($this) = @_; $this->Clear(); $this->Reset(); $this->SetVSourceOutput("off"); $this->SetSourceVoltage(0.0); # $this->print(":syst:zcheck off\n"); } sub Finish { my ($this) = @_; $this->SetVSourceOutput("off"); $this->SetSourceVoltage(0.0); } sub Clear { my ($this) = @_; # $this->print("*CLS\n"); } sub Reset { my ($this) = @_; # $this->print("*RST\n"); } sub GetId { my ($this) = @_; $this->print("U0X\n"); return $this->read(); } sub SetDCCurrentMode { my ($this, $ZeroCheck) = @_; return $this->SetVSourceIMeasureMode($ZeroCheck); } sub SetVSourceIMeasureMode { my ($this, $ZeroCheck) = @_; $this->print("F0,0X\n"); $this->print("S3X\n"); $this->print("P1X\n"); $this->print("H0X\n"); Utils::sleep($delay); } sub SetDCVoltageMode { my ($this, $ZeroCheck) = @_; return $this->SetISourceVMeasureMode($ZeroCheck); } sub SetISourceVMeasureMode { my ($this, $ZeroCheck) = @_; $this->print("F1,0X\n"); $this->print("S3X\n"); $this->print("P1X\n"); $this->print("H0X\n"); Utils::sleep($delay); } sub Measure { my ($this) = @_; $this->print("G4,0,0X\n"); Utils::sleep($delay); my $ReturnStr = $this->read(); ($ReturnStr) = ($ReturnStr =~ /^(\S*)\s*$/); my ($ValueStr) = ($ReturnStr =~ /([+\-\d\.E]+)/i); #print "Ret: $ReturnStr: $ValueStr\n"; return $ValueStr; } sub SetSourceVoltage { my ($this, $V) = @_; $this->print("B$V,0,0X\n"); Utils::sleep($delay); $this->print("H0X\n"); } sub SetSourceCurrent { my ($this, $I) = @_; $this->print("B$I,0,0X\n"); Utils::sleep($delay); $this->print("H0X\n"); } sub SetVSourceOutput { my ($this, $f) = @_; # $f = 'on' or 'off'; if($f eq 'on') { $this->print("N1X\n"); } else { $this->print("N0X\n"); } } sub SetIMeasureLimit { my ($this, $ILimit) = @_; if($ILimit == 0.0) { $this->print("L100.0e-3,0X\n"); } elsif($ILimit <= 1.0e-9) { $this->print("L$ILimit,1X\n"); } elsif($ILimit <= 1.0e-8) { $this->print("L$ILimit,2X\n"); } elsif($ILimit <= 1.0e-7) { $this->print("L$ILimit,3X\n"); } elsif($ILimit <= 1.0e-6) { $this->print("L$ILimit,4X\n"); } elsif($ILimit <= 1.0e-5) { $this->print("L$ILimit,5X\n"); } elsif($ILimit <= 1.0e-4) { $this->print("L$ILimit,6X\n"); } elsif($ILimit <= 1.0e-3) { $this->print("L$ILimit,7X\n"); } elsif($ILimit <= 1.0e-2) { $this->print("L$ILimit,8X\n"); } elsif($ILimit <= 1.0e-1) { $this->print("L$ILimit,9X\n"); } else { print "Error: Keithley236::SetIMeasureLimit: Illeagal Current limit [$ILimit].\n"; return undef; } Utils::sleep($delay); return 1; } sub SetVMeasureLimit { my ($this, $VLimit) = @_; if($VLimit == 0.0) { $this->print("L11,0X\n"); } elsif($VLimit <= 1.1) { $this->print("L$VLimit,1X\n"); } elsif($VLimit <= 11) { $this->print("L$VLimit,2X\n"); } else { print "Error: Keithley236::SetVMeasureLimit: Illeagal Voltage limit [$VLimit].\n"; return undef; } Utils::sleep($delay); return 1; } sub SetAutoRangeForCurrent { my ($this, $f) = @_; # $f = 'ON' or 'OFF' if($f eq 'ON') { $this->SetIMeasureLimit(0.0); } else { $this->SetIMeasureLimit(1.0e-3); } Utils::sleep($delay); } 1;