main content

getting started acquiring data with digilent analog discovery -凯发k8网页登录

this example shows you how to acquire voltage data at a rate of 300 khz. the input waveform is a sine wave (10 hz, 2 vpp) provided by an external function generator.

create a dataacquisition for a digilent device

discover digilent devices connected to your system using daqlist.

daqlist("digilent")
dq = daq("digilent")
ans =
  1×4 table
    deviceid                     description                            model                  deviceinfo       
    ________    _____________________________________________    ____________________    _______________________
     "ad1"      "digilent inc. analog discovery 2 kit rev. c"    "analog discovery 2"    [1×1 daq.di.deviceinfo]
dq = 
dataacquisition using digilent inc. hardware:
                     running: 0
                        rate: 10000
           numscansavailable: 0
            numscansacquired: 0
              numscansqueued: 0
    numscansoutputbyhardware: 0
                   ratelimit: []
show channels
show properties and methods

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_in = addinput(dq, "ad1", "1", "voltage");

set dataacquisition and channel properties

set the acquisition rate to 300 khz and the dynamic range of the incoming signal to -2.5 to 2.5 volts.

ch_in.name = "ad1_1_in"
rate = 300e3;
dq.rate = rate;
ch_in.range = [-2.5 2.5];
ch_in = 
    index    type    device    channel    measurement type          range              name   
    _____    ____    ______    _______    ________________    __________________    __________
      1      "ai"    "ad1"       "1"      "voltage (diff)"    "-25 to  25 volts"    "ad1_1_in"

acquire a single sample

acquire a single scan on-demand, displaying the data and trigger time.

[singlereading, starttime] = read(dq)
singlereading =
  timetable
    time     ad1_1_in
    _____    ________
    0 sec    -0.37211
starttime = 
  datetime
   21-nov-2019 16:56:50.631

acquire timestamped data

acquire a set of clocked data for one second.

[data, starttime] = read(dq, seconds(1));

plot acquired data

plot(data.time, data.ad1_1_in);
xlabel('time (s)');
ylabel('voltage (v)');
title(['clocked data triggered on: ' datestr(starttime)]);

网站地图