Simulink - saw tooth signal minimum counter

조회 수: 9 (최근 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 CenterFile Exchange에서 Classical Control Design에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by