%EE452 Lab 12
%This script plots the theoretical Torque-Speed Curve 
%for the Marathon Electric Squirrel Cage Induction Machine

% machine parameters
we = 2*pi*60; %Electrical frequency (rad/s)
R1 = 11.2904; %Stator resistance (ohm)
R2 = 6.9448; %Rotor resistance (ohm)
X1 = we*0.0215; %Stator Leakage Reactance (ohm at 60Hz)
X2 = we*0.0321; %Rotor Leakage Reactance (ohm at 60Hz)
X0 = we*0.330; %Magnetizing Reactance (ohm at 60Hz)
R0 =  3496.3; %Core Resistance (ohm) 
P = 4; %Number of Poles
Vs = 120; % Line-to-Neutral Voltage, rms
Pwloss = 12; % friction & windage loss, Watts (Measure at No-Load)

% rotor speed
wr = we*linspace(0,2,we*2); %range of speeds to generate Torque-Speed Plot
s = (we - wr)/we; %Slip

% Thevenin voltage & impedance
Zm = (j*X0)*(R0)/(j*X0 + R0); 
Vth = Zm/(R1 + j*X1 + Zm)*Vs;
Zth = 1/(1/(R1 + j*X1) + 1/(Zm));
Rth = real(Zth);
Xth = imag(Zth);

% torque and power vs. speed characteristics
Te = 3*(P/2)*abs(Vth)^2*R2./(s*we)./((Rth + R2./s).^2 + (Xth + X2)^2);
Pe = Te.*wr*(2/P);

figure(2), clf
plot(wr, Te)
xlabel('Rotor Speed, wr (rad/s)')
ylabel('Torque (Nm)')
figure(3)
plot(wr, Pe, 'r')
xlabel('Rotor Speed, wr (rad/s)')
ylabel('Electrical Power, (W)')

%Measured torque vs. speed characteristic
wrmeas = (P/2)*(2*pi)/60*[225 1781 1773 1763 1753 1743 1732 1720 1710 1695 1682]%Measured rotor speed (enter rpm)
Tmeas = 0.112984829*[ 20 1 2 3 4 5 6 7 8 9 10]%Measured torque (enter in*lbs)
figure(2)
hold on
plot(wrmeas,Tmeas, '*')

