MATLAB Answers

0

How to generally use the stream input port in a real-time windows target model?

Asked by Jan Kappen on 10 Jun 2013
Hey guys,
I'm wondering, how I can use the stream input port (via a generic serial interface) in a real-time windows target model. The block needs a sample time, but my source sends asynchronously. So I use the data ready port to trigger a subsystem. I use a sampletime much higher than the signals can occur. This 'solution' works.
But if I plot the values I received there are of course a lot more points, each point for one timestep, although I only need the value at the time I receive the serial packet. So there are a lot more datapoints than I need, and this needs some memory.
So is there a way to handle a asynchronously data transfer to plot (and save) the data only, when there is new data?
Thank you very much!

  0 Comments

Sign in to comment.

1 Answer

Answer by Jan Houska
on 12 Jun 2013
 Accepted Answer

The approach you have chosen to receive the data is correct. As far as I know, you cannot do any better than sampling frequently and using the Data Ready port to detect asynchronous data arrival.
The data plotting and archiving feature of External Mode is designed primarily for regularly sampled data. If you wish to log asynchronous events, your best choice is probably to log all the data as you do now and then post-process the logged data to keep only those values where Data Ready is 1. If you are running out of memory during the logging, you can use the Data Archiving feature to log the data to disk and post-process the files containing logged data.

  1 Comment

Sign in to comment.