1

What I'm doing is a real-time application for visual servoing that needs to read an X and Y values of a coordinate during running time. As the simulation runs, these values are changed in time by a Python Script and then, I need to read every n milliseconds (say 20ms) this changing values in Simulink to move some DC motors based on the said (X,Y) coordinates.

To sum up, what I need is how to read in run-time values from an external file in Simulink. I could be a .txt, or any other kind of file but it has to read the changing values in real-time.

I'd totally appreciate your help!

I've tried to read a .txt file from a user-defined simulink block, but the functions I used are not supported in simulink, like fscanf.

  • 1
    Note that Simulink running on your PC is not a real-time application and is unlikely to give you (and certainly cannot guarantee you) processing times in the 20ms range. If you are happy running in non-real time then you can use the `MATLAB Function` block to write a custom file loader, defining the unsupported functions as `coder.extrinsic`. If you intend using Simulink Coder and running in real-time on at RTOS then you'll need to write your loader as a `C-code` S-function, and also write an associated TLC file for it. – Phil Goddard Jul 29 '19 at 18:38
  • While compiling my simulink model I get the error msg: "The extrinsic function 'fscanf' is not available for standalone code generation. It must be eliminated for stand-alone code to be generated. It could not be eliminated because its outputs appear to influence the calling function. Fix this error by not using 'fscanf' or by ensuring that its outputs are unused. Function 'MATLAB Function1' (#24.149.155), line 8, column 15: "fscanf" " – Alejandro Hernández Villa Jul 29 '19 at 22:59
  • 2
    As per the last sentence of my previous comment: If you intend using Simulink Coder and running in real-time on at RTOS then you'll need to write your loader as a C-code S-function, and also write an associated TLC file for it. – Phil Goddard Jul 29 '19 at 23:45

0 Answers0