Commit 8e36cff3 authored by michael.kohnen's avatar michael.kohnen

Merge branch 'master' of https://git.rwth-aachen.de/ita/toolbox

parents dec646f0 5e2d2cd3
...@@ -106,7 +106,7 @@ ear_d = [-0.07 0.07]; ...@@ -106,7 +106,7 @@ ear_d = [-0.07 0.07];
W = sparse(diag(w)); % diagonal matrix containing weights W = sparse(diag(w)); % diagonal matrix containing weights
D = sparse(diag(dweights_rep)); % decomposition order-dependent Tikhonov regularization D = sparse(diag(dweights_rep)); % decomposition order-dependent Tikhonov regularization
Y = ita_sph_base(this.dirCoord,Nmax,'orthonormal',false); % calculate real-valued SHs using the measurement grid Y = ita_sph_base(this.dirCoord,Nmax,'real'); % calculate real-valued SHs using the measurement grid
%% Calculate HRTF data for field points %% Calculate HRTF data for field points
if Nmax > 25 if Nmax > 25
...@@ -131,7 +131,7 @@ for ear=1:2 ...@@ -131,7 +131,7 @@ for ear=1:2
% % calculate weighted SH coefficients using a decomposition order-dependent Tikhonov regularization % % calculate weighted SH coefficients using a decomposition order-dependent Tikhonov regularization
% %
% freqData_temp = data.freqData; % freqData_temp = data.freqData;
% Y = ita_sph_base(data.channelCoordinates,Nmax,'orthonormal',false); % Y = ita_sph_base(data.channelCoordinates,Nmax,'real');
a0 = (Y.'*W*Y + epsilon*D) \ Y.'*W * freqData_temp.'; a0 = (Y.'*W*Y + epsilon*D) \ Y.'*W * freqData_temp.';
%a0 = (Y.'*W*Y + epsilon*D) \ Y.' * %a0 = (Y.'*W*Y + epsilon*D) \ Y.' *
...@@ -142,10 +142,10 @@ for ear=1:2 ...@@ -142,10 +142,10 @@ for ear=1:2
% calculate range-extrapolated HRTFs % calculate range-extrapolated HRTFs
a1 = a0 .* hankel_rep.'; a1 = a0 .* hankel_rep.';
Yest = ita_sph_base(field,N,'orthonormal',false); % use real-valued SH's Yest = ita_sph_base(field,N,'real'); % use real-valued SH's
hrtf_arbi(:,ear:2:end) = (Yest*a1).'; % interpolated + range-extrapolated HRTFs hrtf_arbi(:,ear:2:end) = (Yest*a1).'; % interpolated + range-extrapolated HRTFs
else else
Yest = ita_sph_base(field,Nmax,'orthonormal',false); % use real-valued SH's Yest = ita_sph_base(field,Nmax,'real'); % use real-valued SH's
hrtf_arbi(:,ear:2:end) = (Yest*a0).'; % interpolated HRTFs hrtf_arbi(:,ear:2:end) = (Yest*a0).'; % interpolated HRTFs
end end
end end
......
...@@ -1110,7 +1110,7 @@ classdef itaHRTF < itaAudio ...@@ -1110,7 +1110,7 @@ classdef itaHRTF < itaAudio
W = diag(vWeights); % diagonal matrix containing weights W = diag(vWeights); % diagonal matrix containing weights
D = diag(regweights_rep); % decomposition order-dependent Tikhonov regularization D = diag(regweights_rep); % decomposition order-dependent Tikhonov regularization
Y = ita_sph_base(this.dirCoord,Nmeas,'orthonormal',false); % calculate real-valued SHs using the measurement grid (high SH-order) Y = ita_sph_base(this.dirCoord,Nmeas,'real'); % calculate real-valued SHs using the measurement grid (high SH-order)
%% Calculate spatially smoothed HRTF data set %% Calculate spatially smoothed HRTF data set
hrtf_smoo_wo_ITD = zeros(this.nBins,2*this.dirCoord.nPoints); % init.: columns: LRLRLR... hrtf_smoo_wo_ITD = zeros(this.nBins,2*this.dirCoord.nPoints); % init.: columns: LRLRLR...
...@@ -1302,11 +1302,11 @@ classdef itaHRTF < itaAudio ...@@ -1302,11 +1302,11 @@ classdef itaHRTF < itaAudio
earSidePlot = sArgs.earSide; earSidePlot = sArgs.earSide;
if numel(phiC_deg)>1, if numel(phiC_deg)>1,
xData = phiC_deg; xData = phiC_deg;
strTitle =[ earSidePlot ' ear, \theta = ' num2str(round(thetaC_deg)) '']; strTitle =[ earSidePlot ' ear, \theta = ' num2str(round(thetaC_deg)) ''];
strXlabel = '\phi in Degree'; strXlabel = '\phi in Degree';
else else
xData = thetaC_deg; xData = thetaC_deg;
strTitle =[earSidePlot ' ear, \phi = ' num2str(round(phiC_deg)) '']; strTitle =[earSidePlot ' ear, \phi = ' num2str(round(phiC_deg)) ''];
strXlabel = '\theta in Degree'; strXlabel = '\theta in Degree';
end end
...@@ -1394,11 +1394,11 @@ classdef itaHRTF < itaAudio ...@@ -1394,11 +1394,11 @@ classdef itaHRTF < itaAudio
earSidePlot = sArgs.earSide; earSidePlot = sArgs.earSide;
if numel(phiC_deg)>1, if numel(phiC_deg)>1,
xData = phiC_deg; xData = phiC_deg;
strTitle =[ earSidePlot ' ear, \theta = ' num2str(round(thetaC_deg)) '']; strTitle =[ earSidePlot ' ear, \theta = ' num2str(round(thetaC_deg)) ''];
strXlabel = '\phi in Degree'; strXlabel = '\phi in Degree';
else else
xData = thetaC_deg; xData = thetaC_deg;
strTitle =[earSidePlot ' ear, \phi = ' num2str(round(phiC_deg)) '']; strTitle =[earSidePlot ' ear, \phi = ' num2str(round(phiC_deg)) ''];
strXlabel = '\theta in Degree'; strXlabel = '\theta in Degree';
end end
......
...@@ -6,7 +6,7 @@ function [ data, samplerate, metadata ] = dfitaHRIRDAFFDataFunc( alpha, beta, it ...@@ -6,7 +6,7 @@ function [ data, samplerate, metadata ] = dfitaHRIRDAFFDataFunc( alpha, beta, it
% DAFF requires data alignment by multiple of 4 % DAFF requires data alignment by multiple of 4
nResidual = mod( hrtf.nSamples, 4 ); nResidual = mod( hrtf.nSamples, 4 );
data = [ hrtf.timeData', zeros( hrtf.nChannels, 4 - nResidual ) ]; data = [ hrtf.timeData', zeros( hrtf.nChannels, mod(4 - nResidual,4) ) ];
metadata = []; metadata = [];
end end
...@@ -44,26 +44,33 @@ end ...@@ -44,26 +44,33 @@ end
theta_start_deg = rad2deg( min( this.channelCoordinates.theta ) ); theta_start_deg = rad2deg( min( this.channelCoordinates.theta ) );
theta_end_deg = rad2deg( max( this.channelCoordinates.theta ) ); theta_end_deg = rad2deg( max( this.channelCoordinates.theta ) );
theta_num_elements = size( unique( this.channelCoordinates.theta ), 1 ); theta_num_elements = size( uniquetol( this.channelCoordinates.theta ), 1 );
phi_start_deg = rad2deg( min( mod( this.channelCoordinates.phi, 2*pi ) ) ); phi_start_deg = rad2deg( min( mod( this.channelCoordinates.phi, 2 * pi ) ) );
phi_end_deg = rad2deg( max( mod( this.channelCoordinates.phi, 2*pi ) ) ); phi_end_deg = rad2deg( max( mod( this.channelCoordinates.phi, 2 * pi ) ) );
phi_num_elements = size( unique( this.channelCoordinates.phi ), 1 ); phi_num_elements = size( uniquetol( this.channelCoordinates.phi ), 1 );
assert( phi_num_elements ~= 0 ); assert( phi_num_elements ~= 0 );
alphares = ( phi_end_deg - phi_start_deg ) / phi_num_elements; % phi end does not cover entire circle in this case alphares = ( phi_end_deg - phi_start_deg ) / phi_num_elements; % phi end does not cover entire circle in this case
alphares_full_circle = ( phi_end_deg - phi_start_deg ) / ( phi_num_elements - 1 ); % phi end does not cover entire circle in this case alphares_full_circle = ( phi_end_deg - phi_start_deg ) / ( phi_num_elements - 1 ); % phi end does not cover entire circle in this case
if phi_end_deg + alphares_full_circle >= 360.0 if phi_end_deg + alphares_full_circle >= 360.0
alpharange = [ phi_start_deg ( phi_end_deg + alphares_full_circle ) ]; % Account for full circle alpharange = [ phi_start_deg 360 ]; % Account for full circle and force end of range to 360 deg
alphares = alphares_full_circle; alphares = alphares_full_circle;
else else
alpharange = [ phi_start_deg phi_end_deg ]; alpharange = [ phi_start_deg phi_end_deg ];
end end
assert( alpharange( 1 ) >= 0.0 )
assert( alpharange( 2 ) <= 360.0 )
assert( theta_num_elements ~= 0 ); assert( theta_num_elements ~= 0 );
betares = ( theta_end_deg - theta_start_deg ) / ( theta_num_elements - 1 ); % phi end does not cover entire circle betares = ( theta_end_deg - theta_start_deg ) / ( theta_num_elements - 1 ); % phi end does not cover entire circle
betarange = 180 - [ theta_start_deg theta_end_deg ]; % Flip poles (DAFF starts at south pole) betarange = 180 - [ theta_start_deg theta_end_deg ]; % Flip poles (DAFF starts at south pole)
assert( betarange( 2 ) >= 0.0 )
assert( betarange( 1 ) <= 180.0 )
%% Assemble metadata %% Assemble metadata
metadata = daffv17_add_metadata( metadata, 'Generation script', 'String', 'writeDAFFFile.m' ); metadata = daffv17_add_metadata( metadata, 'Generation script', 'String', 'writeDAFFFile.m' );
......
...@@ -14,6 +14,7 @@ classdef itaHpTF_Audio < itaHpTF ...@@ -14,6 +14,7 @@ classdef itaHpTF_Audio < itaHpTF
% Audio Engineering Society Convention 130, May 2011) % Audio Engineering Society Convention 130, May 2011)
% normalized (Normalization of HpTF) % normalized (Normalization of HpTF)
% smoothing (Smoothing bandwidth has to be defined in fractions of octaves, see also ita_smooth) % smoothing (Smoothing bandwidth has to be defined in fractions of octaves, see also ita_smooth)
% mic (measured microphone transfer funcions - not inverted: length does not matter; will be adapted)
% %
% itaHpTF_Audio Methods (private): % itaHpTF_Audio Methods (private):
% HP_equalization If this.mic is not set, it will be unused % HP_equalization If this.mic is not set, it will be unused
...@@ -30,7 +31,9 @@ classdef itaHpTF_Audio < itaHpTF ...@@ -30,7 +31,9 @@ classdef itaHpTF_Audio < itaHpTF
m_fUpper = 18000; m_fUpper = 18000;
mMethod = 'mSTD'; mMethod = 'mSTD';
mNormalized = true; mNormalized = true;
mGainComp = true;
mSmoothing = 1/6; mSmoothing = 1/6;
mSelectMeas = 1:8; % select the channels which should be used for the HpTF
end end
properties(Dependent = true, Hidden = false) properties(Dependent = true, Hidden = false)
...@@ -38,8 +41,10 @@ classdef itaHpTF_Audio < itaHpTF ...@@ -38,8 +41,10 @@ classdef itaHpTF_Audio < itaHpTF
fLower = 100; fLower = 100;
fUpper = 18000; fUpper = 18000;
method = 'mSTD'; method = 'mSTD';
normalized = true; normalized = true; % normalization of the signal
gainComp = true; % microphone compensation
smoothing = 1/6; smoothing = 1/6;
selectMeas = 1:8; % select specific measurements
end end
properties (Dependent = true, SetAccess = private) properties (Dependent = true, SetAccess = private)
...@@ -122,6 +127,13 @@ classdef itaHpTF_Audio < itaHpTF ...@@ -122,6 +127,13 @@ classdef itaHpTF_Audio < itaHpTF
function normalized = get.normalized(this) function normalized = get.normalized(this)
normalized = this.mNormalized; end normalized = this.mNormalized; end
function comp = get.gainComp(this)
comp = this.mGainComp; end
function sel = get.selectMeas(this)
sel = this.mSelectMeas; end
function smoothing = get.smoothing(this) function smoothing = get.smoothing(this)
smoothing = this.mSmoothing; end smoothing = this.mSmoothing; end
%% ................................................................ %% ................................................................
...@@ -151,6 +163,16 @@ classdef itaHpTF_Audio < itaHpTF ...@@ -151,6 +163,16 @@ classdef itaHpTF_Audio < itaHpTF
this = HP_equalization(this); this = HP_equalization(this);
end end
function this = set.selectMeas(this,ch)
this.mSelectMeas = ch;
this = HP_equalization(this);
end
function this = set.gainComp(this,comp)
this.mGainComp = comp;
this = HP_equalization(this);
end
function this = set.smoothing(this,smoothing) function this = set.smoothing(this,smoothing)
this.mSmoothing = smoothing; this.mSmoothing = smoothing;
this = HP_equalization(this); this = HP_equalization(this);
...@@ -167,6 +189,7 @@ classdef itaHpTF_Audio < itaHpTF ...@@ -167,6 +189,7 @@ classdef itaHpTF_Audio < itaHpTF
this.nameSubj = var.nameSubj; this.nameSubj = var.nameSubj;
this.repeat = var.repeat; this.repeat = var.repeat;
this.mTF.time = var.time; this.mTF.time = var.time;
this.selectMeas = 1:var.repeat;
this = HP_equalization(this); this = HP_equalization(this);
end end
...@@ -175,11 +198,8 @@ classdef itaHpTF_Audio < itaHpTF ...@@ -175,11 +198,8 @@ classdef itaHpTF_Audio < itaHpTF
% Audio Engineering Society Convention 130, May 2011 % Audio Engineering Society Convention 130, May 2011
tWin = this.TF.trackLength; % crop HPTF tWin = this.TF.trackLength; % crop HPTF
if this.mic.dimensions == 2 % mic min phase + extension measSel = sort([2*this.selectMeas-1 2*this.selectMeas]);
minMic = ita_minimumphase(this.mic); TF = this.TF.ch(measSel);
[mic, TF] = ita_extend_dat(minMic,this.TF);
else TF = this.TF;
end
%init %init
thisEQ = this; thisEQ = this;
...@@ -200,14 +220,19 @@ classdef itaHpTF_Audio < itaHpTF ...@@ -200,14 +220,19 @@ classdef itaHpTF_Audio < itaHpTF
otherwise otherwise
error('Unknown type'); error('Unknown type');
end end
if this.mic.dimensions == 2
Rec = ita_multiply_spk(Rec,mic); if this.mic.dimensions == 2 % Compensation of mic
minMic = ita_minimumphase(this.mic);
RecM = ita_convolve(Rec,minMic.ch(cdx));
RecM.fftDegree = TF.fftDegree;
else
RecM = Rec;
end end
%% Short Filter with no correction for low freqs and minimun phase %% Short Filter with no correction for low freqs and minimum phase
aux = max(abs(Rec.freqData),[],2); aux = max(abs(RecM.freqData),[],2);
% find first maximum and truncate low freq correction at this point % find first maximum and truncate low freq correction at this point
idxDF = Rec.freq2index([this.fLower this.fLower*1.5 ]); idxDF = RecM.freq2index([this.fLower this.fLower*1.5 ]);
d_aux = diff(aux(idxDF(1):idxDF(2))); d_aux = diff(aux(idxDF(1):idxDF(2)));
idx = find(diff(sign(d_aux)) ~= 0,1,'first'); % Bruno style... idx = find(diff(sign(d_aux)) ~= 0,1,'first'); % Bruno style...
aux(1:idxDF(1)+idx+1) = aux(idxDF(1)+idx+2); aux(1:idxDF(1)+idx+1) = aux(idxDF(1)+idx+2);
...@@ -227,10 +252,18 @@ classdef itaHpTF_Audio < itaHpTF ...@@ -227,10 +252,18 @@ classdef itaHpTF_Audio < itaHpTF
this_min = ita_minimumphase(ita_time_shift(HpTF,tWin/2)); this_min = ita_minimumphase(ita_time_shift(HpTF,tWin/2));
this_win = ita_time_window(this_min,[tWin*0.99,tWin],'time','crop'); this_win = ita_time_window(this_min,[tWin*0.99,tWin],'time','crop');
if this.normalized, if this.gainComp % compensate gains from mics (equalize)
this_norm = ita_normalize_dat(this_win); idxDF = this_win.freq2index(this.fLower);
chGain = 20*log10(abs(this_win.freqData(idxDF,:)));
this_comp = this_win;
this_comp.freqData = bsxfun(@times,this_win.freqData,10.^(-chGain/20));
else, this_comp = this_win;
end
if this.normalized
this_norm = ita_normalize_dat(this_comp);
thisEQ.timeData = this_norm.timeData; thisEQ.timeData = this_norm.timeData;
else thisEQ.timeData = this_win.timeData; else, thisEQ.timeData = this_comp.timeData;
end end
if ~isempty(this.savePath) if ~isempty(this.savePath)
......
...@@ -88,6 +88,7 @@ classdef itaHpTF_MS < itaHpTF ...@@ -88,6 +88,7 @@ classdef itaHpTF_MS < itaHpTF
% Measure Right side % Measure Right side
MS.inputChannels = chIn(2); MS.inputChannels = chIn(2);
MS.outputChannels = chOut(2); MS.outputChannels = chOut(2);
commandwindow
resultR = MS.run; resultR = MS.run;
resultR.channelNames{1} = strR; resultR.channelNames{1} = strR;
...@@ -108,7 +109,7 @@ classdef itaHpTF_MS < itaHpTF ...@@ -108,7 +109,7 @@ classdef itaHpTF_MS < itaHpTF
disp(['Measurement ',num2str(idxM),'/',num2str(this.repeat),' finished.']) disp(['Measurement ',num2str(idxM),'/',num2str(this.repeat),' finished.'])
disp('Put headphones off and on again. Press any key to continue.') disp('Put headphones off and on again. Press any key to continue.')
pause pause
pause(2) pause(1)
else else
commandwindow commandwindow
fprintf('\nMEASUREMENT DONE!\n') fprintf('\nMEASUREMENT DONE!\n')
...@@ -118,6 +119,7 @@ classdef itaHpTF_MS < itaHpTF ...@@ -118,6 +119,7 @@ classdef itaHpTF_MS < itaHpTF
MS.inputChannels = chIn; MS.inputChannels = chIn;
HpTF = itaHpTF_Audio(this); HpTF = itaHpTF_Audio(this);
HpTF.selectMeas = 1:this.repeat;
assignin('base', ['HpTF_' this.nameSubj], HpTF) assignin('base', ['HpTF_' this.nameSubj], HpTF)
end end
......
...@@ -40,7 +40,8 @@ ignoreList = {'.svn', ... ...@@ -40,7 +40,8 @@ ignoreList = {'.svn', ...
'doc', ... 'doc', ...
'GuiCallbacks', ... 'GuiCallbacks', ...
'external_packages', ... 'external_packages', ...
'ExternalPackages'}; 'ExternalPackages', ...
'helpers'};
pathStr = genpath(sArgs.rootpath); pathStr = genpath(sArgs.rootpath);
prefixToolbox = fliplr(strtok(fliplr(sArgs.rootpath),filesep)); %get Toolbox folder name prefixToolbox = fliplr(strtok(fliplr(sArgs.rootpath),filesep)); %get Toolbox folder name
......
...@@ -142,7 +142,7 @@ classdef itaMotorControlNanotec < itaMotorControl ...@@ -142,7 +142,7 @@ classdef itaMotorControlNanotec < itaMotorControl
% parse the notfound options for wait % parse the notfound options for wait
[controlOptions, notFound] = ita_parse_arguments(controlOptions,notFound); [controlOptions, notFound] = ita_parse_arguments(controlOptions,notFound);
this.wait = controlOptions.wait;
for index = 1:length(this.motorList) for index = 1:length(this.motorList)
motorposition = sArgs.(this.motorList{index}.getMotorName()); motorposition = sArgs.(this.motorList{index}.getMotorName());
this.started(index) = this.motorList{index}.prepareMove(motorposition,notFound{:}); this.started(index) = this.motorList{index}.prepareMove(motorposition,notFound{:});
...@@ -222,6 +222,15 @@ classdef itaMotorControlNanotec < itaMotorControl ...@@ -222,6 +222,15 @@ classdef itaMotorControlNanotec < itaMotorControl
ita_verbose_info('Finished preparing',2) ita_verbose_info('Finished preparing',2)
end end
function startMove(this)
for index = 1:length(this.motorList)
if this.started(index)
this.motorList{index}.startMoveToPosition();
end
end
this.wait4everything;
end
function startContinuousMoveNow(this) function startContinuousMoveNow(this)
% start moves % start moves
for index = 1:length(this.motorList) for index = 1:length(this.motorList)
...@@ -235,6 +244,7 @@ classdef itaMotorControlNanotec < itaMotorControl ...@@ -235,6 +244,7 @@ classdef itaMotorControlNanotec < itaMotorControl
this.mIsInitialized = false; this.mIsInitialized = false;
error(sprintf('Motor %s is not responding!',this.motorList{index}.getMotorName)); error(sprintf('Motor %s is not responding!',this.motorList{index}.getMotorName));
end end
this.wait4everything
this.preparedList = []; this.preparedList = [];
end end
...@@ -447,7 +457,7 @@ classdef itaMotorControlNanotec < itaMotorControl ...@@ -447,7 +457,7 @@ classdef itaMotorControlNanotec < itaMotorControl
else else
ita_verbose_info('Position NOT reached! - Check for errors!', 0); ita_verbose_info('Position NOT reached! - Check for errors!', 0);
this.send_commandlist(this.failed_command_repititions); % mpo: bugfix: send_commandlist needs argument this.send_commandlist(this.failed_command_repititions); % mpo: bugfix: send_commandlist needs argument
this.isReferenced = false; % this.isReferenced = false;
end end
this.clear_receivedlist; this.clear_receivedlist;
this.started(1:length(this.motorIDList)) = false; this.started(1:length(this.motorIDList)) = false;
......
...@@ -14,6 +14,7 @@ classdef itaMotorNanotec_HRTFarc < itaMotorNanotec ...@@ -14,6 +14,7 @@ classdef itaMotorNanotec_HRTFarc < itaMotorNanotec
end end
properties(Constant, Hidden = true) properties(Constant, Hidden = true)
sArgs_default_motor = struct( ... sArgs_default_motor = struct( ...
'wait', true, ... 'wait', true, ...
'speed', 2, ... 'speed', 2, ...
...@@ -22,10 +23,16 @@ classdef itaMotorNanotec_HRTFarc < itaMotorNanotec ...@@ -22,10 +23,16 @@ classdef itaMotorNanotec_HRTFarc < itaMotorNanotec
'continuous', false, ... 'continuous', false, ...
'absolut', true, ... 'absolut', true, ...
'closed_loop', false, ... 'closed_loop', false, ...
'acceleration_ramp', 1, ... 'acceleration_ramp',1, ...
'gear_ratio', 5, ... 'gear_ratio', 5, ...
'current', 100, ... 'current', 100, ...
'ramp_mode', 2 ); 'ramp_mode', 2, ...
'P', 400, ...
'I', 2.0, ...
'D', 700, ...
'P_nenner', 3, ...
'I_nenner', 5,...
'D_nenner', 3);
end end
methods methods
...@@ -87,11 +94,11 @@ classdef itaMotorNanotec_HRTFarc < itaMotorNanotec ...@@ -87,11 +94,11 @@ classdef itaMotorNanotec_HRTFarc < itaMotorNanotec
% phasenstrom im stillstand % phasenstrom im stillstand
motorControl.add_to_commandlist(sprintf('#%dr=0\r' , this.motorID)); motorControl.add_to_commandlist(sprintf('#%dr=0\r' , this.motorID));
% fehlerkorrekturmodus % fehlerkorrekturmodus
motorControl.add_to_commandlist(sprintf('#%dU=1\r' , this.motorID)); motorControl.add_to_commandlist(sprintf('#%dU=0\r' , this.motorID));
% ausschwingzeit % ausschwingzeit
motorControl.add_to_commandlist(sprintf('#%dO=1\r' , this.motorID)); motorControl.add_to_commandlist(sprintf('#%dO=1\r' , this.motorID));
% umkehrspiel % umkehrspiel
motorControl.add_to_commandlist(sprintf('#%dz=0\r' , this.motorID)); motorControl.add_to_commandlist(sprintf('#%dz=5\r' , this.motorID));
% automatisches senden des status deaktivieren % automatisches senden des status deaktivieren
motorControl.add_to_commandlist(sprintf('#%dJ=0\r' , this.motorID)); motorControl.add_to_commandlist(sprintf('#%dJ=0\r' , this.motorID));
...@@ -125,7 +132,7 @@ classdef itaMotorNanotec_HRTFarc < itaMotorNanotec ...@@ -125,7 +132,7 @@ classdef itaMotorNanotec_HRTFarc < itaMotorNanotec
motorControl.add_to_commandlist(sprintf('#%dd=1\r' , this.motorID)); motorControl.add_to_commandlist(sprintf('#%dd=1\r' , this.motorID));
% Calculate and set lower speed: % Calculate and set lower speed:
% stepspersecond = round(this.sArgs_default_motor.speed/0.9*this.sArgs_default_motor.gear_ratio); % stepspersecond = round(this.sArgs_default_motor.speed/0.9*this.sArgs_default_motor.gear_ratio);
motorControl.add_to_commandlist(sprintf('#%du=%d\r' , this.motorID, 3)); motorControl.add_to_commandlist(sprintf('#%du=%d\r' , this.motorID, 1));
% Calculate and set upper speed: % Calculate and set upper speed:
stepspersecond = round(this.sArgs_default_motor.speed/0.9*this.sArgs_default_motor.gear_ratio); stepspersecond = round(this.sArgs_default_motor.speed/0.9*this.sArgs_default_motor.gear_ratio);
motorControl.add_to_commandlist(sprintf('#%do=%d\r' , this.motorID, stepspersecond)); motorControl.add_to_commandlist(sprintf('#%do=%d\r' , this.motorID, stepspersecond));
...@@ -149,7 +156,7 @@ classdef itaMotorNanotec_HRTFarc < itaMotorNanotec ...@@ -149,7 +156,7 @@ classdef itaMotorNanotec_HRTFarc < itaMotorNanotec
sArgs = ita_parse_arguments(sArgs,varargin); sArgs = ita_parse_arguments(sArgs,varargin);
end end
if sArgs.continuous if sArgs.continuous
ret = this.prepare_move(position, 'speed', sArgs.speed,'continuous', true); ret = this.prepare_move(position, sArgs);
started = true; started = true;
else else
% if only the phi angle is given % if only the phi angle is given
...@@ -300,19 +307,25 @@ classdef itaMotorNanotec_HRTFarc < itaMotorNanotec ...@@ -300,19 +307,25 @@ classdef itaMotorNanotec_HRTFarc < itaMotorNanotec
% Activate CL during movement: % Activate CL during movement:
motorControl.add_to_commandlist(sprintf('#%d:CL_enable=2\r' , this.motorID)); motorControl.add_to_commandlist(sprintf('#%d:CL_enable=2\r' , this.motorID));
% Nice values for the speed closed loop control: % Nice values for the speed closed loop control:
pos = [0.5 1 2 3 4 8 12 16 25 32 40 50]; % pos = [0.5 1 2 3 4 8 12 16 25 32 40 50];
vecP = [0.5 1.5 2.5 3.5 4.5 4.5 5.5 2.5 2.0 1.3 1.3 1.3]; % vecP = [0.5 1.5 2.5 3.5 4.5 4.5 5.5 2.5 2.0 1.3 1.3 1.3];
vecI = [0.05 0.1 0.2 0.3 0.4 0.8 1.2 1.6 2.0 2.5 2.5 2.5]; % vecI = [0.05 0.1 0.2 0.3 0.4 0.8 1.2 1.6 2.0 2.5 2.5 2.5];
vecD = [9 6 4 3 2 1 1 3 6 10 10 10]; % vecD = [9 6 4 3 2 1 1 3 6 10 10 10];
pP = polyfit(pos,vecP,5); % pP = polyfit(pos,vecP,5);
pI = polyfit(pos,vecI,5); % pI = polyfit(pos,vecI,5);
pD = polyfit(pos,vecD,5); % pD = polyfit(pos,vecD,5);
P = polyval(pP,this.sArgs_motor.speed); % P = polyval(pP,this.sArgs_motor.speed);
I = polyval(pI,this.sArgs_motor.speed);