Преглед изворни кода

function generator met scintilla functie

master
Wouter Horlings пре 8 година
родитељ
комит
c5f3f62b6f
2 измењених фајлова са 62 додато и 1 уклоњено
  1. +27
    -0
      OOequipment/subfiles/Equipment.m
  2. +35
    -1
      OOequipment/subfiles/FunctionGenerator.m

+ 27
- 0
OOequipment/subfiles/Equipment.m Прегледај датотеку

@@ -7,6 +7,10 @@ classdef Equipment < handle
tcp
channel
locked
manufacturer
model
serialnumber
firmwarelevel
end
properties (Dependent, SetAccess=private)
error
@@ -30,6 +34,11 @@ classdef Equipment < handle
if channel >= 0
ecq.setPrologix;
end
splitname = strsplit(ecq.name,',');
ecq.manufacturer = splitname{1};
ecq.model = splitname{2};
ecq.serialnumber = splitname{3};
ecq.firmwarelevel = splitname{4};
end
function id = idn(ecq)
@@ -236,6 +245,15 @@ classdef Equipment < handle
ecq.write_unsafe(message);
output = read(ecq);
end
function disableEOI(ecq)
ecq.tcp.Terminator = '';
end
function enableEOI(ecq)
ecq.tcp.Terminator = 'LF';
end
end
methods (Access = protected, Hidden)
@@ -277,6 +295,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^24; %make really large buffer size 64MB. To acquire complete waveforms.
tcpconnection.(ipname).tcp.OutputBufferSize = 2^24; %make really large buffer size 64MB. To acquire complete waveforms.
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.
@@ -324,6 +343,14 @@ classdef Equipment < handle
end
end
function output = optionnum2str(input)
if isnum(input)
output = num2str(input);
else
output = input;
end
end
function [structname,cleanip] = ip2structname(ipAddress,port)
%IP2STRUCTNAME Returns a structname and ip w/out leading zeros.
%structname to store stuff in struct (especially for GETTCP).


+ 35
- 1
OOequipment/subfiles/FunctionGenerator.m Прегледај датотеку

@@ -16,6 +16,7 @@ classdef FunctionGenerator < Equipment
unit
offset
load
output
end
methods
@@ -28,6 +29,7 @@ classdef FunctionGenerator < Equipment
%
% See also EQUIPMENT, OSCILLOSCOPE, DIGITALMULTIMETER.
fg@Equipment(ipAddress,port,channel);
end

function w = get.waveform(fg)
@@ -64,7 +66,15 @@ classdef FunctionGenerator < Equipment
%Get function generator load setting on load variable
% access, using the corresponding SCPI command.
l = FunctionGenerator.getLoad(fg.query('OUTPut:LOAD?'));
end
end
function out = get.output(fg)
if strcmp(fg.model(1:3),'335') || strcmp(fg.model(1:3),'332')
out = fg.query('OUTP?');
else
warning('This generator does not support this function');
end
end

function fg = set.waveform(fg,w)
%Set function generator waveform setting on waveform variable
@@ -104,6 +114,30 @@ classdef FunctionGenerator < Equipment
% using the corresponding SCPI command.
fg.write(['OUTPut:LOAD ' FunctionGenerator.getLoad(l)]);
end
function fg = set.output(fg,out)
if strcmp(fg.model(1:3),'335') || strcmp(fg.model(1:3),'332')
fg.write(['OUTP ' Equipment.optionnum2str(out)])
end
end
function downloadwaveform(fg,waveform,name)
fg.disableEOI;
fg.write_unsafe(['data:arb ' name ',']);
fg.enableEOI;
binblockwrite(fg.tcp,waveform,'float')
fg.error;
fg.write(['func:arb ' name])
fg.write(['MMEM:STORE:DATA "INT:\' name '.arb"'])
end
function scintilla(fg,periods)
periods = round(periods);
x = linspace(-periods*pi,periods*pi,1600);
y = exp(-abs(x./6)).*sin(x)./0.8;
fg.downloadwaveform(y,'scintilla');
end
end

methods (Static)


Loading…
Откажи
Сачувај