GSV-1A8USB und Matlab

Messverstärker mit Schnittstelle (USB, RS232, CANBVus, Bluetooth, GPRS, ...)
Serie GSV-2, GSV-3, GSV-4
Kabelitz
Beiträge: 412
Registriert: Fr 5. Aug 2011, 12:09

GSV-1A8USB und Matlab

Beitragvon Kabelitz » Fr 25. Jul 2014, 14:48

Herr Peter Leinen vom Sportwissenschaftlichen Institut der Uni Saarland hat uns freundlicherweise den Matlab Code für GSV-3 und GSV-8 zur Verfügung gestellt:

Code: Alles auswählen

% This is an example howto to use the Matlab Data Aquisition Tool Box to
% save data from a GSV-1A8USB (Session Based).
%
% Author: Peter Leinen
% Email: peter.leinen@gmail.com
% 11/07/2014

%Creates an DAQ object and defines channels to use.
s = daq.createSession('ni');
chan0=s.addAnalogInputChannel('dev1', 'ai0', 'Voltage')
%chan1=s.addAnalogInputChannel('dev1', 'ai1', 'Voltage')
%chan2=s.addAnalogInputChannel('dev1', 'ai2', 'Voltage')

% Sets the input type to Single Ended.
chan0.InputType='SingleEnded';
%chan1.InputType='SingleEnded';
%chan2.InputType='SingleEnded';

s.Rate = 1000;      % Defines the aquisition sample rate of the GSV-1A8USB.
s.DurationInSeconds = 10;   % Time of aquisition.

% Creates file to save data
filename = sprintf('log%s.txt',datestr(now,30));


display('Collecting Data...')
tic;
[data,time] = s.startForeground;        % starts aquisition

toc

% write data in file
dlmwrite(filename,[time data],';')

% plots data after aquisition
plot(time,data)
xlabel('Time (secs)');
ylabel('Voltage');
pause();           

close all
clear all




Code: Alles auswählen

% This is an example howto to use the Matlab Data Aquisition Tool Box to
% plot and save data from a GSV-1A8USB in real-time (Session Based).
%
% The function file "plotNsave.m" is needed.
%
% Author: Peter Leinen
% Email: peter.leinen@gmail.com
% 11/07/2014

%Creates an DAQ object and defines channels to use.
s = daq.createSession('ni');
chan0=s.addAnalogInputChannel('dev1', 'ai0', 'Voltage')
% chan1=s.addAnalogInputChannel('dev1', 'ai1', 'Voltage')
% chan2=s.addAnalogInputChannel('dev1', 'ai2', 'Voltage')


chan0.InputType='SingleEnded';  % Sets the input type to Single Ended.
% chan1.InputType='SingleEnded';
% chan2.InputType='SingleEnded';

s.Rate = 1000;      % Defines the aquisition sample rate of the GSV-1A8USB.
s.DurationInSeconds = 10;   % Time of aquisition.

% Creates a graph for plotting.
picture=figure('Name','','NumberTitle','off');
bkgnd = 'white';
set(picture,'Color',bkgnd,'Menubar','none');
scrz = get(0,'Screensize');
set (picture, 'Position',scrz);
axis on;
axis([0 10 -0.2 0.2]);
hold on;

% Creates file to save data
filename = sprintf('log%s.txt',datestr(now,30));
fid = fopen(filename,'w');

% Creates a Listener object with a callback function (plotNsave.m).
lh = s.addlistener('DataAvailable',@(src,event)plotNsave(fid,event));
%s.NotifyWhenDataAvailableExceeds = 100;

tic;
s.startBackground();    % starts aquisition
s.wait()
toc;

delete(lh)             
close all


Zurück zu „Digitale Messelektronik“

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 0 Gäste