line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lab::Instrument::MG369xB; |
2
|
|
|
|
|
|
|
#ABSTRACT: Anritsu MG369xB series signal generator |
3
|
|
|
|
|
|
|
$Lab::Instrument::MG369xB::VERSION = '3.881'; |
4
|
1
|
|
|
1
|
|
1700
|
use v5.20; |
|
1
|
|
|
|
|
4
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
7
|
1
|
|
|
1
|
|
6
|
use Lab::Instrument; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
34
|
|
8
|
1
|
|
|
1
|
|
7
|
use Time::HiRes qw (usleep); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Programming manual: |
11
|
|
|
|
|
|
|
# http://www.anritsu.com/en-GB/Downloads/Manuals/Programming-Manual/DWL2029.aspx |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @ISA = ("Lab::Instrument"); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our %fields = ( |
16
|
|
|
|
|
|
|
supported_connections => ['GPIB'], |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# default settings for the supported connections |
19
|
|
|
|
|
|
|
connection_settings => { |
20
|
|
|
|
|
|
|
gpib_board => 0, |
21
|
|
|
|
|
|
|
gpib_address => undef, |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
device_settings => {}, |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub new { |
29
|
0
|
|
|
0
|
1
|
|
my $proto = shift; |
30
|
0
|
|
0
|
|
|
|
my $class = ref($proto) || $proto; |
31
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
32
|
0
|
|
|
|
|
|
$self->${ \( __PACKAGE__ . '::_construct' ) }(__PACKAGE__); |
|
0
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
return $self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub id { |
37
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
38
|
0
|
|
|
|
|
|
return $self->query('*IDN?'); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub reset { |
42
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
43
|
0
|
|
|
|
|
|
$self->write('RST'); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub set_frq { |
47
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my ( $freq, $tail ) = $self->_check_args( \@_, ['value'] ); |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
$freq /= 1000000; |
52
|
0
|
|
|
|
|
|
$self->write("F0 $freq MH ACW"); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub set_power { |
56
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my ( $power, $tail ) = $self->_check_args( \@_, ['value'] ); |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
$self->write("L0 $power DM"); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub get_frq { |
64
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
65
|
0
|
|
|
|
|
|
my $frq = $self->query("OF0"); |
66
|
0
|
|
|
|
|
|
return $frq * 1000000; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub get_power { |
70
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
71
|
0
|
|
|
|
|
|
my $power = $self->query("OL0"); |
72
|
0
|
|
|
|
|
|
return $power; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub power_on { |
76
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
77
|
0
|
|
|
|
|
|
$self->write('RF 1'); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub power_off { |
81
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
82
|
0
|
|
|
|
|
|
$self->write('RF 0'); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# SYZ + UP produce distorted signal |
86
|
|
|
|
|
|
|
sub sweep_single_step { |
87
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
88
|
0
|
0
|
|
|
|
|
my $onoff = (shift) ? "1" : "0"; |
89
|
0
|
|
|
|
|
|
$self->write("DU $onoff"); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub sweep_trigger_manual { |
93
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# RSS = reset sweep |
96
|
0
|
|
|
|
|
|
$self->write("MNT RSS"); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# Note: You have to set trigger type |
100
|
|
|
|
|
|
|
sub init_sweep_linear { |
101
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
102
|
0
|
|
|
|
|
|
my $start = shift; |
103
|
0
|
|
|
|
|
|
my $stop = shift; |
104
|
0
|
|
|
|
|
|
my $step_size = shift; |
105
|
|
|
|
|
|
|
|
106
|
0
|
0
|
|
|
|
|
if ( !defined($stop) ) { |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# Assume $start is a Sweep object |
109
|
0
|
|
|
|
|
|
$step_size = $start->{step_size}; |
110
|
0
|
|
|
|
|
|
$stop = $start->{stop}; |
111
|
0
|
|
|
|
|
|
$start = $start->{start}; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
$self->sweep_single_step(1); |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
my $next_sweep_start = undef; |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
my $nr_of_steps = int( ( $stop - $start ) / ($step_size) ); |
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
my $current_sweep_stop = $start + $step_size * $nr_of_steps; |
121
|
0
|
|
|
|
|
|
print "$nr_of_steps\n"; |
122
|
|
|
|
|
|
|
|
123
|
0
|
0
|
|
|
|
|
if ( $nr_of_steps > 10000 ) { |
124
|
0
|
|
|
|
|
|
$nr_of_steps = 10000; |
125
|
0
|
|
|
|
|
|
$current_sweep_stop = $start + $step_size * 10000; |
126
|
0
|
|
|
|
|
|
$next_sweep_start = $current_sweep_stop + $step_size; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
print |
130
|
0
|
|
|
|
|
|
"$nr_of_steps $next_sweep_start $start $step_size $current_sweep_stop\n"; |
131
|
0
|
|
|
|
|
|
$self->{next_sweep_start} = $next_sweep_start; |
132
|
0
|
|
|
|
|
|
$self->{stop} = $stop; |
133
|
0
|
|
|
|
|
|
$self->{step_size} = $step_size; |
134
|
0
|
|
|
|
|
|
$self->{step_nr} = 0; # Nr of TSS calls |
135
|
0
|
|
|
|
|
|
$self->{nr_of_steps} = $nr_of_steps; |
136
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
$start /= 1e6; |
138
|
0
|
|
|
|
|
|
$current_sweep_stop /= 1e6; |
139
|
0
|
|
|
|
|
|
$step_size /= 1e6; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# SSP = linear step sweep |
142
|
|
|
|
|
|
|
# SP0 = equally spaced steps |
143
|
|
|
|
|
|
|
# RSS = Reset śweep |
144
|
0
|
|
|
|
|
|
my $cmd |
145
|
|
|
|
|
|
|
= "F1 $start MH F2 $current_sweep_stop MH SNS $nr_of_steps SPS SP0 SF1 SSP RSS"; |
146
|
0
|
|
|
|
|
|
print "Sending $cmd\n"; |
147
|
0
|
|
|
|
|
|
$self->write($cmd); |
148
|
0
|
|
|
|
|
|
sleep(1); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub sweep_next_step { |
152
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
153
|
0
|
0
|
|
|
|
|
if ( $self->{step_nr} >= $self->{nr_of_steps} ) { |
154
|
0
|
0
|
|
|
|
|
if ( defined( $self->{next_sweep_start} ) ) { |
155
|
|
|
|
|
|
|
$self->init_sweep_linear( |
156
|
|
|
|
|
|
|
$self->{next_sweep_start}, |
157
|
|
|
|
|
|
|
$self->{stop}, $self->{step_size} |
158
|
0
|
|
|
|
|
|
); |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
else { |
161
|
|
|
|
|
|
|
# Output last point |
162
|
0
|
|
|
|
|
|
my $stop = $self->{stop}; |
163
|
0
|
|
|
|
|
|
$self->write("CF1 $stop"); |
164
|
0
|
|
|
|
|
|
usleep(200000); |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
else { |
168
|
0
|
|
|
|
|
|
$self->write("TSS"); |
169
|
0
|
|
|
|
|
|
$self->{step_nr}++; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
1; |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
__END__ |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=pod |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=encoding utf-8 |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 NAME |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Lab::Instrument::MG369xB - Anritsu MG369xB series signal generator |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 VERSION |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
version 3.881 |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 CAVEATS/BUGS |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
IMPORTANT: Only works for B series devices. MG369xA use SCPI commands and are |
192
|
|
|
|
|
|
|
supported by HP83732A driver. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 SEE ALSO |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=over 4 |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=item * Lab::Instrument |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=back |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
This software is copyright (c) 2023 by the Lab::Measurement team; in detail: |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
Copyright 2012 Hermann Kraus |
207
|
|
|
|
|
|
|
2013-2014 Andreas K. Huettel |
208
|
|
|
|
|
|
|
2016 Simon Reinhardt |
209
|
|
|
|
|
|
|
2017 Andreas K. Huettel |
210
|
|
|
|
|
|
|
2020 Andreas K. Huettel |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
214
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=cut |