Main Content

fgen

Connection to Quick-Control Function Generator instrument

Description

The Quick-Control Function Generator can be used for any function generator that uses an underlying IVI-C driver. You do not have to directly deal with the underlying driver.

For information on the prerequisites for using fgen, see Quick-Control Function Generator Requirements.

Creation

Description

myFGen = fgen creates an object to connect to your function generator. To connect to the function generator specified by myFGen, use connect(myFGen).

example

myFGen = fgen(resource) creates a connection to the function generator with the specified resource string, resource.

myFGen = fgen(resource,driver) creates a connection to the function generator with the specified resource string, resource, and driver, driver.

Input Arguments

expand all

Function generator identifier, specified as a character vector or string scalar.

Example: f = fgen('TCPIP0::172.31.57.100::inst0::INSTR')

Data Types: char | string

Function generator driver, specified as a character vector or string scalar.

Example: f = fgen('GPIB::ics::0::10','Agilent332x0_SCPI')

Data Types: char | string

Properties

expand all

Factor by which the function generator scales the arbitrary waveform data, specified as a number. Use this property to scale the arbitrary waveform to ranges other than -1.0 to +1.0. When set to 2.0, the output signal ranges from -2.0 to +2.0 volts. Only applies if Waveform is of type 'Arb'.

Data Types: double

Number of waveform cycles that the function generator produces after it receives a trigger, specified as a number. Only applies if Mode is set to 'burst'.

Data Types: double

Maximum frequency deviation the modulating waveform applies to the carrier waveform, specified as a number in Hertz (Hz). This deviation corresponds to the maximum amplitude level of the modulating signal. This property affects function generator behavior only when Mode is set to 'FM' and ModulationSource is set to 'Internal'.

Data Types: double

Horizontal offset in degrees of the standard waveform the function generator produces, specified as a number in degrees of one waveform cycle. For example, a 180-degree phase offset means output generation begins halfway through the waveform.

Data Types: double

Rate at which the function generator's internal trigger source produces a trigger, specified as a number in triggers per second. This property affects function generator behavior only when the TriggerSource is set to 'Internal'. Only applies if Mode is set to 'Burst'.

Data Types: double

Trigger source, specified as 'Internal' or 'External'. After the function generator receives a trigger, it generates an output signal if Mode is set to 'Burst'. Valid values are 'Internal' or 'External'.

Data Types: char | string

Instrument Settings

Selected channel name that was set using the selectChannel function, specified as a character vector.

Data Types: char | string

This property is read-only.

Available channel names in a cell array, specified as a cell array of character vectors.

Data Types: cell

Amplitude of the standard waveform, specified as a number in volts peak-to-peak (Vpp). The value is the amplitude at the output terminal. For example, to produce a waveform ranging from -5.0 to +5.0 volts, set this value to 10.0 volts. Does not apply if Waveform is of type 'Arb'.

Data Types: double

Rate at which the function generator outputs an entire arbitrary waveform when Waveform is set to 'Arb', specified as a number in Hertz (Hz). It specifies the frequency of the standard waveform when Waveform is set to standard waveform types.

Data Types: double

Run mode, specified as 'Continuous', 'Burst', 'AM', or 'FM'. Specifies how the function generator produces waveforms. It configures the instrument to generate output continuously or to generate a discrete number of waveform cycles based on a trigger event. It can also be set to AM and FM.

Data Types: char | string

DC offset of the standard waveform if the waveform is not of type 'Arb', specified as a number in volts. If the waveform is of type 'Arb', use Arb Waveform Offset.

Specifies the DC offset of the standard waveform when Waveform is set to standard waveform. For example, a standard waveform ranging from +5.0 volts to 0.0 volts has a DC offset of 2.5 volts. When Waveform is set to 'Arb', this property shifts the arbitrary waveform's range. For example, when it is set to 1.0, the output signal ranges from 2.0 volts to 0.0 volts.

Data Types: double

Function generator's output impedance at the output connector, specified as a number in Ohms.

Data Types: double

Waveform type, specified as 'Arb', for an arbitrary waveform, or these standard waveform types – 'Sine', 'Square', 'Triangle', 'RampUp', 'RampDown', or 'DC'.

Data Types: char | string

AM Settings

Extent of Amplitude modulation the function generator applies to the carrier signal, specified as a number in percentage of full modulation. At 0% depth, the output amplitude equals the carrier signal's amplitude. At 100% depth, the output amplitude equals twice the carrier signal's amplitude. This property affects function generator behavior only when the Mode is set to 'AM' and ModulationResource is set to 'Internal'.

Data Types: double

Frequency of the standard waveform that the function generator uses to modulate the output signal, specified as a number in Hertz (Hz). This attribute affects function generator behavior only when Mode is set to 'AM' or 'FM' and the ModulationSource attribute is set to 'Internal'.

Data Types: double

Signal that the function generator uses to modulate the output signal, specified as 'Internal' or 'External'. This attribute affects function generator behavior only when Mode is set to 'AM' or 'FM'.

Data Types: char | string

Standard waveform type that the function generator uses to modulate the output signal, specified as 'Sine', 'Square', 'Triangle', 'RampUp', 'RampDown', or 'DC'. This affects function generator behavior only when Mode is set to 'AM' or 'FM' and the ModulationSource is set to 'Internal'.

Data Types: char | string

Communication Properties

This property is read-only.

Communication status, specified as 'open' or 'closed'.

Data Types: char | string

VISA resource string for your instrument, specified as a character vector. Set this before connecting to the instrument.

Data Types: char | string

Driver configuration, specified as 'auto' or 'manual'. If set to 'auto', you do not have to set a driver name before connecting to an instrument. If set to 'manual', a driver name must be provided before connecting.

Data Types: char | string

Function generator driver, specified as a character vector. Use only if DriverDetectionMode is set to 'manual'. Use it to give driver name. Only use if driver name cannot be figured out programmatically.

Data Types: char | string

Object Functions

Use these object functions with any Quick-Control interface.

driversList of available instrument drivers for Quick-Control interfaces
resourcesList of available instrument resources for Quick-Control interfaces
connectConnect device object to instrument
disconnectDisconnect device object from instrument

Examples

collapse all

Create an instance of the function generator called myFGen.

myFGen = fgen()

Discover available resources. A resource string is an identifier to the instrument. You need to set it before connecting to the instrument.

availableResources = resources(myFGen)

Set the resource. In this example, we are controlling an instrument that is connected via GPIB with a board index of 0 and primary address of 10.

myFGen.Resource = 'GPIB0::10::INSTR';

Connect to the function generator.

connect(myFGen);

Specify the channel name from which the function generator produces the waveform.

selectChannel(myFGen, '1');

Configure a standard waveform to be a continuous sine wave.

myFGen.Waveform = 'sine';
myFGen.Mode = 'continuous';

Configure the function generator.

% Set the load impedance to 50 Ohms. 
myFGen.OutputImpedance = 50;

% Set the frequency to 2500 Hz. 
myFGen.Frequency = 2500;

% Set the amplitude to 1.2 volts. 
myFGen.Amplitude = 1.2;

% Set the offset to 0.4 volts. 
myFGen.Offset = 0.4;

Communicate with the instrument. For example, output signals. In this example, the enableOutput function enables the function generator to produce a signal that appears at the output connector.

% Enable the output of signals. 
enableOutput(myFGen);

When you are done, disable the output.

% Disable the output of signals. 
disableOutput(myFGen);

Close the session and remove it from the workspace.

disconnect(myFGen);
delete myFGen;
clear myFGen;

These examples used a standard waveform type. For examples using an arbitrary waveform, see Generate Standard Waveforms Using the Quick-Control Function Generator.

Version History

Introduced in R2012a