LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Exporting a LV VI containing clock cycle loop in Python via DLL with the ability to change inputs / read the outputs

Solved!
Go to solution

Hello,

 

I want to export a LV model that makes a continuous process task (with 10 ms clock cycle) in Python with deriving a DLL from a LV virtual instrument. It should have a pre-operate inputs (like the clock cycle input shown in example fig.), but also the dynamic inputs / outputs that should be updated / read in each clock cycle (like signals “ein” and “aus” shown in the example fig.).

 

I thought about removing the loop and calling the DLL function in each clock cycle, but then I have problems with the memory registers like the “Feedback Nodes” because, AFAIK, they would then be again and again reinitialized and therefore useless.

 

So I would ask if somebody could have some ideas and could give me some useful hints. I attach a figure and the data of the example LV project that is a simplified prototype of what is to be implemented in Python via DLL. Once again, the problem is how to make the dynamic change of the DLL inputs / dynamic read of the DLL outputs for the LV DLL function possible.

 

With thanks in advance, Ivan

Download All
0 Kudos
Message 1 of 4
(2,612 Views)

First at all, welcome to the NI Forums Board!

 

If I did get you question right, you search for a way to save the values in the while loop for the next iterations or the next function call.

 

There is a functionality in LabVIEW which does that: It is called the functional global variable.

It is explained here: http://labviewwiki.org/Functional_global_variable

You are right, if you initialize the register, it is initialized every time. You can avoid that, if you build a sort of statemashine, with an not initialized register. If you want to initialize you simply call an initialize case.

Johannes

Message 2 of 4
(2,577 Views)
Solution
Accepted by topic author iv.dom

Hello Johaness,

 

thank you for your post.

 

I already found the global variable solution quite a handy. I'm using it to do the thing by starting the loop with the main VI, and than periodically writing inputs / reading outputs with calling the auxilary VI-s as functions in each time-step. I'm doing that with the Programming / Structures / Global variable blocks which make the VI with the global memory variables which can be called from any VI in project for read or write. That does the trick for me...

0 Kudos
Message 3 of 4
(2,565 Views)

Also to mention if somebody would need this method, if the Labview loop contents with the feedback nodes are being imported without the loop in a DLL and called each T ms (from the Python) the feedback nodes do not reinitialise in each time step, but only on the first, and after releasing and reretrieving the DLL handle. So the best solution for my problem was to implement a VI with the loop contents without the loop and to call it as a DLL function iteratively with the time.

0 Kudos
Message 4 of 4
(2,539 Views)