| 1 | package Lab::Moose::Instrument::HP33120A; | ||
| 2 | 1 | $Lab::Moose::Instrument::HP33120A::VERSION = '3.881'; | |
| 3 | #ABSTRACT: HP 33120A 15 MHz Arbitrary Waveform Generator, also as voltage source | ||
| 4 | |||
| 5 | 1 | ▶ | use v5.20; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use Time::HiRes qw (usleep); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 1 | ▶ | use Moose::Util::TypeConstraints qw/enum/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 1 | ▶ | use MooseX::Params::Validate; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 1 | use Lab::Moose::Instrument qw/ | |
| 13 | validated_getter | ||
| 14 | validated_setter | ||
| 15 | validated_no_param_setter | ||
| 16 | setter_params | ||
| 17 | 1 | ▶ | /; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 18 | 1 | ▶ | use Lab::Moose::Instrument::Cache; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 19 | 1 | ▶ | use Carp; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 20 | 1 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 21 | 1 | ▶ | use Time::HiRes qw/time usleep/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 22 | 1 | ▶ | use Lab::Moose 'linspace'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 23 | |||
| 24 | 1 | extends 'Lab::Moose::Instrument'; | |
| 25 | |||
| 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 | 0 | $self->get_id(); | |
| 45 | } | ||
| 46 | |||
| 47 | sub get_id { | ||
| 48 | 0 | ▶ | my $self = shift; |
|
Subroutine
get_id: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 49 | 0 | return $self->query( command => sprintf("*IDN?") ); | |
| 50 | } | ||
| 51 | |||
| 52 | |||
| 53 | |||
| 54 | sub reset { | ||
| 55 | 0 | ▶ | my $self = shift; |
|
Subroutine
reset: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 56 | 0 | $self->write( command => sprintf("*RST") ); | |
| 57 | } | ||
| 58 | |||
| 59 | |||
| 60 | sub set_frq { | ||
| 61 | 0 | ▶ | my ( $self, $value, %args ) = validated_setter( \@_, |
|
Subroutine
set_frq: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 62 | value => { isa => 'Num' }, | ||
| 63 | ); | ||
| 64 | |||
| 65 | 0 | $self->write( command => sprintf("FREQuency %d Hz", $value), %args ); | |
| 66 | } | ||
| 67 | |||
| 68 | |||
| 69 | sub get_frq { | ||
| 70 | 0 | ▶ | my $self = shift; |
|
Subroutine
get_frq: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 71 | |||
| 72 | 0 | return $self->query( command => sprintf("FREQuency?") ); | |
| 73 | } | ||
| 74 | |||
| 75 | |||
| 76 | sub set_amplitude { | ||
| 77 | 0 | ▶ | my ( $self, $value, %args ) = validated_setter( \@_, |
|
Subroutine
set_amplitude: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 78 | value => { isa => 'Num' }, | ||
| 79 | ); | ||
| 80 | |||
| 81 | 0 | $self->write( command => sprintf("VOLTage %e V", $value) ); | |
| 82 | } | ||
| 83 | |||
| 84 | |||
| 85 | sub get_amplitude { | ||
| 86 | 0 | ▶ | my $self = shift; |
|
Subroutine
get_amplitude: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 87 | |||
| 88 | 0 | return $self->query( command => sprintf("VOLTage?") ); | |
| 89 | } | ||
| 90 | |||
| 91 | |||
| 92 | |||
| 93 | sub set_offset { | ||
| 94 | 0 | ▶ | my ( $self, $value, %args ) = validated_setter( \@_, |
|
Subroutine
set_offset: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 95 | value => { isa => 'Num' }, | ||
| 96 | ); | ||
| 97 | |||
| 98 | 0 | $self->write( command => sprintf("VOLTage:OFFSet %e V", $value) ); | |
| 99 | } | ||
| 100 | |||
| 101 | |||
| 102 | sub get_offset { | ||
| 103 | 0 | ▶ | my $self = shift; |
|
Subroutine
get_offset: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 104 | |||
| 105 | 0 | return $self->query( command => "VOLTage:OFFSet?" ); | |
| 106 | } | ||
| 107 | |||
| 108 | # | ||
| 109 | # from here on we define the voltage source interface to be able | ||
| 110 | # to use the AWG as replacement for a boring dc source | ||
| 111 | # | ||
| 112 | |||
| 113 | 1 | cache source_level => ( getter => 'source_level_query' ); | |
| 114 | |||
| 115 | sub source_level_query { | ||
| 116 | 0 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); |
|
Subroutine
source_level_query: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 117 | |||
| 118 | 0 | return $self->cached_source_level( | |
| 119 | $self->get_offset() | ||
| 120 | ); | ||
| 121 | } | ||
| 122 | |||
| 123 | sub source_level { | ||
| 124 | 0 | ▶ | my ( $self, $value, %args ) = validated_setter( |
|
Subroutine
source_level: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 125 | \@_, | ||
| 126 | value => { isa => 'Num' } | ||
| 127 | ); | ||
| 128 | |||
| 129 | 0 | $self->set_offset( value => $value, %args ); | |
| 130 | 0 | $self->cached_source_level($value); | |
| 131 | } | ||
| 132 | |||
| 133 | |||
| 134 | sub set_level { | ||
| 135 | 0 | ▶ | my ( $self, $value, %args ) = validated_setter( |
|
Subroutine
set_level: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 136 | \@_, | ||
| 137 | value => { isa => 'Num' }, | ||
| 138 | ); | ||
| 139 | |||
| 140 | 0 | return $self->linear_step_sweep( | |
| 141 | to => $value, verbose => $self->verbose, | ||
| 142 | %args | ||
| 143 | ); | ||
| 144 | } | ||
| 145 | |||
| 146 | |||
| 147 | sub cached_level { | ||
| 148 | 0 | ▶ | my $self = shift; |
|
Subroutine
cached_level: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 149 | 0 | return $self->cached_source_level(@_); | |
| 150 | } | ||
| 151 | |||
| 152 | |||
| 153 | sub get_level { | ||
| 154 | 0 | ▶ | my $self = shift; |
|
Subroutine
get_level: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 155 | 0 | return $self->source_level_query(@_); | |
| 156 | } | ||
| 157 | |||
| 158 | # odds and oods | ||
| 159 | |||
| 160 | |||
| 161 | sub selftest { | ||
| 162 | 0 | ▶ | my $self = shift; |
|
Subroutine
selftest: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 163 | 0 | return $self->query( command => sprintf("*TST?") ); | |
| 164 | } | ||
| 165 | |||
| 166 | sub display_on { | ||
| 167 | 0 | ▶ | my $self = shift; |
|
Subroutine
display_on: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 168 | 0 | $self->write( command => sprintf("DISPlay ON") ); | |
| 169 | } | ||
| 170 | |||
| 171 | sub display_off { | ||
| 172 | 0 | ▶ | my $self = shift; |
|
Subroutine
display_off: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 173 | 0 | $self->write( command => sprintf("DISPlay OFF") ); | |
| 174 | } | ||
| 175 | |||
| 176 | sub set_shape { | ||
| 177 | 0 | ▶ | my ( $self, $value, %args ) = validated_setter( \@_, |
|
Subroutine
set_shape: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 178 | value => { isa => 'Str' }, | ||
| 179 | ); | ||
| 180 | |||
| 181 | 0 | $self->write( command => 'FUNCtion:SHAPe '.$value ); | |
| 182 | } | ||
| 183 | |||
| 184 | sub get_shape { | ||
| 185 | 0 | ▶ | my $self = shift; |
|
Subroutine
get_shape: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 186 | 0 | return $self->query( command => 'FUNCtion:SHAPe?' ); | |
| 187 | } | ||
| 188 | |||
| 189 | |||
| 190 | 1 | with qw( | |
| 191 | Lab::Moose::Instrument::Common | ||
| 192 | Lab::Moose::Instrument::SCPI::Source::Function | ||
| 193 | Lab::Moose::Instrument::LinearStepSweep | ||
| 194 | ); | ||
| 195 | |||
| 196 | |||
| 197 | |||
| 198 | 1 | 1; | |
| 199 | |||
| 200 | __END__ | ||
| 201 | |||
| 202 | =pod | ||
| 203 | |||
| 204 | =encoding UTF-8 | ||
| 205 | |||
| 206 | =head1 NAME | ||
| 207 | |||
| 208 | Lab::Moose::Instrument::HP33120A - HP 33120A 15 MHz Arbitrary Waveform Generator, also as voltage source | ||
| 209 | |||
| 210 | =head1 VERSION | ||
| 211 | |||
| 212 | version 3.881 | ||
| 213 | |||
| 214 | =head1 SYNOPSIS | ||
| 215 | |||
| 216 | use Lab::Moose; | ||
| 217 | |||
| 218 | # Constructor | ||
| 219 | my $HP = instrument( | ||
| 220 | type => 'HP33120A', | ||
| 221 | connection_type => 'VISA_GPIB', | ||
| 222 | connection_options => { | ||
| 223 | pad => 28, | ||
| 224 | }, | ||
| 225 | ); | ||
| 226 | |||
| 227 | =head1 METHODS | ||
| 228 | |||
| 229 | =head2 reset | ||
| 230 | |||
| 231 | $HP->reset(); | ||
| 232 | |||
| 233 | =head2 set_frq | ||
| 234 | |||
| 235 | $HP->set_frq( value => ); | ||
| 236 | |||
| 237 | The frequency can range up to 15MHz | ||
| 238 | |||
| 239 | =head2 get_frq | ||
| 240 | |||
| 241 | $HP->get_frq(); | ||
| 242 | |||
| 243 | =head2 set_amplitude | ||
| 244 | |||
| 245 | $HP->set_amplitude( value => ); | ||
| 246 | |||
| 247 | =head2 get_amplitude | ||
| 248 | |||
| 249 | $HP->get_amplitude(); | ||
| 250 | |||
| 251 | =head2 set_offset | ||
| 252 | |||
| 253 | $HP->set_offset( value => ); | ||
| 254 | |||
| 255 | =head2 get_offset | ||
| 256 | |||
| 257 | $HP->get_offset(); | ||
| 258 | |||
| 259 | =head2 set_level | ||
| 260 | |||
| 261 | $HP->set_level(value => $new_level); | ||
| 262 | |||
| 263 | Go to new level. Sweep with multiple steps if the distance between current and | ||
| 264 | new level is larger than C<max_units_per_step>. | ||
| 265 | |||
| 266 | =head2 cached_level | ||
| 267 | |||
| 268 | my $current_level = $hp->cached_level(); | ||
| 269 | |||
| 270 | Get current value from device cache. | ||
| 271 | |||
| 272 | =head2 get_level | ||
| 273 | |||
| 274 | my $current_level = $hp->get_level(); | ||
| 275 | |||
| 276 | Query current level. | ||
| 277 | |||
| 278 | =head1 COPYRIGHT AND LICENSE | ||
| 279 | |||
| 280 | This software is copyright (c) 2023 by the Lab::Measurement team; in detail: | ||
| 281 | |||
| 282 | Copyright 2023 Andreas K. Huettel | ||
| 283 | |||
| 284 | |||
| 285 | This is free software; you can redistribute it and/or modify it under | ||
| 286 | the same terms as the Perl 5 programming language system itself. | ||
| 287 | |||
| 288 | =cut | ||