Storing a portion of a signal for real time processing in Simulink

조회 수: 1 (최근 30일)
ZACH LOUIS DANIEL
ZACH LOUIS DANIEL 2022년 12월 16일
편집: Bora Eryilmaz 2022년 12월 19일
I would like to perform sine to square wave conversion in my simulink model for feedback control of an LC circuit. I already have a little alogrithm I wrote that performs this wave form conversion after a simulation has run, but I'm now trying to do it in my simulation to create input waveforms for a circuit based on LQG control.
What I'm trying to do is store all the values of a sine wave in between it's two zero crossings, and then sending that array of data into a Matlab function block. My thought was to start storing data when the current value changes sign from the previous value, and then stop storing data and begin processing when another sign change occurs.
How do I go about storing multiple values of a signal coming out of a block before processing them?

답변 (1개)

Bora Eryilmaz
Bora Eryilmaz 2022년 12월 16일
편집: Bora Eryilmaz 2022년 12월 16일
The typical approach to convert a sine wave to square wave is to use a Schmitt Trigger. Simscape library has a block for this, which also explains the method:
However, Simulink itself does not have a matching block. It is easy to implement in code or using Simulink blocks. You don't need to store previous sine wave values (except perhaps the immediate previous value) to be able to do that.
  댓글 수: 2
ZACH LOUIS DANIEL
ZACH LOUIS DANIEL 2022년 12월 18일
편집: ZACH LOUIS DANIEL 2022년 12월 18일
The problem I see with a schmidt trigger is that it doesn't guarantee that the output square wave has a sufficient zero crossing time to be used on the power supplies that are on the experiment I'm modelling.
Basically I want to turn the output gain of LQR into a usable control input for a set of h-bridge SPA's that use square waves require adaquete zero crossing times.
Edit: I didn't read enough about Schmitt Triggers and this would be perfect! Thank you so much
Bora Eryilmaz
Bora Eryilmaz 2022년 12월 19일
편집: Bora Eryilmaz 2022년 12월 19일
Perhaps a low pass filter before the Schmitt Trigger can also help a bit by getting rid of fast power supply transients... But typically, the hysteresis is there to handle noise fluctuations in the signal.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Sources에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by