Motor_A1_dq_t_data.m 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. % This MATLAB script was used to extract the PMSM flux linkage data and
  2. % other parameters from Motor-CAD that are required by example model
  3. % ee_import_fem_motorcad.slx. Lines that call Motor-CAD are commented
  4. % out and return data loaded from a previously-created mat file.
  5. % Copyright 2018 The MathWorks, Inc. Portions Copyright Motor Design Ltd 2018.
  6. %% Start MotorCAD ActiveX server and load design data
  7. %mcad = actxserver('motorcad.appautomation');
  8. %invoke (mcad,'LoadFromFile','C:\PMSM.mot' );
  9. clear;
  10. % Clear workspace
  11. close all
  12. clear
  13. clc
  14. % Load model parameters
  15. Ts = 5e-7; % [s] Model sampling time (200 KHz)
  16. Ts_ctrl = 2e-5; % [s] Controller sampling time (50us)5e-5
  17. f_speed_ctrl = 500; % [Hz] Speed/torque Controller frequency = (500 Hz)
  18. Ts_Spd_ctl = 1/f_speed_ctrl;
  19. PWM_Cnt = 6000;
  20. PWM_Half_Cnt = PWM_Cnt/2;
  21. DeatTime = 0;
  22. DT_PWM_CNT = PWM_Cnt/(Ts_ctrl)*DeatTime;
  23. Torque_Mode = 1;
  24. Speed_Mode = 2;
  25. Ctrl_Mode = Torque_Mode;
  26. %Simulink provider Motor parameters
  27. n_polePairs = 4; % [-] Number of motor pole pairs
  28. PM = 0.01688; % Permanent magnet flux linkage,
  29. Ld = 0.7e-4;%0.07e-3;% d-axis inductance,
  30. Lq = 0.178e-3; % q-axis inductance,
  31. Rs = 0.011; % Stator resistance,
  32. J = 0.03945; % Moment of inertia,
  33. bandwith = 600*2*pi;
  34. i_Udc = 96; % DCbus max voltage
  35. Rload = 1e6;
  36. % A1 6匝电机数据
  37. %Current=xlsread('E:\works\项目\MC100\电机仿真数据\PhiD-I230405.xlsx','Sheet1','B2:N2');
  38. %FluxD = xlsread('E:\works\项目\MC100\电机仿真数据\PhiD-I230405.xlsx','Sheet1','B4:N40');
  39. %FluxQ = xlsread('E:\works\项目\MC100\电机仿真数据\PhiQ-I230405.xlsx','Sheet1','B4:N40');
  40. %Torque = xlsread('E:\works\项目\MC100\电机仿真数据\T-I230405.xlsx','Sheet1','B4:N40');
  41. % A1 5匝电机数据
  42. % FluxD = xlsread('E:\works\项目\MC100\电机仿真数据\5N-phiD-Current.xlsx','Sheet1','B4:N40');
  43. % FluxQ = xlsread('E:\works\项目\MC100\电机仿真数据\5N-phiQ-Current.xlsx','Sheet1','B4:N40');
  44. % Torque = xlsread('E:\works\项目\MC100\电机仿真数据\5N-Torque-Current.xlsx','Sheet1','B4:N40');
  45. % 五菱电机数据
  46. % FluxD = xlsread('E:\works\项目\MC100\电机仿真数据\96-9000\M155-phiD-IS.xlsx','Sheet1','B4:N40');
  47. % FluxQ = xlsread('E:\works\项目\MC100\电机仿真数据\96-9000\M155-phiQ-IS.xlsx','Sheet1','B4:N40');
  48. % Torque = xlsread('E:\works\项目\MC100\电机仿真数据\96-9000\M155-Torque-IS.xlsx','Sheet1','B4:N40');
  49. %% Define operating point and flux linkage table breakpoints
  50. PointsPerCycle = 36; % Number of angle data points
  51. Shaft_Speed = 3500; % Nominal shaft speed (RPM)
  52. DCBusVoltage = 96; % DC bus voltage
  53. magVec = linspace(0,300,13); % Current magnitude vector
  54. gammaVec = linspace(0,360,PointsPerCycle+1); % Current advance angle
  55. angleVec = linspace(0,360/n_polePairs,PointsPerCycle+1); % Rotor angle vector
  56. nMag = length(magVec);
  57. nGamma = length(gammaVec);
  58. nAngle = length(angleVec);
  59. fluxDmat = zeros(nMag,nGamma,nAngle);
  60. fluxQmat = zeros(nMag,nGamma,nAngle);
  61. torqueMat = zeros(nMag,nGamma,nAngle);
  62. % for i = 1:nMag
  63. % for j = 1:nGamma
  64. % for m = 1:nAngle
  65. % fluxDmat(i,j,m) = FluxD(j, i);
  66. % fluxQmat(i,j,m) = FluxQ(j, i);
  67. % torqueMat(i,j,m) = Torque(j, i);
  68. % end
  69. % end
  70. % end
  71. load A1_motor_flux_data
  72. %load A1_motor_flux_data
  73. %load M155_motor_flux_data
  74. % fluxDmat=fluxDmat.*0.707;
  75. % fluxQmat=fluxQmat.*0.707;
  76. % torqueMat=torqueMat.*0.707;
  77. %% Extract flux linkdage data from Motor-CAD
  78. % nMag = length(magVec);
  79. % nGamma = length(gammaVec);
  80. % nX = length(angleVec);
  81. % fluxDmat = zeros(nMag,nGamma,nX);
  82. % fluxQmat = zeros(nMag,nGamma,nX);
  83. % torqueMat = zeros(nMag,nGamma,nX);
  84. % fluxAmat = zeros(nMag,nGamma,nX);
  85. % for i = 1:nMag
  86. % for j = 1:nGamma
  87. % invoke(mcad,'SetVariable','PeakCurrent',magVec(i));
  88. % invoke(mcad,'SetVariable','DCBusVoltage',DCBusVoltage);
  89. % invoke(mcad,'SetVariable','Shaft_Speed_[RPM]',Shaft_Speed);
  90. % invoke(mcad,'SetVariable','TorqueCalculation',1);
  91. % invoke(mcad,'SetVariable','TorquePointsPerCycle',PointsPerCycle);
  92. % invoke(mcad,'SetVariable','PhaseAdvance',gammaVec(j));
  93. % invoke(mcad,'DoMagneticCalculation');
  94. % for m = 1:nX % Loop over rotor angles
  95. % xe = N*angleVec(m)*pi/180; % Electrical angle in radians
  96. % [res1, x1, torque] = invoke(mcad, 'GetMagneticGraphPoint', 'TorqueVW',m-1);
  97. % [res2, x2, fluxD] = invoke(mcad, 'GetMagneticGraphPoint', 'FluxLinkageLoadTotalD',m-1);
  98. % [res3, x3, fluxQ] = invoke(mcad, 'GetMagneticGraphPoint', 'FluxLinkageLoadTotalQ',m-1);
  99. % fluxDmat(i,j,m) = fluxD;
  100. % fluxQmat(i,j,m) = fluxQ;
  101. % torqueMat(i,j,m) = torque;
  102. % % Optional calculation of A-phase flux linkage. Note Park's
  103. % % transform for MotorCAD is Q leads D, rotor angle measured
  104. % % from A-phase flux axis to Q-axis.
  105. % invP = [sin(xe+[0;-2*pi/3;2*pi/3]),cos(xe+[0;-2*pi/3;2*pi/3])];
  106. % fluxes = invP*[fluxD;fluxQ];
  107. % fluxAmat(i,j,m) = fluxes(1);
  108. % end
  109. % end
  110. % end