LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Import Shared Library Doubles Array Length

Hello Forum,

 

I was creating a VI using the Wizard from a DLL I created to do some external computations. Everything seemed to work fine until I saved the results from the functions to a CSV.

 

There were 128 data values per sample when there should have been only 64. The last 64 values were all zero. I thought it had to do with how I initialized an array or some improper indexing in my code. Then I opened the VI's created by the wizard and double-clicked the "Call Library Function Node" and noticed that all the "Minimum size" fields had been doubled from the value I input in the wizard.

 

You can see this in the attached image. I gave EEPROM data a length of 248 in the Wizard but looking in the node it was 496.

 

I fixed all the Minimum size fields for all my functions and everything was output correctly.

 

If someone could give me an idea of what I might be doing wrong or what might be going on that would be greatly appreciated!

 

Thanks

 

Lodo

0 Kudos
Message 1 of 7
(3,819 Views)

Hello iamojuve, 

 

I am not sure why you are seeing these results. When you drop down the "Minimum size" field in the screenshot you provided what do you see?

 

If you change this number and click "OK", do you still see the same results when you run your program?

 

To better understand what your VI is doing, could you provide screenshots of the code on your block diagram?

 

Best, 

Danielle

0 Kudos
Message 2 of 7
(3,740 Views)

Thank you very much for your reply Danielle.

 

When I click the "Minimum size" field in the drop-down menu the only item in the list is "<None>". Fortunately the answer to your next question is that when I changed the value in the field and clicked okay my code worked as I expected. For example, the text file written in the VI in the second attached file contains 64 elements per line instead of the incorrect 128 that were in each line (each sample from the thermal sensor) before I found the Doubling error.

 

You can see in the first screenshot the VI of the imported DLL function calculateTo. This calculates the object temperature given an imput of 256 bytes that are the calibration data of the thermal sensor, 128 bytes (a high and a low byte per pixel since there are 64 pixels in the sensor), 9 precalculated float constants, 5 precalculated int constants, and 2 more bytes each for a pixel compensation offset and sensor temperature (CPIX and PTAT). If you want you can try to import the DLL. I have attached the DLL, its header file, and the two other headers it requires in the MLX90621.zip

 

I know it takes a little while to import the DLL so no worries if you can't but it would be interesting if you get the same doubling of whatever size you define the array to be while using the wizard. I have indicated what I mean with the red arrow in the last image.

 

Thank you again for your help!

 

Lodo

0 Kudos
Message 3 of 7
(3,728 Views)

Sorry it did not allow me to attach the files in the .zip file. Here they are in a .7z I hope (requires 7zip but I'm sure you have that!).

0 Kudos
Message 4 of 7
(3,727 Views)

Thank you for the detailed explaination! So just for clarification, you are not seeing the doubling error when you define "Minimum Size"? But you do see if when this is not defined?

 

I will try importing the DLL on my computer. 

 

Best, 

Danielle

0 Kudos
Message 5 of 7
(3,698 Views)

Hello Danielle,

 

The error occurs when you define the length of an input to a DLL function that is "pass by array" while using the Import shared library wizard. Then when you go open the custom function after closing the wizard the "Minimum length" is twice the size of the value that I insert when I defined the length in the wizard.

 

So strange... thanks for your input !

 

Lodo

0 Kudos
Message 6 of 7
(3,685 Views)

Hmm that is strange.. Are you able to run the original code without the DLL function? 

0 Kudos
Message 7 of 7
(3,671 Views)