Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

HELP !! Cannot get WriteDigitalLines working !!

Please can someone help with this problem.

All I am trying to do is swtich some relays using the NI USB 9472 board from VB6. I send it a channel number from 1 to 8 and the function writes the appropriate bytes..

Here is the very simple code

------------------------------------------------------  
Dim sampsPerChanWritten As Long
Dim taskHandle As Long

   
DeviceAddr = "Dev1/port0/line0:7"
DAQmxErrChk DAQmxCreateTask("", taskHandle)
DAQmxErrChk DAQmxCreateDOChan(taskHandle, DeviceAddr, "", DAQmx_Val_ChanForAllLines)
   
DAQmxErrChk DAQmxStartTask(taskHandle)
RelayStatusBytes(0) = 1
DAQmxErrChk DAQmxWriteDigitalLines(taskHandle, 1, 1, 10#, DAQmx_Val_GroupByChannel, RelayStatusBytes(0), sampsPerChanWritten, 0)
DAQmxErrChk DAQmxStopTask(taskHandle)
DAQmxErrChk DAQmxClearTask(taskHandle)
-------------------------------------------------------------

See what I mean.. simple..
Yet every time I run it I get an error when the WriteDigitalLines part of the code tries to execute

DAQMx error code = -200492
Error Message=Reserved Parameter must be NULL..

I am stumped !

I've tried changing the last parameter from 0 to NULL or "" and it makes no difference..

What am I doing wrong !

Cheers

Peter
0 Kudos
Message 1 of 12
(11,088 Views)
The Visual Basic 6.0 equivalent to NULL is Nothing. Try passing Nothing as the last parameter (no quotes) and please let us know if this works for you.
0 Kudos
Message 2 of 12
(11,072 Views)
Hi Peter-
 
You should actually pass "ByVal 0&" for the NULL parameters.  
 
Thanks-
Tom W
National Instruments
0 Kudos
Message 3 of 12
(11,055 Views)
My mistake; thanks for correcting it Tom.
0 Kudos
Message 4 of 12
(11,050 Views)
Thanks for everyone's help but it turned out to be a VB6 funny. For some time I have been trying to work out how to use the NI functions without loading the whole 4Gb of software provided by NI on disk. When I spoke to a representative at NI they said it was  not possible to add a reference to the NIdaqmx.tlb file without installing all the software.

For this example I used NIDAQmxErrorCheck.bas file for the VB project but added declarations to the various functions and it seemed to work but created all sorts of funnies as I was still referencing the nidaqmx.tLB file. When I removed the declarations the project ran fine !

Does anyone know how to reference these functions ( the ..dll file ) without installing the whole suite.

Thanks again

Peter
0 Kudos
Message 5 of 12
(11,046 Views)
Hi Peter-
 
I'm not sure which 4GB of software you are installing, but if you only need NI-DAQmx functionality you can just install the standalone driver.  This is the smallest installation option that will give you full NI-DAQmx functionality with VB6.
 
Hopefully this helps-
Tom W
National Instruments
0 Kudos
Message 6 of 12
(11,042 Views)
does NI have a new nidaqmx.TLB for VB6 that includes all functions in the C library? I cannot use the DAQmxWriteDigitalU16 because it is not included. Nor can I cannot find  the nidaqmx.dll to call it directly. How about providing a DLL?
0 Kudos
Message 7 of 12
(10,345 Views)

Hi,

The reason that this and other functions are not supported is because they use data types that are not supported within Visual Basic. - i.e unsigned integer - which VB does not have a valid data type for.

The correct method to write to digital lines with DAQmx in VB 6.0 is

int32 DAQmxWriteDigitalLines (TaskHandle taskHandle, int32 numSampsPerChan, bool32 autoStart, float64 timeout, bool32 dataLayout, uInt8 writeArray[], int32 *sampsPerChanWritten, bool32 *reserved)

Refer to the DAQmx API C Reference Help for more information

Hope this helps

Hannah
NIUK & Ireland

 

0 Kudos
Message 8 of 12
(10,329 Views)

thanks, I have been using this function. But it looks like I have to write an array of 8 bytes to set one port. Is there a way to set a whole port using the bits of a byte or integer? Am I missing something?

 

Joe

0 Kudos
Message 9 of 12
(10,320 Views)

also there is uint8 in the lines routine that is successfully used in VB6 as a byte array --see below. Why can't this be done for writeuint8

in C header

int32 __CFUNC     DAQmxWriteDigitalLines       (TaskHandle taskHandle, int32 numSampsPerChan, bool32 autoStart, float64 timeout, bool32 dataLayout, uInt8 writeArray[], int32 *sampsPerChanWritten, bool32 *reserved);

in VB^

Function DAQmxWriteDigitalLines(taskHandle As Long, numSampsPerChan As Long, autoStart As Boolean, timeout As Double, dataLayout As DAQmxFillMode, writeArray As Byte, sampsPerChanWritten As Long, reserved As Any) As Long

0 Kudos
Message 10 of 12
(10,312 Views)