S-function sampling time, is it possible to use several sampling time ?

1 次查看(过去 30 天)
Hi all,
I'm working with a C S-function. I want to call two different function at fixe frequenties. One every 125.06 µs and one at 250µs.
I have tried setting several sampling times :
ssSetSampleTime(S, 0, CONTINUOUS_SAMPLE_TIME);
ssSetOffsetTime(S, 0, 0.0);
ssSetSampleTime(S, 1 , 0.00012506 );
ssSetOffsetTime(S, 1 , 0.0);
ssSetSampleTime(S, 2 , 0.000250);
ssSetOffsetTime(S, 2 , 0.0);
And to call the functions I've been using:
if (ssIsSampleHit(S , 1, tid ))
function1()
if (ssIsSampleHit(S , 2, tid ))
function2()
But this does work at all, has someone got any idea how I can do ? The ssIsSampleHit doesn't seen to detect the right times.
Thank you,
George

采纳的回答

Kaustubha Govind
Kaustubha Govind 2012-8-29
I don't have much experience with multi-rate S-functions, but I thought I would recommend that you look at the demo sfcndemo_sfun_multirate.mdl. Just type the model name at the MATLAB prompt to open it up:
>> sfcndemo_sfun_multirate
Hopefully the example will give you some tips about how to use ssIsSampleHit.

更多回答(1 个)

George
George 2012-8-29
Thank you. My example ahead dose actually work.

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by