How can control the phase delay of the signal generated by "Pulse Generator" block externally?

8 views (last 30 days)
Hi friends,
I want to generate a square wave by using pulse generator block in simulink where phase delay is coming from an external source. As you know the phase delay of the output signal of this block can be set internally. Is it possible to control the phase delay of this block by a external signal?
Regards Foad

Accepted Answer

Niklas Nylén
Niklas Nylén on 7 Feb 2014
Edited: Niklas Nylén on 7 Feb 2014
If you have a limited range of number of samples that your signal should be delayed you could build a block for variable delay using a number of unit delays and a multiport switch. I have attached a model which could handle between 0 and 10 samples of delay (although I have not verified it more than that it is simulatable).
  2 Comments

Sign in to comment.

More Answers (2)

ES
ES on 7 Feb 2014
When the external signal comes, do a
set_param(BlockName,'PhaseDelay',PhaseDelayValue);
  1 Comment
Seyedfoad Taghizadeh
Seyedfoad Taghizadeh on 7 Feb 2014
The external signal comes from a "Matlab Embeded Function" block. Where should I write this command (set_param (BlockName,'PhaseDelay',PhaseDelayValue);)? Do I have to make another "Matlab Embeded Function" block between the first block and the "pulse generator" block and write this code into that? and then I should connect the output of the new "Matlab Embeded Function" block to pulse generator block?
Please make it clearer for me how I should implement it.
Highly appreciated.
Regards Foad

Sign in to comment.


Niklas Nylén
Niklas Nylén on 7 Feb 2014
If I understand your question correctly it could probably be solved by placing a "Variable time delay" block after the pulse generator block and connect the external source to that block.
  1 Comment
Seyedfoad Taghizadeh
Seyedfoad Taghizadeh on 7 Feb 2014
Thanks a lot for your reply, Actually, due to I want to compile the file on a DSP(F28335), I have to use discrete-function blocks. According to your suggestion I used "Discrete Variable Time Delay", and I connected the output signal of "pulse generator" block to the input port of this block. In the simulation the signal was shifted properly, but as this block is a non-inlined s-function, my compiler didn`t accept it.
Hence, please let me know how I can use the set_param command to shift the output signal of "pulse generator" block. I think it works.
Highly appreciated for taking your time,
Regards Foad

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!