Generate a Standard Waveform Using Function Waveform Generator Channels
This example shows how to use the function generator channel in a
DataAcquisition to generate a sine function waveform at a frequency of 100 kHz. The signal
output voltage range is specified as -5.0 to +5.0
volts.
Discover available Digilent® devices.
dev = daqlist("digilent")dev =
1×4 table
DeviceID Description Model DeviceInfo
________ _____________________________________________ ____________________ _______________________
"AD1" "Digilent Inc. Analog Discovery 2 Kit Rev. C" "Analog Discovery 2" [1×1 daq.di.DeviceInfo]Create a DataAcquisition object for Digilent devices.
d = daq("digilent")d =
DataAcquisition using Digilent Inc. hardware:
Running: 0
Rate: 10000
NumScansAvailable: 0
NumScansAcquired: 0
NumScansQueued: 0
NumScansOutputByHardware: 0
RateLimit: []Add a waveform function generator channel for device AD1 with a
Sine waveform type.
fgenCh = addoutput(d,"AD1",1,"Sine")
fgenCh =
Index Type Device Channel Measurement Type Range Name
_____ ______ ______ _______ ________________ ____________________ ____________
1 "fgen" "AD1" "1" "Sine" "-5.0 to +5.0 Volts" "AD1_1_fgen"Set the channel amplitude to 5 v using the Gain property and the
channel frequency to 100 kHz.
fgenCh.Gain = 5; fgenCh.Frequency = 100e3;
Specify the output duration to run for 5 seconds and start the
generation.
write(d,seconds(5))