Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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

Akzeptierte Antwort

Kaustubha Govind
Kaustubha Govind am 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.

Weitere Antworten (1)

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

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by