close all
clear all

Kt = 0.137;  %N-m/AmpRMS
Kv = 32.1;  %V/krpm
%Kv = (Kv*60/2*pi)/1000;  %V/rad/sec

Rw = 10.5;  %Ohms

Po = 10; %Output Power dissipated by load. (watts)




spd_rpm = 100:10:3000;  %rev per minute
spd = spd_rpm*2*pi/60;  %rad/sec

V = Kv*spd_rpm/1000; 

Rl = V.^2/Po;  %Effective load resistance required to dissipated specified output power (Po).

I = V./(Rw*ones(1,length(Rl))+Rl);  %Current in windings.
%I = V./Rl;  %Current in windings.

T = Kt*I;  %Torque required to turn generator at this speed.

Pi = T.*spd;

Pw = Rw*I.^2;  %Power dissipated in Windings
Pl = Rl.*I.^2;  %Power dissipated in Load

eff = Pl./Pi;


paperwidth = 8.5;
paperheight = 11.0;
h_summary = figure('PaperPositionMode','manual','PaperSize',[paperwidth paperheight],'PaperPosition',[0 0 paperwidth paperheight],'Units','inches','Position',[2 -1 paperwidth paperheight],'Visible','on'); 

left = 1.0; bottom = 9.3; width = 6.5; height = 1.50;
h_VoltsVsSpd  = subplot('Position',[left/paperwidth bottom/paperheight width/paperwidth height/paperheight]);

left = 1.0; bottom = 7.15; width = 6.5; height = 1.50;
h_CurrentVsSpd = subplot('Position',[left/paperwidth bottom/paperheight width/paperwidth height/paperheight]);

left = 1.0; bottom = 5.0; width = 6.5; height = 1.50;
h_TorqueVsSpd = subplot('Position',[left/paperwidth bottom/paperheight width/paperwidth height/paperheight]);

left = 1.0; bottom = 2.85; width = 6.5; height = 1.50;
h_PowerVsSpd = subplot('Position',[left/paperwidth bottom/paperheight width/paperwidth height/paperheight]);

left = 1.0; bottom = 0.7; width = 6.5; height = 1.50;
h_Efficiency = subplot('Position',[left/paperwidth bottom/paperheight width/paperwidth height/paperheight]);

subplot(h_VoltsVsSpd)
plot(spd_rpm,V)
xlabel('speed (rpm)');
ylabel('Voltage (Volts)');
title('Kt =   Kv = ');

subplot(h_CurrentVsSpd)
plot(spd_rpm,I)
xlabel('speed (rpm)');
ylabel('Current (Amps)');

subplot(h_TorqueVsSpd)
plot(spd_rpm,T)
xlabel('speed (rpm)');
ylabel('Torque (N-m)');

subplot(h_PowerVsSpd)
plot(spd_rpm,Pw,spd_rpm,Pl,spd_rpm,Pi)
xlabel('speed (rpm)');
ylabel('Power (Watts)');
legend('Windings','Load','Input');

subplot(h_Efficiency)
plot(spd_rpm,eff)
xlabel('speed (rpm)');
ylabel('Efficiency');


print -depsc2 MotorPerformance.eps









