LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make instrument drivers using dll file of the instrument control software?

Hello everyone,I am still new to labview and I am currently in need to make Labview drivers to control our injection set(ORTS32)..I tried to build VI's to control this instrument

but I am still struggling to establish communication with the instrument.I have attached (see the zip folder) the VIs that I developed as well as all necessary information.e.g instrument datasheet,dll files etc

 

Please help on how to build the VIs successfully.

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

First off, I would recommend putting all these files into a project (.lvproj). Also, you can set error handling on the "Call Library Function Node" to maximum which might (but usually doesn't) give you more descriptive help when errors occur.

 

So what kind of behavior are you seeing? What do you try that tells you you're not communicating with the instrument? Have you already established communication using the manufacturer's software?

0 Kudos
Message 2 of 7
(3,315 Views)

The information in the ZIP file is kind of dispersed all around.

While the only documentation for the DLL seems to be RES Test Set Control.doc it references the APTSPR.DLL but you have an APTSCOM.DLL. The function names at least seem to match. The function documentation is hardly worth anything as it doesn't document the parameter types well, everything has to be derived from the Visual Basic declaration which leaves more than a little ambiguity open.

 

However I do notice that the Visual Basic declaration in there doesn't specify a calling convention so it would seem very likely that the DLL uses the default Visual Basic calling convention which is Winapi and that in turn means stdcall on Win32 systems. With that said the cdecl (C) configuration in the Call Library Node inside each VI would seem wrong! Try with stdcall instead.

 

Also notice the Note under EX_init():

 

NOTE: this function no longer returns a status value. (Test set health would have previously been established with APTS_init)

 

So it may very well be that you should first call APTS_init(....) before you can do anything else.

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

Hi Gregory,Thanks very much for the advice,to answer is yes I can communicates with the device using the manufacture's software..however I would like to communicate with the device in labview for automation reasons..I have also set the error handling to maximum,but no positive results..The instrument display still shows me COMMS ERROR as I try to communicate with it.(using APTS Init.VI).I tried to build this VI as shown RES Test Control.doc..

 

APTS_init( acp_binary, acp_binary_size)

Performs an actual test set processor reset and then loads the specified binary image specified. Apart from APTS_get_stat, this is the very FIRST AND ONLY command that can be issued if APTS_get_stat is returning OFF-LINE. 

Where:    acp_binary is a pointer to a memory area containing the test set code to be loaded and executed.

acp_binary_size specifies the number of bytes to be transferred

 

Returns : 0              if the test set is present and healthy.

               1              Unable to detect/initialise test set.

 

Defined as :

Declare Function APTS_init Lib "c:\wherever\aptspr.dll" (ByVal acp_binary As String,

ByVal acp_binary_size As Long) As Integer

 

I believe acp_binary refers to the file named ACP2C with .bin file extension..(see zip folder)

 

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

@Meshack wrote:

 

I believe acp_binary refers to the file named ACP2C with .bin file extension..(see zip folder)

 


Quite possible but I wonder if they expect you to pass in the path here or rather the file contents. From the wording of it I would tend to believe that they actually expect you to load the file into memory and then pass this to this parameter, rather than the file path.

 

Taking a quick look into the Visual Basic example confirms this suspicions. They load the file into a byte array that was allocated to be as long as the file is. Then pass this byte array in the first parameter and the length of it in the second. The declaration in the documentation which declares this parameter as String is factually wrong. You better take the file DLLDECL.BAS in the example folder to determine the actual data types, here APTS_init() is correctly declared as:

 

Public Declare Function APTS_init Lib "aptsCom.dll" (ByRef code As Byte, ByVal size As Long) As Integer

 

and there isn't any calling convention declaration so Visual Basic uses the default which for Win32 DLLs is stdcall, while you configured (some of the) the Call Library Nodes to use C calling convention.

 

This would mean that the Call Library Node should be configured as follows:

 

return value: Numeric, 32 bit signed integer

1st parameter: Array, 1 dimensional, 8 bit unsigned integer, passed as pointer to array

2nd parameter: Numeric, 32 bit integer, pass value

 

and the function should very likely be configured to be stdcall calling convention

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 7
(3,264 Views)

Hi Rolf,I would like advise you that RES is the company that manufactured ORTS,APTS and BTS..So it came to my understanding that the software  of these above mentioned Instuments is slightly different and so does the DLLs..I did use stdcall,but I got no positive results and I am conviced that c APTS int vi must be the first to run successfully as to establish communication. (see VBAPTS Example Program.doc ).. I have also tried using VBAPTS .exe which is a demo program and it works fine..

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

@Meshack wrote:

Hi Rolf,I would like advise you that RES is the company that manufactured ORTS,APTS and BTS..So it came to my understanding that the software  of these above mentioned Instuments is slightly different and so does the DLLs..I did use stdcall,but I got no positive results and I am conviced that c APTS int vi must be the first to run successfully as to establish communication. (see VBAPTS Example Program.doc ).. I have also tried using VBAPTS .exe which is a demo program and it works fine..


I didn't say anything about RES except that the documentation seems outdated and pretty terse in terms of describing datatypes of the functions. The documentation refers to a different DLL than what the ZIP file contains (both having the APTS prefix however, so I would guess either the documentation is from an older version or nobody ever bothered to update the documentation.

 

Except for the stdcall calling convention I'm missing any comment about the other points I brought up. There are obviously 100 things that can possibly be wrong but your ZIP archive for instance doesn't contain an APTS_init.vi, so all I have to go by why it could not work are guesses. I looked at the EX_init() and except that it doesn't have any parameters, so you can't really do anything wrong there, it is configured to use C calling convention which definitely is different to what the Visual Basic DLLDECL.BAS file would cause to be used in a Visual Basic program. As you say that that example works it would seem to indicate that the Visual Basic example source code is the reference to which you should compare everything else.

 

That means:

 

-All the functions should be stdcall:

 

-APTS_init() has as first parameter a byte array which contains the binary contents of the file that should be downloaded to the controller and as second parameter the number of bytes that the first parameter contains.

 

-Until this function works, nothing else in the DLL will work,

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