This example shows how to generate analog output voltage data (at a rate of 300kHz). The output voltage-range of the outgoing signal is -5.0 to +5.0 volts. You will use the session-based interface with Digilent Analog Discovery hardware.
|On this page…|
Discover Digilent devices connected to your system using daq.getDevices and create a session using the listed Digilent device.
s = daq.createSession('digilent')
s = Data acquisition session using Digilent Inc. hardware: Will run for 1 second (10000 scans) at 10000 scans/second. No channels have been added.
Add an analog output channel with device ID AD1 and channel ID 1. Set the measurement type to Voltage.
ch = addAnalogOutputChannel(s,'AD1', 1, 'Voltage')
ch = Data acquisition analog output voltage channel '1' on device 'AD1': TerminalConfig: SingleEnded Range: -5.0 to +5.0 Volts Name: '' ID: '1' Device: [1x1 daq.di.DeviceInfo] MeasurementType: 'Voltage'
Generate a single scan on-demand.
outVal = 2; outputSingleScan(s,outVal);
Set the generation rate to 300kHz.
rate = 300e3; s.Rate = rate;
Generate a 10 Hz sine-wave for half a second. The length of the output waveform and the specified output rate define the duration of the waveform.
f = 10; duration = 0.5; t = (1:(duration*rate))/rate; output = sin(2*pi*f*t)';
Queue some data and start a clocked foreground generation.