how to measure the average duty cycle in discrete domain

1 view (last 30 days)
This give the correct result when we are working in continuous domain i.e.
but when i give sample time then it is not giving the correct result i.e.
please help me how to measure the duty cycle for this

Answers (1)

Raghava S N
Raghava S N on 21 May 2024
Hi Jayshree,
I understand you are working on a model that calculates the duty cycle of a pulse. It seems like the model is performing as per expectations with continuous inputs but encounters issues when handling discrete inputs.
To measure the average duty cycle of a discrete pulse, the pulse's "on" time during one period of the pulse must be calculated first. The duty cycle can then be calculated by following the below steps:
  1. Firstly, within the model, locate the “Pulse Generator” block. Adjust its settings by selecting "time based" for the "Pulse type" parameter. This step is necessary for defining the nature of the pulse.
  2. Next, specify the desired "Pulse Width" and "Period" parameters to shape the pulse according to the requirements.
  3. To measure the average duty cycle, the "on" time of the pulse within a specific period must be calculated. The “Discrete-Time Integrator” block (found under “Simulink > Discrete”) should be used to integrate the pulse over one time period. The value of the integration at the end of a period is the total "on" time within that period.
  4. Ensure the reset port of the “Discrete-Time Integrator” block is set to reset at each period's end, allowing for measurement from period to period. It is important to note that the sample time of the “Discrete-Time Integrator” block should be set smaller than that of the “Pulse Generator” block to maintain accuracy.
The output of the above steps is the “on” time of the pulse. This signal is then fed to a “Divide” block and divided by the time period of the pulse to obtain the duty cycle. Connect the scope to the output of the “Divide” block to view the average duty cycle.
For a more detailed understanding, refer to the attached Simulink model – “dutycycle.slx”. Additionally, here is the MATLAB R2024a documentation link for the discrete Integrator block for your reference - https://www.mathworks.com/help/releases/R2024a/simulink/slref/discretetimeintegrator.html

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!