PLECS please add a Stopwatch Block

We have a few RT Boxes used as Hardware-In-the-Loop and would like to use them to measure response time of our attached Controls PCB.

For example, we want to measure the response time for overvoltage protection.

Ideally we would like to send a rising voltage signal through an AnalogOut pin to our MCU. When a defined voltage threshold is crossed, we start a Timer. Then we wait for a response on a DigitalIn pin and stop the Timer. Then, we store the time interval to be recalled using a data capture block to return said signal via XML-RPC to Python.

I failed implementing this in any intelligent way. How to I implement timers, stopwatches, cycle counters or similar?

Thanks!I have attached an example file trying to show what we wanted to do. The triggered data capture blocks are not performing as we would love to. (Ideally record the number of samples defined once triggered, and said data stored until it is called, with a time stamp/cycle number when this block was triggered)

PLECS Sandbox.plecs (18.3 KB)

You can create simple timers / edge detectors using basic components in PLECS like delays and integrators. See the attached example of a very basic “stop watch” and “edge counter”. You would probably want to expand on these designs based on the characteristics of the signals you are trying to measure.

For the triggered capture, it is about determining the appropriate trigger condition. If you want to ensure you always capture the first trigger and not have the data overwritten, then perhaps one could have a Programmable Value block output as the trigger. The trigger would be set initially, and then reset only once the getCaptureTriggerCount() associated with the desired Capture block increases. You could pass the timestamp into a Capture block as a signal.

simple_timer.plecs (21.4 KB)

Thank you @bryan!

I have implemented a similar solution and wanted to share it. Thanks for your support though, I hope this helps the next person.

PLECS Stopwatch.plecs (13.6 KB)