Please take a minute to review and accept our Terms of Use.
Welcome to the PLECS User Forum, where you can ask questions and receive answers from other members of the community.

Many technical questions regarding PLECS are answered on the Technical Solutions page of our website. Tutorial videos, specific application examples, and pre-recorded webinars are available on our YouTube page. Please follow us on LinkedIn for the latest Plexim news.

PLECS please add a Stopwatch Block

0 votes

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?

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)

asked Dec 4, 2023 by KaBrusa (19 points)

2 Answers

0 votes
Best answer
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.
answered Dec 6, 2023 by Bryan Lieblick (1,795 points)
selected Dec 7, 2023 by KaBrusa
0 votes
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.
answered Dec 7, 2023 by KaBrusa (19 points)