|
|
|
@@ -12,23 +12,97 @@ classdef FunctionGenerator < Equipment |
|
|
|
end |
|
|
|
|
|
|
|
methods |
|
|
|
function wf = get.waveform(fg) |
|
|
|
wf = fg.query('FUNCtion:SHAPe?') |
|
|
|
|
|
|
|
function fg = FunctionGenerator(ipAddress,port,channel) |
|
|
|
fg@Equipment(ipAddress,port,channel); |
|
|
|
end |
|
|
|
|
|
|
|
function w = get.waveform(fg) |
|
|
|
w = FunctionGenerator.getWave(fg.query('FUNCtion:SHAPe?')); |
|
|
|
end |
|
|
|
|
|
|
|
function f = get.frequency(fg) |
|
|
|
f = str2num(fg.query('FREQuency?')); |
|
|
|
end |
|
|
|
|
|
|
|
function v = get.voltage(fg) |
|
|
|
v = str2num(fg.query('VOLTage?')); |
|
|
|
end |
|
|
|
|
|
|
|
function u = get.unit(fg) |
|
|
|
u = FunctionGenerator.getUnit(fg.query('VOLTage:UNIT?')); |
|
|
|
end |
|
|
|
|
|
|
|
function o = get.offset(fg) |
|
|
|
o = str2num(fg.query('VOLTage:OFFSet?')); |
|
|
|
end |
|
|
|
|
|
|
|
function l = get.load(fg) |
|
|
|
o = FunctionGenerator.getLoad(fg.query('OUTPut:LOAD?')); |
|
|
|
end |
|
|
|
|
|
|
|
function fg = set.waveform(fg,w) |
|
|
|
fg.waveform = FunctionGenerator.getWave(w); |
|
|
|
fg.write(strcat('FUNCtion:SHAPe ', fg.waveform)); |
|
|
|
end |
|
|
|
|
|
|
|
function fg = set.frequency(fg,f) |
|
|
|
fg.frequency = Equipment.forceNum(f); |
|
|
|
fg.write(strcat('FREQuency ', num2str(fg.frequency))); |
|
|
|
end |
|
|
|
|
|
|
|
function fg = set.voltage(fg,v) |
|
|
|
fg.voltage = Equipment.forceNum(v); |
|
|
|
fg.write(strcat('VOLTage ', num2str(fg.voltage))); |
|
|
|
end |
|
|
|
|
|
|
|
function fg = set.unit(fg,u) |
|
|
|
fg.unit = FunctionGenerator.getUnit(u); |
|
|
|
fg.write(strcat('VOLTage:UNIT ', fg.unit)); |
|
|
|
end |
|
|
|
|
|
|
|
function fg = set.offset(fg,o) |
|
|
|
fg.offset = Equipment.forceNum(o); |
|
|
|
fg.write(strcat('VOLTage:OFFSet ', num2str(fg.offset))); |
|
|
|
end |
|
|
|
|
|
|
|
function fg = set.load(fg,l) |
|
|
|
fg.load = FunctionGenerator.getLoad(l); |
|
|
|
fg.write(strcat('OUTPut:LOAD ', fg.load)); |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
methods (Static) |
|
|
|
function wf = getWave(inwf) |
|
|
|
wf = regexp(inwf, '(?i)(si|sq|[trndu1-7]|s)', 'match', 'once'); |
|
|
|
function w = getWave(win) |
|
|
|
w = regexp(num2str(win), '(si|sq|mi|ma[trndu1-7]|s)', 'match', 'once', 'ignorecase'); |
|
|
|
|
|
|
|
if isempty(w) |
|
|
|
error(strcat('Invalid waveform: ', win)); |
|
|
|
end |
|
|
|
|
|
|
|
if isempty(wf) |
|
|
|
error('Invalid waveform.'); |
|
|
|
w = regexprep(w, {'^(1|si|(?-i)s)$', '^(2|sq|(?-i)S)$', '^[3t]$', '^[4r]$', '^[5n]$', '^[6d]$', '^[7u]$', '^mi$', '^ma$'}, ... |
|
|
|
{'sinusoid', 'square', 'triangle', 'ramp', 'noise', 'dc', 'user', 'minimum', 'maximum'}, 'ignorecase'); |
|
|
|
end |
|
|
|
|
|
|
|
function u = getUnit(uin) |
|
|
|
u = regexp(num2str(uin), '([1-4]|vp|vr|db|de)', 'match', 'once', 'ignorecase'); |
|
|
|
|
|
|
|
if isempty(u) |
|
|
|
error(strcat('Invalid voltage unit: ', uin)); |
|
|
|
end |
|
|
|
|
|
|
|
wf = regexprep(wf, {'^(1|si|(?-i)s)$', '^(2|sq|(?-i)S)$', '^[3t]$', '^[4r]$', '^[5n]$', '^[6d]$', '^[7u]$'}, ... |
|
|
|
{'sinusoid', 'square', 'triangle', 'ramp', 'noise', 'dc', 'user'}, 'ignorecase'); |
|
|
|
u = regexprep(u, {'^(1|vp)$', '^(2|vr)$', '^(3|db)$', '^(4|de)$'}, ... |
|
|
|
{'Vpp', 'Vrms', 'dBm', 'default'}, 'ignorecase'); |
|
|
|
end |
|
|
|
|
|
|
|
function l = getLoad(lin) |
|
|
|
l = regexp(num2str(lin), '([12]|50|in|mi|ma)', 'match', 'once', 'ignorecase'); |
|
|
|
|
|
|
|
if isempty(u) |
|
|
|
error(strcat('Invalid load: ', lin)); |
|
|
|
end |
|
|
|
|
|
|
|
u = regexprep(l, {'^(1|50)$', '^(2|in)$', '^mi$', '^ma$'}, ... |
|
|
|
{'50', 'infinity', 'minimum', 'maximum'}, 'ignorecase'); |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|