LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with c++ code an LabVIEW

Hello,

I am a student from Germany. In one of our lectures we  have to work with a robot platform. For controling we have a c++ project from the company who made this robot.In this project we have all function for controlling like drive forward, drive back turn left and right. We export this methods into a dll file to use it in labview, because the whole robot should be controlled by a labview VI. No we have some problems. At first I show you a little cutout of on method to describe our problem a littlebit easier.

 

extern "C" __declspec(dllexport) void drive_back(int timeToDrive){

  VMC::CVmc vmc;      //create an object of class VMC, open com1 for connection to the robot

  vmc.setMotors(-50, -50); //set speed an direction of motor left and right

  vmc.wait(timeToDrive); //wait timeToDrive ms, this time the robot will move backward

}

 

 

In the c++ Project all methodes are components of the VMC class. So if we want to use some of these functions, like setMotors(), we have to create an object of VMC. When an object is created the com1 is open for communication to the robot.  At the end of the Programm the comport is closed. If we call the function out of labview(we inserted the dll into labview) the robot drives two seconds back. So the dll in generall works fine. But know I come to our problem. If we call this function two times, one afte another, the robot stops for a little moment and then he drive again. The movement of the robot is choppy. We think  that the problem is the opening of comport conection by creation a VMC object and closing the comport by destroying the object. The computer takes a little time to open/close comport and in this time the robot stand still. Is it possible to return an object of VMC into labview and give it to the calling functions ? Is it possible to create one VMC object and use it in all other methods? Is there something available to break a running dll function? (My idea is to implement a infinit loop in the dll. In this loop i would say that the robot schould countiniously drive back. If I can stop the running dll fucntion out of labview a could stop the movement of the robot). 

 

Do you have some ideas to solve this problem?

 

Thanks for your help(sorry for my bad english)

 

best regard

Thomas

0 Kudos
Message 1 of 3
(2,656 Views)
Why not use the serial functions in Labview?


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 2 of 3
(2,653 Views)
The problem is that the companie used static labrarys. So we dont have some acces to the VMC class. We cant change the code of the c++ project.
0 Kudos
Message 3 of 3
(2,637 Views)