LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Interfacing HS4 scope through dll library

Solved!
Go to solution

Hello,

 

As I mentionned in title, I try to interface a scope HS4 from TiePie with Labview.

For this, I have a dll file from the manufacturer. I already implemented a lots of functions (and it works) but two are missing.

The first one is a callback function and the second one is using event (see pic below):

 

Functions.PNG

I don't know how I have to proceed to translate these functions into Labview...

If somebody can help me...I already had a look on the forum but no good answers...

 

Thanks.

0 Kudos
Message 1 of 7
(3,514 Views)

Well callback without a wrapper DLL written in C is not a feasible solution. There are theoretical ways to do it, but they involve so much of playing C compiler on the LabVIEW diagram to such an amount that I could write a book about it and virtually nobody would be able to reproduce it anyhow. Basically at the point where you can do it, you have so much of C programming knowledge, that writing a wrapper DLL is factors faster than trying to do the pointer vodoo on the LabVIEW diagram yourself. And besides, the wrapper DLL in C is many times more easy to maintain and debug than trying to play assembly language code generation on the LabVIEW diagram.

The HEVENT is a Windows API element. You can call the function CreateEvent() in kernel32.dll to create such an event, and then WaitForSingleObject() in the same DLL to wait for the event to be triggered. It's workable but not very LabVIEW friendly. The WaitForSingleObject() will basically block until your library triggers your event, the dwMilliseconds timeout occurs, or you issue the SetEvent() function for that event handle yourself in some other part of your code. Always close the event created with CreateEvent() after you are done with it by calling CloseHandle() on the event handle.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 7
(3,477 Views)

Thanks a lot for your answer! I unsderstand a little bit more the way to do it!

Do you have an example of C wrapper or the way to do it?

0 Kudos
Message 3 of 7
(3,465 Views)

I tried this for the event....

code hevent.PNG

But the code doesn't detect an event only a timout (100ms), I don't know if it the good way to proceed...

0 Kudos
Message 4 of 7
(3,460 Views)

A picture may say more than 1000 words sometimes, but a LabVIEW program is a lot more than a simple picture. By just posting the pic, you show us only a tiny part of what you are doing. Yes I do not have the hardware to run the DLL on my computer, but I could go into the VIs and check what you have done and if there was a problem somewhere if I had the VIs. In this way all I can say is that it looks ok except that you probably should not continuously call the SetDataReadyEvent() inside the loop but only once before you go into the loop, maybe even before you do the ADC Start.

Also Windows events can be a bit tricky in that they can be created in signaled and non signaled state originally and once signaled need to be reset to detect another signal. You can also set them with flags during creation to either autoreset after a Wait has been triggered or to require explicit resetting. All nice features that make them very powerful but one of these settings wrong and it simply won't work. Reading the MSDN page about those functions very carefully is an absolute requirement.

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 7
(3,455 Views)
Solution
Accepted by topic author Julien.Epslog

Thanks for your help, I put the SetDataReadyEvent() before the ADC start and I modified a bit the code, and now, all is working fine.

0 Kudos
Message 6 of 7
(3,440 Views)

Hello, can you send me the source code of your Labview program?

0 Kudos
Message 7 of 7
(1,894 Views)