Continuously read from workspace using Real-time workshop

Discussion in 'MATLAB' started by Leo Steenson, Sep 20, 2010.

  1. Leo Steenson

    Leo Steenson Guest

    I have built a control system for a robot using matlab simulink and the real-time workshop, which all works great. However I have a C++ program which does our vision processing and I would like to get the processed data into the matlab real-time system.

    One approach I am trying at the minute is to use the Matlab engine library to send the variables from the C++ program into the matlab workspace. This currently works, but I don't know how to then read the variables from the workspace into the real-time system continuously (not just at the beginning). I have tried using the 'from workspace' block without success.

    Is what I am attempting possible or am I going the completely wrong way around this problem?

    The basic objective is to stream data from a C++ program into the matlab real-time system while it is running, so if there are better methods of doing this I would appreciate the advice.

    Thanks in advance.
    Leo
     
    Leo Steenson, Sep 20, 2010
    #1
    1. Advertisements

  2. I seem to recall there is a Simulink UDP or TCP block that can be used with RTW.
     
    Walter Roberson, Sep 20, 2010
    #2
    1. Advertisements

  3. Leo Steenson

    Leo Steenson Guest


    Any recommendations as to how to send UDP packets using C++? The Matlab receiving side seems straight forward enough but the examples I find online for the C++ side all seem overly sophisticated for all I need.

    All I need to do is pass four integers over from C++ to matlab RTT. Thanks again.
     
    Leo Steenson, Sep 21, 2010
    #3
  4. It has been several years since I last did that kind of thing. It
    involves several steps.

    Generally speaking, UDP packets can be sent with fewer calls than are
    needed for TCP, but if you send UDP using those short-cuts then I
    believe the UDP has to be received with the same kind of short-cuts; as
    it seems unlikely to me that Mathworks would have implemented both kinds
    of receiving, it seems more probable that you would have to go through
    the more detailed steps, a sequence that would look nearly identical to
    the set up required for TCP.

    The work is less if you use a numeric IP address rather than looking up
    a host name... but of course using a numeric IP address is less flexible
    in the long run.

    The O'Reilly TCP/UDP book is pretty good.
     
    Walter Roberson, Sep 23, 2010
    #4
  5. Hi Leo,

    Did you find the solution for you problem. I am actually trying to do the same thing. I am trying to send some numerical variables from C++ to UDP and import them in Matlab in real time. I cannot find good c++ examples. I would appreciate if you could give me an advice how to solve this issue.

    Thanks,

    Boris
     
    Boris Skopljak, Feb 14, 2011
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.