Probing time delay between signals in transient simulation

Hi I am interested to plot time delay between zero crossings (or other events, lets say peaks) in the same direction of two AC signals in transient simulation. This delay suppose to change during the simulation so I want to plot it vs time.
Is it possible?
What is the correct way to do it?
Thanks.

@uzbek40 ,

I’m trying to better understanding your request.

Are you trying to plot of 0V-crossings and peaks (+ or - ?) at sim time or post-sim time?

You indicate sim-time but you don’t define the components you plan to use in the sim to detect 0V-crossings or peaks?

Without these components listed above, you can perform post-sim measurements and plot them.

To perform a plot at sim time, you need components in the sim schematic that can measure and compute on-the-fly. Note: Even with these components, there is guaranteed to be a delay for the results to show up.

Len

This is not a definitive solution, but I would like to provide an example to demonstrate that achieving what you need may be possible with a DLL (Dynamic Link Library) block. There are many aspects to consider when discussing the measurement of delay between two signals.

In this example, the DLL block can provide the simulation time at which the comparator output changes its state. The delay can be calculated by determining the difference in rise times between the zero crossings of the two signals. However, please note that the calculation result resets to 0 in this setup, as it does not yet handle transitions effectively. Nevertheless, if you have a clear understanding of your specific requirements, it may be possible to write a single DLL to handle your situation. My intention is simply to demonstrate that it is possible to calculate the time difference between two signals in a .tran simulation, although it can be a challenging task.

time_delay_between_signal.qsch (4.9 KB)
comp_timer.cpp (3.1 KB)

I understand that I have to define problem more specifically. What is the way to plot it in post-sim?

About running measurements I need to think how to define it correctly.

@uzbek40 ,

Are you trying to measure 0V-crossing delays and peaks on a single signal or two signals (as @KSKelvin did) ?

Len

I am trying to measure phase or time delay between two different signals.