LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with .dll, something wierd

Okay, i am at a total loss here. I want to make a .dll file for use in labview that will use functions from a static library that i have included called disconnect203. The first function i used was the library was called UTMToGeocentric. This function is working fine for me. The second function I am tyring to use from the library is called GeocEulerFromUTMEuler. I use this function in C++ applications frequently and it works just fine. However, when i look at the return values in Labview I get all 0's and a NaN, which i know is not correct. The two functions are very similar when it comes to setting them up. I can only guess that Labview is causing a problem somewhere since the function does work in a C++ application. I have attached the disconnect203.lib, and it's documentation, along with my .dll workspace, and a subvi i have been using to test with. If 0's are inputed for the pitch,roll,yaw input of the GeocEulerFromUTMEuler function, values of pi, and near 0 should be returned for psi,theta, and phi. I am at a total loss here, so anyhelp would be greatly appreciated. Thank you very very much.
0 Kudos
Message 1 of 10
(4,150 Views)
Anyone have any ideas?
0 Kudos
Message 2 of 10
(4,108 Views)
Hi,

If I am understanding you correctly, you have created a dll called utm11.dll that calls the static library disconnect203.lib. You are now able to call utm11.dll from C++ but you are unable to call it from LabVIEW(you can call one function correctly but not the other one). Am I correct?

It would help if you could post utm11.dll (it is not included in teh zip file you attached with your post). Also it is not very clear where are the psi,theta, and phi outputs are coming from and what their individual values should be...should it be pi or should it be close to zero? In the LabVIEW VI you posted, there are no such outputs.

Ankita
0 Kudos
Message 3 of 10
(4,086 Views)
Sorry, i guess i was not very clear. I did create the .dll with microsoft visual studio 6. I can successfully call both functions within the .dll from labview. The problem is that only one of the functions returns correct values. The other function returns 0's or NaN's, no matter what i enter as inputs. I know that the function does work because it returns correct values in my C++ applications.

Okay, i did not rename my workspace from a previous project. It is called motionfilterDll.dsw. The dll that needs to be used in labview is in the debug folder attached and is called motionfilter.dll. It can be seen in the source for the .dll what variables are what. I hope this makes more sense. If not please let me know what else you need to know.

One thing that i did find strange was that I cannot include the hosttype.h header file before the headerfile for the static library i am using. (disconnect.h) If i do, i get compiling errors. If i list the hosttyype.h after the diconnect.h it compiles fine, or if i dont even include the hosttype.h it compiles fine.
0 Kudos
Message 4 of 10
(4,074 Views)
Forgot to address what the inputs and outputs to the second function should be. The inputs are roll pitch and yaw in radians. I usually test with 0,0,0 and these are in a UTM coordinate system. The outputs of the GeocEulerFromUTMEuler are also coming out in radians. I can't remember offhand which order, but inputs of 0,0,0 should yield outputs of pi, about .0132, and about -.0132 or so.
0 Kudos
Message 5 of 10
(4,067 Views)
I got it so i can compile with the both header files, but still the function is not working correctly with labview.
0 Kudos
Message 6 of 10
(4,043 Views)
It looks like that the function GeocEulerFromUTMEuler (called in DLL) is having some problems. I tried passing values in and out of your function GeocEulercomingfromUTMEuler (created in DLL) and they passed just fine. So it looks like that the values that are computed within the function are incorrect.

I would suggest that you try writing the values computed within that function to a file to keep track if the values are computed correctly in the DLL. In the meantime I will try to work more on your program.

I hope it'll help.
Ankita A.
Message 7 of 10
(4,016 Views)
Thanks for the help so far, i really appreciate it. I know that the function GeocEulerfromUTMEuler does work when used in an flight simulation application we use here created in C++. I will get together some in's and out's to the function so I can show you what the values should be.
In the past i had to write a vi that went the opposite direction, UTM to Geocentric, and I actually had the source for those functions so i just used a formula block to do the calculations. Unfortunately I dont have the source for these particular functions so I am pretty much forced to try and make these work in a dll.
Ill get started on an output file, and ill post as soon as i am done. Thanks again,
Dave
0 Kudos
Message 8 of 10
(4,005 Views)
Ankita:
I want to thank you for taking the time to look through my vi and code ( i know it was sloppy, but after 50 tries it tends to get that way 🙂 )
I have finally figured out the problem, but maybe you could shed some light as to why it would make a difference. If i list ATITUDE attt, FORIENT angled, and GEO geod_coords directly after my include statements and not inside of my dll function calls it works fine. If i put these inside of the function call as I did in the example i posted then the function no longer works. What would cause this?
Anyways, thanks again, i am just happy i can continue on with this project. Thanks for all the help, ill leave you some stars.
Dave
0 Kudos
Message 9 of 10
(3,991 Views)
Hi Dave,

Thanks for the stars 🙂

The only big difference between declaring the variables at the top and inside the DLL function is changing from a local variable to global. It definitely helped in this case because; when DLL function was called the data types were declared and as soon as the function finished they were removed from the memory stack (not being static). Thus if the value from reference for those functions was accessed after the DLL function completed execution it would represent garbage or null value.

In the other case when the variables were made global the referenced values stayed in the memory until the DLL was unloaded and that happens when the VI calling that DLL closes. This is the best explanation I can come up with at this time and hope it makes some sense.

I hope it helps,
Ankita
0 Kudos
Message 10 of 10
(3,965 Views)