pythonctypesuint64nidaqmx

ctypes uint64 conversion error


I got the following problem :

I load via c types the nicaiu.dll to control a NI-USB6218 Data Acquisition Pad and i have to call several function to initialise it (DAQmxCreateTask(), DAQmxCreateAIVoltageChan() and DAQmxCfgSampClkTiming() ).

The first two calls work but DAQmxCfgSampClkTiming() raises this error

Traceback (most recent call last):
File "C:/*********/Voltage.py", line 68, in <module>
values)
ctypes.ArgumentError: argument 6: <type 'exceptions.TypeError'>: Don't know how to convert
parameter 6

Parameter 6 should be uint64 see Doc This is my function call:

DAQmx_Val_Rising = 10280 #see NIDAQmx.h
DAQmx_Val_FiniteSamps = 10178 # see NIDAQmx.h
values = uint64(40000) #numpy function
dll.DAQmxCfgSampClkTiming(taskHandle, "OnboardClock", c_float(4000.0), DAQmx_Val_Rising, DAQmx_Val_FiniteSamps,
                                    values)  

I also tried values = c_uint64(40000) but it did not work.

Edit1: The dll is located in System32 folder (Win7)

dll = cdll.nicaiu

E.g this function call works (returnvalue = 0)

DAQmx_Val_Diff = 10106
DAQmx_Val_RSE = 10083
DAQmx_Val_Volts = 10348
returnvalue = dll.DAQmxCreateAIVoltageChan(taskHandle, "Dev1/ai1", taskName, DAQmx_Val_RSE,
                                           c_float(-1.0),c_float(1.0), DAQmx_Val_Volts, None)

Edit2:

Added argtypes line

dll.DAQmxCfgSampClkTiming.argtypes = [c_int, c_char_p, c_float, c_int32, c_int32, c_uint64]
returnvalue = dll.DAQmxCfgSampClkTiming(taskHandle, None, c_float(4000.0), DAQmx_Val_Rising,
                                        DAQmx_Val_FiniteSamps,values)

Still get Error Code -200077 Definition of this code is :

nierror code = -200077
Requested value is not a supported value for this property. The property value may be invalid
because it conflicts with another property.

Solution

  • I can't test it as I don't have that instrument, but I would start with something like:

    samp_clk_timing = dll.DAQmxCfgSampClkTiming
    samp_clk_timing.restype = c_int32
    samp_clk_timing.argtypes = (TaskHandle,
                                c_char_p,          
                                c_double,         
                                c_int32,
                                c_int32,           
                                c_uint64)
    
    return_val = samp_clk_timing(taskHandle,
                                 "OnboardClock",
                                 c_double(4000),
                                 c_int32(10106),
                                 c_int32(10178),
                                 c_uint64(40000))