Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading out a DIO Card by LV made dll using Visual Basic 6

Hey,

 

we have a Detector that is connected to a NI PCI-DIO-32HS Card. A Vi reads out the input using the DAQMX dll, and processes it. It contains a functions that can be called to read out the detector and computes the data arrays and lists we need. It is also important that the 10 Mhz clock is initialised beforehand. We got an application from the company that made the hardware to do this. We made a dll from this Vi to use this function from Visual Basic 6 since the rest of out measurement routine is written with it. The problem is we do not get any errors from Visual basic, but the function does not write anything into the return values.

 

The header from the dll is:

 

#include "extcode.h"
#pragma pack(push)
#pragma pack(1)

#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
int32_t dimSizes[2];
double elt[1];
} DoubleArrayBase;
typedef DoubleArrayBase **DoubleArray;

void __stdcall FPAS2UniversalScanAcquireMX(int16_t DIOPORT, 

LVBoolean SafeModeDISABLED, LVBoolean NoExternals, double Elements,
double TotalPointsToAcquireCHScans, double EXTInputsMEAN[],
DoubleArray *DetectorOutputALL, double DetectorOutputArrayMEAN[],
DoubleArray *EXTChAll, double DetectorOutputSTDDEV[], int32_t len1,
int32_t len2, int32_t len3)

#ifdef __cplusplus
} // extern "C"
#endif

#pragma pack(pop)

 

In Visual Basic we use this code to call the function:

 

'Function input parameters
Const intDIOPORT As Integer = 0 
Const bytSafeModeDisabled As Byte = 0 
Const bytNoExternals As Byte = 0 
Const dblElements As Double = 127 '128 pixels
Const dblTotalPointsToAcquireCHScans As Double = 1279 '10 laser pulses
Const lngLen1 As Long = 15 '16 external channels
Const lngLen2 As Long = 127 '128 pixels
Const lngLen3 As Long = 127 '128 pixels
 
'Function output parameters;The lists are initiated 1 element shorter as, because they start at zero.
Dim DetectorOutputSTDDEV(127) As Double 
Dim EXTInputsMEAN(15) As Double 
Dim DetectorOutputAll As Long 'Since This is C-Pointer this should Probably be long.
Dim EXTChALL As Long 'Since This is C-Pointer this should Probably be long.
Dim DetectorOutputArrayMEAN(127) As Double
 
'declare the function as sub; this is the way to go if a function is a void. Pointers have to be ByRef as well as Lists. All the inputs can be given as ByVal.
 Private Declare Sub callfunctionsub Lib "FPAS2UniversalScanAcquireMX.dll" Alias "FPAS2UniversalScanAcquireMX" _
 (ByVal intDIOPORT As Integer, _
 ByVal bytSafeModeDisabled As Byte, _
 ByVal bytNoExternals As Byte, _
 ByVal dblElements As Double, _
 ByVal dblTotalPointsToAcquireCHScans As Double, _
 ByRef EXTInputsMEAN() As Double, _
 ByRef DetectorOutputAll As Long, _
 ByRef DetectorOutputArrayMEAN() As Double, _
 ByRef EXTChALL As Long, _
 ByRef DetectorOutputSTDDEV() As Double, _
 ByVal lngLen1 As Long, _
 ByVal lngLen2 As Long, _
 ByVal lngLen3 As Long)
 
Private Sub callfunction_Click()
Call callfunctionsub(intDIOPORT, bytSafeModeDisabled, bytNoExternals, dblElements, dblTotalPointsToAcquireCHScans, _
EXTInputsMEAN(), DetectorOutputAll, DetectorOutputArrayMEAN(), EXTChALL, DetectorOutputSTDDEV(), lngLen1, lngLen2, lngLen3)
End Sub
 
Are we getting the communication between VB6 and LabView wrong? Please do not hesitate to ask if you need any additional files/code to clarify this matter.
 
Thank you in advance!

 

0 Kudos
Message 1 of 2
(3,246 Views)

Hi,

 

did you check, the DLL is loaded into memory and you have the correct LabVIEW runtime engine present on the machine?

 

Best,

Melanie

Best regards,
Melanie Eisfeld
Senior Applications Engineer, National Instruments Germany
Certified LabVIEW Developer
Certified TestStand Architect
0 Kudos
Message 2 of 2
(3,216 Views)