inspy.instrument.signalgenerator

Signal Generator modules.

class inspy.instrument.signalgenerator.SigGenAgilent33220A(visa_address=None, transport=None)[source]

Bases: SigGenAgilentBase

Signal generator instrument class for 33220A.

tags: AWG, Arb, Arbitrary Waveform Generator, Function Generator, Keysight Suports VISA

Agilent 33220A User Manual

auto_log_level: int = 20

The log level used for automatic logging of method calls.

To disable logging set to logging.NOTSET.

await_completion()

Wait for the signal generator to complete the current operation.

Return type:

None

channel_error_message = 'Valid channel(s): '
channels: list[int] = [1]
connect()

Connect to instrument using the transport layer.

Return type:

None

delete_all_saved_user_waveforms(channel=1)

Delete all the saved arbitrary waveforms in the signal generator.

Parameters:

channel (int) – Channel to delete all saved waveforms of

Return type:

None

delete_saved_user_waveform(name='userFunc')

Delete the user waveform from the signal generator.

Parameters:

name (str) – Name of the user waveform to delete

Return type:

None

disconnect()
Return type:

None

get_channel_state(channel=1)

Get the current state of the output.

Parameters:

channel (int) – channel to get state of

Return type:

bool

Returns:

True if output enabled

get_errors()

Get a list of errors and error numbers from the instrument.

Return type:

list[tuple[int, str]]

Returns:

A list where each value is a tuple of the error number and error description

get_frequency(channel=1)

Get the set frequency of the desired channel.

Parameters:

channel (int) – channel to get the set frequency from

Return type:

float

Returns:

Frequency in Hz

get_id()

Identification Query.

Return type:

str

Returns:

Instrument Identification String.

get_impedance(channel=1)

Get the set impedance of the channel.

Parameters:

channel (int) – Channel to get the set impedance of

Return type:

str

Returns:

Impedance string (‘50’, ‘HIGH’)

get_saved_user_waveforms(channel=1)

Get the list of saved user waveforms in the signal generator.

Parameters:

channel (int) – Channel to get the user waveforms from

Return type:

list[str]

Returns:

List of user waveform names

get_voltage_amplitude(channel=1)

Get the currently set amplitude of the signal.

Parameters:

channel (int) – Channel to get the set amplitude of

Return type:

float

Returns:

Voltage in V

get_voltage_high(channel=1)

Get the currently set high/maximum voltage of the signal.

Parameters:

channel (int) – Channel to get the set high voltage of

Return type:

float

Returns:

Voltage in V

get_voltage_low(channel=1)

Get the currently set low/minimum voltage of the signal.

Parameters:

channel (int) – Channel to get the set low voltage of

Return type:

float

Returns:

Voltage in V

get_voltage_offset(channel=1)

Get the currently set offset of the signal.

Parameters:

channel (int) – Channel to get the set offset of

Return type:

float

Returns:

Voltage in V

get_waveform_mode(channel=1)

Get the type/shape of the waveform.

Parameters:

channel (int) – Channel to get the set waveform of

Return type:

str

Returns:

Waveform type as string

is_connected: bool
logger: logging.Logger
reset()

Reset the signal generator to default settings.

Return type:

None

property scpi_to_waveform_type: dict[str, str]

Map the SCPI query result from the SigGen to type of waveform.

Done to update the attribute when the waveform_type_to_scpi is redefined. Otherwise, the scpi_to_waveform_type will not be updated and will always be {}.

set_channel_state(enable, channel=1)

Enable or Disable the channel(s) output/input.

tags: Enable, Disable, On, Off, state, channel, Output, Input, Source, Sink

Parameters:
  • enable (bool) – Enable the channel output

  • channel (int) – channel(s) to set the state of

Return type:

None

set_frequency(frequency, channel=1)

Set the frequency (in Hz) of the required channel(s).

Parameters:
  • frequency (float) – Frequency in Hz

  • channel (int) – Channel(s) to set frequency of

Return type:

None

set_impedance(impedance, channel=1)

Set the output impedance of the channel.

Parameters:
  • impedance (str) – string of impedance mode. Can be only ‘50’ (50 Ohm) or ‘HIGH’ (1 Meg typ.)

  • channel (int) – Channel to set impedance of

Return type:

None

set_new_arbitrary_waveform(array, name='userFunc', channel=1)

Save a new arbitrary waveform to the signal generator’s memory.

This method also sets the waveform mode to USER and enables the channel.

The array should be a list of values that represent the waveform.

Examples:

>>> [0.3       ,  0.302002  ,  0.304004  ,  0.30600601,  0.30800801,
>>>  0.31001001,  0.31201201,  0.31401401,  0.31601602,  0.31801802,
>>>  0.32002002,  0.32202202,  0.32402402,  0.32602603,  0.32802803,
>>>  0.33003003,  0.33203203,  0.33403403,  0.33603604,  0.33803804]

This is an example of a summation of square & sawtooth waveform generated. This example is generated using numpy and scipy libraries.

You can have any arbitrary waveform as long as it is a list of values. Ideally you would want to have a large number of points to have a smooth wave.

The values must be a list of:

  • floating point values from -1.0 to +1.0 (Representing the peaks)

You can have from 1 to 65,536 such points. If less than 16,384 points, a 16,384 point waveform is generated. If more than 16,384 points, a 65,536-point waveform is generated.

You can specify the characteristics of the waveform using other functions. For example, you can set the frequency, voltage, offset, etc.

  • If you want a wave from -5V to +5V, you can set the amplitude to 10V and use the range of -1.0 to +1.0 in the array. -1.0 will be scaled to -5V and +1.0 will be scaled to +5V

Things to keep in mind:

Parameters:
  • array (list[Any]) – data to set the waveform to be

  • name (str) – Name of the waveform to store in the SigGen

  • channel (int) – Channel to set the waveform data of

Return type:

None

set_saved_user_waveform(name='userFunc', channel=1)

Select the user waveform for the USER mode of the signal generator.

This method just selects the waveform for the USER mode. It does not set the waveform mode to USER.

Parameters:
  • name (str) – Name of the user waveform to select

  • channel (int) – Channel to select the user waveform of

Return type:

None

set_voltage_amplitude(voltage, channel=1)

Set the amplitude of the signal.

set_voltage_offset and set_voltage_amplitude are used together. Alternatively, you can use set_voltage_low and set_voltage_high together.

Parameters:
  • voltage (float) – Amplitude of the signal in V

  • channel (int) – Channel(s) to set voltage of

Return type:

None

set_voltage_high(voltage, channel=1)

Set the high/maximum voltage of the signal.

set_voltage_low and set_voltage_high are used together. Alternatively, you can use set_voltage_offset and set_voltage_amplitude together.

Parameters:
  • voltage (float) – High/maximum voltage of signal

  • channel (int) – Channel(s) to set voltage of

Return type:

None

set_voltage_low(voltage, channel=1)

Set the low/minimum voltage of the signal.

set_voltage_low and set_voltage_high are used together. Alternatively, you can use set_voltage_offset and set_voltage_amplitude together.

Parameters:
  • voltage (float) – Low/minimum voltage of signal

  • channel (int) – Channel(s) to set voltage of

Return type:

None

set_voltage_offset(voltage, channel=1)

Set the offset of the signal.

set_voltage_offset and set_voltage_amplitude are used together. Alternatively, you can use set_voltage_low and set_voltage_high together.

Parameters:
  • voltage (float) – Offset of the signal in V

  • channel (int) – Channel(s) to set voltage of

Return type:

None

set_waveform_mode(mode, channel=1)

Set the type/shape of the waveform.

For user waveform, you can set the waveform using set_new_arbitrary_waveform() or select a waveform from the saved waveforms using set_saved_user_waveform() and then set the waveform mode to USER using this function.

Parameters:
  • mode ('SINE' | 'SQUARE' | 'RAMP' | 'PULSE' | 'NOISE' | 'DC' | 'USER') – Type of waveform to set

  • channel (int) – channel to set waveform type of

Return type:

None

transport: PyVisaTransport
waveform_type_to_scpi: dict[str, str] = {'DC': 'DC', 'NOISE': 'NOIS', 'PULSE': 'PULS', 'RAMP': 'RAMP', 'SINE': 'SIN', 'SQUARE': 'SQU', 'USER': 'USER'}
class inspy.instrument.signalgenerator.SigGenHP33120A(visa_address=None, transport=None)[source]

Bases: SigGenHPBase

Signal generator instrument class for 33120A.

tags: AWG, Arb, Arbitrary Waveform Generator, Function Generator, Keysight Suports VISA

Instructions: https://www.keysight.com/gb/en/assets/9018-04436/user-manuals/9018-04436.pdf

auto_log_level: int = 20

The log level used for automatic logging of method calls.

To disable logging set to logging.NOTSET.

await_completion()

Wait for the instrument to complete the current operation.

Return type:

None

channel_error_message = 'Valid channel(s): '
channels: list[int] = [1]
connect()

Connect to instrument using the transport layer.

Return type:

None

delete_all_saved_user_waveforms(channel=1)

Delete all the saved arbitrary waveforms in the signal generator.

Parameters:

channel (int) – Channel to delete all saved waveforms of

Return type:

None

delete_saved_user_waveform(name='userFunc')

Delete the user waveform from the signal generator.

Parameters:

name (str) – Name of the user waveform to delete

Return type:

None

disconnect()
Return type:

None

get_channel_state(channel=1)[source]

Return the output state, which is always enabled on the 33120A.

The 33120A output cannot be switched off (there is no OUTPut[:STATe] command), so this always reports True.

Parameters:

channel (int) – Channel to get the state of.

Return type:

bool

Returns:

Always True.

get_errors()

Get a list of errors and error numbers from the instrument.

Return type:

list[tuple[int, str]]

Returns:

A list where each value is a tuple of the error number and error description

get_frequency(channel=1)

Get the set frequency of the desired channel.

Parameters:

channel (int) – channel to get the set frequency from

Return type:

float

Returns:

Frequency in Hz

get_id()

Identification Query.

Return type:

str

Returns:

Instrument Identification String.

get_impedance(channel=1)

Get the set impedance of the channel.

Parameters:

channel (int) – Channel to get the set impedance of

Return type:

str

Returns:

Impedance string (‘50’, ‘HIGH’)

get_saved_user_waveforms(channel=1)

Get the list of saved user waveforms in the signal generator.

Parameters:

channel (int) – Channel to get the user waveforms from

Return type:

list[str]

Returns:

List of user waveform names

get_voltage_amplitude(channel=1)

Get the currently set amplitude of the signal.

Parameters:

channel (int) – Channel to get the set amplitude of

Return type:

float

Returns:

Voltage in V

get_voltage_high(channel=1)

Not applicable for this instrument.

get_voltage_low(channel=1)

Not applicable for this instrument.

get_voltage_offset(channel=1)

Get the currently set offset of the signal.

Parameters:

channel (int) – Channel to get the set offset of

Return type:

float

Returns:

Voltage in V

get_waveform_mode(channel=1)

Get the type/shape of the waveform.

Parameters:

channel (int) – Channel to get the set waveform of

Return type:

str

Returns:

Waveform type as string

is_connected: bool
logger: logging.Logger
reset()[source]

Reset to defaults and clear all stored user (arbitrary) waveforms.

In addition to the standard *RST, this empties the non-volatile ARB memory so the instrument starts from a known, empty state (the 33120A has only four non-volatile ARB slots, and a full memory blocks new waveforms). :rtype: None

Warning

This permanently deletes any user waveforms stored on the instrument.

property scpi_to_waveform_type: dict[str, str]

Map the SCPI query result from the SigGen to type of waveform.

Done to update the attribute when the waveform_type_to_scpi is redefined. Otherwise, the scpi_to_waveform_type will not be updated and will always be {}.

set_channel_state(enable, channel=1)[source]

The 33120A output is always on and cannot be switched off.

Parameters:
  • enable (bool) – Requested output state (only True is achievable).

  • channel (int) – Channel to set the state of.

Return type:

None

set_frequency(frequency, channel=1)

Set the frequency (in Hz) of the required channel(s).

Parameters:
  • frequency (float) – Frequency in Hz

  • channel (int) – Channel(s) to set frequency of

Return type:

None

set_impedance(impedance, channel=1)

Set the output impedance of the channel.

Parameters:
  • impedance (str) – string of impedance mode Can be only ‘50’ (50 Ohm) or ‘HIGH’ (1 Meg typ.)

  • channel (int) – Channel to set impedance of

Return type:

None

set_new_arbitrary_waveform(array, name='userFunc', channel=1)

Save a new arbitrary waveform to the signal generator’s memory.

This method also sets the waveform mode to USER and enables the channel.

The array should be a list of values that represent the waveform.

Examples

>>> [0.3       ,  0.302002  ,  0.304004  ,  0.30600601,  0.30800801,
>>>  0.31001001,  0.31201201,  0.31401401,  0.31601602,  0.31801802,
>>>  0.32002002,  0.32202202,  0.32402402,  0.32602603,  0.32802803,
>>>  0.33003003,  0.33203203,  0.33403403,  0.33603604,  0.33803804]

This is an example of a summation of square & sawtooth waveform generated. This example is generated using numpy and scipy libraries.

You can have any arbitrary waveform as long as it is a list of values. Ideally you would want to have a large number of points to have a smooth wave.

The values must be a list of:
>>> floating point values from -1.0 to +1.0 (Representing the peaks)

You can specify the characteristics of the waveform using other functions. For example, you can set the frequency, amplitude, offset, etc.

To be noted:
>>> If you want a wave from -5V to +5V, you can set the amplitude to 10V
... and use the range of -1.0 to +1.0 in the array.
... -1.0 will be scaled to -5V and +1.0 will be scaled to +5V
Things to keep in mind:
>>> The sig gen will distribute the array evenly in time over the period
... (= 1 / set frequency) specified, and linearly interpolate between them
>>> It is up to the user to ensure the number of points in the waveform is
... high enough to accurately represent the equivalent analogue signal
... (>> 2* the key max frequency of interest, as per Nyquist sampling)
>>> The sample rate indicates the digitisation frequency of the instrument,
... and if your signal frequencies approach this value you may not get the
... instrument accurately reproducing the signal as it cannot sample fast
... enough. In that case, the user should get a different instrument
... that supports higher sampling frequencies
Parameters:
  • array (list[Any]) – data to set the waveform to be

  • name (str) – Name of the waveform to save

  • channel (int) – Channel to set the waveform data of

Return type:

None

set_saved_user_waveform(name='userFunc', channel=1)

Select the user waveform for the USER mode of the signal generator.

This method just selects the waveform for the USER mode. It does not set the waveform mode to USER.

Parameters:
  • name (str) – Name of the user waveform to select

  • channel (int) – Channel to select the user waveform of

Return type:

None

set_voltage_amplitude(voltage, channel=1)

Set the amplitude of the signal.

set_voltage_offset and set_voltage_amplitude are used together.

Parameters:
  • voltage (float) – Amplitude of the signal in V

  • channel (int) – Channel(s) to set voltage of

Return type:

None

set_voltage_high(voltage, channel=1)

Not applicable for this instrument.

Return type:

None

set_voltage_low(voltage, channel=1)

Not applicable for this instrument.

Return type:

None

set_voltage_offset(voltage, channel=1)

Set the offset of the signal.

set_voltage_offset and set_voltage_amplitude are used together.

Parameters:
  • voltage (float) – Offset of the signal in V

  • channel (int) – Channel(s) to set voltage of

Return type:

None

set_waveform_mode(mode, channel=1)

Set the type/shape of the waveform.

For arb waveform, you can set the waveform using set_new_arbitrary_waveform() or select a waveform from the saved waveforms using set_saved_user_waveform() and then set the waveform mode to USER using this function.

Parameters:
  • mode ('SINE' | 'SQUARE' | 'TRIANGLE' | 'RAMP' | 'NOISE' | 'DC' | 'USER') – Type of waveform to set

  • channel (int) – channel to set waveform type of

Return type:

None

transport: SerialTransport
waveform_type_to_scpi: dict[str, str] = {'DC': 'DC', 'NOISE': 'NOIS', 'RAMP': 'RAMP', 'SINE': 'SIN', 'SQUARE': 'SQU', 'TRIANGLE': 'TRI', 'USER': 'USER'}
class inspy.instrument.signalgenerator.SigGenKeysight33522B(visa_address=None, transport=None)[source]

Bases: SigGenKeysightBase

Signal generator instrument class for 33522B.

tags: AWG, Arb, Arbitrary Waveform Generator, Function Generator

Instructions: Keysight Waveform Generator User Guide

auto_log_level: int = 20

The log level used for automatic logging of method calls.

To disable logging set to logging.NOTSET.

await_completion()

Wait for the signal generator to complete the current operation.

Return type:

None

channel_error_message = 'Valid channel(s): '
channels: list[int] = [1, 2]
connect()

Connect to instrument using the transport layer.

Return type:

None

delete_all_saved_user_waveforms(channel=1)

Delete all the saved arbitrary waveforms in the signal generator.

There is no direct command to delete a particular waveform for this signal generator.

Parameters:

channel (int) – Channel to delete the user waveform from

Return type:

None

disconnect()
Return type:

None

get_channel_state(channel=1)

Get the current state of the output.

Parameters:

channel (int) – channel to get state of

Return type:

bool

Returns:

True if output enabled

get_errors()

Get a list of errors and error numbers from the instrument.

Return type:

list[tuple[int, str]]

Returns:

A list where each value is a tuple of the error number and error description

get_frequency(channel=1)

Get the set frequency of the desired channel.

Parameters:

channel (int) – channel to get the set frequency from

Return type:

float

Returns:

Frequency in Hz

get_id()

Identification Query.

Return type:

str

Returns:

Instrument Identification String.

get_impedance(channel=1)

Get the set impedance of the channel.

Parameters:

channel (int) – Channel to get the set impedance of

Return type:

str

Returns:

Impedance string (‘50’, ‘HIGH’)

get_saved_user_waveforms(channel=1)

Get the list of saved user waveforms in the signal generator.

Parameters:

channel (int) – Channel to get the user waveforms from

Return type:

list[str]

Returns:

List of user waveform names

get_voltage_amplitude(channel=1)

Get the currently set amplitude of the signal.

Parameters:

channel (int) – Channel to get the set amplitude of

Return type:

float

Returns:

Voltage in V

get_voltage_high(channel=1)

Get the currently set high/maximum voltage of the signal.

Parameters:

channel (int) – Channel to get the set high voltage of

Return type:

float

Returns:

Voltage in V

get_voltage_low(channel=1)

Get the currently set low/minimum voltage of the signal.

Parameters:

channel (int) – Channel to get the set low voltage of

Return type:

float

Returns:

Voltage in V

get_voltage_offset(channel=1)

Get the currently set offset of the signal.

Parameters:

channel (int) – Channel to get the set offset of

Return type:

float

Returns:

Voltage in V

get_waveform_mode(channel=1)

Get the type/shape of the waveform.

Parameters:

channel (int) – Channel to get the set waveform of

Return type:

str

Returns:

Waveform type as string

is_connected: bool
logger: logging.Logger
reset()

Reset the signal generator to default settings.

Return type:

None

property scpi_to_waveform_type: dict[str, str]

Map the SCPI query result from the SigGen to type of waveform.

Done to update the attribute when the waveform_type_to_scpi is redefined. Otherwise, the scpi_to_waveform_type will not be updated and will always be {}.

set_channel_state(enable, channel=1)

Enable or Disable the channel(s) output/input.

tags: Enable, Disable, On, Off, state, channel, Output, Input, Source, Sink

Parameters:
  • enable (bool) – Enable the channel output

  • channel (int) – channel(s) to set the state of

Return type:

None

set_frequency(frequency, channel=1)

Set the frequency (in Hz) of the required channel(s).

Parameters:
  • frequency (float) – Frequency in Hz

  • channel (int) – Channel(s) to set frequency of

Return type:

None

set_impedance(impedance, channel=1)

Set the output impedance of the channel.

Parameters:
  • impedance (str) – string of impedance mode. Can be only ‘50’ (50 Ohm) or ‘HIGH’ (1 Meg typ.)

  • channel (int) – Channel to set impedance of

Return type:

None

set_new_arbitrary_waveform(array, name='userFunc', channel=1)

Save a new arbitrary waveform to the signal generator’s memory.

This method also sets the waveform mode to USER and enables the channel.

The array should be a list of values that represent the waveform.

Examples:

>>> [0.3       ,  0.302002  ,  0.304004  ,  0.30600601,  0.30800801,
>>>  0.31001001,  0.31201201,  0.31401401,  0.31601602,  0.31801802,
>>>  0.32002002,  0.32202202,  0.32402402,  0.32602603,  0.32802803,
>>>  0.33003003,  0.33203203,  0.33403403,  0.33603604,  0.33803804]

This is an example of a summation of square & sawtooth waveform generated. This example is generated using numpy and scipy libraries.

You can have any arbitrary waveform as long as it is a list of values. Ideally, you would want to have a large number of points to have a smooth wave.

The values must be a list of:

  • floating point values from -1.0 to +1.0 (Representing the peaks)

You can have from 1 to 65,536 such points. If less than 16,384 points, a 16,384 point waveform is generated. If more than 16,384 points, a 65,536-point waveform is generated.

You can specify the characteristics of the waveform using other functions. For example, you can set the frequency, voltage, offset, etc.

  • If you want a wave from -5V to +5V, you can set the amplitude to 10V and use the range of -1.0 to +1.0 in the array. -1.0 will be scaled to -5V and +1.0 will be scaled to +5V

Things to keep in mind:

  • The sig gen will distribute the array evenly in time over the period (= 1 / set frequency) specified, and linearly interpolate between them

  • It is up to the user to ensure the number of points in the waveform is high enough to accurately represent the equivalent analogue signal (>> 2* the key max frequency of interest, as per Nyquist sampling)

  • The sample rate indicates the digitisation frequency of the instrument, and if your signal frequencies approach this value you may not get the instrument accurately reproducing the signal as it cannot sample fast enough. In that case, the user should get a different instrument that supports higher sampling frequencies

Parameters:
  • array (list[Any]) – data to set the waveform to be

  • name (str) – Name of the waveform to store in the SigGen

  • channel (int) – Channel to set the waveform data of

Return type:

None

set_saved_user_waveform(name='userFunc', channel=1)

Select the user waveform for the ARB mode of the signal generator.

This method just selects the waveform for the ARB mode. It does not set the waveform mode to ARB.

Parameters:
  • name (str) – Name of the user waveform to select

  • channel (int) – Channel to select the user waveform of

Return type:

None

set_voltage_amplitude(voltage, channel=1)

Set the amplitude of the signal.

set_voltage_offset and set_voltage_amplitude are used together. Alternatively, you can use set_voltage_low and set_voltage_high together.

Parameters:
  • voltage (float) – Amplitude of the signal in V

  • channel (int) – Channel(s) to set voltage of

Return type:

None

set_voltage_high(voltage, channel=1)

Set the high/maximum voltage of the signal.

set_voltage_low and set_voltage_high are used together. Alternatively, you can use set_voltage_offset and set_voltage_amplitude together.

Parameters:
  • voltage (float) – High/maximum voltage of signal

  • channel (int) – Channel(s) to set voltage of

Return type:

None

set_voltage_low(voltage, channel=1)

Set the low/minimum voltage of the signal.

set_voltage_low and set_voltage_high are used together. Alternatively, you can use set_voltage_offset and set_voltage_amplitude together.

Parameters:
  • voltage (float) – Low/minimum voltage of signal

  • channel (int) – Channel(s) to set voltage of

Return type:

None

set_voltage_offset(voltage, channel=1)

Set the offset of the signal.

set_voltage_offset and set_voltage_amplitude are used together. Alternatively, you can use set_voltage_low and set_voltage_high together.

Parameters:
  • voltage (float) – Offset of the signal in V

  • channel (int) – Channel(s) to set voltage of

Return type:

None

set_waveform_mode(mode, channel=1)

Set the type/shape of the waveform.

For arb waveform, you can set the waveform using set_new_arbitrary_waveform() or select a waveform from the saved waveforms using set_saved_user_waveform() and then set the waveform mode to USER using this function.

Parameters:
  • mode ('SINE' | 'SQUARE' | 'TRIANGLE' | 'RAMP' | 'PULSE' | 'PRBS' | 'NOISE' | 'ARB' | 'DC') – Type of waveform to set

  • channel (int) – channel to set waveform type of

Return type:

None

transport: PyVisaTransport
waveform_type_to_scpi: dict[str, str] = {'ARB': 'ARB', 'DC': 'DC', 'NOISE': 'NOIS', 'PRBS': 'PRBS', 'PULSE': 'PULS', 'RAMP': 'RAMP', 'SINE': 'SIN', 'SQUARE': 'SQU', 'TRIANGLE': 'TRI'}