Hi All, I was trying to tune my PID controller following this article. http://wiki.scilab.org/Xcos/Examples/PID
I have setup my environment like this, <http://mailinglists.scilab.org/file/n4030508/BikeModelWith_PID.gif> <http://mailinglists.scilab.org/file/n4030508/BikeContextParameters.gif> And up to the first simulation, the process went well. <http://mailinglists.scilab.org/file/n4030508/Bike-SimulationOK.gif> I got a warning for the CMSCOPE but I guess it has nothing to do with this problem. *CMSCOPE('set'): Wrong size for block parameter 'Refresh period': 2 expected, getting 30 30 30 30 * But when I tried to start the optimization, I got this error. *-->[f_opt, x_opt] = optim(my_optim_pid,'b',Lower,Upper,x0,algo='qn','ar',MaxEvalFunc,MaxEvalFunc,1e-3,1e-3,[1e-3;1e-3]); CMSCOPE('set'): Wrong size for block parameter 'Refresh period': 2 expecte d, getting 30 30 30 30 !--error 21 Invalid index. at line 12 of function f_pid called by : at line 2 of function my_optim_pid called by : unc,MaxEvalFunc,1e-3,1e-3,[1e-3;1e-3])* My f_pid function goes like this. *function y = f_pid(x) global Iter; %scicos_context.l = l %scicos_context.g = g %scicos_context.v = v %scicos_context.phi = phi %scicos_context.w = w %scicos_context.P = x(1)*Pfact; %scicos_context.I = x(2)*Ifact; Iter = Iter + 1; Info = scicos_simulate(scs_m,list(),%scicos_context,flag='nw'); y_error = mean(abs((block_output('values')(:,1) - block_output('values')(:,2)))); y_diff = mean(abs(diff(block_output('values')(:,2)))); y = 0.5*y_error + 0.5*1*y_diff; ... printf('Evaluation %d - P = %f I = %f y = %f (y_error = %f, y_diff = %f)\n',Iter,x(1),x(2),y,y_error,y_diff); endfunction* I guess the problem lies in the block_output variable. When I tried to see the content of the block_output('values')(:,2) I got the same error. *-->block_output('values')(:,2) !--error 21 Invalid index.* I guess in my system the block_output is not in the same dimensions as that of the example shown in the article. How can I fix this issue. Anyone please shed some light on this issue ? and how can I add the D gain in to the optimization ? any help is highly appreciated. Thanks BR Gona -- View this message in context: http://mailinglists.scilab.org/PID-tuning-with-Optimization-tp4030508.html Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com. _______________________________________________ users mailing list [email protected] http://lists.scilab.org/mailman/listinfo/users
