From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

dll developed in labview crushing in visual studio c++

Hi everyone,

 

I am developing an application in LabVIEW 2015 (version 15.0f2 32bit) to control servo drive for a linear motors from the company LinMot. More information over the servo drive can be found on the following link: http://shop.linmot.com/E/ag7000.b11/drives-for-motors-p01-&-pr01/series-b1100/b1100-gp-hc.htm. The connection between my LabVIEW software and the servodrive is over the CANopen standard, and I use the module NI USB-8473s to establish the communication between my PC and the drive.

 

All develped software works very well when I execute it in the LabVIEW environment. But then I would like to create a DLL file with all control functions, so the end customer can use my software in his Visual Studio C++ program. The application build and the linking of the DLL in Visual Studio works fine, and most of the functions could be used without problem. But in one of the functions is used an endless loop in a timed loop, that needs to execute all the commandos in a sequence with endless repetition until another command is asked to cancel it execution. When this function is executed in the C++ code I can see that the hardware is getting the right commandos, but the software is crushing completely. I was suggested to create something in LabVIEW that would be similar to the Application::DoEvents method in Visual Studio, and from my knowledge I add a timer into the loop with 0 milliseconds connected, so I can release the resources at the end of the loop. But still I am getting the same behaviour. 

 

Could anyone please give me some suggestion what I should consider in order to solve the problem?

 

Thank you very much in advance.

 

 

Kind Regards,

Nikola Todorovski

 

 

0 Kudos
Message 1 of 9
(3,054 Views)

Hi Nikola,

 

is there a reason, why you use a timed loop for the enless task? Since you are running the code in a DLL on Windows, this may have an influence on the behavior. Could you try it out with a while loop and a timimg inside the loop?

 

Best regards,

Melanie Eisfeld

Staff Applications Engineer

National Instruments

Best regards,
Melanie Eisfeld
Senior Applications Engineer, National Instruments Germany
Certified LabVIEW Developer
Certified TestStand Architect
0 Kudos
Message 2 of 9
(2,999 Views)

Hi Melanie,

 

thank you very much for your reply.

 

I am using the timed loop in roder to control the execution of the code in a secure manner. But I just changed the timed loop with a while loop and still the program is crushing. Attached to my post you can see the VI from which I create the DLL. This function is actually crushing the program.

 

I would be very thankful if you give me some tips and ideas how to solve the problem. Please let me know if you need the full code.

 

Thank you very mich in advance.

 

 

Kind Regards,

Nikola

0 Kudos
Message 3 of 9
(2,966 Views)
If you have something that needs to run in a loop like that you should build it into an executable of its own that is then controlled via the .net components.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 9
(2,961 Views)

Hi Nikola,

 

The complete code would be very helpfull, as well as, the line that calls the code from c++.

 

My suggestion is, that maybe some parameter is passed the wrong way or something like that. To analyze this, the call and the VI could help me.

 

Best regards,

Melanie

Best regards,
Melanie Eisfeld
Senior Applications Engineer, National Instruments Germany
Certified LabVIEW Developer
Certified TestStand Architect
0 Kudos
Message 5 of 9
(2,959 Views)

Hi Melanie,

 

I was working on my code and I figure it out that the main problem for me is to stop the while loop in C. So basically if I have a while loop which loops until state of some variable is changed, how can I change the state of that variable in C? So maybe I need more information about working with pointers in LabVIEW? Any help on this issue?

 

 

Kind Regards,

Nikola

0 Kudos
Message 6 of 9
(2,918 Views)

Hi Mike,

 

thank you very much for your reply. I can't understand you what you mean about working with .NET components. My knowledge is very poor in that field. Can you please give me some more infos or some examples?

 

Thank you very much.

 

 

Kind Regards,

Nikola

0 Kudos
Message 7 of 9
(2,916 Views)

Hi Nikola,

 

this is a general question that is not related specially to LabVIEW.

 

The general process that works for nearly every application architechture like you have is the following:

 

  1. EXE calls a function in DLL.
  2. EXE passes parameters as necessary.
  3. DLL performs work, starts thread, returns a handle.
  4. EXE can now communicate further with DLL by calling more functions, passing the handle.
  5. DLL can communicate with EXE, e.g. by calling DLL functions.
  6. When it is time to stop, the EXE calls a DLL function, passing the handle. At this point the DLL tidies up.

I hope this helps you getting started with it. I'd recomment reading about general DLL and calling application challenges.

 

Best regards,

Melanie

Best regards,
Melanie Eisfeld
Senior Applications Engineer, National Instruments Germany
Certified LabVIEW Developer
Certified TestStand Architect
0 Kudos
Message 8 of 9
(2,908 Views)
You said that you had a part of your process that needs to run continuously. The idea is to create a small standalone executable that fulfills that requirement. This executable would be designed to run in the background with no user interface. You would instead design it to be controlled through VI Server. For your c++ program interface you would then create a .net assembly that provides methods that make those calls.

In other words, the standalone performs the continuous operation and the .net assembly you create let's the c++ program control that process.

I have written about these sorts of architectural design issues in my blog -- in fact I had a post written to do exactly what you are doing but I am not a c++ programmer and the guy I had lined up to do the c++ test code got a new job so I couldn't test what I had created, and I wasn't willing to publish something I hadn't tested.

The link to my blog is in my signature.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 9 of 9
(2,904 Views)