How can write a pulse generator block with coding?

조회 수: 3 (최근 30일)
Seyedfoad Taghizadeh
Seyedfoad Taghizadeh 2014년 2월 3일
댓글: Mohamed Al-Hasheem 2014년 9월 27일
Hi,
I have to write a pulse generator block via coding in a "Matlab embeded function" I want to control the phase shift of the generated square wave signal continuously. It is not possible with the pulse generator block of Matlab simulatiom due to this block does not have external phase shift input signal. Therefore, I thought I could generate square wave via coding in a Matlab embeded function block. In the other word I wanted to create a pulse generator block which is able to control the phase externally. At the end I wanted to compile the simulation on a DSP board (F28335).
I used these codes to generate square wave signal in Matlab embeded function:
function y = fcn(t)
%#eml
h = sign(sin(125600*t));
y= (h+1)/2
Note that I connected the function block to a digital clock to provide t. I connected the digital clock to the pulse generator block as well. And also connected both output signals to "Digital Output" block which is considered by Texas Instrument Co. in Matlab.
Using two methods, (Pulse generator block and the embeded Matlab function block) I could generate two identical square waves in the simulation in terms of amplitude and frequency. But when I compile the simulation and transfer them to the DSP, only the square wave which has been generated by Pulse generator block was appeared on Oscilloscope. It means that the above codes do not do the same job the pulse generator block does.
Please let me know where the problem is that the embeded function operates exactly the same as pulse generator block in simulation but on hardware they have different behaviors? Whether the above codes are not complete or any thing else? If the first one is true, what codes I do have to add to create a pulse generator block manually,
Regards
Foad
  댓글 수: 1
Mohamed Al-Hasheem
Mohamed Al-Hasheem 2014년 9월 27일
Hi, Can you send the model to try solving it Regards

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

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