This commit is contained in:
2018-10-08 17:30:26 +02:00
parent be82fa20e0
commit 5543582557
6 changed files with 136 additions and 126 deletions

39
matlab/simFxFyStage.m Normal file
View File

@@ -0,0 +1,39 @@
function out=simFxFyStage()
global Kp Kvfb Ki Kvff Kaff MaxInt
global m1 m2 mot_num mot_den Ts MaxDac MaxPosErr
global A B C D
function ServoDeltaTau_z(motid)
Ts=2E-4; % 0.2ms=5kHz
MaxDac=2011.968;
MaxPosErr=10000;
if motid==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')
Kp=25;Kvfb=400;Ki=0.02;Kvff=350;Kaff=5000;MaxInt=1000;
mot_num=m1.tf_mdl.Numerator;
mot_den=m1.tf_mdl.Denominator;
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')
Kp=22;Kvfb=350;Ki=0.02;Kvff=240;Kaff=1500;MaxInt=1000;
mot_num=m2.tf_mdl.Numerator;
mot_den=m2.tf_mdl.Denominator;
end
end
mdlName='stage_closed_loop';
open(mdlName)
ServoDeltaTau_z(2)
[A,B,C,D]=tf2ss(mot_num,mot_den);
%mdlWks=get_param(mdlName,'ModelWorkspace')
%whos global
%whos(mdlWks)
%assignin(mdlWks,'Ts',1234)
%getVariable(mdlWks,'Ts')
% in global space call:
%global Kp Kvfb Ki Kvff Kaff MaxInt
%global m1 m2 mot_num mot_den Ts MaxDac MaxPosErr
%[m1,m2]=identifyFxFyStage();
%
end