xPC stream values from memory during run

조회 수: 4 (최근 30일)
Istvan
Istvan 2014년 3월 21일
답변: Istvan 2014년 4월 16일
Hello,
I would like to stream values one by one each time step in an xPC model, just like a "from file" block would do, but from memory instead. The "constant" block can get a vector but puts out all at once....
Say, if there was something where I could upload datat to in the memory of the target and then replay them point by point each timestep during the run, that would be perfect.
The issue came up as I am already using a "to file" block to log massive amounts of data. Now if I also use a "from file" block, the values streamed from file are not fluent: sometimes a value is kept for several dt, as if the file ended (which is not the case) and than updating resumes. The holding time is the typical hard-disk rotation time... so I guess having both blocks is not wise. Increasing buffers does not help.
Thanks for suggestions!

답변 (3개)

Suneesh
Suneesh 2014년 3월 21일
You may be looking for the 'From Workspace' block. Although you would have to enter the values themselves into the block instead of using a workspace variable as the MATLAB workspace is not relevant on a target.
  댓글 수: 2
Istvan
Istvan 2014년 3월 25일
I have tried that block, but I did not manage so far:
1) to use it, the Data field must be filled before compiling the model - and it must be filled with like a million data points. Of course I can use set_param( myModelName/myFromWS, 'VariableName', myData);, where myData is of [time1, value1 ; time2, value2 ; ... ; timen, valuen] type.. but obviously this is an overkill for the block..
2) I must re-compile the model each time. I would like to set the values as a parameter, to the existing model already on xPC, like: tg.setparam(tg.getparamid( 'OutVal', 'Value') ,outvoltage); would be for a "Constant" block. The "From Workspace" block does not have its data field accessible as a parameter...
Would you know a work-around or an alternative?
It seems to be a trivial problem, yet tricky....
Thank you for your help!
Istvan
Istvan 2014년 3월 26일
Anyone any ideas?

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


Rajiv Ghosh-Roy
Rajiv Ghosh-Roy 2014년 3월 21일
You could use the "From Workspace" block from Simulink/Sources. On generating code, this will cache the values in memory and then output them one at a time.
  댓글 수: 2
Istvan
Istvan 2014년 3월 25일
Thank you! Actually your answer is similar to the above one. I commented there on some difficulties...
Rajiv Ghosh-Roy
Rajiv Ghosh-Roy 2014년 3월 26일
You can use the From Workspace block with a variable (e.g. a time series object). However, you are probably right about the tunability. Your other option is the Lookup table block (e.g. 1-D lookup table) with time as an input. This should be tunable, but the new values must of course have the same dimension as the old ones.

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


Istvan
Istvan 2014년 4월 16일
Thanks for all your answers!
So, after quite a bit of investigation... the answer is: there is no such element. The only true way is writing an S-function that loads values into memory on the model initialization phase.
A work-around might be a from file block with a large buffer size... but this might cause trouble if also to file blocks are present due to slow disk access.

카테고리

Help CenterFile Exchange에서 Event Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by