LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Transfom simulink block into Labview VI

Hi,

i work on project that consists in programming a tool to transform a block diagram in the *.mdl file to a block diagram in LabVIEW. The goal is to use its inputs and outputs in the front panel by manipulating "Controls" and "Indicators".

I start with exploring the Simulation Interface Toolkit but i think i'm in the false way because i don't need to simulate the behavior of the block diagram!! I just need to transform it from Simulink file to LabVIEW.

Any idea or suggestions!!

Thx for your response.

0 Kudos
Message 1 of 11
(4,245 Views)

Wow,

 

this is really a great ambition. The correct tool ("competative") for Simulink would be the NI LabVIEW Control Design and Simulation Module.

You would use LV Scripting to generate a blockdiagram reflecting the content of the simulink model.

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 11
(4,239 Views)

Thank you for help, but i'm lost!!

can you explain more how can i start!! What functions from this toolkit should i use!!

Have you an example for tranformation of a simple block in simulink (sum, switch..) into a blockdiagram in LV!

thx

0 Kudos
Message 3 of 11
(4,233 Views)

Hi wad,

 

that really is a big challenge!

- First you need a tool (or the knowledge) to parse the mdl file to know it's contents (and it's corresponding "block diagram").

- Then you need the knowledge to create VIs by using LV scripting. That's a  topic for advanced LV programmers...

- Additionally you need the knowledge to choose the corresponding LV functions for each Simulink function block. Probably more than often you will not find a one-to-one translation...

 

Start on your own. I doubt there are many people doing such tasks before or after you.

But it will be a great source of learning internals of both programming environments for you! 🙂

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 11
(4,226 Views)

There is no "transform", at least i am not aware of any tool capable of doing this. From my understanding, that is the reason why you are approaching this task.

And as i already mentioned: This is a very complex and not-easy-to-solve task. I find it possible, that you have to schedule more than twelve "mythical man month" for this task.

 

That being said, the tools and steps you require are:

1. Analyze the Simulink Model programmatically. If there are any questions on tools/processes, you have to ask MathWorks.

2. Translate the model into LV code. You will have to use VI Scripting to create new VIs and place appropriate function blocks (from the Control Design and Simulation Module and other sources) and connect them.

Note that VI Scripting is not supported by normal NI support channels as it is a LV Labs product.

3. Verify correctness of the LV code as well as code quality. You can use VI Analyzer for some of those tasks.

 

The biggest concern about this kind of application:

How should the Simulink model to be modularized within different subVIs?

How can you make sure, that those VIs do fit together and are called correctly from a calling VI?

How do you make sure that timing constraints are kept?

What is the platform the LV application is going to run on?

 

Therefore, i rather suggest you a different, maybe less worksome approach:

Use the models as are and include them in LV code.

  • You have to use LabVIEW MathScript RT as module if you have to include m-files.
  • If you require the model itself to run in LV, LabVIEW Simulation Interface Toolkit (SIT) is exactly what you need (which, i understand, you already have available). The SIT toolkit is NOT designed to "transform" the model, it simply embeds it in LV code.

 

hope this clears up things,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 5 of 11
(4,220 Views)

Thank you for your help and your details Smiley Wink

If i understand, it should be an impossible mission as i'm a begginer in LV world Smiley Tongue . So i will search an other solution and an other way.

Actually, the purpose of my project is to design a tool to facilitate the work of my teammates.

Infact, the user upload the *.mdl file which will be transformed into a the VI, then we can use the Unit Test Toolkit to perform unit tests. This is the main idea.

So have you another idea how can i process to do that!!

Thank you for your collaboration.

0 Kudos
Message 6 of 11
(4,213 Views)

I am really confused about the aim of the project. You say that fellow developer work with Simulink to create models (for what?).

You want to convert those models *somehow* to LV code which is going to be tested for functionality with the LV Unit Test Framework.

 

So my conclussion:

  • The LV code will only be used for verification purpose
  • The model will still be used as Simulink model

 

My questions:

  1. Why would i burden myself converting sources from tool A to tool B to make a verification within B; but i still only use A later on in my project? Does that really make sense?
  2. What if the conversion tool introduces errors which are not present in the original sources?
  3. What if the conversion tool removes errors during conversion?
  4. What if verification of B fails? What are going to change about A? Do you get appropriate information about WHAT IS WRONG in A by such an approach?

 

Coming to the bottom line:

Why are you not searching for a "model verification tool" directly for Simulink?

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 7 of 11
(4,207 Views)

The LabVIEW Control Design and Simulatio Module has a tool (Under the Tools menu >> Control and Simulation) that allows you to convert .mdl files into Control and Simulation diagrams in LabVIEW. I would strongly recommend trying this route first before trying to script all in pure LabVIEW code.

 

For more information, search for Simulation Model Converter in the LabVIEW help with the LabVIEW Control Design and Simulation Module. It is also available online:

 

https://www.ni.com/docs/en-US/bundle/labview-control-design-and-simulation-module/page/lvsimconcepts...

 

Note: This module is additional to LabVIEW and, if you are academic user, in general your license already have this option.

Barp - Control, Simulation, RTT and HIL - National Instruments
Message 8 of 11
(4,193 Views)

To :

 

I should developp a tool with LV that makes a unit test on a blockdiagram in simulink.

This is the main idea!!!

The tool should has as input the *.mdl file and generate a report witch contain the resluts of the unit test passed on every block of the simulink blockdiagram.

How can i do that!!

 

Thx

0 Kudos
Message 9 of 11
(4,186 Views)

wadjabh wrote:

I should developp a tool with LV that makes a unit test on a blockdiagram in simulink.

This is the main idea!!!

The tool should has as input the *.mdl file and generate a report witch contain the resluts of the unit test passed on every block of the simulink blockdiagram.

[..]


You should ask MathWorks if there is such a tool available.

Thanks Barp for clearification about the conversion tool. I wasn't aware of that 🙂

So essentially, wadjabh, you can use that tool to get a bunch of LV VIs. I am not sure how easy it will be to test those with the Unit Test Framework though.

Even if its possible, i doubt that this is worth the effort since the result refers to the LV code, not the Simulink model.

 

So you have to decide weather or not you put faith into the conversion tool for a verification process of your model.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 10 of 11
(4,180 Views)