LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

collecting data from hardware using dll

Im calling my dll which contains  imported provided dll (hd.dll)I calling functions one by one 

1.init.

2.work(int *a, int *b, int *c)

3. disable.

 

and it works fine when I`m using console aplication calling this functions.

 

I use pointers and I only get position  but it works slowly, 

and Id like to get its position in real time .

0 Kudos
Message 11 of 14
(483 Views)

"I`m calling my dll which contains imported functions from provided dll" (hd.dll)

So there s no possibility to run dll on its own thread ? 

0 Kudos
Message 12 of 14
(479 Views)

Putting something in its own thread is as easy as putting library calls in a labview while loop and passing data out of that while loop using queues or notifiers. Just make sure these library calls just don't crash or block indefinitely!

 

Do you know which command is running slow? I think this would be an interesting next step.

0 Kudos
Message 13 of 14
(472 Views)

With your code as it currently stands, there's no need for the DLL you wrote - all the functions you call can be called directly from LabVIEW.  I would start there, see if removing one layer of DLL improves performance.  Of course, since your callback does not currently do anything, there's no need for it nor for the calls to set it up.  Without your LabVIEW code it is impossible to know if your LabVIEW code is not well-written, or if the problem is the library.

 

If you have not already done so, you should search this forum for OpenHaptics.  You're not the first person to try to use this software with LabVIEW, and you may find that someone has already done the work and is willing to share.

 

A callback is a function that some other library or application calls on your behalf.  You pass a pointer to the function, and the application or library calls your function at the right time, usually with the option to pass some data with it.  In your case, I think the callback can be a simple function in C that calls PostLVUserEvent with the a pointer to the position array (you'll have to test that part).  In LabVIEW, set up a user event with a data type of a cluster containing 3 integers, matching the position array (there are no fixed-size arrays in LabVIEW, so you'll need to use a cluster instead).  You will also need to use the LabVIEW event structure, and this may not be intuitive to a new LabVIEW user; it also may not be supported in the evaluation version, I'm not sure.

 

Putting a DLL call in its own loop is not sufficient to make it run in a separate thread.  You need to set the DLL call to run in any thread (reentrant).  Make sure your DLL is thread safe; or, if it is not, that you only call it in one location to avoid accidentally calling it concurrently.

0 Kudos
Message 14 of 14
(463 Views)