LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programaticaly inserting block into block diagram.

Solved!
Go to solution

Hello 2 all !

 

I'm wondering if there is a way to programaticaly insert a new block into a existing block diagram.

 

Take a look at the attached vi to see what i mean.

 

So...when i click a picture the corresponding function is inserted into the block diagram, having as inputs the two controls.

 

Is there a way to achive this or this is just wishfull thinking ? :))

 

Thank you very much !

0 Kudos
Message 1 of 17
(3,177 Views)
Solution
Accepted by topic author AndreiN2014

It is possible to programatically manipulate the block diagram by obtaining a reference to it, and operating on it with the use of property and invoke nodes. This is called VI scripting. You can only write code that utilizes scripting in LabVIEW 7.1, but it can be imported into newer versions of LabVIEW. This feature is unsupported by National Instruments. Being that it is unsupported, I would not recommend looking into it if you're developing code for a customer.

 

This should get you started:

http://forums.lavag.org/VI-Scripting-Readme-First-t1207.html

 

http://forums.lavag.org/LabVIEW-VI-Scripting-f29.html&s=3fea8247be8d214406abf99a30e64e94 is a forum where you can ask about scripting, being that it is pretty much undocumented.

 

Welcome to the dark side, good luck on your journey, and watch out for the rusty nails as you rummage through NI's attic. (lol sry, feeling nerdy on my lucnh break)

Message Edited by sgregor249 on 03-25-2009 11:37 AM
Message 2 of 17
(3,168 Views)

Andoro wrote:

So...when i click a picture the corresponding function is inserted into the block diagram, having as inputs the two controls.


You have contradicting requirements. on the front panel it says: " So...i want that when i click one of these pictures, the corresponding logic function is executed."

 

That's very different. The first is an editing operation, changing the code, the second is just alternative execution paths depending on inputs during thr run. Since it seems you simply want to decide at runtime which calculation takes place, all you need is to make the two pictures as buttons and a case structure that executes one or the other function.

 

You can import the two images on buttons (e.g. one on the TRUE face and one of the FALSE face, or you could make a radio button control having the two buttons) and connect their output to the case structure. Add some code (e.g. an event structure in a while loop) and you're all set.

 

Please let me know if I misunderstood. 😉

Message Edited by altenbach on 03-25-2009 10:00 AM
Message 3 of 17
(3,151 Views)

You could even make the calls dynamic using VI Server.

Browse through a specified directory, having a picture and a vi with fixed Connector panes for each function and load it.

With recursion and a tree control you can even write a logic programming enviornment with reasonable effort.

 

<whisper>

No need to play with those dark powers, rumours say that you might see scary things looking like the intestines of a vi torn apart. They are called something similar to 'external entities' and are believed to live hidden on your function palette.

So if leaving the orange crowd protected by the blue guards, prepare for some nightmares...

</whisper>

 

Felix

Message 4 of 17
(3,124 Views)

Hi Felix,

 

LOL - funny whispering Smiley Wink

 

<whisper> So if leaving the orange crowd protected by the blue guards, prepare for some nightmares..</whisper> 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 17
(3,094 Views)

Ok....thank you 4 all your answers.

 

First of all let me clarfy a little bit what i'm trying to do.

 

I want to build the LabView equivalent of the following simple ladder diagram program:

 

Ladderdiagram -  test program

 

And since i have available only LabView 8.2. and don't have the new ladder kit enhancement, i want to build a small test program.

 

I know (basicaly) how to do such a thing in C++ but i'm more interested if it could be done and how in LabView.

 

Any opinions/ ideas ?

 

Thank you very much for your patience and interest ! 🙂

 

 

0 Kudos
Message 6 of 17
(3,072 Views)
We cannot see your image. Please attach the image directly to a post so it resides on the NI servers.
Message 7 of 17
(3,034 Views)

Having seen the picture when it was available, it still wasn't clear to me what you want to get. Maybe you could write down some specs.

Furthemore, point out wich are the unresolved issues for you (GUI, recursion, parser?).

 

If you want a simple tester/simulator and not a source code generator, you don't need to get into that 'dark side' thing.

 

Just to point you to some general concepts (this works on 7.1., I'm not sure if still in 8.2), you can open some of the VIs in your function palette (those with white icons). The xml operations show recursion with VI Server. Also there is a formula parser left open, that could show you some implementation of such things in pure G. For recursion, there was a signicant improvement going on during the 8-generation, so you should look up in the help and the example finder of LabVIEW about that topic.

 

So the basic concept would be to translate the input ('picture') to a tree or graph data structure, and from this data structure you can go on execution.

 

As LabView doesn't allows you to shoot around with pointers, the dynamic and recursive things are a bit of a hassle. So the more constraints you could put on the specs e.g. 'max/const number of steps' or 'each stage has two inputs', the more easy things will wire.

 

Felix

Message 8 of 17
(3,007 Views)

First of all ... thank you 4 your interest in this matter.

 

I've attached another example of what i'm trying to do.

 

As u can see in the attached picture, it is not only a question of boolean logic.

 

So.... let's say that we have a simple setup for starting a motor.

All we need is 1 start button, 1 stop button and a contactor. I'm using the contactor auxiliary to mantain power supply to the coil even when the start button has returned to his initial state.

Let's say that the start and the stop button can be easily represented as 2 booleans.

The boolean equation is  : (stop_button) & ( (start_button) | (contactor) ) = energized CONTACTOR coil.

My question is this :

As u can see in the picture, the auxiliary contact is "in paralel" with the start button. How can i achive the logic operation "OR" programaticaly, by "dropping"  the control in place ?

 

Hope it makes sense. :smileywink:

 

Thank you very much !

0 Kudos
Message 9 of 17
(2,977 Views)

And another thing .... my aim in at this time is to make a simple ladder simulator.

 

In the future i plan to make a compiler but this is along way for me because i'm still learning how to use labView.

0 Kudos
Message 10 of 17
(2,974 Views)