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: 

Function Call DLL

Hello Everyone,

 

My question is very related tot this one: http://forums.ni.com/t5/LabVIEW/DLL-help/m-p/1629426/highlight/true#M587634

 

It's about converting a EXCEL (2003) Macro code to LabVIEW (8.2).

 

I do have a datalogger called: Squirrel Data Logger Grant 2010 Series. It can communicate with the PC through USB and RS232. On the website of Squirrel, I found an Active X Driver.

 

http://www.grant.co.uk/Support/Data+Acquisition+Support/Software+Downloads/

( Scroll to bottom (2208kb)

 

Within, I found a help file but it's very limited as the Active X driver could be useful for many applications.

 

While installing the driver, an DLL is created in the WINDOWS\System32 folder. Now I can do 2 things:

 

1. Importing the DLL to LabVIEW using a wizard

2. Manually Call functions of the DLL

 

First I tried importing with the wizard but it asks me for an header (.h) file. Without it, I cannot go any further. 

 

So I tried the second function and in theory I should work, but my point is:

 

I've included the Macro code from Excel ( I think in C) and I want to translate all the functions to come usable in LabVIEW. Now I do have an idea if the DLL wasn't to complicated but this is the begin of the Macro Code:

 

Dim grantComDriver As Grant20xxCOMDriver.cGDLCTL32

 

So how can I translate the functions in the Marco Code (or with the included help file from the driver for a better overview for all functions) to LabVIEW with the Call Library Function Node?

 

Thanks,

 

Dennis 

 

 

 

Download All
0 Kudos
Message 1 of 13
(3,307 Views)

Using LV ActiveX palette would be more than useful... You can find it in the 'connectivity' palette (diagram side). Adding an automation open, you could be able to load your activeX and see methods and property availables with your driver.

CLA, CTA, LV Champion
View Cyril Gambini's profile on LinkedIn
This post is made under CC BY 4.0 DEED licensing
0 Kudos
Message 2 of 13
(3,295 Views)

@zyl7 wrote:

Using LV ActiveX palette would be more than useful... You can find it in the 'connectivity' palette (diagram side). Adding an automation open, you could be able to load your activeX and see methods and property availables with your driver.


This is exactly right.  You cannot use Call Library Function to get at the functions included in an ActiveX component (even though that component is packaged as a DLL).  You need to use the Automation Open function to get a reference to the driver (this is roughly the equivalent of the DIM statement in your Excel code), and from there you can use property and invoke nodes to access the datalogger functions.

0 Kudos
Message 3 of 13
(3,275 Views)

Thank you guys! It worked except one thing. I think the answer is already given in this topic:

 

http://forums.ni.com/t5/LabVIEW/Import-dll-callback-function/m-p/1407780/highlight/true#M547242

 

 

 

This is what i have in the help file of the DLL:  

 

typedef struct

{

    BYTE alarmState;

    BYTE loggerState;

    float internalVoltage;

    float externalVoltage;

    long internalMemTotal;

    long internalMemFree;

    long externalMemTotal;

    long externalMemFree;

}t_BCommand;

 

In the topic, it says it's unsupoorted bij LabVIEW so i guess i look in that topic for the answer to my problem.

 

Thank you for your help

 

 

0 Kudos
Message 4 of 13
(3,263 Views)

Why are you linking to a topic about callbacks?  Your structure does not use one.  You can duplicate that structure in LabVIEW and pass data to it without problems.  You'll need to create a cluster that has the same data types as the struct.  For BYTE, use a U8.  For float, use a single-precision value (SGL).  For long, use a U32.  You may need to add an additional U16 value for padding between "loggerState" and "internalVoltage."

0 Kudos
Message 5 of 13
(3,254 Views)

Thank you for your help.

 

I tried your solution, with and without het U16 between loggerstatus and internalvoltage but it gives me an error about the gpib.

 

Check the attachment so it will be clear for you guys.

 

But thanks alot for your help!

 

 

0 Kudos
Message 6 of 13
(3,236 Views)

I do not know if it is important but I would use a control instead of a Constant for the Input cluster.  Within the cluster I would make sure the names are the same as the struct and that they are in the same order (Sequence) as those in the struct.  You can specify this by right clicking on the cluster control and selecting reorder.

 

Craig

LabVIEW 2012
0 Kudos
Message 7 of 13
(3,221 Views)

There's nothing wrong with using a constant, no need for a control.  However, you're not calling a DLL here (and you should completely ignore that link you posted about callbacks, it is completely unrelated).  You're calling an ActiveX method.  Also, you're not getting an error about GPIB, the key part of the error is the bit about the input parameter being invalid, which admittedly isn't very helpful here.  The GPIB error is because somewhere way back in the history of LabVIEW, some error codes were used twice - once in LabVIEW and once in the GPIB driver.  This has never been resolved, unfortunately, leading to dual-message error codes.  Unfortunately your screen shot shows almost nothing so it is impossible to guess what the problem is; I can't even tell you whether the problem is the bCommandData structure or the ActiveX reference.

 

The links to download the Grant software aren't working - perhaps they've reorganized their web site since you first posted.  I'm not certain why you're getting the error and without access to the hardware and dll I can't test it out, but there probably is a way to make this work without too much additional effort if it's a function you need.

0 Kudos
Message 8 of 13
(3,209 Views)

Okay now i understand the problem about the 2 errors 😉

 

Now I’ve included the DLL, the help file, the macro file (which is basically a code written in Visual Basic) and the VI.

In the Macro file, I’ve highlighted some code that is related to bCommand. Somewhere I says:

    If grantComDriver.LoggerStatus(bCommandData) = 0 Then

 

But I don’t think it has something to do with the error.

Another thing is that you don’t have do have the datalogger. I’ve tested my VI without the datalogger and everything is working fine except you could

have some strang data coming in like: The graph is showing a zigzag line and the ChannelDetails shows -6.

 

I already had tested it with a cluster as input with and without the U16 as gap,

 

The last thing is that the purple wire you see, leading to the tekst “ReadingData”, the input of that fist gave me the same error: I had connected a constant to it and gave me the same error as now but, when I replace it with an array, it started to all work fine.

 

I hope you understand the problem, if not, I will add extra information,

 

Thank you,

 

0 Kudos
Message 9 of 13
(3,188 Views)

I can't run your VI as the error message I get suggests I'd need to install the entire Grant Data Acquisition program, which I'd prefer not to do.  I did modify and clean up your VI a bit.  There's no need for the sequence structure, the random unwired "First Call?" and the numeric constant set to 0 with an "Equal to 0?" after it.  It's a good idea to chain one ActiveX refnum wire through all nodes, and to close the reference at the end, as shown here.  I can't save this back to your version of LabVIEW (your VI is in 8.2) so you'll have to refer to the image.

 

It's possible your error is that there's nothing wired on the input side of BCD in the call to LoggerStatus.  At least under my version of LabVIEW, I get an error about this.  You may not get this error, but try creating a constant as the BCD input.  You'll get an empty variant, which is fine - you may just need to have something there but its contents aren't important.

 

grant.png

0 Kudos
Message 10 of 13
(3,169 Views)