Documentation

This is machine translation

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

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

Getting Started Acquiring Data with Digilent® Analog Discovery™

This example shows how to acquire analog input voltage data (at a sampling rate of 300kHz). The dynamic range of the incoming signal is -2.5 to 2.5 volts. You will use the session-based interface with the 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 input channel

Add an analog input channel with device ID AD1 and channel ID 1. Set the measurement type to Voltage.

ch = addAnalogInputChannel(s,'AD1', 1, 'Voltage')
ch = 

Data acquisition analog input voltage channel '1' on device 'AD1':

       Coupling: DC
 TerminalConfig: Differential
          Range: -25 to +25 Volts
           Name: ''
             ID: '1'
         Device: [1x1 daq.di.DeviceInfo]
MeasurementType: 'Voltage'


Set session and channel properties

Set the sampling rate to 300kHz and the channel range to -2.5 to 2.5 volts. Set the duration to 0.5 seconds.

s.Rate = 300e3;
s.Channels.Range = [-2.5 2.5];
s.DurationInSeconds = 0.5
s = 

Data acquisition session using Digilent Inc. hardware:
   Will run for 0.5 seconds (150000 scans) at 300000 scans/second.
   Number of channels: 1
      index Type Device Channel MeasurementType       Range        Name
      ----- ---- ------ ------- --------------- ------------------ ----
      1     ai   AD1    1       Voltage (Diff)  -2.5 to +2.5 Volts
   

Acquire a single sample

Acquire a single scan on-demand, measuring the data and trigger time.

[singleReading, triggerTime] = inputSingleScan(s)
singleReading =

   -0.0104


triggerTime =

   7.3532e+05

Acquire timestamped data

Start a clocked foreground acquisition.

[data, timestamps, triggerTime] = startForeground(s);

Display the results

plot(timestamps, data);
xlabel('Time (seconds)')
ylabel('Voltage (Volts)')
title(['Clocked Data Triggered on: ' datestr(triggerTime)])

Was this topic helpful?