LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a LabVIEW-built DLL in LabVIEW - is this the correct set of instructions?

I will check these out soon...but keep in mind the last bullet of the first link addresses the situation where one is showing the front panel of the called DLL (which by the way I did not know one could do), and if one's system is crashing, rather than hanging.  I am not showing the DLL front panel (have to learn how to do that because it could be a great idea for this application) and my run is not crashing, only hanging.

My code overall is not that complex but does involve a number of matrix math operations.  I am starting to wonder if memory allocation could be the issue.  But if so, I would have expected a crash and not a hang.

Sincerely,

 

Don

0 Kudos
Message 11 of 19
(1,773 Views)

I have some updates on this topic. In the original code, I operated on input 2d arrays that produced output 2d arrays. I revised my LabVIEW-created DLL to read in .bmp images from a folder on disk, and to write out .bmp images to disk in place of these arrays.  This strategy worked fine in the sense that I was then able to place the dll on a LabVIEW block diagram, configure it, and test it successfully.

However, then I went back to see what would happen if I produced an array of 2d arrays (3d array) rather than a set of .bmp images as the output.  During testing/running of the dll within LabVIEW, I get an exception occurring within the node.  I am attaching a screenshot that shows how I configured the DLL prototype, and then configured the call library function node.  Is there a logical explanation as to why such an array is creating trouble?  What is the workaround?  Does the fact that it will not successfully run in LabVIEW mean that it definitely will not run within another programming environment?

Thanks,

Don

0 Kudos
Message 12 of 19
(1,751 Views)

ps. I am looking for a guinea pig to integrate the working DLL into c++.  In trade for testing and documenting how you did the integration, you get to keep the DLL which calculates the principal component images for a time-series of images.  Here is the zip file containing all of the necessary files (such as .h file) and also an example time-series of images.

"This DLL calculates Principal Components (PCA) Images and stores them as .bmp images to disk. It is fairly rapid.  Specify:

 

1)       the folder location of the I vs. t .bmp images (char string)

2)       the starting frame #  I vs. t .bmp image to use in the analysis (I32)

3)       the ending frame #  I vs. t .bmp image to use in the analysis (I32)

4)       the number of principal component images to calculate (I32)  

 

I save the PCA images in the same folder as the original I vs. t bitmaps are stored.  I name them *_PCA.bmp with * being equal to 1 to n where n is the number of PCA images you have chosen to calculate."

 

Thanks,

Don

0 Kudos
Message 13 of 19
(1,739 Views)
Don,

One possible reason why LabVIEW is crashing when you call your dll is because you don't have "ImageArrayOut" wired on the left side of the Call Library Function node.  When you call a dll you must first allocate the necessary memory for any input or output parameters to ensure that the external code doesn't overwrite LabVIEW memory.

The error message you posted is typically what happens when a dll reallocates memory that LabVIEW was using.

Try initializing an array of the appropriate size and data type in LabVIEW and wiring it into the left side of the Call Library Function node.

Regards,

Simon
0 Kudos
Message 14 of 19
(1,720 Views)
 

Tried and received only 1 value back at first array position of 3d array.  At least did not crash. Not sure why entire array not filled. I initialized the array using 200 x 200 x 10 positions which would be a little larger than necessary....Don

 

ps. for those wanting to test working DLL in c++, you need LabVIEW 8.2 run-time engine if you do not have LabVIEW 8.2

0 Kudos
Message 15 of 19
(1,705 Views)
Don,

Did you get an error or warning when your dll ran?

Does the VI itself run successfully when you pass it the exact same inputs?

It seems strange that external code would exit prematurely without throwing an error. 

~Simon
0 Kudos
Message 16 of 19
(1,685 Views)

The VI itself does not need a preallocated array.  It just forms the array it needs via autoindexing on the outside of a for loop.

Right now, it seems the best thing to do is stick with my working code.  But I sure would like to figure out how to work with multiple-dimension arrays in DLLs since they cannot be passed by value.  I am sure it is something basic I am doing wrong having to do with how memory must be allocated and how the arrays are passed back into LabVIEW.  I have read almost all documentation in LabVIEW related to formation and use of DLLs, though, plus the tips you have provided (some of which have been confirmed by the docs) but the solution has not hit me yet.  Probably the best strategy will be to keep building very simple examples until the lightbulb goes off.  Or maybe someone else has had success with building DLLs having multi-dimension arrays as outputs.

 

Sincerely,

 

Don

0 Kudos
Message 17 of 19
(1,677 Views)
Hello

I need some help with regard to calling a LabVIEW-built DLL in LabVIEW.

I have created a vi in LabVIEW. I made the DLL for this vi. I called this VI as a re-entrant in another vi.

This vi(calling DLL) has been working fine till yesterday. Since yesterday, it started crashing LV.

I need some help in this regard.

I am attaching the screenshots of the Application Builder configuration window, the B.D of the vi using DLL and that of the configuration window which pops up when i call the DLL.

I made a vi which performs FRA. I built its DLL.
I have around 10 inputs. I output 3 one-dimensional arrays, and a string from the DLL.
When i build the DLL, the builder defines the outputs 'gain', 'phase' and 'frequency' as arrays of 8-byte double.
When i call this DLL in my vi, the configuration window sets them as 'numeric' outputs.

Why does this happen? What is the solution to this?

When i try to set them as 'array' in this configuration window, i get a warning that i am trying to change the data types which do not match with the data type found in the DLL.

Is this the problem with my code or with the Application Builder?

Now, after i change the 3 output datatypes to Arrays, and set their minimum length(i assumed that this value means the size of the array ), the vi runs and crashes LV. I am nto sure when it crashes, why it crashes. It runs fine at one time. It crashes at another time. I am nto sure if these arrays are teh reason why LV crashes. If that is the erason, why is it happening only sicne yesterday and not earlier?

Also, the string output can is a maximum of 412 characters. Will this play a role in LV crashing?

Kindly someone help me!!

I have checked multiple times for the data types of the otehr inputs and ouputs. My only doubt is on these arrays.


Download All
0 Kudos
Message 18 of 19
(1,402 Views)
Hi,

Do you know if anything changed in the past couple of days since this problems started happening? Do you get some error code when LabVIEW crashes or when you open LabVIEW again?

You mention that you are also having problems getting the data type to match the datatype of the DLL, was this also the case when the program was working?

Have you tried selecting Adapt to Type as the datatype in the configuration of the call library function node? If this still doesn't work I would try re-building the DLL again.

Let me know how it goes.

Eli S.
National Instruments
Applications Engineer
0 Kudos
Message 19 of 19
(1,336 Views)