Page 345 - Solutions Manual to accompany Electric Machinery Fundamentals
P. 345

%   fire   = Firing angle in degrees

                 % vu
                 if ( vin > vx )
                    vu = 100;
                 else
                    vu = 0;
                 end

                 % vv
                 if ( vin >= vy )
                    vv = 0;
                 else
                    vv = 100;
                 end

                 % Caclulate vout
                 vout = vv - vu;


                                                                                                          v
                 Now we need a MATLAB program to generate the input voltage    tv in   and the reference voltages    t
                                                                                                           x
                 and   tv y  .  After the voltages are generated, function vout will be used to calculate  v out   t  and the
                                                                                 v
                                                                                           v
                 frequency spectrum of  v out  t  .  Finally, the program will plot    tv in  ,    t  and   t  ,  v out   t , and the
                                                                                            y
                                                                                  x
                 spectrum of  v out  t  .  (Note that in order to have a valid spectrum, we need to create several cycles of the
                 60 Hz output waveform, and we need to sample the data at a fairly high frequency.  This problem creates
                 4 cycles of v out  t   and samples all data at a 20,000 Hz rate.)

                 % M-file: probs1_15a.m
                 % M-file to calculate the output voltage from a PWM
                 % modulator with a 500 Hz reference frequency.  Note
                 % that the only change between this program and that
                 % of part b is the frequency of the reference "fr".

                 % Sample the data at 20000 Hz to get enough information
                 % for spectral analysis.  Declare arrays.
                 fs = 20000;               % Sampling frequency (Hz)
                 t = (0:1/fs:4/15);        % Time in seconds
                 vx = zeros(size(t));      % vx
                 vy = zeros(size(t));      % vy
                 vin = zeros(size(t));     % Driving signal
                 vu = zeros(size(t));      % vx
                 vv = zeros(size(t));      % vy
                 vout = zeros(size(t));    % Output signal
                 fr = 500;                 % Frequency of reference signal
                 T = 1/fr;                 % Period of refernce signal

                 % Calculate vx at fr = 500 Hz.
                 for ii = 1:length(t)
                    vx(ii) = vref(t(ii),T);
                    vy(ii) = - vx(ii);
                 end

                 % Calculate vin as a 50 Hz sine wave with a peak voltage of
                                                           339
   340   341   342   343   344   345   346   347   348   349   350