0

I have the following Simulink model : DC/AC Half-Bridge Inverter, that uses an PWM block (inside the Green Frame) to generate the switching signals to the IGBTs, The From block (inside the Red frame) accepts a signal from the PWM using the Goto block, then passes it as output to the IGBTs.

Schema

I'm trying to build a custom PWM using Matlab code :

clc;
close all;
clear all;
t=0:0.001:1;
s=sawtooth(2*pi*10*t+pi);
m=0.75*sin(2*pi*1*t);
n=length(s);
for i=1:n
    if (m(i)>=s(i))
        pwm(i)=1;
    elseif (m(i)<=s(i))
        pwm(i)=0;
    end
end
plot(t,pwm,'-g',t,m,'--r',t,s,'--b');
grid on;
ylabel('Amplitude');
xlabel('Time index');
title('PWM Wave');
axis([0 1 -1.5 1.5]);

Here is the result of the plot :

enter image description here

My Question :

I know that t contains the time values and pwm contains the pwm values, So i want to know how to "somehow" redirect those Data from the Matlab code, through the From Block into the IGBTs so i can use them as switching signal ?

1 Answer 1

1

The are multiple ways to do this, but the easiest is to just use a From Workspace block as a direct replacement for the PWM Generator (2 Pulses) block.

Run your MATLAB code to define the variables in the MATLAB Workspace, and (assuming your G1_1 and G2_1 signals are the negation of each other) use [t(:) pwm(:) ~pwm(:)] as the block's Data parameter.

Note also, that you don't need the loop in your code:

pwm = (m >= s);

or if you need them to be doubles rather than logical then

pwm = double(m >= s);
Sign up to request clarification or add additional context in comments.

1 Comment

using From Workspace actually worked perfectly, thank you so much

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.