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

8 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Niklas Nylén
Niklas Nylén il 7 Feb 2014
Modificato: Niklas Nylén il 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 Commenti
Seyedfoad Taghizadeh
Seyedfoad Taghizadeh il 7 Feb 2014
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

Accedi per commentare.

Più risposte (2)

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

Accedi per commentare.


Niklas Nylén
Niklas Nylén il 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 Commento
Seyedfoad Taghizadeh
Seyedfoad Taghizadeh il 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

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by