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)
.
myFGen = fgen(
creates a connection
to the function generator with the specified resource string,
resource
)resource
.
Input Arguments
resource
— Function generator identifier
character vector | string scalar
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
driver
— Function generator driver
character vector | string scalar
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
ArbWaveformGain
— Factor by which the function generator scales the arbitrary waveform data
0 (default) | numeric
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
BurstCount
— Number of waveform cycles that function generator produces
1 (default) | numeric
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
FMDeviation
— Maximum frequency deviation the modulating waveform applies to the carrier waveform
0 (default) | numeric
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
StartPhase
— Horizontal offset in degrees of the standard waveform the function generator produces
0 (default) | numeric
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
TriggerRate
— Rate at which the function generator's internal trigger source produces a trigger
1000 (default) | numeric
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
TriggerSource
— Trigger source
'Internal'
(default) | 'External'
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
SelectedChannel
— Selected channel name
character vector
Selected channel name that was set using the selectChannel
function, specified as a character vector.
Data Types: char
| string
ChannelNames
— Available channel names
cell array of character vectors
This property is read-only.
Available channel names in a cell array, specified as a cell array of character vectors.
Data Types: cell
Amplitude
— Amplitude of standard waveform
10 (default) | numeric
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
Frequency
— Rate at which the function generator outputs an entire arbitrary waveform
2000 (default) | numeric
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
Mode
— Run mode
'AM'
(default) | 'Continuous'
| 'Burst'
| 'FM'
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
Offset
— DC offset of the standard waveform
0 (default) | numeric
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
OutputImpedance
— Output impedance
50 (default) | numeric
Function generator's output impedance at the output connector, specified as a number in Ohms.
Data Types: double
Waveform
— Waveform type
'Sine'
(default) | 'Arb'
| 'Square'
| 'Triangle'
| 'RampUp'
| 'RampDown'
| 'DC'
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
AMDepth
— Extent of amplitude modulation
numeric
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
ModulationFrequency
— Frequency to modulate output signal
500 (default) | numeric
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
ModulationSource
— Signal to modulate output signal
'Internal'
(default) | 'External'
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
ModulationWaveform
— Waveform type to modulate output signal
'Sine'
(default) | 'Square'
| 'Triangle'
| 'RampUp'
| 'RampDown'
| 'DC'
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
Status
— Communication status
'open'
(default) | 'closed'
This property is read-only.
Communication status, specified as 'open'
or
'closed'
.
Data Types: char
| string
Resource
— VISA resource string
character vector
VISA resource string for your instrument, specified as a character vector. Set this before connecting to the instrument.
Data Types: char
| string
DriverDetectionMode
— Criteria for connection
'auto'
(default) | 'manual'
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
Driver
— Function generator driver
character vector
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.
drivers | List of available instrument drivers for Quick-Control interfaces |
resources | List of available instrument resources for Quick-Control interfaces |
connect | Connect device object to instrument |
disconnect | Disconnect device object from instrument |
Examples
Connect to Function Generator
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
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)