LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I write a Dll to perform a union in visual studio for use in LabVIEW?

Solved!
Go to solution

Hello,

 

I'm new to writing dll(s). I'm attempting to write a Dll that will perform a union on a number from LabVIEW and then return the result to LabVIEW for my use. I've been struggling with this for a few days and I'm finally giving in to get some help.

 

This screenshot is the only description that I have to help me with what I am trying to do. Basically, I'm trying to pass a value that will be different based on a measured partial discharge value. In the screen below, the value used is "1061111989" This number is my reading. I need to pass this value from labVIEW into my dll to perform a union on it.

 

In my Dll, I need to write MeterReading.IntVal's value and get the MeterReading.FloatVal back.

 

screen for labVIEW.jpg

 

I have Visual Studio 2012 Full and LabVIEW 2012 Full, I'm LabVIEW CLAD and I've written 17 test floors in the US to date; however, I've never had any need of Visual Studio until now. Can anyone help me out with this?

 

Thanks in advance, -Chris

-Chris
"You must be some sort of an engineer?" -Close Friend
0 Kudos
Message 1 of 4
(2,351 Views)

You don't need a union to pass this value between LV and your DLL. Just pass your integer value to your DLL and do whatever you want with it in your C code.

Btw, a union is nothing you can perform, it's neither a function nor operation. It's just a data structure that can hold several data types but all at the same memory address. In your example you have a union that holds 4 bytes. Reading the IntVal interprets these 4 bytes as integer, reading the FloatVal interprets the very same 4 bytes as float.

0 Kudos
Message 2 of 4
(2,342 Views)
Solution
Accepted by topic author transformertester
Trying to create a union is silly. Have you tried doing a simple typecast?
Message 3 of 4
(2,338 Views)

Sometimes, I try to solve simple issues in very complicated ways. What got me so confused here was the solution from the engineer of the device that I am reading from was using a union to get the value. I'm not familiar with unions so I thought that it was some structure that was not creatable in LabVIEW. Anyways, a typecast to single point gave me the proper value. Thank you.

-Chris
"You must be some sort of an engineer?" -Close Friend
0 Kudos
Message 4 of 4
(2,317 Views)