Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx error -200230 with python

Hi all,

 

I trying to write data to a digital output with DAWmxWritteDigitalLines who returns an -200230 error code

I use NI-6509 board (96 digital I/O) and python3.2

 

The code I try to run is the following:

 

import ctypes

 

#Load the DLL

nidaq=ctypes.windll.nicaiu

 

#Create a Task

taskHandle=ctypes.c_uint32(0)

nidaq.DAQmxCreateTask("",ctypes.byref(taskHandle))

 

#Create a Digital Output

chan=ctypes.create_string_buffer(b'1/port10/line0:7')

DAQmx_Val_ChanForAllLines=ctypes.c_int32(1)

nidaq.DAQmxCreateDOChan(taskHandle,chan,"",DAQmx_Val_ChanForAllLines)

 

#Start the Task

nidaq.DAQmxStartTask(taskHandle)

 

#Write data

numSampsPerChan=ctypes.c_ulong(1)

autoStart=ctypes.c_uint32(1)

timeout=ctypes.c_double(10.0)

DAQmx_Val_GroupByChannel=ctypes.c_uint32(0)

writeArray=ctypes.c_ubyte(0)

sampsPerChanWritten=???????

nidaq.DAQmxWriteDigitalLines(taskHandle,\

                                              numSampsPerChan,\

                                              autoStart,\

                                              timeout,\

                                              DAQmx_Val_GroupByChannel,\

                                              writeArray,\

                                              sampsPerChanWritten,\

                                              null)

 

#Clear Task

nidaq.DAQmxClearTask(taskHandle)

 

1- sampsPerChanWritten is an output. what is the value for this field?

2- Why does DAQmxWriteDigitalLines returns an errorcode?

3- What is the signification of the errorcode?

 

Thanks for your help.

0 Kudos
Message 1 of 4
(3,824 Views)

Are you using PyDAQmx? Just a suggestion...never used it myself. That error means there's a NULL pointer somewhere.

 

-gavin

0 Kudos
Message 2 of 4
(3,819 Views)

No, before your reply I did not know pyQADmx. I will try it.

I will look for my NULL error

Thanks

0 Kudos
Message 3 of 4
(3,811 Views)

Hi there,

 

The SampsPerChannelWritten should be a pointer when used in the DAQmxWrite function, so that's probably why you get a Null error. The PyDAQmx is also a good option to me 😄

 

Regards,

Eric

Eric M. - Senior Software Engineer
Certified LabVIEW Architect - Certified LabVIEW Embedded Systems Developer - Certified LabWindows™/CVI Developer
Neosoft Technologies inc.

0 Kudos
Message 4 of 4
(3,799 Views)