Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Time between two zero crossing

Time between two zero crossing

I want to measure the time between zero crossings of an AC voltage to measure calculate the frequency.

Some tries with the  Modelica.Blocks.Discrete.TriggeredSampler as well as the eventclock from the modelica_synchronous package were not successful.

I need something which detects the zero crossings and returns the last measured period of time between (or even better: the half reciprocal as its frequency) the last two. If the time is 0 (start of the simulation) it should return 50 Hz or 0.1 s.

Maybe some sort of event triggered integrator could do the job? I couldn´t find something similar and my tries to do build one myself failed.

If anyone has an other Idea, feel free to share it.

Attached is a minimal example. For the first some milliseconds, the integrator (or something else) should return 50 Hz (or 0.1 ms), afterwards, it should return 49 Hz (the real frequency of the voltage source.

Just grabbing the real frequency is not an option, since it is a varying result of a controlled in the real model.

Thanks in advance and best regards,

Henrik


zerocrossing.mo


Edited by: Mota - Jun-07-20 19:07:14
Attachments:
There are 0 guests and 0 other users also viewing this topic
You are here: