-
Notifications
You must be signed in to change notification settings - Fork 0
/
NIDAQ.m
81 lines (62 loc) · 2.4 KB
/
NIDAQ.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
% clear Workspace
clear; clc; close all
% set up UI to allow user to select DAQ settings
Cfg = NI_ConfigureSession;
% Initialises a session interface for NI devices. A Labview-like UI
% provides device and channel selection.
%
% Input Params:
%
% sampleRate (optional) - the sampling frequency of the session
% Default: 1kHz
% defaultRecordingTime - the length of each acquistion operation in
% seconds. Default: 10s. Enter 0 for continuous recording.
% This can be overridden in the NI_Acquire function.
%
% Output:
%
% session - the session object that was crea ted
% device - the NI device that was chosen
S = NI_CreateSession (Cfg.SampleRate, Cfg.Duration);
% Acquire data from NI devices
%
% session (required) - the DAQ session to be used.
%
% duration (optional) - overrides the target duration of the session (in
% seconds). Default is the currently configured session duration.
% Pass an empty string '' to use the session's default duration
%
% plotOption (optional) - the type of preview plot:
% 0: no preview plot.
% 1: graph preview (shows the current input buffer only).
% 2: chart preview type 1 (shows all the data from the current
% acquisition in a chart that grows in width as more data is
% acquired).
% 3: chart preview type 2 (shows all the data in a chart that is
% starts at the full width and gradually fills up).
%
% logName (optional) - a unique name to identify the log.
% Pass an empty string to use the dafault name 'Data Log'.
% Pass the string 'ui' to enter the name at a prompt
%
% logFilename (optional) - the prefix for the filename of the log file.
% Pass an empty string to use the default name 'Data Log'
% Pass the string 'ui' to enter the name at a prompt
% Pass the string 'same' to use the same name as the logName above
%
% logDirectory (optional) -
% Pass a path string for direct specification of a folder path
% Pass an empty string to use the default directory
% Pass the string 'ui' to enter the name at a prompt
NI_Acquire (...
S, ...
Cfg.Duration, ...
Cfg.PreviewMode, ...
Cfg.LogName, ...
'same', ...
Cfg.LogFolder, ...
Cfg.SaveAsText...
);
% Cleans up the NI DAQ session and associated objects. Run after all DAQ
% operations are complete.
NI_Cleanup(S); clear;