Does Simulink Desktop Real Time (SDRT) Build code is same as "C" code build by Simulink Coder in "Simulink"

7 visualizaciones (últimos 30 días)
I designed MPC controller in simulink and then generated c and s function using simulink coder and embedded coder.
My pupose is to deploy this MPC controller in real time. for this I found that SDRT is used which uses laptop processor and memory and it is the only feasible option for me rightnow.
Howere upon reading the documentary of SDRT I found that I can't use S-Function in it, and I need to use Build for generating code.
However I have tested s-function against the MPC simulink block and find out that s-function run super super faster than MPC Simulink block now I want that when I deploy on the hardware using SDRT I could get same speed as s-function.
BTW for SDRT, I used the MPC Controller Simulink block in the SDRT and then Build >> Deploy >>> Connect >>> Start
It executed but I am not sure about the speed, how to check, but I think it was very slow like MPC block simulink.
Please let me know how can I speed up the real time simulation. Currently I haven't deploy it to hardware because I am facing following error

Respuestas (1)

Hassaan
Hassaan el 16 de En. de 2024
Simulink Desktop Real-Time (SDRT) and Simulink Coder (formerly Real-Time Workshop) are both tools used for different purposes in MATLAB and Simulink environments, and they handle code generation differently.
  1. Simulink Coder (including Embedded Coder): This tool generates C and C++ code from Simulink models, which can then be used for embedded systems and other applications. The code generated is optimized for performance and can be customized for specific hardware targets. It supports S-functions, which are a powerful way to extend Simulink's capabilities.
  2. Simulink Desktop Real-Time (SDRT): SDRT, on the other hand, is designed to convert your Simulink models into real-time applications that run on your computer. It's typically used for hardware-in-the-loop (HIL) testing, real-time simulation, and prototyping. SDRT uses your computer's CPU and memory to execute the model in real-time. However, it has limitations in terms of compatibility with certain Simulink features, like S-functions, as you noted.
Regarding your specific situation:
  • Performance Difference: The S-function you created with Simulink Coder is likely highly optimized, which is why you're seeing faster performance compared to the standard MPC Simulink block. When using SDRT, the code might not be as optimized as the S-function, leading to slower execution.
  • Deploying with SDRT: To maintain high performance when deploying with SDRT, you need to ensure that the model is as optimized as possible within the constraints of SDRT. This might involve simplifying the model or finding ways to optimize the MPC Controller Simulink block for real-time execution.
  • Checking Speed in SDRT: To check the execution speed in SDRT, you can use real-time monitoring tools in MATLAB to measure the time taken for each step or execution cycle. This can help you compare the performance with the S-function.
  • Error with NI USB-6363: The error you're encountering with the NI USB-6363 in SDRT seems to be related to port widths or dimensions. This might require specific troubleshooting, often involving checking the configuration of your model, compatibility with the hardware, and ensuring that all dimensions and data types match what the hardware expects.
For speeding up real-time simulation:
  • Optimize Your Simulink Model: Simplify the model where possible, and use fixed-step solvers that are suitable for real-time simulation.
  • Hardware Considerations: Ensure that your hardware (in this case, your laptop) has sufficient resources and is configured correctly for real-time execution.
  • Model Configuration: Check all model configurations and parameters for real-time execution, ensuring they are set for optimal performance.
  • Consult MATLAB Documentation and Support: Given the complexity of your issue, consulting MATLAB's documentation or seeking support from MathWorks might provide more targeted solutions, especially for the specific error with NI USB-6363.
Remember, transitioning from a simulation environment to a real-time environment often requires significant adjustments to ensure optimal performance.
------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering
Feel free to contact me.

Categorías

Más información sobre Simulink Coder en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by