+ Post New Thread
Results 1 to 14 of 14
  1. #1
    Full Member level 5
    Points: 7,870, Level: 21
    usernam's Avatar
    Join Date
    Mar 2004
    Posts
    268
    Helped
    132 / 132
    Points
    7,870
    Level
    21

    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

  2. #2
    Advanced Member level 2
    Points: 21,612, Level: 35

    Join Date
    Sep 2004
    Posts
    661
    Helped
    74 / 74
    Points
    21,612
    Level
    35

    simulink pwm generator

    Quote Originally Posted by usernam
    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.
    I used Matlab/Simulink before. Probably we can discuss.
    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.

    •   Alt10th November 2004, 10:56

      advertising

        
       

  3. #3
    Full Member level 5
    Points: 7,870, Level: 21
    usernam's Avatar
    Join Date
    Mar 2004
    Posts
    268
    Helped
    132 / 132
    Points
    7,870
    Level
    21

    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 1-D - 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.



  4. #4
    Advanced Member level 2
    Points: 21,612, Level: 35

    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.



  5. #5
    Full Member level 5
    Points: 7,870, Level: 21
    usernam's Avatar
    Join Date
    Mar 2004
    Posts
    268
    Helped
    132 / 132
    Points
    7,870
    Level
    21

    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 = (Tstop-Tstart)/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.
    Right now I'm getting a sawtooth from -4 to 5 even though the amplitude I specified was 5.
    Is there anyway I can get a sawtooth waveform from 0 to 5 (other than summing the sawtooth output with a constant).



  6. #6
    Advanced Member level 2
    Points: 21,612, Level: 35

    Join Date
    Sep 2004
    Posts
    661
    Helped
    74 / 74
    Points
    21,612
    Level
    35

    pwm generator in simulink

    Quote Originally Posted by usernam
    Right now I'm getting a sawtooth from -4 to 5 even though the amplitude I specified was 5. Is there anyway I can get a sawtooth waveform from 0 to 5 (other than summing the sawtooth output with a constant).
    Option A
    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.



    •   Alt10th November 2004, 17:31

      advertising

        
       

  7. #7
    Full Member level 5
    Points: 7,870, Level: 21
    usernam's Avatar
    Join Date
    Mar 2004
    Posts
    268
    Helped
    132 / 132
    Points
    7,870
    Level
    21

    sawtooth in simulink

    Yes it works with repeating sequence.
    Frequency 1 KHz.
    Max step size = 1e-4
    Amplitude of sawtooth is about 4.5 but its good enuf.



  8. #8
    Full Member level 5
    Points: 7,870, Level: 21
    usernam's Avatar
    Join Date
    Mar 2004
    Posts
    268
    Helped
    132 / 132
    Points
    7,870
    Level
    21

    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.

  9. #9
    Advanced Member level 2
    Points: 21,612, Level: 35

    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 0-5V 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.



    •   Alt12th November 2004, 08:22

      advertising

        
       

  10. #10
    Full Member level 5
    Points: 7,870, Level: 21
    usernam's Avatar
    Join Date
    Mar 2004
    Posts
    268
    Helped
    132 / 132
    Points
    7,870
    Level
    21

    repeating sequence simulink frequency problem

    Yes this does work. Actually this occured to me too just after I posted the message.

    Thnx. :)



  11. #11
    Advanced Member level 2
    Points: 21,612, Level: 35

    Join Date
    Sep 2004
    Posts
    661
    Helped
    74 / 74
    Points
    21,612
    Level
    35

    pwm matlab simulink

    Quote Originally Posted by usernam
    Yes this does work. Actually this occured to me too just after I posted the message.

    Thnx. :)
    Great!!! Glad to know that it works. I used Matlab/Simulink long time ago. So, I was worried that my suggestion in previous post might not work correctly. By the way, do you mind to share the final objective your your simulation model? I'm interested too and probably we can discuss together.



  12. #12
    Full Member level 5
    Points: 7,870, Level: 21
    usernam's Avatar
    Join Date
    Mar 2004
    Posts
    268
    Helped
    132 / 132
    Points
    7,870
    Level
    21

    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 sine-wave with a DC-offset 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.



  13. #13
    Newbie level 1
    Points: 520, Level: 4

    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



  14. #14
    Newbie level 2
    Points: 562, Level: 5

    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



--[[ ]]--