Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
toolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Institute of Technical Acoustics (ITA)
toolbox
Commits
ed12db6b
Commit
ed12db6b
authored
7 years ago
by
Markus Mueller-Trapet
Browse files
Options
Downloads
Patches
Plain Diff
add smaller increment to prevent being stuck in loop for abruptly increasing THD
parent
c38b46cc
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
applications/Measurement/LoudspeakerTools/ita_loudspeakertools_maxSPL.m
+11
-10
11 additions, 10 deletions
...easurement/LoudspeakerTools/ita_loudspeakertools_maxSPL.m
with
11 additions
and
10 deletions
applications/Measurement/LoudspeakerTools/ita_loudspeakertools_maxSPL.m
+
11
−
10
View file @
ed12db6b
...
...
@@ -92,7 +92,6 @@ sArgs.distortionLimit = sArgs.distortionLimit / 100;
upperTolVal
=
sArgs
.
distortionLimit
*
(
1
+
sArgs
.
tolerance
);
lowerTolVal
=
sArgs
.
distortionLimit
*
(
1
-
sArgs
.
tolerance
);
%% go through the excitation frequencies, process measurement
ita_verbose_info
(
'Measurement process'
,
1
);
wb
=
itaWaitbar
([
numel
(
excitationFreq
),
numel
(
sArgs
.
distortionLimit
)],
'maxSPL'
,{
'Frequencies'
,
'Limits'
});
...
...
@@ -108,10 +107,15 @@ for freqIdx = 1:numel(excitationFreq)
% distortion limit loop
for
distIdx
=
1
:
numel
(
sArgs
.
distortionLimit
)
currentPowerIncrement
=
sArgs
.
powerIncrement
;
distIter
=
0
;
wb
.
inc
% Amplification and measurement
while
outputVoltage
>=
(
outputVoltageRange
(
1
)/
10
)
&&
outputVoltage
<=
outputVoltageRange
(
2
)
distIter
=
distIter
+
1
;
if
distIter
==
10
% too many iterations going back and forth
currentPowerIncrement
=
sArgs
.
powerIncrement
/
2
;
end
lastSignalReferenceValue
=
eval
([
sArgs
.
signalReference
'(freqIdx,distIdx)'
]);
try
...
...
@@ -133,7 +137,6 @@ for freqIdx = 1:numel(excitationFreq)
% frequency
signalReferenceValue
=
eval
([
sArgs
.
signalReference
'(freqIdx,distIdx)'
]);
% logical values for if conditions
inTol
=
(
signalReferenceValue
>=
lowerTolVal
(
distIdx
))
&
(
signalReferenceValue
<=
upperTolVal
(
distIdx
));
aboveTol
=
signalReferenceValue
>
upperTolVal
(
distIdx
);
...
...
@@ -141,11 +144,11 @@ for freqIdx = 1:numel(excitationFreq)
if
lastSignalReferenceValue
==
0
% this may be the first measurement
gain
=
10
^
(
sArgs
.
p
owerIncrement
/
20
);
gain
=
10
^
(
currentP
owerIncrement
/
20
);
else
% use logarithm to attenuate high gain values
% gain = (log((abs(signalReferenceValue)/lastSignalReferenceValue + exp(1)))) * 10^(
sArgs.p
owerIncrement/20);
gain
=
(
log
((
abs
(
signalReferenceValue
-
sArgs
.
distortionLimit
(
distIdx
))/
signalReferenceValue
+
exp
(
1
)))
)
*
10
^
(
sArgs
.
p
owerIncrement
/
20
);
% gain = (log((abs(signalReferenceValue)/lastSignalReferenceValue + exp(1)))) * 10^(
currentP
owerIncrement/20);
gain
=
log
((
abs
(
signalReferenceValue
-
sArgs
.
distortionLimit
(
distIdx
))/
signalReferenceValue
+
exp
(
1
)))
*
10
^
(
currentP
owerIncrement
/
20
);
end
gainMatrix
(
freqIdx
,
distIdx
)
=
gain
;
...
...
@@ -166,13 +169,12 @@ for freqIdx = 1:numel(excitationFreq)
% went above limit -> decrement and show info
ita_verbose_info
([
num2str
(
sArgs
.
distortionLimit
(
distIdx
)
*
100
)
'% '
sArgs
.
signalReference
' too high, exact value: '
num2str
(
signalReferenceValue
*
100
,
'%0.2f'
)
'%'
],
0
);
% factor to avoid getting stuck
outputVoltage
=
outputVoltage
/
(
0.8
*
gain
);
outputVoltage
=
outputVoltage
/
(
ceil
((
10
^
(
-
currentPowerIncrement
/
20
))/
0.1
)
*
0.1
*
gain
);
elseif
belowTol
% keep increasing
outputVoltage
=
outputVoltage
*
gain
;
ita_verbose_info
([
num2str
(
sArgs
.
distortionLimit
(
distIdx
)
*
100
)
'% '
sArgs
.
signalReference
' not reached, exact value: '
num2str
(
signalReferenceValue
*
100
,
'%0.2f'
)
'%'
],
0
);
end
if
outputVoltage
>
outputVoltageRange
(
2
)
if
~
lastMeasurement
...
...
@@ -194,7 +196,7 @@ for freqIdx = 1:numel(excitationFreq)
max_spl
(
freqIdx
,
distIdx
:
numel
(
sArgs
.
distortionLimit
))
=
abs
(
uSPL
);
% divide by gain as the voltage has been increased
% since the measuremen has been carried out
max_voltage
(
freqIdx
,
distIdx
:
numel
(
sArgs
.
distortionLimit
))
=
outputVoltage
/
gain
;
max_voltage
(
freqIdx
,
distIdx
:
numel
(
sArgs
.
distortionLimit
))
=
outputVoltage
Range
(
2
)
;
lastMeasurement
=
false
;
...
...
@@ -220,7 +222,6 @@ end
wb
.
close
;
%% Post-processing and Results
% Max SPL will be returned as an itaResult
res_maxSPL
=
itaResult
([
max_spl
,
max_voltage
],
excitationFreq
.
','
freq
'
);
res_maxSPL
.
channelUnits
(
1
:
numel
(
sArgs
.
distortionLimit
))
=
{
'Pa'
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment