% CONTOH Motor punya Haris Mukasir
clear
Ta = 20; % Waktu akhir simulasi [sec]
% DATA MOTOR
Ea = 220; % Ea NOMINAL [Volt]
Ra = 0.62; % Tahanan Jangkar [Ohm]
La = 0.01; % Induktansi Jangkar [Henry]
Km = 1.01384; % Konstanta Motor [Nm/Amp]
Kb = 1.0419; % EaNOM/w[rad/sec]
B = 0.0139897195; % [Nm/(rad/sec}]
J = 0.0006909712; %[Nm sec^2/rad]
D = 60.079810908887; % Lihat catatan PWM DC Motor Control
Vsec = 300;% Lihat catatan PWM DC Motor Control
Ia0 = 2.889912134602839; % Kondisi Stady State yang menjadi kondisi awal
omega0 = 1.999937941490438e+03*(2*pi/60); % 2000 RPM ---> rad/sec Kondisi Steady State menjadi kondisi awal
RPM_ref = 2000; % RPM Acuan/Setting
% PENGENDALI PID
Kp = 100;
Ki = 0;
Kd = 0;
%
sim('Motor2021_PWM_CLOSED_LOOP.slx')
%
subplot(411), plot(time, tegangan), grid on, xlabel('time [sec]'), ylabel('Ea(t), [Volt]')
subplot(412), plot(time, beban), grid on, xlabel('time [sec]'), ylabel('Variasi Beban')
subplot(413), plot(time, RPM), grid on, xlabel('time [sec]'), ylabel('RPM')
subplot(414), plot(time, arus), grid on, xlabel('time [sec]'), ylabel('Ia(t), [Amp]')
pause
clf
subplot(211), plot(time, error), grid on, xlabel('time [sec]'), ylabel('ERROR [Volt]')
subplot(212), plot(time, effort), grid on, xlabel('time [sec]'), ylabel('EFFORT [%]')
N = length(error);
RMS_Error_RPM = RMSEr(N)
RMS_Effort_Duty_Cycle = RMSEf(N)

