Azzera filtri
Azzera filtri

Finding the peak of a sinusoidal voltage using only Simulink Blocks (No Matlab Function Block)

15 visualizzazioni (ultimi 30 giorni)
Hi there!
I have a simulink model where I am measuring the line voltages. I need to find the peak of the line voltages over the first 10 cycles for example. So I will have a varaible named "peak_voltage" which should have a value of 0 when the simulation time did not reach 10 cycles, and a value of the peak line voltage afterwards.
I have achieved this using piece of code within a "Matlab Function Block" where I use a persistent variable that gets updated each cycle with the value of the current line voltage when it is on the positive slop of the line signal. But I need to achieve this by only using Simulink Blocks! Any ideas would be appreciated. Thanks
  1 Commento
Madhusudan
Madhusudan il 3 Lug 2024 alle 6:45
Hello Hassan,
how did you created the model for finding peak max value of voltage ?
i am replacing the RMS block with MATLAB function block or simulink model, because RMS block is not valid block for generating HDL from simulink model.

Accedi per commentare.

Risposte (1)

Sam Chak
Sam Chak il 24 Feb 2024
Isn't the MATLAB Function block part of the Simulink block families that grants you the greater potential to achieve what you want in a more convenient way? It is also possible to create a Custom Simulink block to strictly execute the tasks that you specify. You can refer to the following tutorial for detailed instructions:
  3 Commenti
Sam Chak
Sam Chak il 26 Feb 2024
No worries, @HASSAN ABDELGABIR. However, what specifically hinders you from enhancing your efficiency by utilizing the MATLAB Function and Custom Blocks? Have you experimented with the Max block?
HASSAN ABDELGABIR
HASSAN ABDELGABIR il 26 Feb 2024
Yes I was able to achieve it using Max block and if block in Simulink. The key was to use the Data Store Memory block to replicate the behavior of persistent variables.
Thank you

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by