Simulink - saw tooth signal minimum counter
조회 수: 2 (최근 30일)
이전 댓글 표시
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!
채택된 답변
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Sources에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!