Files
PBSwissMX/matlab
2018-11-22 16:26:46 +01:00
..
2018-11-22 16:26:46 +01:00
wip
2018-11-19 15:54:16 +01:00
wip
2018-11-19 15:54:16 +01:00
2018-10-11 17:19:48 +02:00
wip
2018-11-19 15:54:16 +01:00
wip
2018-11-19 15:54:16 +01:00
2018-10-10 17:15:36 +02:00
2018-11-13 15:29:20 +01:00
wip
2018-11-19 15:54:16 +01:00
wip
2018-11-19 15:54:16 +01:00
wip
2018-11-19 15:54:16 +01:00
2018-11-13 15:29:20 +01:00

[gfa-lc6-64 ~]
[-bash INSTBASE=/prod]$
cd ~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/matlab
module load matlab/2018a
matlab&
or start directly: /afs/psi.ch/sys/psi.x86_64_slp6/Programming/matlab/2018a/bin/matlab&
this works also on my linux computers

Files overview

identifyFxFyStage.m:       read python data and build motor objects. plot bode
simFxFyStage.m:            build a pb structure which contains current Okt 2018) Powerbrick controller settings
StateSpaceControlDesign.m: design a discrete observer for Fx,Fy stages

important calls

clear;
clear global;
close all;
[mot1,mot2]=identifyFxFyStage();
[pb]=simFxFyStage(mot1);sim('stage_closed_loop');
close all;[ssc]=StateSpaceControlDesign(mot1);sim('observer');
[pb]=simFxFyStage(mot2);sim('stage_closed_loop');
close all;[ssc]=StateSpaceControlDesign(mot2);sim('observer');


mögliche tf:
iqCmd---->iqMeas
iqVolts-->iqMeas
iqMeas--->actPos

OLD STUFF

Open and run ESB_stage.m (takes very long to open simulink...)

// default frq: 20 kHz Phase, 5 kHz Servo, 6.25MHz AdcAmp

Values for current loop:
PwmSf-> User MAnual page 245
PwmSf=15134.8909 # =.95*16384. PMAC3-style DSPGATE3 ASIC is being used for the output, the counter moves between +/- 16384. PwmSf is typically set to 95% of 16384

scale = 1 for 2 phase motors
      = cos(30)=0.866 for 3 phase motors

 Amplifier specs (Power Brick LV User Manual.pdf p.19)
 5A_rms continous current
 15A_rms peak current
 14 bit ADC resolution
 2us PWM deadBand
 33.85A Maximum ADC Current (corresponds to a DAC Value 32737 ==2^15)

Tested values from IDE:
 3 Phase, 1A_rms  -> MaxDac=1184.895    =   np.sqrt(2)*np.sqrt(3)/2*32767/33.850
 3 Phase, 1A_peak -> MaxDac=837.8478    =   np.sqrt(3)/2*32767/33.850

 A_peak=A_rms*sqrt(2)
 np.sqrt(3)/2 because of 3 phase (the coil has not always current)
 A_peak is used. (A_rms is more dangerous to burn the motor)
 if not kw.has_key('IdCmd'):
   kw['IdCmd']   = dirCur*scale
 kw['MaxDac']  = peakCur*scale;

gpasciiCommander --host MOTTEST-CPPM-CRM0573 -i

$$$***
!common()
!encoder_inc(enc=1,tbl=9,mot=9)
!encoder_sim(enc=1)
!motor(mot=1,dirCur=200,JogSpeed=1024,invDir=False,InPosBand=1)
Defaut:
IiGain=.2
IpfGain=6
IpbGain=6

Current loop:
-> Monitor idMead, idVolts
idVolts: -32768..32,767 Value that goes to the PWM

out{constant} specifying the output magnitude as a percentage of
 the maximum output parameter for the motor: Motor[x].MaxDac.

Motor[1].MaxDac=580.80603
#1out1
-> 1 % of 580.8 -> Motor[1].ServoOut=5.808
-> idVolts= 1500
-> idMeas = 155

https://ch.mathworks.com/de/products/simcontrol.html
https://ch.mathworks.com/help/slcontrol/ug/design-compensator-in-simulink-using-automated-pid-tuning.html#responsive_offcanvas
https://ch.mathworks.com/help/slcontrol/ug/analyze-designs-using-response-plots.html
https://ch.mathworks.com/help/control/ug/bode-diagram-design.html
https://ch.mathworks.com/help/control/ug/edit-compensator-dynamics.html
https://ch.mathworks.com/help/control/ug/root-locus-design.html

controlSystemDesigner(1,sys);

controlSystemDesigner('bode',sys);