Implementation of custom counter logic in SIMULINK

我怕爱的太早我们不能终老 提交于 2019-12-31 05:15:15

问题


I am trying to implement a counter logic in SIMULINK where

in1, in2 are inputs

out1 is the output

if in2 = 0, out1 = 0;

if in2 = 1, out1 = 1 after x high edges of in1

I have tried using "Detect Rise Positive" block but failed miserably because I don't have sufficient experience of implementing a timing diagram correctly in SIMULINK. Could anyone kindly point me to the right direction?

Update

An approach I have taken since I posted this question is the "Triggered and enabled subsystem". I am trying to set it up so that:

in2 becomes the enable signal
in1 becomes the trigger
in2 becomes the intput to the subsystem
Out1 becomes the output of the subsystem

But I think that the above was rubbish. Unfortunately it is not VHDL where I could have implemented it using 4-5 lines of description of the hardware logic.


回答1:


Using a Triggered and Enabled subsystem is the right approach, but your inputs (and no doubt what's inside the subsystem) needs to be modified.

Don't have any input to the subsystem (other than the trigger and enable signals).

Inside the subsystem,

  • set the enable block property to reset the state when disabled.
  • set the outport property to reset when disabled and give the initial condition as 0.
  • create a counter out of a constant (value=1), a summation and a unit delay block.
  • feed the counter into a Compare to Constant block set to the 'x' value in your question.
  • feed that block to the outport.

When enabled, the counter should count the required number of steps (when triggered) before the output goes high.




回答2:


A counter logic can be implemented very easily in simulink. Take a switch,give the control input as int1. If int1 is 1 ur output shuld be 0 else take another switch give its control input as int2. if int2 is 1 ur output shuld be 1+ previous value given in feedback funit delay block



来源:https://stackoverflow.com/questions/17862816/implementation-of-custom-counter-logic-in-simulink

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!