Simulink - saw tooth signal minimum counter

2 ビュー (過去 30 日間)
Dom
Dom 2021 年 10 月 4 日
コメント済み: Dom 2021 年 10 月 6 日
Hi guys,
I have a sawtooth singal, from which i am trying to create a signal with alternating sing. Meaning after one "tooth" (one rising and one falling edge) i want to change the sign to + or -1. Resulting in a signal alternating from -1 to 1 and so on. I tried using the derivative and then a sign block, but that does not yield a working result. I thought about implementing a counter that counts up as soon as the min value is reached, meaning that the sign of the derivative has changed. So in theory counting the local minima of the sawtooth signal. Do you have an idea how to implement that?
Thanks in advance!
  2 件のコメント
Alex Alex
Alex Alex 2021 年 10 月 5 日
show the signal please
Dom
Dom 2021 年 10 月 5 日
This is the ideal signal. I want to count the "teeth", meaning I want to count up as soon as the signal reaches a local minimum. The real signals usually dont go to zero or a distinct low value, so a counter that triggers at a specific value does not work, at least while I tried to do so.

サインインしてコメントする。

採用された回答

Paul
Paul 2021 年 10 月 5 日
Assuming that your signal has sharp corners .... One approach may be to:
Input the signal into a Detect Increase block. The output of that block will flip from 0 to 1 at the minimum corner. Feed the ouput of that block into a Triggered Subsystem. By default that subsystem will execute on the rising edge of the input, i.e., when the sawtooth turns the minimum corner. In that subsystem, use a simple loop with memory block that increments a count when the subsystem is triggered.
The accuracy, i.e., the time when the count increments, of this approach will depend on the sample rate of the sawtooth and the step size of the solver, both of which you should have some control over.
A similar, but more robust approach, would be to use a zero crossing or hit detection indicator exactly at the reversal, but nothing obvious comes to mind as to how to implement that.
  1 件のコメント
Dom
Dom 2021 年 10 月 6 日
The detect increase block was exactly what I was looking for! TY

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSources についてさらに検索

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by