Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Adaptive Minimization for loop

2 vues (au cours des 30 derniers jours)
Steven
Steven le 17 Nov 2016
Clôturé : MATLAB Answer Bot le 20 Août 2021
I have a DAC that I'm calibrating by measuring the values. I use a simple search to find the minimum between a voltage I desire and the measured voltage of the DAC. (don't worry, I know how to calibrate DAC's with a polynomial but I can't do that in this case.) Instead of using a stepped search where I change the values I would like to use an adaptive approach to make the algorithm faster.
I am using hardware in the loop. How can I use an adaptive algorithm to make the minimization faster?
findvalue = 0.5;%desired voltage
flagreached = 1;%flag if done finding voltage
count = 1;
while flagreached
voltage(count) = voltagefromADC();%Measure voltage
if count > 6 %wait 6 measurements before averaging
meanv = mean(voltage(count-5:count));
if meanv< findvalue - 0.5
compdacV = compdacV + 100;
elseif meanv< findvalue - 0.05
compdacV = compdacV + 10;
elseif meanv< findvalue -0.005
compdacV = compdacV + 1;
elseif meanv <= findvalue
%found value
flagreached = 0;
end
end
changeDAC(compdacV);%Set the DAC
compdacVvec(count) = compdacV;
count = count +1;
end

Réponses (0)

Cette question est clôturée.

Tags

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by