| 1 | package Lab::Instrument::Lakeshore224; | ||
| 2 | #ABSTRACT: Lake Shore 224 temperature monitor | ||
| 3 | $Lab::Instrument::Lakeshore224::VERSION = '3.899'; | ||
| 4 | use v5.20; | ||
| 5 | |||
| 6 | use strict; | ||
| 7 | |||
| 8 | use Lab::Instrument; | ||
| 9 | use Lab::MultiChannelInstrument; | ||
| 10 | use Carp; | ||
| 11 | |||
| 12 | our @ISA = ( "Lab::MultiChannelInstrument", "Lab::Instrument" ); | ||
| 13 | |||
| 14 | our %fields = ( | ||
| 15 | supported_connections => [ 'VISA', 'VISA_GPIB', 'GPIB', 'DEBUG' ], | ||
| 16 | |||
| 17 | # default settings for the supported connections | ||
| 18 | connection_settings => { | ||
| 19 | gpib_board => 0, | ||
| 20 | gpib_address => 12, | ||
| 21 | connection_type => 'VISA_GPIB', | ||
| 22 | timeout => 1, | ||
| 23 | }, | ||
| 24 | |||
| 25 | device_settings => { | ||
| 26 | channels => { | ||
| 27 | ChA => 'A', | ||
| 28 | ChB => 'B', | ||
| 29 | ChC1 => 'C1', | ||
| 30 | ChC2 => 'C2', | ||
| 31 | ChC3 => 'C3', | ||
| 32 | ChC4 => 'C4', | ||
| 33 | ChC5 => 'C5', | ||
| 34 | ChD1 => 'D1', | ||
| 35 | ChD2 => 'D2', | ||
| 36 | ChD3 => 'D3', | ||
| 37 | ChD4 => 'D4', | ||
| 38 | ChD5 => 'D5', | ||
| 39 | }, | ||
| 40 | channel_default => 'ChA', | ||
| 41 | channel => undef | ||
| 42 | }, | ||
| 43 | |||
| 44 | device_cache => { T => undef }, | ||
| 45 | |||
| 46 | device_cache_order => [], | ||
| 47 | |||
| 48 | multichannel_shared_cache => [], | ||
| 49 | |||
| 50 | ); | ||
| 51 | |||
| 52 | sub new { | ||
| 53 | my $proto = shift; | ||
| 54 | my $class = ref($proto) || $proto; | ||
| 55 | my $self = $class->SUPER::new(@_); | ||
| 56 | $self->${ \( __PACKAGE__ . '::_construct' ) }(__PACKAGE__); | ||
| 57 | |||
| 58 | return $self; | ||
| 59 | } | ||
| 60 | |||
| 61 | sub _device_init { | ||
| 62 | my $self = shift; | ||
| 63 | |||
| 64 | } | ||
| 65 | |||
| 66 | sub get_tst { | ||
| 67 | my $self = shift; | ||
| 68 | my ($tail) = $self->_check_args( \@_, [] ); | ||
| 69 | |||
| 70 | return $self->query( "*TST? ", $tail ); | ||
| 71 | } | ||
| 72 | |||
| 73 | sub get_T { | ||
| 74 | my $self = shift; | ||
| 75 | my ($tail) = $self->_check_args( \@_, [] ); | ||
| 76 | |||
| 77 | return $self->query( 'KRDG? ' . $self->{channel}, $tail ); | ||
| 78 | } | ||
| 79 | |||
| 80 | sub get_R { | ||
| 81 | my $self = shift; | ||
| 82 | my ($tail) = $self->_check_args( \@_, [] ); | ||
| 83 | |||
| 84 | return $self->query( "SRDG? " . $self->{channel}, $tail ); | ||
| 85 | } | ||
| 86 | |||
| 87 | sub set_leds { | ||
| 88 | my $self = shift; | ||
| 89 | my ( $state, $tail ) = $self->_check_args( \@_, ['state'] ); | ||
| 90 | |||
| 91 | if ( defined $state and ( $state != 1 and $state != 0 ) ) { | ||
| 92 | carp('State has to be 1 or 0'); | ||
| 93 | return; | ||
| 94 | } | ||
| 95 | |||
| 96 | $self->write( "LEDS " . $state, $tail ); | ||
| 97 | } | ||
| 98 | |||
| 99 | sub get_leds { | ||
| 100 | my $self = shift; | ||
| 101 | my ($tail) = $self->_check_args( \@_, [] ); | ||
| 102 | |||
| 103 | return $self->query( "LEDS?", $tail ); | ||
| 104 | } | ||
| 105 | |||
| 106 | sub reset_minmax { | ||
| 107 | my $self = shift; | ||
| 108 | my ($tail) = $self->_check_args( \@_, [] ); | ||
| 109 | |||
| 110 | $self->write("MNMXRST"); | ||
| 111 | |||
| 112 | } | ||
| 113 | |||
| 114 | sub get_minmax { | ||
| 115 | my $self = shift; | ||
| 116 | my ($tail) = $self->_check_args( \@_, [] ); | ||
| 117 | |||
| 118 | return $self->query( "MDAT?" . $self->{channel}, $tail ); | ||
| 119 | } | ||
| 120 | |||
| 121 | sub get_T_Celsius { | ||
| 122 | my $self = shift; | ||
| 123 | my ($tail) = $self->_check_args( \@_, [] ); | ||
| 124 | |||
| 125 | return $self->query( "CRDG? " . $self->{channel}, $tail ); | ||
| 126 | } | ||
| 127 | |||
| 128 | sub get_filter { | ||
| 129 | my $self = shift; | ||
| 130 | my ($tail) = $self->_check_args( \@_, [] ); | ||
| 131 | |||
| 132 | return $self->query( "FILTER?" . $self->{channel}, $tail ); | ||
| 133 | } | ||
| 134 | |||
| 135 | sub set_filter { | ||
| 136 | my $self = shift; | ||
| 137 | my ( $on_off, $points, $window, $tail ) | ||
| 138 | = $self->_check_args( \@_, [ 'on_off', 'points', 'window' ] ); | ||
| 139 | |||
| 140 | if ( defined $on_off and ( $on_off != 1 and $on_off != 0 ) ) { | ||
| 141 | carp('on_off has to be 1 or 0'); | ||
| 142 | return; | ||
| 143 | } | ||
| 144 | |||
| 145 | if ( defined $points and ( $points < 2 or $points > 64 ) ) { | ||
| 146 | carp('Valid range for points is 2 to 64'); | ||
| 147 | return; | ||
| 148 | } | ||
| 149 | |||
| 150 | if ( defined $window and ( $window < 1 or $window > 10 ) ) { | ||
| 151 | carp('Valid range for window is 1 to 10'); | ||
| 152 | return; | ||
| 153 | } | ||
| 154 | |||
| 155 | $self->write( "FILTER $self->{channel},$on_off,$points,$window", $tail ); | ||
| 156 | } | ||
| 157 | |||
| 158 | sub get_mode { | ||
| 159 | my $self = shift; | ||
| 160 | my ($tail) = $self->_check_args( \@_, [] ); | ||
| 161 | |||
| 162 | return $self->query( "MODE?", $tail ); | ||
| 163 | } | ||
| 164 | |||
| 165 | sub set_mode { | ||
| 166 | my $self = shift; | ||
| 167 | my ( $state, $tail ) = $self->_check_args( \@_, ['state'] ); | ||
| 168 | |||
| 169 | if ( defined $state and ( $state < 1 or $state > 2 ) ) { | ||
| 170 | carp( | ||
| 171 | 'State has to be 0 (local), 1 (remote) or 2 (remote with local lockout)' | ||
| 172 | ); | ||
| 173 | return; | ||
| 174 | } | ||
| 175 | |||
| 176 | $self->write( "MODE " . $state, $tail ); | ||
| 177 | } | ||
| 178 | |||
| 179 | sub get_lock { | ||
| 180 | my $self = shift; | ||
| 181 | my ($tail) = $self->_check_args( \@_, [] ); | ||
| 182 | |||
| 183 | return $self->query( "LOCK?", $tail ); | ||
| 184 | } | ||
| 185 | |||
| 186 | sub set_lock { | ||
| 187 | my $self = shift; | ||
| 188 | my ( $state, $tail ) = $self->_check_args( \@_, ['state'] ); | ||
| 189 | |||
| 190 | if ( defined $state and ( $state != 0 and $state != 1 ) ) { | ||
| 191 | carp('State has to be 0 (unlocked) or 1 (locked)'); | ||
| 192 | return; | ||
| 193 | } | ||
| 194 | |||
| 195 | $self->write( "LOCK " . $state, $tail ); | ||
| 196 | } | ||
| 197 | |||
| 198 | sub get_alarm { | ||
| 199 | my $self = shift; | ||
| 200 | my ( $state, $tail ) = $self->_check_args( \@_, ['state'] ); | ||
| 201 | |||
| 202 | return $self->query( "ALARM?" . $self->{channel}, $tail ); | ||
| 203 | } | ||
| 204 | |||
| 205 | sub set_alarm { | ||
| 206 | my $self = shift; | ||
| 207 | my ( | ||
| 208 | $on_off, $high_setpoint, $low_setpoint, $deadband, $latch_enable, | ||
| 209 | $audible, $display, $tail | ||
| 210 | ) | ||
| 211 | = $self->_check_args( | ||
| 212 | \@_, | ||
| 213 | [ | ||
| 214 | 'on_off', 'high_setpoint', 'low_setpoint', 'deadband', | ||
| 215 | 'latch_enable', 'audible', 'display' | ||
| 216 | ] | ||
| 217 | ); | ||
| 218 | |||
| 219 | if ( defined $on_off and ( $on_off != 1 and $on_off != 0 ) ) { | ||
| 220 | carp('on_off has to be 1 or 0'); | ||
| 221 | return; | ||
| 222 | } | ||
| 223 | |||
| 224 | if ( defined $latch_enable | ||
| 225 | and ( $latch_enable != 1 or $latch_enable != 0 ) ) { | ||
| 226 | carp('latch_enable has to be 1 or 0'); | ||
| 227 | return; | ||
| 228 | } | ||
| 229 | |||
| 230 | if ( defined $audible and ( $audible != 1 and $audible != 0 ) ) { | ||
| 231 | carp('audible has to be 1 or 0'); | ||
| 232 | return; | ||
| 233 | } | ||
| 234 | |||
| 235 | if ( defined $display and ( $display != 1 or $display != 0 ) ) { | ||
| 236 | carp('display has to be 1 or 0'); | ||
| 237 | return; | ||
| 238 | } | ||
| 239 | |||
| 240 | $self->write( | ||
| 241 | "ALARM $self->{channel}, $on_off, $high_setpoint, $low_setpoint, $deadband, $latch_enable, $audible, $display", | ||
| 242 | $tail | ||
| 243 | ); | ||
| 244 | } | ||
| 245 | |||
| 246 | sub reset_alarm { | ||
| 247 | my $self = shift; | ||
| 248 | my ($tail) = $self->_check_args( \@_, [] ); | ||
| 249 | |||
| 250 | $self->write( "ALMRST", $tail ); | ||
| 251 | } | ||
| 252 | |||
| 253 | sub get_value { | ||
| 254 | my $self = shift; | ||
| 255 | return $self->get_T(@_); | ||
| 256 | } | ||
| 257 | |||
| 258 | 1; | ||
| 259 | |||
| 260 | #----------Include features in measurment scripts----------------------------------------------------------------------------------------------------------------------------------- | ||
| 261 | # use Lab::Measurement::Legacy; | ||
| 262 | |||
| 263 | # my $lake=Instrument('Lakeshore224'); | ||
| 264 | |||
| 265 | # my $t_sample=$lake->get_value(); | ||
| 266 | |||
| 267 | # my $minmax = $lake->get_minmax(); | ||
| 268 | |||
| 269 | # my $celsius = $lake->get_T_Celsius(); | ||
| 270 | |||
| 271 | # $lake->reset_minmax; | ||
| 272 | |||
| 273 | # my $light = $lake->get_leds(); | ||
| 274 | |||
| 275 | # $lake->set_leds(1); | ||
| 276 | |||
| 277 | # my $filter=$lake->get_filter(); | ||
| 278 | |||
| 279 | # my $mode=$lake->get_mode(); | ||
| 280 | |||
| 281 | # $lake->set_mode(2); #State has to be 0 (local), 1 (remote) or 2 (remote with local lockout) | ||
| 282 | |||
| 283 | # my $lock = $lake ->get_lock(); | ||
| 284 | |||
| 285 | # $lake->set_lock(0); | ||
| 286 | |||
| 287 | # my $alarm = $lake->get_alarm(); | ||
| 288 | |||
| 289 | # $lake->reset_alarm(); | ||
| 290 | |||
| 291 | # $lake->set_alarm({ | ||
| 292 | # on_off => 0, #0=off, 1=on | ||
| 293 | # high_setpoint => 296.906, | ||
| 294 | # low_setpoint => 290.00, | ||
| 295 | # deadband => 0, #Sets the value that the source must change outside of an alarm condition to deactivate an unclatched alarm | ||
| 296 | # latch_enable => 1, #Specifies wheter alarm remains active after alarm condition correction. 0=off, 1=on | ||
| 297 | # audible => 0, #speaker will beep when alarm condition occurs: 0=off, 1=on | ||
| 298 | # display => 1, #Alarm LED on front panel will blink when an alarm condition occurs: 0=off, 1=on | ||
| 299 | # }); | ||
| 300 | |||
| 301 | # $lake->set_filter({ | ||
| 302 | # on_off => 1, #Specifies wheter the filter function is 0=Off or 1=On | ||
| 303 | # points => 2, #Specifies how many data points the filtering function uses. Valid range= 2 to 64 | ||
| 304 | # window => 10, #Specifies what percent of full scale reading limits the filtering fuction. Valid range = 1 to 10 % | ||
| 305 | # }); | ||
| 306 | |||
| 307 | __END__ |