Generate Standard Waveforms Using the Quick-Control Function Generator
This example shows how to use the Quick-Control Function Generator to generate a standard waveform. To generate an arbitrary waveform, see Generate Arbitrary Waveforms Using Quick-Control Function Generator. Quick-Control Function Generator works with any function generator using an IVI-C driver as long as the instrument and the driver support the functionality. You can follow the basic steps using your particular function generator. This example uses Keysight® VISA, but you can use any vendor's implementation of VISA.
In this example, an electronic test engineer wants to create a simple sine waveform to test the clock operating range of a digital circuit.
- Ensure all necessary software is installed. See Quick-Control Function Generator Requirements for the list. 
- Create an instance of the function generator. - % Instantiate an instance of the fgen. myFGen = fgen(); 
- Discover available resources. A resource string is an identifier to the instrument. You must set it before connecting to the instrument. - % Find resources. availableResources = resources(myFGen) - This returns a resource string or an array of resource strings, for example: - ans = ASRL::COM1 GPIB0::INTFC GPIB0::10::INSTR PXI0::MEMACC TCPIP0::172.28.16.153::inst0::INSTR TCPIP0::172.28.16.174::inst0::INSTR 
- Set the resource for the function generator you want to communicate with. - 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 the function generator. - You can configure any of the instrument’s properties that are settable. Configure the waveform to be a continuous sine wave and then configure various settings as shown. - % Set the type of waveform to a sine wave. myFGen.Waveform = 'sine'; % Set the output mode to continuous. myFGen.Mode = 'continuous'; % 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; 
- Enable signal generation with the instrument, for example, output signals. - In this example, the - enableOutputfunction 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); 
- After configuring the instrument and generating a signal, close the session and remove it from the workspace. - disconnect(myFGen); clear myFgen; 
For a list of supported functions for use with Quick-Control Function Generator, see Quick-Control Function Generator Functions.