This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

Getting Started Generating Data with Digilent® Analog Discovery™

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.

Create a session with a Digilent device

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

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 sample

Generate a single scan on-demand.

outVal = 2;

Set session and channel properties

Set the generation rate to 300kHz.

rate = 300e3;
s.Rate = rate;

Define the output waveform

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)';

Generate continuous data

Queue some data and start a clocked foreground generation.

Was this topic helpful?