# Triangular wave with variable frequency

**URL:** <https://forum.plexim.com/t/triangular-wave-with-variable-frequency/1152>\
**Category:** PLECS\
**Tags:** triangular-waveform, variable-frequency, switching-frequency\
**Created:** [August 15, 2022, 3:59pm UTC](https://forum.plexim.com/t/triangular-wave-with-variable-frequency/1152 "2022-08-15T15:59:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Seyager](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@Seyager](https://forum.plexim.com/u/Seyager)\
**Post date:** [August 15, 2022, 3:59pm UTC](https://forum.plexim.com/t/triangular-wave-with-variable-frequency/1152/1 "2022-08-15T15:59:26Z")

</div>

Hello.

I would like to know how to make a triangular or sawtooth wave in PLECS with a variable frequency in time. I tried with a C-Script, but it makes the simulation slower and because of the time delay, the frequency is not on point.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Bryan\_Lieblick](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/bryan_lieblick/32/10_2.png) [@Bryan\_Lieblick](https://forum.plexim.com/u/Bryan_Lieblick)\
**Post date:** [August 18, 2022, 10:41am UTC](https://forum.plexim.com/t/triangular-wave-with-variable-frequency/1152/2 "2022-08-18T10:41:20Z")

</div>

A good reference for variable frequency ramp generation is the “Half-Bridge LLC Converter with Analysis Tools” demo model. Refer to the “VCO w/ programmable clock duty cycle” subsystem which implements the carrier generation. It uses a resettable integrator to generate a sawtooth waveform. The sawtooth waveform is then mapped into a triangular waveform.

I attached a model of that subsystem here as well.

[VoltageControlledOscillator.plecs](https://forum.plexim.com/uploads/short-url/9JFl3hZ3J8FpybMdIzsY8lot2H3.plecs) (26.1 KB)
