Contents

%Script file for demonstrating the space-vector based back-EMF calculation.
%
% (c) 2020 Smeklab Ltd. All rights reserved.

Ns = [5 200]; %number of time-steps to analyse
rpm = 6000;

%initializing problem
problem = MagneticsProblem(motor);
winding = motor.circuits.get('Phase winding');

%initializing figures
figure(2); clf; hold on; box on; grid on;
figure(3); clf; hold on; box on; grid on;
for k = 1:numel(Ns)
    angles = linspace(0, 2*pi*2, 2*Ns(k) ); %electrical angles to step through

    %setting zero current density in winding
    Is = xy([0;0], problem, 'angles', angles);
    winding.set_source('uniform coil current', Is);


    pars = SimulationParameters('f', rpm/60*dim.p, 'rotorAngle', angles/dim.p, ...
        'silent', true);

    %solving problem
    stepping_solution = problem.solve_static(pars);

    %direct differentiation
    figure(2);
    Uraw = winding.phase_bemf(stepping_solution, 'differentiation', 'raw');
    plot(stepping_solution.angles/pi*180, Uraw(1,:), 'linewidth', 1);

    % space-vector based approach
    figure(3);

    %phase flux linkages
    Phi = winding.phase_flux_linkage(stepping_solution);

    %transformation to synchronous frame
    Phidq = ParkClarke.dq(Phi, angles);

    %DC and ripple components
    Phidq_0 = mean(Phidq, 2);
    Phidq_ripple = Phidq - Phidq_0;

    %interpolating flux to denser grid
    angles_dense = linspace(0, 2*pi*2, 1000);
    ts_dense = angles_dense / (2*pi * pars.f);
    Phidq_dense = Phidq_0 + interp1(angles, Phidq_ripple', angles_dense, 'linear', 'extrap')';

    %transforming interpolated fluxes to static frame
    Phi_dense = ParkClarke.xy(Phidq_dense, angles_dense, motor);

    %reconstructing voltage
    U_reconstructed = rolldiff(Phi_dense,[],2) ./ rolldiff(ts_dense,[],2);


    plot(angles_dense/pi*180, U_reconstructed(1,:), 'linewidth', 1);
end

figure(2); title('Direct differentiation');
xlabel('Angle (el.deg.)');
ylabel('Phase voltage (V)');
legend( strcat( num2str(Ns'), ' samples per period'), 'linewidth', 1 );

figure(3); title('Space-vector differentiation');
xlabel('Angle (el.deg.)');
ylabel('Phase voltage (V)');
legend( strcat( num2str(Ns'), ' samples per period'), 'linewidth', 1 );

Return

Back to index.