0% found this document useful (0 votes)
3 views2 pages

Unit 2 - Matlab For Data Aquisition

This document outlines a procedure for acquiring data from a National Instruments DAQ device using MATLAB. It includes steps for creating a session, adding an analog input channel, configuring properties, acquiring data, and performing basic analysis. Additionally, it provides instructions for saving the acquired data to a CSV file and suggests further analysis techniques.

Uploaded by

padminisuthakar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Unit 2 - Matlab For Data Aquisition

This document outlines a procedure for acquiring data from a National Instruments DAQ device using MATLAB. It includes steps for creating a session, adding an analog input channel, configuring properties, acquiring data, and performing basic analysis. Additionally, it provides instructions for saving the acquired data to a CSV file and suggests further analysis techniques.

Uploaded by

padminisuthakar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

% --- Hardware Configuration ---

% Assuming you have a National Instruments DAQ device (e.g., USB-6008)

% and a sensor connected to analog input channel 0 (ai0).

% You may need to adjust the device and channel names based on your setup.

% --- Create DAQ Session ---

s = daq.createSession('ni'); % 'ni' for National Instruments devices

% --- Add Analog Input Channel ---

ch = addAnalogInputChannel(s, 'Dev1', 'ai0', 'Voltage'); % 'Dev1' might change.

% --- Configure Channel Properties ---

ch.Range = [-10 10]; % Set input voltage range (adjust as needed)

ch.TerminalConfig = 'SingleEnded'; % or 'Differential', 'PseudoDifferential'

% --- Set Acquisition Parameters ---

s.Rate = 1000; % Sampling rate (samples per second)

s.DurationInSeconds = 10; % Acquisition duration (seconds)

% --- Acquire Data ---

disp('Acquiring data...');

data = startForeground(s); % Acquire data synchronously

time = (0:length(data)-1)'/s.Rate; % Generate time vector

disp('Data acquisition complete.');

% --- Display and Analyze Data ---

figure;

plot(time, data);

xlabel('Time (s)');

ylabel('Voltage (V)');
title('Acquired Data');

% --- Basic Analysis ---

meanValue = mean(data);

stdValue = std(data);

fprintf('Mean Value: %.4f V\n', meanValue);

fprintf('Standard Deviation: %.4f V\n', stdValue);

% --- Saving Data to File ---

% Example: Saving to a CSV file

dataTable = table(time, data, 'VariableNames', {'Time', 'Voltage'});

writetable(dataTable, 'acquired_data.csv');

disp('Data saved to acquired_data.csv');

% --- Further Analysis ---

% You can perform more advanced analysis, such as:

% - Filtering (e.g., using `filter` function)

% - Frequency analysis (e.g., using `fft` function)

% - Signal processing techniques

% - Building predictive models

% - etc.

% --- Cleanup ---

clear s; % Clear the session object

You might also like