81 lines
3.4 KiB
Matlab
81 lines
3.4 KiB
Matlab
function [pb]=DeltaTauParam(mot,mdl,param)
|
|
% !!! first it need to run: [mot1,mot2]=identifyFxFyStage() tobuild a motor object !!!
|
|
%
|
|
%loads the current (11.10.2018) controller settings of the
|
|
%Powerbrick and opens its simulink file
|
|
%the returned variable pb contains varous parameters:
|
|
% Kp,Kvfb,Ki,Kvff,Kaff,MaxInt,mot_num,mot_den,Ts,MaxDac,MaxPosErr,A,B,C,D
|
|
|
|
pb=struct(...
|
|
'Ts', 2E-4, ... % 0.2ms=5kHz
|
|
'MaxDac' ,2011.968, ...
|
|
'MaxPosErr', 10000);
|
|
desc=sprintf('mot:%d mdl:',mot.id);
|
|
switch mdl
|
|
case 1
|
|
pb.ss_plt=mot.ss_plt;desc=desc+"plt"; pb.sel={3,[3]};
|
|
case 2
|
|
pb.ss_plt=mot.ss_plt0;desc=desc+"plt0"; pb.sel={3,[3]};
|
|
case 3
|
|
pb.ss_plt=mot.ss_c1;desc=desc+"c1"; pb.sel={3,[3]};
|
|
case 4
|
|
pb.ss_plt=mot.ss_d1;desc=desc+"d1"; pb.sel={3,[3]};
|
|
case 5
|
|
pb.ss_plt=mot.ss_1;desc=desc+"1"; pb.sel={2,[2]};
|
|
case 6
|
|
pb.ss_plt=mot.ss_p;desc=desc+"p"; pb.sel={2,[2]};
|
|
case 7
|
|
pb.ss_plt=mot.ss_q;desc=desc+"q"; pb.sel={2,[2]};
|
|
case 8
|
|
pb.ss_plt=mot.ss_cq;desc=desc+"cq"; pb.sel={3,[3]};
|
|
case 9
|
|
pb.ss_plt=mot.ss_cqr;desc=desc+"cqr"; pb.sel={3,[3]};
|
|
end
|
|
pb.A=[1];pb.B=[1];pb.C=[1];pb.D=[1];pb.E=[1];pb.F=[1];
|
|
|
|
desc=desc+" param:";
|
|
if mot.id==1
|
|
%!motor_servo(mot=1,ctrl='ServoCtrl',Kp=25,Kvfb=400,Ki=0.02,Kvff=350,Kaff=5000,MaxInt=1000)
|
|
%!motor(mot=1,dirCur=0,contCur=800,peakCur=2400,timeAtPeak=1,IiGain=5,IpfGain=8,IpbGain=8,JogSpeed=10.,numPhase=3,invDir=True,servo=None,PhasePosSf=1./81250,PhaseFindingDac=100,PhaseFindingTime=50,SlipGain=0,AdvGain=0,PwmSf=10000,FatalFeLimit=200,WarnFeLimit=100,InPosBand=2,homing='enc-index')
|
|
switch param
|
|
case 0 %scratch
|
|
desc=desc+"scratch";
|
|
case 1 %origin parameters
|
|
desc=desc+"orig";
|
|
pb.Kp=25;pb.Kvfb=400;pb.Ki=0.02;pb.Kvff=350;pb.Kaff=5000;pb.MaxInt=1000;
|
|
case 2%enhances first step
|
|
desc=desc+"2";
|
|
pb.Kp=25;pb.Kvfb=350;pb.Ki=0.02;pb.Kvff=350;pb.Kaff=1/(1.548e04*(pb.Ts^2));pb.MaxInt=1000;
|
|
end
|
|
%pb.Kp=0.1;pb.Kvfb=0;pb.Ki=0.00;pb.Kvff=0;pb.Kaff=1/(1.548e04*(pb.Ts^2));pb.MaxInt=1000;
|
|
%filter [z^0 z^-1 ... z^-n];
|
|
%19.8Hz 0dB K=(19.8*2*np.pi)**2=15477.1 Ts=5kHz=.2ms
|
|
%Kaff = 1/(Ts*Ts*K) = 1/((19.8*2*np.pi)**2/5000**2) = 1615.2877200403302
|
|
%Kfff=100
|
|
else
|
|
%!motor_servo(mot=2,ctrl='ServoCtrl',Kp=22,Kvfb=350,Ki=0.02,Kvff=240,Kaff=1500,MaxInt=1000)
|
|
%!motor(mot=2,dirCur=0,contCur=800,peakCur=2400,timeAtPeak=1,IiGain=5,IpfGain=8,IpbGain=8,JogSpeed=10.,numPhase=3,invDir=True,servo=None,PhasePosSf=1./81250,PhaseFindingDac=100,PhaseFindingTime=50,SlipGain=0,AdvGain=0,PwmSf=10000,FatalFeLimit=200,WarnFeLimit=100,InPosBand=2,homing='enc-index')
|
|
switch param
|
|
case 0 %scratch
|
|
desc=desc+"scratch";
|
|
pb.Kp=22;pb.Kvfb=450;pb.Ki=0.02;pb.Kvff=450;pb.Kaff=4517;pb.MaxInt=1000;
|
|
case 1 %origin parameters
|
|
desc=desc+"orig";
|
|
pb.Kp=22;pb.Kvfb=350;pb.Ki=0.02;pb.Kvff=240;pb.Kaff=1500;pb.MaxInt=1000;
|
|
case 2%enhances first step
|
|
desc=desc+"2";
|
|
pb.Kp=22;pb.Kvfb=450;pb.Ki=0.02;pb.Kvff=450;pb.Kaff=4517;pb.MaxInt=1000;
|
|
%pb.Kp=22;pb.Kvfb=350;pb.Ki=0.02;pb.Kvff=240;pb.Kaff=3500;pb.MaxInt=1000;
|
|
end
|
|
%11.84Hz 0dB K=(11.84*2*np.pi)**2=5534.3 Ts=5kHz=.2ms
|
|
%Kaff = 1/(Ts*Ts*K) = 1/((11.84*2*np.pi)**2/5000**2) = 4517.278506241803
|
|
%Kfff=100
|
|
%pb.MaxInt=200 %200mA should be enought to fix static errors
|
|
|
|
end
|
|
pb.desc=desc;
|
|
%mdlName='stage_closed_loop';
|
|
%open(mdlName)
|
|
%sim(mdlName)
|
|
end
|