+ Post New Thread
Results 1 to 14 of 14

10th November 2004, 10:18 #1
pwm simulation
Hi
I am trying to simulate PWM for a boost converter in Matlab. My plan is to compare the error with a sawtooth waveform of frequency arnd 1KHz.
I am using the signal generator in Simulink>Sources>Signal Generator to generate a sawtooth waveform. Unfortunately the sawtooth waveform is not working for a frequency beyond 1 Hz (atleast I'm unable to see it on the scope) and even then it is not a perfect sawtooth. The fall time from peak value to zero is significantly high.
I tried using the repeating sequence block in Simulink>Sources>Repeating Sequence but I was unable to get a sawtooth of high enuf frequency.
Does anybody know what the problem is and how to proceed.
Thnx

10th November 2004, 10:56 #2
 Join Date
 Sep 2004
 Posts
 661
 Helped
 74 / 74
 Points
 21,612
 Level
 35
simulink pwm generator
Originally Posted by usernam
First, do you wish to generate a 1Hz or 1kHz sawtooth waveform?
2nd, what is your Matlab/Simulink version?
I have built a simple one, but not sure it's the one you wish to have or not. By the way, the setting of scope should be correct, e.g. you should disable the '5000' data limit option.
1 members found this post helpful.

10th November 2004, 15:12 #3
pwm generator simulink
Nicleo thnx for the prompt reply.
I need a 1 KHz sawtooth.
Matlab version 6.5 Release 13.
I'm attaching the waveforms I obtained at 2 Hz and 10 Hz. At 1 Hz and arnd 4Hz I'm getting something similar to what you posted.
My scope settings are
Limit data points to last  unchecked
Save data to workspace  unchecked
Signal Generator settings
Waveform  sawtooth
Amplitude  5
Frequency  2 Hz
Interpret vector parameters as 1D  checked.
Relational Operator settings
Require all inputs to have same data type  unchecked
Output data mode  uint(8 )
Enable zero crossing detection  unchecked
Also the sawtooth waveform is going into the negative region. I want a sawtooth that goes from 0 to peak then back to 0 immidiately and then repeat continously.

10th November 2004, 15:12

10th November 2004, 15:59 #4
 Join Date
 Sep 2004
 Posts
 661
 Helped
 74 / 74
 Points
 21,612
 Level
 35
simulink pwm block
Need to modify the Simulation settings (see figure below). Hope it helps.

10th November 2004, 16:54 #5
sawtooth simulink
Thnx its working gr8.
I found this in the simulink manual after searching for it.
Maximum step size. The Max step size parameter controls the largest time step the solver can take. The default is determined from the start and stop times.
Hmax = (TstopTstart)/50
Generally, the default maximum step size is sufficient. If you are concerned about the solverâ€™s missing significant behavior, change the parameter to prevent the solver from taking too large a step. If the time span of the simulation is very long, the default step size might be too large for the solver to find the solution. Also, if your model contains periodic or nearly periodic behavior and you know the period, set the maximum step size to some fraction (such as 1/4) of that period.
Is there anyway I can get a sawtooth waveform from 0 to 5 (other than summing the sawtooth output with a constant).

10th November 2004, 17:31 #6
 Join Date
 Sep 2004
 Posts
 661
 Helped
 74 / 74
 Points
 21,612
 Level
 35
pwm generator in simulink
Originally Posted by usernam
We can add an OFFSET after the "Signal Generator" block. Pls see attachment.
Option B
In this case, probably we need to use "Simulink>Sources>Repeating Sequence", and set the "Max step size" to smaller if it's distorted at high frequency. Pls update.

10th November 2004, 17:31

10th November 2004, 17:50 #7
sawtooth in simulink
Yes it works with repeating sequence.
Frequency 1 KHz.
Max step size = 1e4
Amplitude of sawtooth is about 4.5 but its good enuf.

12th November 2004, 07:31 #8
perfect sawtooth in simulink
I now need to generate a sawtooth of variable amplitude .i.e I need to calculate the amplitude of my sawtooth from the given input voltage and reference voltage. Then I need to construct the sawtooth.
How can I go about this?
1 members found this post helpful.

12th November 2004, 08:22 #9
 Join Date
 Sep 2004
 Posts
 661
 Helped
 74 / 74
 Points
 21,612
 Level
 35
matlab pwm simulation
Pls refer to my post above, which explained how to obtain 05V sawtooth signal. We can use Option A to achieve the variable amplitude. Pls see the modified version in the attachment at below.
Explanation (sorry, I could not access Matlab/Simulink now):
1) Output from Gain block (A) is 0 ~ 5V (as you requested)
2) Amplitude Calculation module/block. The output of this module (B) should be normalized to within 0 ~ 1.
3) The signals from A and B are routed to a Product block.
4) Output of Product block (C) is connected as shown in the figure.
Say now, based on the input voltage and reference, the calculated amplitude (the range should be within 0 ~ 5 V) is 2.5V. So, after normalization (2.5/5), B = 0.5. When A is multiplied by B, the amplitude of A will be 'scaled' by HALF (0.5). So, you can get a variable amplitude sawtooth at C. Pls update whether it can work or not. Thanks.
Another way of doing:
1) The amplitude at Signal Generator is set to '1'.
2) The value of Constant block (as offset) is set to '1'.
3) The value of Gain block is set to '0.5'. So, the output from the Gain block (A) is a 0 ~ 1 sawtooth.
4) No need normalization after the amplitude calculation module.

12th November 2004, 08:27 #10
repeating sequence simulink frequency problem
Yes this does work. Actually this occured to me too just after I posted the message.
Thnx. :)

12th November 2004, 08:33 #11
 Join Date
 Sep 2004
 Posts
 661
 Helped
 74 / 74
 Points
 21,612
 Level
 35
pwm matlab simulink
Originally Posted by usernam

13th November 2004, 07:15 #12
pwm generator simulation
Hi nicleo
Well the final objective is to connect a fuel cell and a PV array through two parallel boost converters to a load. The power must be shared between these two boosts. I have to maintain the PV in MPPT(Maximum Power Point Tracking) mode.
I am responsible for the PV section. The fuel cell is being modelled by my partner. The purpose of the present simulation is to model a boost converter and maintain it's output voltage at a constant (which is given by the reference voltage). Right now I'm just using a sinewave with a DCoffset for the input source since my PV source program is not yet done.
I'm attaching the model for the boost converter in case you're interested.

13th November 2004, 07:15

9th January 2010, 16:26 #13
 Join Date
 Jan 2010
 Posts
 1
 Helped
 0 / 0
 Points
 520
 Level
 4
Re: simulink pwm block
Hey Can u help me to generate a 600 Hz carrier signal using Repeating Sequence in MATLAB.
Amplitude must be: Starts from 0 then to 2 and then to 0 and 2(one cycle)
Time:[0 .0016]
Output Amplitude:[2 2]
Help me out with this repeating sequence

5th May 2010, 18:11 #14
 Join Date
 Nov 2009
 Location
 france
 Posts
 2
 Helped
 0 / 0
 Points
 562
 Level
 5
dc to ac converter Simulation
Hi usernam
I m intersting in the topic. I sumulated your boost model but I have the following error, can yu please say how i can resolve it "Only 'double' signals are accepted by type Integrator. The signals at the ports of 'full_loop_final_sinewave/Boost Converter/Integrator1' are of data type 'uint8'."
thx
+ Post New Thread
Please login