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

14 次查看(过去 30 天)
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

采纳的回答

Niklas Nylén
Niklas Nylén 2014-2-7
编辑:Niklas Nylén 2014-2-7
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 个评论
Seyedfoad Taghizadeh
Thanks a lot for the reply, It would be suitable for my system. However, I do not know how I can use these codes in order to create a delay block. Should I open a Matlab embeded function then I put the codes there? Please guide me,
Thanks

请先登录,再进行评论。

更多回答(2 个)

ES
ES 2014-2-7
When the external signal comes, do a
set_param(BlockName,'PhaseDelay',PhaseDelayValue);
  1 个评论
Seyedfoad Taghizadeh
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

请先登录,再进行评论。


Niklas Nylén
Niklas Nylén 2014-2-7
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 个评论
Seyedfoad Taghizadeh
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Sources 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by