07-12-2016 04:10 PM
Hello!
Iam using the sbRIO-9627 with Real Time Linux.
I want to access external code i have written in Matlab on this embedded System within the Labview RT Software iam running on it.
I have to admit that i am a newbie concerning compiling C programms and integrating .dll/ .so into labview. On a Windows host i successfully managed to include the Matlab code using a dll file.
But i need to run the Matlab code on the RT Target.
Could anybody please explain how to compile C code (which i got from using the Matlab coder) and wrap it to a .so File and furthermore use it within Labview code?
I have installed the Eclipse 2014 mentioned in a couple of Knowledge Base Postings and compiled a .o file from my C code. But how to get the Library from this and how to put it on the RT target (i read about using ldconfig for instance, but have no clue what to do).
Thank you very mouch!
07-12-2016
06:02 PM
- last edited on
01-09-2025
10:03 AM
by
Content Cleaner
This may be a silly question, but do you have access to the NI Mathscript RT Module? This supports running computation-oriented .m files on RT.
If you create a project as a "Shared Library" type of project, this will handle compiling the .c file to a .o and finally to a .so file. There are many good examples out there, this guide is specifically for NI Linux RT: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000YGvGCAW&l=en-US
07-12-2016
11:41 PM
- last edited on
01-09-2025
10:04 AM
by
Content Cleaner
If you are using Simulink, another option is to use following SW package:
https://www.ni.com/en-us/shop/product/labview-model-interface-toolkit.html
that allows you to run the models created in Simulik and compiled by Simulink coder and Eclipse on LV linux targets.
CLA, CTA
07-13-2016
09:53 AM
- last edited on
01-09-2025
10:04 AM
by
Content Cleaner
Another option is the LabVIEW Control Design and Simuation Module because it comes with a simulation model converter (shows up under the tools menu in LabVIEW) that can import .mdl and .m files and automatically generate native LabVIEW models that can run on all of the NI real-time targets. It has been tested on general control systems and also on motor and hydraulic plant models.
05-01-2020
03:08 PM
- last edited on
01-09-2025
10:05 AM
by
Content Cleaner
Hi,
Here are steps that worked for me:
Step 1: Write your MATLAB code.
Step 2: Convert your MATLAB code to C (or C++, but better to be C because the Call Library Function Node in LabVIEW only accepts C code style, otherwise you need to do something like a wrapper). You can use coder in MATLAB to do so.
Step 3: Compile it using gcc. Reading the following link:
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000YHR7CAO&l=en-US
Step 4: Write a LabVIEW program to call Call Library Function Node. Configure Call Library Function Node properly. Copy the shared library to a folder in your sbRIO and set the path in Call Library Function Node. The path worked for me was: /home/lvuser.
Step 5: Run the program.
Bests,
-P