- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Time between two zero crossing
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
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Time between two zero crossing