You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
trigger block in simulink
3 views (last 30 days)
Show older comments
Rahul kumar
on 4 Sep 2012
I need to have a trigger block, which should trigger only one block at a time.
For example
I have 2 blocks A , B connected to the trigger block T, this triggering block T should trigger one of these A, B blocks at different instances. i.e trigger A at instant 0, A at instant 1, B at instant 2, A at instant 2 and so on.
which triggering block should i use?
And should i use any code to have this timed triggering
waiting fr ur valuable response
Thank you
3 Comments
Rahul kumar
on 5 Sep 2012
it should fire contiously.. as i am trying to convert a synchronous data flow graph into a synchronous block diagram..!
when A block is triggered should produce some tokens ( 2 for my model) when B block is triggered should consume some tokens ( 3 for my model)
Rahul kumar
on 5 Sep 2012
Edited: Rahul kumar
on 5 Sep 2012
So like this i need to form a producer-consumer model!! the trigger can be in any order.!
But preferably A,A,B,A,B because when A is fired twice (2+2 tokens produced), it is sufficient for B to get 3 tokens from double firing of A, then so on.
Accepted Answer
TAB
on 5 Sep 2012
Edited: TAB
on 5 Sep 2012
[Edited]
Please see the model snapshot below:
4 Comments
Rahul kumar
on 5 Sep 2012
Can u please explain what is happening in the switch block and what is the purpose of repeating sequence stair?
Rahul kumar
on 5 Sep 2012
Yes the trigger sequence is as expected!! thank you,
And which block did you use for A, B is it triggered subsystem block?
TAB
on 5 Sep 2012
Edited: TAB
on 5 Sep 2012
Yes it is triggered subsystem with rising edge trigger type.
Initially at t=0, output of unit delay block will be 1 (Initial condition:1). So switch block will send the input-1 to the output which is equal to 1.
Afterward, output of switch block will come from input-3 connected to repeating sequence stair.
Repeating sequence stair will generate the sequence of 0 & 1 continuously.
So
Sample Time : 0 1 2 3 4 5 6 ....
Switch Blk Intput-1: 1 1 1 1 1 1 1 ....
Switch Blk Intput-2: 0 1 0 1 0 1 0 ....
Switch Blk output : 1 1 0 1 0 1 0 ....
NOT Blk output : 0 0 1 0 1 0 1 ....
Hope now it is clear.
More Answers (1)
Azzi Abdelmalek
on 4 Sep 2012
Edited: Azzi Abdelmalek
on 4 Sep 2012
try this
- set all sample time block to ts
- set initial value of unit delay block to 1
35 Comments
Rahul kumar
on 4 Sep 2012
can you please explain what is happening in the given diagram above..! the signal is starting from where?
thank you
Azzi Abdelmalek
on 4 Sep 2012
- the initial value of "unit delay" block is set to 0 by default. you can change it.
- then the first value of signal 1 is 0 while the first value of signal 2 is 1 not(0)
- at the next step signal1=1 while signal2=0 and so
Azzi Abdelmalek
on 4 Sep 2012
can you explain how are you triggering your blocks
Rahul kumar
on 4 Sep 2012
ya this triggering looks correct if we trigger one after one ie. A then B then A so on.. but i need t´rigger like this A,A,B,A,B.
Azzi Abdelmalek
on 4 Sep 2012
are you working with specified sample time?
Rahul kumar
on 4 Sep 2012
yes having a sample time would make more sense, as the block produces outputs and if appropriate, updates its internal state at the given sample time. but i dont know wat sample time to use.
Azzi Abdelmalek
on 4 Sep 2012
depends on what system are you working on? check the updated model
Azzi Abdelmalek
on 4 Sep 2012
I think you can do it with inherited sampe time
Rahul kumar
on 4 Sep 2012
Edited: Rahul kumar
on 4 Sep 2012
Can u pls explain the block again if u dont mind, wat is the clock and constant block doing and what is that >0 port also doing in the block.
Thanks in advance.
Azzi Abdelmalek
on 4 Sep 2012
Edited: Azzi Abdelmalek
on 4 Sep 2012
- the clock block is calculating time
- the switch block output is from constant 1(third input) when time(second input)>0 ;else its from the (unit delay-not) block (first iput)
that means at step 1 the signal1=1 and signal2=0; at step 2: sgnal1=1 ; signal2=0; at step3: signal1=0;signl2=1
do not forget to set initial value of unit delay block to 1 and the threshold of switch block to 0 and threshold condition of switch block to >threshold
Rahul kumar
on 4 Sep 2012
actually u said, If the time(second input)>0 output from constant block 1 else from(unit delay-not) block
so is the time(second input) keeps changing at different instances?
and at step 2 the o/p from not block also 1 and from the constant block also 1, so how it works at this step.
at step 3 othe o/p from not block is 0 and from the constant block also 1, so how it became signal 1=0 and signl2=1
so for bothering you.
Thanks for clarifying
Azzi Abdelmalek
on 4 Sep 2012
you don't bother me. but I ask you to connect signals to a scope, and simulate and look what is going on
Rahul kumar
on 4 Sep 2012
ya i ll simulate with the display n let you know!!
thank you
Rahul kumar
on 5 Sep 2012
I simulate it with display,on the first o/p, signal 1 is 0 and signal 2 is 1 and the simulate is nt happening continuously. it stops after one simulation.
And what is the decimation value to use in the clock? it has some effect?
Rahul kumar
on 5 Sep 2012
Edited: Rahul kumar
on 5 Sep 2012
the simulation is running continuously if i set the simulation time to inf, but i cannot view the o/ps from the signals, as it is changing very very fastly in the display block.
Is something to change so that the o/p changes after a finite time, so that it will be easy to view
Rahul kumar
on 5 Sep 2012
ya i connected with Scope block and saw, it gave a continuous triangular waveforms in scope 1 and it gave a continuous square waveform in scope 2.
Azzi Abdelmalek
on 5 Sep 2012
- Exactly. I can't explain the differents shapes, from the modlel: signal2=not(signal1), maby someone else can explain this.
- Now use "to workspace" block, you will observe that signal1= 1 1 0 1 0 1 and |signal2= 0 0 1 0 1 0 1 0 thats what we were looking for.
- Then try to use these signals and tell us what is the rsult
Rahul kumar
on 5 Sep 2012
Can u pls tell me where to view the output from 'To workspace' block
Azzi Abdelmalek
on 5 Sep 2012
you can view it on workspace, just set the parameters of "to workspace" blocks
- Variable Name = y1 for example for the first signal
- Save format to array
Rahul kumar
on 5 Sep 2012
Edited: Rahul kumar
on 5 Sep 2012
Ya i can view the output well in the work space as expected..!! thank you, can you please help me to view the the same output in a display block inside the simulink.. The outputs 1 and 0 should change afer a finite time (say 1sec)
As of nw it is changing very very fastly in the display block, i cannot view whether it is 1 0r 0 in the display block
Azzi Abdelmalek
on 5 Sep 2012
because you are not runing on real time
Azzi Abdelmalek
on 5 Sep 2012
Edited: Azzi Abdelmalek
on 5 Sep 2012
if you have a "real time windows target" toolbox, you can simulate on real time
Rahul kumar
on 5 Sep 2012
oh ok, So is it possible to do it on real time?
Azzi Abdelmalek
on 5 Sep 2012
Edited: Azzi Abdelmalek
on 5 Sep 2012
yes, if you are on 64 bit you can do it just on normal, the extarnal mode is allowed only on 32 bit (its more efficient)
Azzi Abdelmalek
on 5 Sep 2012
when I added 2 not blocks I 'm not getting triangular signal(above model)
Rahul kumar
on 6 Sep 2012
@azzi abdelmalek. hw to accept your answer?
Azzi Abdelmalek
on 6 Sep 2012
you can't accept two answers
TAB
on 6 Sep 2012
Edited: TAB
on 6 Sep 2012
I think the first output (trigger block 1) was showing ramp because it's type was double. Now after connecting to logical block (2 NOT blocks) output is as expected as is it converted to boolean.
Alternative of adding 2 NOT block is change the datatype of Constant block to boolean.
Azzi Abdelmalek
on 6 Sep 2012
Exactly, that what I was going to post. I set data type of a constant block to boolean and now it works. Thanks TAB
Rahul kumar
on 9 Sep 2012
hi i have another task also to do it
I am trying to convert a synchronous data flow graph into a synchronous block diagram in simulink..!
I have 2 blocks A and B with a FIFO in between them for buffer.
A has to produce 2 tokens in a iteration and 2 on the next. These 2 tokens from 1st iteration has to be stored in a block(FIF0 queue) and if it is reaches 3 ( on next iteration) it should trigger B
I need to figure a FIFO model with some specifications.
-FIFO register size 4, as we should store 4 tokens
-The criteria for firing of A (producing 2 tokens) is that there should be 2 free space at the head of FIFO
-The criteria for firing of B (consuming 3 tokens) is that there should be 3 tokens available at the tail of FIFO
Any ideas pls lets discuss!!
Thank you
Azzi Abdelmalek
on 9 Sep 2012
why do'nt you post it in another question?
Rahul kumar
on 9 Sep 2012
ya i posted bt no one commented.. so ly trying to get help from u
Rahul kumar
on 9 Sep 2012
Rahul kumar
on 10 Sep 2012
Any ideas azzi abdelmalek?
See Also
Categories
Find more on Schedule Model Components in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)