Generate a pulse train

8 views (last 30 days)
Peter
Peter on 10 Mar 2025
Edited: Jack on 10 Mar 2025
generate a pulse train with Pulse generator - how?
it ends up with a single pulse only ...
how reconfigure a pulse genearator to generate continous pulse train?

Answers (1)

Jack
Jack on 10 Mar 2025
Edited: Jack on 10 Mar 2025
A continuous pulse train requires the Pulse Generator block to repeat its pulse cycle over your entire simulation time. Here are the key settings to check:
  1. Use “Time-based” with “Use simulation time”In the Block Parameters dialog, set Pulse type to Time based and choose Use simulation time. That way, the block repeats pulses according to the Period you specify rather than generating a single event.
  2. Set a proper Period and Pulse Width
  • Period (secs) controls how often each pulse cycle repeats.
  • Pulse Width (secs) is how long each pulse stays at the “high” amplitude within one period.For example, if you want a 50% duty cycle at 100 kHz, you could use:Period=1x10^-5 seconds, Pulse width= 5x10^-6
  1. Run the simulation long enoughMake sure the Stop Time of your simulation is at least several multiples of the period so that you see multiple pulses on the Scope. For instance, if the period is 1×10^-5, try a stop time of 1x10^-3 or more.
  2. Solver considerations
  • If you use a variable-step solver, it might skip over very short transitions unless you tighten the max step size.
  • If you use a fixed-step solver, choose a step size small enough to capture the pulse transitions accurately (e.g., smaller than your Pulse Width).
  1. Example Setup
  • Amplitude: 1 (or 40, whatever you need)
  • Period (secs): 1×10^-5
  • Pulse Width (secs): 5×10^-6 (for 50% duty cycle)
  • Phase Delay (secs): 0
  • Simulation Stop Time: 1e-3 (or bigger)
With these settings, you should see a repeated pulse rather than just a single high level. If you still see only one pulse, confirm your simulation is running long enough and that your solver is resolving the short pulse durations.
Follow me so you can message me anytime with future questions. If this helps, please accept the answer and upvote it as well.

Products


Release

R2024b

Community Treasure Hunt

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

Start Hunting!