Borrar filtros
Borrar filtros

use of timer for simulating voltage regulator

1 visualización (últimos 30 días)
Umberto
Umberto el 27 de Mzo. de 2013
Respondida: Sabin el 22 de En. de 2024
Hello everybody! I need to simulate a voltage regulator: in this system voltage has to be regulated if it's out of tolerance for more than 30 seconds. If voltage returns to the correct range the timer has to be stopped. I wrote this code
function simulation
% parameters
Vnom = 3850;
s = 0.01;
delay = 30;
g = 50;
n = 1000;
Vmin = Vnom*(1-s);
Vmax = Vnom*(1+s);
V = xlsread('data.xls', 1, 'C2:C1002'); %import data from Excel
t = timer('Period', delay, 'TimerFcn', calculate(V, g, n, Vmin, Vmax));
function calculate
for i=1:n
if V(i) < Vmin
start(t);
if "30 seconds are passed"
V(i) = V(i)+ g;
end
elseif V(i) > Vmax
start(t);
if "30 seconds are passed"
V(i) = V(i)- g;
end
elseif (V(i) >= Vmin && V(i) <= Vmax)
stop(t);
end
end
xlswrite('data.xls', V, 1, 'E2:E1002');
Problems:
1)Error message ("Too many input arguments") in this line t = timer('Period', delay, 'TimerFcn', calculate(V, g, n, Vmin, Vmax))
2)How can I express in matlab code the fact that "30 seconds are passed"?

Respuestas (1)

Sabin
Sabin el 22 de En. de 2024

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by