Wouter Horlings 8 anni fa
parent
commit
191e18b539
5 ha cambiato i file con 76 aggiunte e 4 eliminazioni
  1. +1
    -1
      OOequipment/Channel.m
  2. +11
    -0
      OOequipment/Equipment.m
  3. +1
    -1
      OOequipment/FunctionGenerator.m
  4. +52
    -0
      OOequipment/Oscilloscope.m
  5. +11
    -2
      OOequipment/transferFunction.m

+ 1
- 1
OOequipment/Channel.m Vedi File

@@ -107,7 +107,7 @@ classdef Channel
ch.scope.write('SING');
header = str2num(ch.CHAN('DATA:HEAD?'));
ch.scope.opc;
ch.scope.write_unsafe('CHAN1:DATA?');
ch.scope.write_unsafe(['CHAN',num2str(ch.channelnumber),':DATA?']);
prefixstring = fscanf(ch.scope.tcp,'%c',2);
prefixlength = str2double(prefixstring(2));
datalength = fscanf(ch.scope.tcp,'%c',prefixlength);


+ 11
- 0
OOequipment/Equipment.m Vedi File

@@ -152,6 +152,16 @@ classdef Equipment < handle
fprintf(['>> ',message,'\n']);
end
function write_noerror(ecq,message)
%WRITE Sends a command to the channel.
%The function will first check if the device is ready to
%recieve a command via the OPC function. Then send the command.
%
%See also WRITE
ecq.opc;
ecq.write_unsafe(message);
end
function output = query_unsafe(ecq,message)
%QUERY_UNSAFE Sends command to device and reads device output.
%This function does not check if device is ready or check if an
@@ -202,6 +212,7 @@ classdef Equipment < handle
tcpconnection.(ipname).tcp = tcpip(ipAddress,port); %Make TCP-connection
tcpconnection.(ipname).nopen = 1; %Set number of connections in use to 1
tcpconnection.(ipname).tcp.InputBufferSize = 2^20; %make really large buffer size
tcpconnection.(ipname).tcp.Timeout = 5; %set timeout to 5 seconds.
fopen(tcpconnection.(ipname).tcp); %Open the TCP-connection
else %If connection already exist. Increase number of connections in use by 1.
tcpconnection.(ipname).nopen = tcpconnection.(ipname).nopen + 1;


+ 1
- 1
OOequipment/FunctionGenerator.m Vedi File

@@ -65,7 +65,7 @@ classdef FunctionGenerator < Equipment
function fg = set.load(fg,l)
fg.write(['OUTPut:LOAD ' FunctionGenerator.getLoad(l)]);
end
end
end
methods (Static)


+ 52
- 0
OOequipment/Oscilloscope.m Vedi File

@@ -25,6 +25,58 @@ classdef Oscilloscope < Equipment
end
end
function s = get.acquisition(sc)
s = sc.query('ACQ:STAT?');
end
function run(sc)
sc.write('RUN');
end
function single(sc)
sc.write('SING');
end
function stop(sc)
sc.write('STOP');
end
function auto(sc)
sc.write_noerror('AUT');
end
function enable_channels(sc)
for i = 1:sc.nchannels
sc.(['ch',num2str(i)]).state = 'ON';
end
end
function disable_channels(sc)
for i = 1:sc.nchannels
sc.(['ch',num2str(i)]).state = 'OFF';
end
end
function setMeasurement(sc,measurement,type,source1,source2)
prefix = ['MEAS',num2str(measurement),':'];
fprintf(num2str(nargin))
if nargin < 5
source2 = 'CH2';
if nargin < 4
source1 = 'CH1';
end
end
source = [source1,', ',source2];
sc.write([prefix,'SOUR ',source]);
sc.write([prefix,'MAIN ',type]);
end
function m = getMeasurement(sc,measurement)
m = sc.query(['MEAS',num2str(measurement),':RES:ACT?']);
end
% function data = waveform(ch,cha)
% ch.scope.clear;
% ch.scope.write('CHAN1:TYPE HRES');


+ 11
- 2
OOequipment/transferFunction.m Vedi File

@@ -1,12 +1,21 @@
function data = transferFunction(oscilloscope,functiongenerator,f_start,f_stop,n_steps)
function data = transferFunction(oscilloscope,functiongenerator,f_start,f_stop,n_steps,amplitude)
%TRANSFERFUNCTION Summary of this function goes here
% Detailed explanation goes here

f_array = linspace(f_start,f_stop,n_steps);
data = zeros(n_steps,1);
functiongenerator.voltage = amplitude;
functiongenerator.waveform = 'SINUSOID';
oscilloscope.enable_channels;
oscilloscope.trigger.source = 'CH1';
oscilloscope.setMeasurement(1,'phase');
oscilloscope.setMeasurement(2,'peak');
oscilloscope.setMeasurement(3,'peak','ch2');

for i = 1:n_steps
functiongenerator.frequency = f_array(i);
data(i) = oscilloscope.ch1.peak2peak;
oscilloscope.auto;
data(i) = oscilloscope.getMeasurement(1);
end
end


Loading…
Annulla
Salva