How to create triangular waveform with variable phase shift

How to create variable delay for non-smooth signals? Specifically, I’m interested in a variable delay for a triangular waveform. The delay value should depend on a signal on the simulation sheet.

Thank you very much

2 Likes

Please find attached a PLECS model that creates a set of triangular waveforms with variable phase shift in two stages:

First a reference ramp signal is generated, which is phase-shifted by subtracting a (vertical) offset and wrapping the result back to the interval [0, 1]. The trick here is to add a “Hit Crossing” block so that a variable-step solver will make a simulation step at the instant when the shifted ramp resets to zero.Map the ramp signals to a symmetrical triangle using a simple 1D Look-up Table. Again, the trick is to add a “Hit Crossing” block so that a variable-step solver will make a simulation step when the triangle signal reaches its maximum. (The minimum will be hit automatically because it coincides with the reset of the ramp signals.)

TrianglePhaseShift.plecs (23.1 KB)