Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Adaptive Minimization for loop

1 Ansicht (letzte 30 Tage)
Steven
Steven am 17 Nov. 2016
Geschlossen: MATLAB Answer Bot am 20 Aug. 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

Antworten (0)

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by