The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Lab::Instrument::HP33120A - HP 33120A 15MHz function/arbitrary waveform generator

VERSION

version 3.610

SYNOPSIS

    use Lab::Instrument::HP33120A;

    my $g = new Lab::Instrument::HP33120A (
                connection_type => 'LinuxGPIB',
                gpib_address => 10
               );
    $g->set_frequency('3.78kHz');
    $g->set_shape('square');

    ...

Getting started, system control

new

$g = new Lab::Instrument::HP33120A->(%options);

      options:  gpib_board => 0,
                gpib_address => 10,
                connection_type => 'LinuxGPIB',
                no_cache => 1,  # turn off cache

get_id

$id = $g->get_id();

reads the *IDN? string from device

get_status

%status = $g->get_status();

return a hash with status bits { ERROR => .., DATA=> ..

get_error

$errmsg = $g->get_error();

Fetch the first error in the error queue. Returns ($code,$message); code == 0 means 'no error'

reset

$g->reset();

reset the function generator (*RST, *CLS)

get_trigger_slope

$slope = $g->get_trigger_slope();

fetch the trigger slope, returns POS or NEG

set_trigger_slope

$g->set_trigger_slope($slope);

set the slope of the signal used to trigger $slope = 'POS','+' or 'NEG','-'

wait_complete

$g->wait_complete();

Wait for operations to be completed

TODO: probably need to revise, with a *OPC? checking loop

trigger

$g->trigger();

Send a bus trigger to the function generator, wait until trigger complete.

get_trigger_source

$src = $g->get_trigger_source();

fetch the 'trigger source' from the function generator. Possible values are 'IMM', 'BUS' or 'EXT'. IMM => immediate self-triggering; BUS => gpib/serial trigger input, such as *TRG; EXT => external trigger input.

set_trigger_source

$g->set_trigger_source($src);

Set the trigger source for the function generator. Possible values are 'IMM' (immediate, i.e., internal free-running self-trigger) 'BUS' GPIB *TRG type triggering; 'EXT' trigger from external input.

set_display

$g->set_display(BOOL);

turn the display off (BOOL = false) or on (BOOL = true)

get_display

$display_on = $g->get_display();

get the state of the display (boolean)

set_text

$g->set_text("text to show");

display text on the function generator, in the place of the usual voltage/frequency/etc. Text is truncated at 11 chars, comma, semicolon, period are combined with char, so not counted in length

get_text

$mytext = $g->get_text();

fetches the text shown on the display with set_text

clear_text

$g->clear_text();

remove the text from the display

beep

$g->beep();

Cause the function generator to 'beep'

get_sync

$sync = $g->get_sync();

fetch boolean value indicating whether 'sync' output on the front panel is enabled

set_sync

$g->set_sync($sync);

enable or disable SYNC output on front panel. $sync is a boolean (1/true/yes/on) => sync output enabled

save_setup

$g->save_setup($n);

save function generator setup to internal non-volatile memory. $n = 0..3.

NOTE: $n=0 is overwritten by the 'current setup' when the generator is turned off.

recall_setup

$g->recall_setup($n);

restore function generator configuration from internal non-volatile memory. $n=0..3

delete_setup

$g->delete_setup($n);

delete one of the internal non-volatile setups $n=0..3

get_load

$zload = $g->get_load();

fetch the output load impedance of the generator. Possible values are '50' and 'INF'. This does NOT make any physical changes in the generator, but affects the internal calculation of amplitudes.

set_load

$g->set_load($z);

Tell the function generator what load impedance the output is being terminated to, so that other characteristics can be correctly calculated. Possible values are '50', 'INF', 'MIN', 'MAX' (can also use '50ohm', '0.05kohm', etc)

Basic waveform output routines

get_shape

$shape = $g->get_shape();

returns the waveform shape = SIN|SQU|TRI|RAMP|USER

set_shape

$g=>set_shape($shape);

Sets the output function shape = SIN|SQU|TRI|RAMP|USER USER = arbitary waveform, separately selected

get_frequency

$f = $g->get_frequency();

reads the function generator frequency, in Hz

set_frequency

$g->set_frequency($f);

sets the function generator frequency in Hz. The frequency limits are 10mHz to 15MHz . The frequency can be specified as a simple number (in Hz), MIN, MAX or a string in standard IEEE488-2 NRf format. NOTE: if you use the Hz unit, the standard is to interpret mHz as megahertz.

    set_frequency(10) 10Hz

    set_frequency('0.01kHz') 10Hz

    set_frequency('1mHz') 1E6 Hz

    set_frequency('10m') 10e-3 Hz (note, without Hz, `m' means `milli')

The upper frequency limit depends on the function shape

get_duty_cycle

$dc = $g->get_duty_cycle()'

fetch the duty cycle, in percent; only relevent for square waves

set_duty_cycle

$g->set_duty_cycle(percent);

sets the square wave duty cycle, in percent. The available range depends on frequency, so percent = 20..80 for <= 5MHz and percent = 40..60 for higher frequencies

get_amplitude

$vamp = $g->get_amplitude();

fetch the function amplitude, default is amplitude in volts peak-to-peak (Vpp), but depending on the units setting [see get_vunit()], so might be Vrms or dBm.

set_amplitude

$g->set_amplitude($vamp);

sets the function amplitude, in units from the set_vunit() call, defaults to Vpp.

The amplitude can be either a number, or string with magnitude (and optionally, units), MAX or MIN.

Examples: `100uV', `50mV', `123E-3', `20dBm', `5.5E1dBmV'.

NOTE: attaching units with $vamp does not change vunit, so if vunit=`VPP' and you set $vamp=`5.5e1dBmV', you'll get 55mVpp.

The minimum and maximum amplitudes depend on the output load selection, the function shape, and the DC offset.

Max output voltage is +-20V into a high-Z load, +-10V into 50 ohm load.

TODO: automatically adjust units based on input text: 4Vpp, 3.5Vrms, 7.3dbm ...

Since limits are rather hard to determine, you should check for errors after setting.

get_vunit

$unit = $g->get_vunit()

Fetch the units that are being used to specify the output amplitude Possible values are VPP, VRMS, DBM, or DEF (default, VPP)

set_vunit

$g->set_vunit($unit);

Set the way that amplitudes are specified. Possible values are Vpp, Vrms, dBm or DEF (default = Vpp)

get_offset

$voff = $g->get_offset();

Get the DC offset in volts (not affected by vunit)

set_offset

$g->set_offset($voff);

Set the DC offset, either as a number (volts), as a string '100mV', '0.01kV' '1e3u', MIN or MAX. The specification of the DC offset is not affected by the selection of vunit.

Note that the DC offset is limited in combination with the output load, amplitude, and function shape.

Arbitrary 'user' waveforms

get_waveform_list

@list = $g->get_waveform_list();

Get a list of the available 'user' waveforms. Five of these are built-in, up to four are user-storable in non-volatile memory, and possibly VOLATILE for a waveform in volatile memory

The names of the five built-in arbitrary waveforms are: SINC, NEG_RAMP, EXP_RISE, EXP_FALL, and CARDIAC.

get_user_waveform

$wname = $g->get_user_waveform();

Fetches the name of the currently selected 'user' waveform.

set_user_waveform

$g->set_user_waveform($wname);

Sets the name of the current 'user' waveform. This should be a name from the $g->get_waveform_list() set of nonvolatile waveforms, or 'VOLATILE'.

load_waveform

$g->load_waveform(...);

store waveform as 'volatile' data (can be used by selecting 'volatile' user waveform) perhaps for persistant storage.

    load_waveform(v1,v2,v3...) voltages |v(j)| <= 1

    load_waveform(d1,d2,d3...) DAC values |d(j)| < 2048

    load_waveform(\@array) voltages or DAC values

    load_waveform(waveform=>[voltage array ref]);

    load_waveform(dac=>[DAC array ref]);

number of data points 8..16000

In the first three cases above, where it is not specified "voltage" or "DAC" values, it is assumed to be voltages if the quantities are within the range -1..+1, and otherwise assumed to be DAC values.

get_waveform_average

$vavg = $g->get_waveform_average($name);

calculates and returns the 'average voltage' of waveform $name (nonvolatile stored waveform, or VOLATILE)

get_waveform_crestfactor

$vcr = $g->get_waveform_crestfactor($name);

calculates and returns the voltage 'crest factor' (ratio of Vpeak/Vrms) for the waveform stored in $name.

get_waveform_points

$npts = $g->get_waveform_points($name) Returns the number of points in the waveform $name

get_waveform_peak2peak

$vpp = $g->get_waveform_peak2peak($name);

calculates and returns the peak-to-peak voltage of waveform $name

store_waveform

$g->store_waveform($name);

Stores the waveform in VOLATILE to non-volatile memory as $name. Note that $name cannot be one of the 'hard-coded' names, is a maximum of 8 characters in length, must start with a-z, and contain only alphanumeric and underscore (_) characters. All names are converted to uppercase.

There is memory for 4 user waveforms to be stored, after which some must be deleted to allow further storage.

delete_waveform

$g->delete_waveform($name);

Delete one of the non-volatile user waveforms (or VOLATILE). Note that the 5 'built-in' user waveforms cannot be deleted.

get_waveform_free

$n = $g->get_waveform_free();

returns the number of 'free' user waveform storage areas (0..4) that can be used for $g->store_waveform

Modulation

get_modulation

$mod = $g->get_modulation();

Fetch the type of modulation being used: NONE,AM,FM,BURST,FSK,SWEEP

set_modulation

$g->set_modulation($mod);

Set the type of modulation to use: NONE,AM,FM,BURST,FSK,SWEEP if $mod='' or 'off', selects NONE.

set_am_depth

$g->set_am_depth(percent);

set AM modulation depth percent: 0..120, MIN, MAX

get_am_depth

$depth = $g->get_am_depth();

get the AM modulation depth, in percent

get_am_shape

$shape = $g->get_am_shape();

gets the waveform used for AM modulation returns $shape = (SIN|SQU|TRI|RAMP|NOIS|USER)

set_am_shape

$g->set_am_shape($shape);

sets the waveform used for AM modulation $shape = (SIN|SQU|TRI|RAMP|NOIS|USER)

get_am_frequency

$freq = $g->get_am_frequency();

get the frequency of the AM modulation

set_am_frequency

$g->set_am_frequency($f);

sets the frequency of AM modulation $f = value in Hz, 10mHz..20kHz, MIN, MAX

Note that $f can be a string, with suffixes, and that 'mHz' suffix -> MEGAHz 'm' suffix with no 'Hz' -> millihertz

get_am_source

$source = $g->get_am_source();

get the source of the AM modulation signal: BOTH|EXT

set_am_source

$g->set_am_source(BOTH|EXT);

set the source of the AM modulation; BOTH = internal+external EXT = external only. INT = translated to BOTH

get_fm_deviation

$dev = $g->get_fm_deviation();

fetch the FM modulation deviation, in Hz

set_fm_deviation

$g->set_fm_deviation($dev);

Set the FM modulation deviation in Hz. $dev can be a simple number, in Hz, or a string with suffixes, or MIN or MAX.

Ex: $dev='10.3kHz' $dev='1.2MHZ' $dev='200m' NOTE: MHZ -> megahertz (case independent). A simple 'm' suffix => millihertz

dev range 10mHz .. 7.5MHz carrier frequency must be >= deviation frequency carrier + deviation < peak frequency for carrier waveform + 100kHz So: 15.1MHz for sine and square 200kHz for triangle and ramp 5.1MHz for 'user' waveforms

get_fm_shape

$shape = $g->get_fm_shape();

gets the waveform used for FM modulation returns $shape = (SIN|SQU|TRI|RAMP|NOIS|USER)

set_fm_shape

$g->set_fm_shape($shape);

sets the waveform used for FM modulation $shape = (SIN|SQU|TRI|RAMP|NOIS|USER)

NOTE: NOISE and DC cannot be used as FM carrier

get_fm_frequency

$freq = $g->get_fm_frequency();

get the frequency of the FM modulation, in Hz

set_fm_frequency

$g->set_fm_frequency($f);

sets the frequency of AM modulation $f = value in Hz, 10mHz..10kHz, MIN, MAX

Note that $f can be a string with the usual suffixes, but XmHz -> X megahz Xm-> X millihz

get_burst_cycles

$ncyc = $g->get_burst_cycles();

Fetch the number of cycles in burst modulation

set_burst_cycles

$g->set_burst_cycles($ncyc);

Set the number of cycles in burst modulation. $ncyc is an integer 1..50,000 or MIN or MAX or INF

For SIN, SQU, or USER waveform shapes, the minumim number of cycles is related to the carrier frequency. <= 1MHz min 1 cycle 1..2MHz min 2 cycles 2..3MHz min 3 cycles 3..4MHz min 4 cycles 4..5MHz min 5 cycles

For carrier frequency <= 100Hz, cycles <= 500sec * carrier freq

get_burst_phase

$ph = $g->get_burst_phase();

Fetches the starting phase of the burst, in degrees, when bursts are triggered.

set_burst_phase

$g->set_burst_phase($ph);

Sets the starting phase of burst, in degrees (or MIN or MAX) from -360 to 360 in 0.001 degree increments.

phase examples: 30.1, '20deg', 'min', 'max'

get_burst_rate

$rate = $g->get_burst_rate();

Fetch the burst rate (in Hz) for internally triggered bursts

set_burst_rate

$g->set_burst_rate($rate);

Set the burst rate (in Hz) for internally triggered bursts. $rate can be a simple number, or a string with the usual suffixes. Note that 'mHz' (case independent) -> megahertz while 'm' -> millihertz. Rate 10mHz .. 50kHz or MIN or MAX

If the burst rate is too large for the carrier frequency and burst count, the function generator will (silently) adjust to continually retrigger.

get_burst_source

$source = $g->get_burst_source();

Fetch the source of the burst modulation: INT or EXT

set_burst_source

$g->set_burst_source($source);

Set the source of burst modulation: $source = 'INT' or 'EXT'. If source is external, burst cycle count, rate, are ignored.

get_fsk_frequency

$freq = $g->get_fsk_frequency();

get the FSK 'hop' frequency, in Hz

set_fsk_frequency

$g->set_fsk_frequency($f);

sets the FSK 'hop' frequency $f = value in Hz, 10mHz..15MHz, MIN, MAX (max freq 100kHz for TRIANGLE and RAMP shapes)

Note that $f can be a string with the usual suffixes, but XmHz -> X megahz Xm-> X millihz

get_fsk_rate

$rate = $g->get_fsk_rate();

Fetch the rate at which fsk shifts between frequencies (in Hz) for internally triggered modulation.

set_fsk_rate

$g->set_fsk_rate($rate);

Set the rate for fsk shifting between frequencies (in Hz) for internally triggered modulation.

$rate can be a simple number, or a string with the usual suffixes. Note that 'mHz' (case independent) -> megahertz while 'm' -> millihertz. Rate 10mHz .. 50kHz or MIN or MAX

get_fsk_source

$source = $g->get_fsk_source();

Fetch the source of the FSK modulation: INT or EXT

set_fsk_source

$g->set_fsk_source($source);

Set the source of FSK modulation: $source = 'INT' or 'EXT'. If source is external, FSK rate is ignored.

get_sweep_start_frequency

$g->get_sweep_start_frequency();

Fetch the starting frequency of the sweep, in Hz

get_sweep_stop_frequency

$g->get_sweep_stop_frequency();

Fetch the stopping frequency of the sweep, in Hz

set_sweep_start_frequency

$g->set_sweep_start_frequency($f);

sets the frequency sweep starting frequency $f = value in Hz, 10mHz..15MHz, MIN, MAX

Note that $f can be a string with the usual suffixes, but XmHz -> X megahz Xm-> X millihz

if fstart>fstop, sweep decreases in frequency; if fstart<fstop, sweep increases in frequency.

set_sweep_stop_frequency

$g->set_sweep_stop_frequency($f);

sets the frequency sweep stopping frequency $f = value in Hz, 10mHz..15MHz, MIN, MAX

Note that $f can be a string with the usual suffixes, but XmHz -> X megahz Xm-> X millihz

if fstart>fstop, sweep decreases in frequency; if fstart<fstop, sweep increases in frequency.

get_sweep_spacing

$spc = $g->get_sweep_spacing();

Fetches the sweep 'spacing', returns 'LIN' or 'LOG' for linear or logarithmic spacing.

set_sweep_spacing

$g->set_sweep_spacing($spc);

Sets sweep to either LIN or LOG spacing

get_sweep_time

$time = $g->get_sweep_time();

Fetch the time (in seconds) to sweep from starting to stopping frequency.

set_sweep_time

$g->set_sweep_time($time);

Sets the time to sweep between starting and stopping frequencies. The number of frequencies steps is internally calculated by the function generator.

$time can be a simple number (in seconds) or a string with suffices such as "5ms" "0.03ks", or MIN or MAX. The range of sweep times is 1ms .. 500s

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by the Lab::Measurement team; in detail:

  Copyright 2016       Charles Lane, Simon Reinhardt
            2017       Andreas K. Huettel

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.