LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

help to understant code and "convert" it to the Labview

Solved!
Go to solution

Hi all!

 

I have tried to create Labview code with dll-librarys. It have been goes well, but now i am stuck. The device is USB scope. I have already initialized it, set trigger and got number of cumulative sample. But now problem is to get those samples. Below have specification from dll-library which read buffer. Can someone help and say same in english and Labview-language what that library do and what i should do 🙂 What array (pointer?), where to put that array? Numsofar?

 

-Thx again-

 

 

in: int (channel)
inout: float (data array)
in: int (samples)
in: int (numsofar)
return: none

This function is used to fetch zero or more data samples into a user’s buffer for use in a roll-mode scope display. It is not intended for any other use.

 

channel can range from 1 to “devices found”.

 

data is a pointer to an array of floats, that must be large enough to hold the requested total size of (samples) floats

 

samples is the number of sample points to recover.


numsofar is the running total maintained by the application of the data points collected since trigger. The data is copied into the data array at the index (numsofar).
When running in roll-mode, the application repeatedly checks the number of samples that have been collected by the hardware since trigger (or acquisition start for free-run mode) using the GetSamplesSinceTrigger call. This value is checked to see if it has advanced sufficiently to make it worth collecting and/or displaying (or saving) these new data points. For the USBscope50 software, a threshold of 10 new points is used. Then, the GetBufferIncremental call is used to recover these samples onto the “end” of the data buffer in use by the application. The new samples are copied to the array at index (numsofar). The application must ensure that numsofar is zeroed before each acquisition sweep, and it then increases by no more than the number of incremental samples reported since trigger prior to the next GetBufferIncremental call. Additionally, the GetAcqusitionState call is used to see when the overall acquisition finishes, so that the process can start over again.

0 Kudos
Message 1 of 13
(2,878 Views)
Solution
Accepted by topic author Alias A

There are two different questions here. The first is how to use Call Library Function Node to pass an array into the DLL's function. To do this you need to allocate an array in LabVIEW by using the Initialize Array function. Open the Example Finder (Help -> Find Examples) and search for "DLL". There's an excellent example called "Call DLL". Run this VI, then scroll down the list of examples until you see "1-D Array" and open that. You'll see how to pass an array. (Note that in your case you will probably be initializing the array early on in your program and then passing it for each function call).

 

The second question has to do with how to actually use this function, and what to do with the parameters "samples" and "numsofar". These are parameters that you must keep track of in your app. You tell the function where to insert the samples in the array that you pass it. You also have to tell the function how many samples to collect. For example, let's say you initialize an array of 100 points. You decide to gather 10 samples each time you call the function. The first time you call the function numsofar would be zero to indicate that you want it to place the 10 samples at the beginning of the array. The next time you call it numsofar would be 9 to indicate that you want the function to place the next 10 samples in the array right after the previous 10 samples. And so on... After 100 points numsofar would be reset to 0.

 

At least I think that's what it's saying. Smiley Wink The source code for the app the manufacturer provides is available on their web site, so you should be able to download it and see what they do. 

Message 2 of 13
(2,859 Views)

smercurio_fc wrote:

There are two different questions here. The first is how to use Call Library Function Node to pass an array into the DLL's function. To do this you need to allocate an array in LabVIEW by using the Initialize Array function. Open the Example Finder (Help -> Find Examples) and search for "DLL". There's an excellent example called "Call DLL". Run this VI, then scroll down the list of examples until you see "1-D Array" and open that. You'll see how to pass an array. (Note that in your case you will probably be initializing the array early on in your program and then passing it for each function call).

 

The second question has to do with how to actually use this function, and what to do with the parameters "samples" and "numsofar". These are parameters that you must keep track of in your app. You tell the function where to insert the samples in the array that you pass it. You also have to tell the function how many samples to collect. For example, let's say you initialize an array of 100 points. You decide to gather 10 samples each time you call the function. The first time you call the function numsofar would be zero to indicate that you want it to place the 10 samples at the beginning of the array. The next time you call it numsofar would be 9 to indicate that you want the function to place the next 10 samples in the array right after the previous 10 samples. And so on... After 100 points numsofar would be reset to 0.

 

At least I think that's what it's saying. Smiley Wink The source code for the app the manufacturer provides is available on their web site, so you should be able to download it and see what they do. 


Nice... so nice. Than You alot 🙂 Now i understan what that specification trying to tell. In/out float (data array) takes in only SGL data format. So i have to create/collect that array somewhere else... (?)

 

I'll try.... thx...

0 Kudos
Message 3 of 13
(2,813 Views)
No, that's not correct. You are passing a single float value. The function wants an array. Please look at the "Call DLL" example that I mentioned.
0 Kudos
Message 4 of 13
(2,780 Views)

smercurio_fc wrote:
No, that's not correct. You are passing a single float value. The function wants an array. Please look at the "Call DLL" example that I mentioned.

Hi Smercuiro, can't connect array type to SGL. Picture which I have attached is inside of the dll function (vi). Can only connect SGL type data to input (?). Here is the Vi where u can see what i am tying to do. 

 

Thx again 🙂

0 Kudos
Message 5 of 13
(2,766 Views)
You did not include any subVIs so I can't look at the way you configured the Call Library Function Node since that's in the subVI that you're pointing to.
0 Kudos
Message 6 of 13
(2,750 Views)

Hmm... i think u just say right words here: "the way you configured the Call Library Function Node". I haven't configure that node (i automaticly thought that all configs are correct). So i'll try that (changing data from SGL to array)... thx again 🙂

 

but here is Vis if u like to watch them.

 

 

0 Kudos
Message 7 of 13
(2,742 Views)
Did you write those VIs, or did you get them from the manufacturer? The "Get Buffer Incremental" VI does not match the prototype. The "data" argument is supposed to be an array (according to your initial post), but it has been configured as a single SGL.
0 Kudos
Message 8 of 13
(2,734 Views)

That I was trying to say... I generated those Vis with Labview dll wizard (import shared dll librarys) using source code's *.dll and header file. Thats why I thought configures were automaticly correct.

0 Kudos
Message 9 of 13
(2,724 Views)
Odd. Can you upload the DLL and the header file? (Place them into a zip file.)
0 Kudos
Message 10 of 13
(2,719 Views)