Clear Filters
Clear Filters

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

1 view (last 30 days)
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

Accepted Answer

Kaustubha Govind
Kaustubha Govind on 29 Aug 2012
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.

More Answers (1)

George
George on 29 Aug 2012
Thank you. My example ahead dose actually work.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!