%EE452 Lab 9
%This script plots the theoretical Torque-Speed Curve 
%for the Lab-Volt Squirrel-Cage Induction Machine
%Machine parameters are from Hao Chen's Vienna Rectifier paper
clear all, clc

% machine parameters
we = 2*pi*60; %rad/s
R1 = 12.3; %ohm
R2 = 12.3; %ohm
X1 = we*0.0686; %ohm at 60Hz
X2 = we*0.0686; %ohm at 60Hz
X0 = we*0.440; %ohm at 60Hz
P = 4; %Number of Poles
Vs = 120; % Line-to-Neutral Voltage, rms
Pwloss = 20; % friction & windage loss, Watts (Measure at No-Load)

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


% Thevenin voltage & impedance
Vth = j*X0/(R1 + j*X1 + j*X0)*Vs;
Zth = 1/(1/(R1 + j*X1) + 1/(j*X0));
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(1), clf
hold on
grid on
plot(wrm, Te)
xlabel('Rotor Speed, wrm (rpm)')
ylabel('Torque (Nm)')

figure(2)
plot(wrm, Pe, 'r')
hold on 
grid on
xlabel('Rotor Speed, wrm (rpm)')
ylabel('Electrical Power, (W)')

%Additional code to plot Stator Current (rms), and Power Factor
%You may need to derive equations from the equivalent circuit.




