| 1 | package Lab::Moose::Instrument::KeysightN9310A; | ||||||||||
| 2 | 1 | $Lab::Moose::Instrument::KeysightN9310A::VERSION = '3.881'; | |||||||||
| 3 | #ABSTRACT: Keysight N9310A Signal Generator | ||||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use v5.20; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use Moose::Util::TypeConstraints; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use MooseX::Params::Validate; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use Lab::Moose::Instrument qw/validated_getter validated_setter/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 1 | ▶ | use Lab::Moose::Instrument::Cache; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 1 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 1 | extends 'Lab::Moose::Instrument'; | |||||||||
| 17 | |||||||||||
| 18 | |||||||||||
| 19 | #around default_connection_options => sub { | ||||||||||
| 20 | # my $orig = shift; | ||||||||||
| 21 | # my $self = shift; | ||||||||||
| 22 | # my $options = $self->$orig(); | ||||||||||
| 23 | # my $usb_opts = { vid => 0x0aad, pid => 0x0054 }; | ||||||||||
| 24 | # $options->{USB} = $usb_opts; | ||||||||||
| 25 | # $options->{'VISA::USB'} = $usb_opts; | ||||||||||
| 26 | # return $options; | ||||||||||
| 27 | #}; | ||||||||||
| 28 | |||||||||||
| 29 | 1 | with qw( | |||||||||
| 30 | Lab::Moose::Instrument::Common | ||||||||||
| 31 | |||||||||||
| 32 | Lab::Moose::Instrument::SCPI::Output::State | ||||||||||
| 33 | ); | ||||||||||
| 34 | |||||||||||
| 35 | sub BUILD { | ||||||||||
| 36 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
BUILD: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 37 | # $self->cls(); | ||||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | |||||||||||
| 41 | |||||||||||
| 42 | 1 | cache source_frequency => ( getter => 'source_frequency_query' ); | |||||||||
| 43 | |||||||||||
| 44 | sub source_frequency_query { | ||||||||||
| 45 | 0 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||
|
Subroutine
source_frequency_query: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 46 | 0 | return $self->cached_source_frequency( | |||||||||
| 47 | $self->query( command => ":FREQuency:CW?", %args ) ); | ||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | sub source_frequency { | ||||||||||
| 51 | 0 | ▶ | my ( $self, $value, %args ) = validated_setter( | ||||||||
|
Subroutine
source_frequency: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 52 | \@_, | ||||||||||
| 53 | value => { isa => 'Num' }, | ||||||||||
| 54 | ); | ||||||||||
| 55 | |||||||||||
| 56 | 0 | my $min_freq = 9e3; | |||||||||
| 57 | 0 | ▶ | if ( $value < $min_freq ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | 0 | croak "value smaller than minimal frequency $min_freq"; | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | 0 | $self->write( command => sprintf( ":FREQuency:CW %f MHz", ($value/1e6) ), %args ); | |||||||||
| 62 | 0 | $self->cached_source_frequency($value); | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 1 | cache source_power => ( getter => 'source_power_query' ); | |||||||||
| 66 | |||||||||||
| 67 | sub source_power_query { | ||||||||||
| 68 | 0 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||
|
Subroutine
source_power_query: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 69 | 0 | return $self->cached_source_power( | |||||||||
| 70 | $self->query( command => ":AMPLitude:CW?", %args ) ); | ||||||||||
| 71 | } | ||||||||||
| 72 | |||||||||||
| 73 | sub source_power { | ||||||||||
| 74 | 0 | ▶ | my ( $self, $value, %args ) = validated_setter( | ||||||||
|
Subroutine
source_power: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 75 | \@_, | ||||||||||
| 76 | value => { isa => 'Num' }, | ||||||||||
| 77 | ); | ||||||||||
| 78 | |||||||||||
| 79 | 0 | $self->write( command => sprintf( ":AMPLitude:CW %f dBm", $value ), %args ); | |||||||||
| 80 | 0 | $self->cached_source_power($value); | |||||||||
| 81 | } | ||||||||||
| 82 | |||||||||||
| 83 | |||||||||||
| 84 | |||||||||||
| 85 | |||||||||||
| 86 | sub set_power { | ||||||||||
| 87 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
set_power: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 88 | 0 | return $self->source_power(@_); | |||||||||
| 89 | } | ||||||||||
| 90 | |||||||||||
| 91 | sub get_power { | ||||||||||
| 92 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
get_power: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 93 | 0 | return $self->source_power_query(@_); | |||||||||
| 94 | } | ||||||||||
| 95 | |||||||||||
| 96 | sub cached_power { | ||||||||||
| 97 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
cached_power: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 98 | 0 | return $self->cached_source_power(@_); | |||||||||
| 99 | } | ||||||||||
| 100 | |||||||||||
| 101 | |||||||||||
| 102 | |||||||||||
| 103 | sub cached_frq { | ||||||||||
| 104 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
cached_frq: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 105 | 0 | return $self->cached_source_frequency(@_); | |||||||||
| 106 | } | ||||||||||
| 107 | |||||||||||
| 108 | sub set_frq { | ||||||||||
| 109 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
set_frq: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 110 | 0 | return $self->source_frequency(@_); | |||||||||
| 111 | } | ||||||||||
| 112 | |||||||||||
| 113 | sub get_frq { | ||||||||||
| 114 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
get_frq: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 115 | 0 | return $self->source_frequency_query(); | |||||||||
| 116 | } | ||||||||||
| 117 | |||||||||||
| 118 | # | ||||||||||
| 119 | # Pulse/AM modulation stuff from old RSSMB100A driver; TODO: caching + docs | ||||||||||
| 120 | # | ||||||||||
| 121 | |||||||||||
| 122 | sub set_pulselength { | ||||||||||
| 123 | 0 | ▶ | my ( $self, $value, %args ) = validated_setter( \@_ ); | ||||||||
|
Subroutine
set_pulselength: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 124 | 0 | $self->write( command => "PULM:WIDT $value s", %args ); | |||||||||
| 125 | } | ||||||||||
| 126 | |||||||||||
| 127 | sub get_pulselength { | ||||||||||
| 128 | 0 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||
|
Subroutine
get_pulselength: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 129 | 0 | return $self->query( command => "PULM:WIDT?", %args ); | |||||||||
| 130 | } | ||||||||||
| 131 | |||||||||||
| 132 | sub set_pulseperiod { | ||||||||||
| 133 | 0 | ▶ | my ( $self, $value, %args ) = validated_setter( \@_ ); | ||||||||
|
Subroutine
set_pulseperiod: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 134 | 0 | $self->write( command => "PULM:PER $value s", %args ); | |||||||||
| 135 | } | ||||||||||
| 136 | |||||||||||
| 137 | sub get_pulseperiod { | ||||||||||
| 138 | 0 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||
|
Subroutine
get_pulseperiod: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 139 | 0 | return $self->query( command => "PULM:PER?", %args ); | |||||||||
| 140 | } | ||||||||||
| 141 | |||||||||||
| 142 | sub selftest { | ||||||||||
| 143 | 0 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||
|
Subroutine
selftest: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 144 | 0 | return $self->query( command => "*TST?", %args ); | |||||||||
| 145 | } | ||||||||||
| 146 | |||||||||||
| 147 | sub display_on { | ||||||||||
| 148 | 0 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||
|
Subroutine
display_on: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 149 | 0 | $self->write( command => "DISPlay ON", %args ); | |||||||||
| 150 | } | ||||||||||
| 151 | |||||||||||
| 152 | sub display_off { | ||||||||||
| 153 | 0 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||
|
Subroutine
display_off: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 154 | 0 | $self->write( command => "DISPlay OFF", %args ); | |||||||||
| 155 | } | ||||||||||
| 156 | |||||||||||
| 157 | sub enable_external_am { | ||||||||||
| 158 | 0 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||
|
Subroutine
enable_external_am: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 159 | 0 | $self->write( command => "AM:DEPTh MAX", %args ); | |||||||||
| 160 | 0 | $self->write( command => "AM:SENSitivity 70PCT/VOLT", %args ); | |||||||||
| 161 | 0 | $self->write( command => "AM:TYPE LINear", %args ); | |||||||||
| 162 | 0 | $self->write( command => "AM:STATe ON", %args ); | |||||||||
| 163 | } | ||||||||||
| 164 | |||||||||||
| 165 | sub disable_external_am { | ||||||||||
| 166 | 0 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||
|
Subroutine
disable_external_am: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 167 | 0 | $self->write( command => "AM:STATe OFF", %args ); | |||||||||
| 168 | } | ||||||||||
| 169 | |||||||||||
| 170 | sub enable_internal_pulsemod { | ||||||||||
| 171 | 0 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||
|
Subroutine
enable_internal_pulsemod: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 172 | 0 | $self->write( command => "PULM:SOUR INT", %args ); | |||||||||
| 173 | 0 | $self->write( command => "PULM:DOUB:STAT OFF", %args ); | |||||||||
| 174 | 0 | $self->write( command => "PULM:MODE SING", %args ); | |||||||||
| 175 | 0 | $self->write( command => "PULM:STAT ON", %args ); | |||||||||
| 176 | } | ||||||||||
| 177 | |||||||||||
| 178 | sub disable_internal_pulsemod { | ||||||||||
| 179 | 0 | ▶ | my ( $self, %args ) = validated_getter( \@_ ); | ||||||||
|
Subroutine
disable_internal_pulsemod: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 180 | 0 | $self->write( command => "PULM:STAT OFF", %args ); | |||||||||
| 181 | } | ||||||||||
| 182 | |||||||||||
| 183 | 1 | __PACKAGE__->meta()->make_immutable(); | |||||||||
| 184 | |||||||||||
| 185 | 1 | 1; | |||||||||
| 186 | |||||||||||
| 187 | __END__ | ||||||||||
| 188 | |||||||||||
| 189 | =pod | ||||||||||
| 190 | |||||||||||
| 191 | =encoding UTF-8 | ||||||||||
| 192 | |||||||||||
| 193 | =head1 NAME | ||||||||||
| 194 | |||||||||||
| 195 | Lab::Moose::Instrument::KeysightN9310A - Keysight N9310A Signal Generator | ||||||||||
| 196 | |||||||||||
| 197 | =head1 VERSION | ||||||||||
| 198 | |||||||||||
| 199 | version 3.881 | ||||||||||
| 200 | |||||||||||
| 201 | =head1 SYNOPSIS | ||||||||||
| 202 | |||||||||||
| 203 | my $gen = instrument( | ||||||||||
| 204 | type => 'KeysightN9310A', | ||||||||||
| 205 | connection_type => 'VISA', | ||||||||||
| 206 | connection_options => {host => '192.168.3.26'}, | ||||||||||
| 207 | ); | ||||||||||
| 208 | |||||||||||
| 209 | # Set frequency to 2 GHz | ||||||||||
| 210 | $gen->set_frq(value => 2e9); | ||||||||||
| 211 | |||||||||||
| 212 | # Get frequency from device cache | ||||||||||
| 213 | my $frq = $gen->cached_frq(); | ||||||||||
| 214 | |||||||||||
| 215 | # Set power to -10 dBm | ||||||||||
| 216 | $gen->set_power(value => -10); | ||||||||||
| 217 | |||||||||||
| 218 | =head1 METHODS | ||||||||||
| 219 | |||||||||||
| 220 | Used roles: | ||||||||||
| 221 | |||||||||||
| 222 | =over | ||||||||||
| 223 | |||||||||||
| 224 | =item L<Lab::Moose::Instrument::SCPI::Output::State> | ||||||||||
| 225 | |||||||||||
| 226 | =back | ||||||||||
| 227 | |||||||||||
| 228 | =head2 get_power/set_power | ||||||||||
| 229 | |||||||||||
| 230 | $gen->set_power(value => -10); | ||||||||||
| 231 | $power = $gen->get_power(); # or $get->cached_power(); | ||||||||||
| 232 | |||||||||||
| 233 | Get set output power (dBm); | ||||||||||
| 234 | |||||||||||
| 235 | =head2 get_frq/set_frq | ||||||||||
| 236 | |||||||||||
| 237 | $gen->set_frq(value => 1e6); # 1MHz | ||||||||||
| 238 | $frq = $gen->get_frq(); # or $gen->cached_frq(); | ||||||||||
| 239 | |||||||||||
| 240 | Get/Set output frequency (Hz). | ||||||||||
| 241 | |||||||||||
| 242 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 243 | |||||||||||
| 244 | This software is copyright (c) 2023 by the Lab::Measurement team; in detail: | ||||||||||
| 245 | |||||||||||
| 246 | Copyright 2017 Andreas K. Huettel, Simon Reinhardt | ||||||||||
| 247 | 2018 Simon Reinhardt | ||||||||||
| 248 | 2020 Andreas K. Huettel | ||||||||||
| 249 | 2023 Andreas K. Huettel | ||||||||||
| 250 | |||||||||||
| 251 | |||||||||||
| 252 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 253 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 254 | |||||||||||
| 255 | =cut | ||||||||||