line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lab::Moose::Instrument::KeysightN9310A; |
2
|
|
|
|
|
|
|
$Lab::Moose::Instrument::KeysightN9310A::VERSION = '3.880'; |
3
|
|
|
|
|
|
|
#ABSTRACT: Keysight N9310A Signal Generator |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
5010
|
use v5.20; |
|
1
|
|
|
|
|
5
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
7
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
9
|
1
|
|
|
1
|
|
7474
|
use Moose::Util::TypeConstraints; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
10
|
1
|
|
|
1
|
|
2712
|
use MooseX::Params::Validate; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
11
|
|
11
|
1
|
|
|
1
|
|
569
|
use Lab::Moose::Instrument qw/validated_getter validated_setter/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
68
|
|
12
|
1
|
|
|
1
|
|
8
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
90
|
|
13
|
1
|
|
|
1
|
|
8
|
use Lab::Moose::Instrument::Cache; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
11
|
|
14
|
1
|
|
|
1
|
|
727
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
with qw( |
30
|
|
|
|
|
|
|
Lab::Moose::Instrument::Common |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Lab::Moose::Instrument::SCPI::Output::State |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub BUILD { |
36
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
37
|
|
|
|
|
|
|
# $self->cls(); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
cache source_frequency => ( getter => 'source_frequency_query' ); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub source_frequency_query { |
45
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_getter( \@_ ); |
46
|
0
|
|
|
|
|
|
return $self->cached_source_frequency( |
47
|
|
|
|
|
|
|
$self->query( command => ":FREQuency:CW?", %args ) ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub source_frequency { |
51
|
0
|
|
|
0
|
0
|
|
my ( $self, $value, %args ) = validated_setter( |
52
|
|
|
|
|
|
|
\@_, |
53
|
|
|
|
|
|
|
value => { isa => 'Num' }, |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my $min_freq = 9e3; |
57
|
0
|
0
|
|
|
|
|
if ( $value < $min_freq ) { |
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
|
|
|
|
|
|
|
cache source_power => ( getter => 'source_power_query' ); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub source_power_query { |
68
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_getter( \@_ ); |
69
|
0
|
|
|
|
|
|
return $self->cached_source_power( |
70
|
|
|
|
|
|
|
$self->query( command => ":AMPLitude:CW?", %args ) ); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub source_power { |
74
|
0
|
|
|
0
|
0
|
|
my ( $self, $value, %args ) = validated_setter( |
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
|
|
|
0
|
1
|
|
my $self = shift; |
88
|
0
|
|
|
|
|
|
return $self->source_power(@_); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub get_power { |
92
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
93
|
0
|
|
|
|
|
|
return $self->source_power_query(@_); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub cached_power { |
97
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
98
|
0
|
|
|
|
|
|
return $self->cached_source_power(@_); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub cached_frq { |
104
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
105
|
0
|
|
|
|
|
|
return $self->cached_source_frequency(@_); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub set_frq { |
109
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
110
|
0
|
|
|
|
|
|
return $self->source_frequency(@_); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub get_frq { |
114
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
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
|
|
|
0
|
0
|
|
my ( $self, $value, %args ) = validated_setter( \@_ ); |
124
|
0
|
|
|
|
|
|
$self->write( command => "PULM:WIDT $value s", %args ); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub get_pulselength { |
128
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_getter( \@_ ); |
129
|
0
|
|
|
|
|
|
return $self->query( command => "PULM:WIDT?", %args ); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub set_pulseperiod { |
133
|
0
|
|
|
0
|
0
|
|
my ( $self, $value, %args ) = validated_setter( \@_ ); |
134
|
0
|
|
|
|
|
|
$self->write( command => "PULM:PER $value s", %args ); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub get_pulseperiod { |
138
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_getter( \@_ ); |
139
|
0
|
|
|
|
|
|
return $self->query( command => "PULM:PER?", %args ); |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub selftest { |
143
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_getter( \@_ ); |
144
|
0
|
|
|
|
|
|
return $self->query( command => "*TST?", %args ); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub display_on { |
148
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_getter( \@_ ); |
149
|
0
|
|
|
|
|
|
$self->write( command => "DISPlay ON", %args ); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub display_off { |
153
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_getter( \@_ ); |
154
|
0
|
|
|
|
|
|
$self->write( command => "DISPlay OFF", %args ); |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub enable_external_am { |
158
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_getter( \@_ ); |
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
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_getter( \@_ ); |
167
|
0
|
|
|
|
|
|
$self->write( command => "AM:STATe OFF", %args ); |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub enable_internal_pulsemod { |
171
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_getter( \@_ ); |
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
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_getter( \@_ ); |
180
|
0
|
|
|
|
|
|
$self->write( command => "PULM:STAT OFF", %args ); |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
__PACKAGE__->meta()->make_immutable(); |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
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.880 |
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 |